| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 3737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3748 // We have a fast integer-only case here to avoid a conversion to double in | 3748 // We have a fast integer-only case here to avoid a conversion to double in |
| 3749 // the common case where from and to are Smis. | 3749 // the common case where from and to are Smis. |
| 3750 if (args[1]->IsSmi() && args[2]->IsSmi()) { | 3750 if (args[1]->IsSmi() && args[2]->IsSmi()) { |
| 3751 CONVERT_SMI_ARG_CHECKED(from_number, 1); | 3751 CONVERT_SMI_ARG_CHECKED(from_number, 1); |
| 3752 CONVERT_SMI_ARG_CHECKED(to_number, 2); | 3752 CONVERT_SMI_ARG_CHECKED(to_number, 2); |
| 3753 start = from_number; | 3753 start = from_number; |
| 3754 end = to_number; | 3754 end = to_number; |
| 3755 } else { | 3755 } else { |
| 3756 CONVERT_DOUBLE_ARG_CHECKED(from_number, 1); | 3756 CONVERT_DOUBLE_ARG_CHECKED(from_number, 1); |
| 3757 CONVERT_DOUBLE_ARG_CHECKED(to_number, 2); | 3757 CONVERT_DOUBLE_ARG_CHECKED(to_number, 2); |
| 3758 start = FastD2I(from_number); | 3758 start = FastD2IChecked(from_number); |
| 3759 end = FastD2I(to_number); | 3759 end = FastD2IChecked(to_number); |
| 3760 } | 3760 } |
| 3761 RUNTIME_ASSERT(end >= start); | 3761 RUNTIME_ASSERT(end >= start); |
| 3762 RUNTIME_ASSERT(start >= 0); | 3762 RUNTIME_ASSERT(start >= 0); |
| 3763 RUNTIME_ASSERT(end <= value->length()); | 3763 RUNTIME_ASSERT(end <= value->length()); |
| 3764 isolate->counters()->sub_string_runtime()->Increment(); | 3764 isolate->counters()->sub_string_runtime()->Increment(); |
| 3765 return value->SubString(start, end); | 3765 return value->SubString(start, end); |
| 3766 } | 3766 } |
| 3767 | 3767 |
| 3768 | 3768 |
| 3769 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringMatch) { | 3769 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringMatch) { |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4217 if (isnan(value)) { | 4217 if (isnan(value)) { |
| 4218 return *isolate->factory()->nan_symbol(); | 4218 return *isolate->factory()->nan_symbol(); |
| 4219 } | 4219 } |
| 4220 if (isinf(value)) { | 4220 if (isinf(value)) { |
| 4221 if (value < 0) { | 4221 if (value < 0) { |
| 4222 return *isolate->factory()->minus_infinity_symbol(); | 4222 return *isolate->factory()->minus_infinity_symbol(); |
| 4223 } | 4223 } |
| 4224 return *isolate->factory()->infinity_symbol(); | 4224 return *isolate->factory()->infinity_symbol(); |
| 4225 } | 4225 } |
| 4226 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); | 4226 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); |
| 4227 int f = FastD2I(f_number); | 4227 int f = FastD2IChecked(f_number); |
| 4228 RUNTIME_ASSERT(f >= 0); | 4228 RUNTIME_ASSERT(f >= 0); |
| 4229 char* str = DoubleToFixedCString(value, f); | 4229 char* str = DoubleToFixedCString(value, f); |
| 4230 MaybeObject* res = | 4230 MaybeObject* res = |
| 4231 isolate->heap()->AllocateStringFromAscii(CStrVector(str)); | 4231 isolate->heap()->AllocateStringFromAscii(CStrVector(str)); |
| 4232 DeleteArray(str); | 4232 DeleteArray(str); |
| 4233 return res; | 4233 return res; |
| 4234 } | 4234 } |
| 4235 | 4235 |
| 4236 | 4236 |
| 4237 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToExponential) { | 4237 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToExponential) { |
| 4238 NoHandleAllocation ha; | 4238 NoHandleAllocation ha; |
| 4239 ASSERT(args.length() == 2); | 4239 ASSERT(args.length() == 2); |
| 4240 | 4240 |
| 4241 CONVERT_DOUBLE_ARG_CHECKED(value, 0); | 4241 CONVERT_DOUBLE_ARG_CHECKED(value, 0); |
| 4242 if (isnan(value)) { | 4242 if (isnan(value)) { |
| 4243 return *isolate->factory()->nan_symbol(); | 4243 return *isolate->factory()->nan_symbol(); |
| 4244 } | 4244 } |
| 4245 if (isinf(value)) { | 4245 if (isinf(value)) { |
| 4246 if (value < 0) { | 4246 if (value < 0) { |
| 4247 return *isolate->factory()->minus_infinity_symbol(); | 4247 return *isolate->factory()->minus_infinity_symbol(); |
| 4248 } | 4248 } |
| 4249 return *isolate->factory()->infinity_symbol(); | 4249 return *isolate->factory()->infinity_symbol(); |
| 4250 } | 4250 } |
| 4251 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); | 4251 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); |
| 4252 int f = FastD2I(f_number); | 4252 int f = FastD2IChecked(f_number); |
| 4253 RUNTIME_ASSERT(f >= -1 && f <= 20); | 4253 RUNTIME_ASSERT(f >= -1 && f <= 20); |
| 4254 char* str = DoubleToExponentialCString(value, f); | 4254 char* str = DoubleToExponentialCString(value, f); |
| 4255 MaybeObject* res = | 4255 MaybeObject* res = |
| 4256 isolate->heap()->AllocateStringFromAscii(CStrVector(str)); | 4256 isolate->heap()->AllocateStringFromAscii(CStrVector(str)); |
| 4257 DeleteArray(str); | 4257 DeleteArray(str); |
| 4258 return res; | 4258 return res; |
| 4259 } | 4259 } |
| 4260 | 4260 |
| 4261 | 4261 |
| 4262 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToPrecision) { | 4262 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToPrecision) { |
| 4263 NoHandleAllocation ha; | 4263 NoHandleAllocation ha; |
| 4264 ASSERT(args.length() == 2); | 4264 ASSERT(args.length() == 2); |
| 4265 | 4265 |
| 4266 CONVERT_DOUBLE_ARG_CHECKED(value, 0); | 4266 CONVERT_DOUBLE_ARG_CHECKED(value, 0); |
| 4267 if (isnan(value)) { | 4267 if (isnan(value)) { |
| 4268 return *isolate->factory()->nan_symbol(); | 4268 return *isolate->factory()->nan_symbol(); |
| 4269 } | 4269 } |
| 4270 if (isinf(value)) { | 4270 if (isinf(value)) { |
| 4271 if (value < 0) { | 4271 if (value < 0) { |
| 4272 return *isolate->factory()->minus_infinity_symbol(); | 4272 return *isolate->factory()->minus_infinity_symbol(); |
| 4273 } | 4273 } |
| 4274 return *isolate->factory()->infinity_symbol(); | 4274 return *isolate->factory()->infinity_symbol(); |
| 4275 } | 4275 } |
| 4276 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); | 4276 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); |
| 4277 int f = FastD2I(f_number); | 4277 int f = FastD2IChecked(f_number); |
| 4278 RUNTIME_ASSERT(f >= 1 && f <= 21); | 4278 RUNTIME_ASSERT(f >= 1 && f <= 21); |
| 4279 char* str = DoubleToPrecisionCString(value, f); | 4279 char* str = DoubleToPrecisionCString(value, f); |
| 4280 MaybeObject* res = | 4280 MaybeObject* res = |
| 4281 isolate->heap()->AllocateStringFromAscii(CStrVector(str)); | 4281 isolate->heap()->AllocateStringFromAscii(CStrVector(str)); |
| 4282 DeleteArray(str); | 4282 DeleteArray(str); |
| 4283 return res; | 4283 return res; |
| 4284 } | 4284 } |
| 4285 | 4285 |
| 4286 | 4286 |
| 4287 // Returns a single character string where first character equals | 4287 // Returns a single character string where first character equals |
| (...skipping 9427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13715 // Handle last resort GC and make sure to allow future allocations | 13715 // Handle last resort GC and make sure to allow future allocations |
| 13716 // to grow the heap without causing GCs (if possible). | 13716 // to grow the heap without causing GCs (if possible). |
| 13717 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13717 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 13718 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13718 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 13719 "Runtime::PerformGC"); | 13719 "Runtime::PerformGC"); |
| 13720 } | 13720 } |
| 13721 } | 13721 } |
| 13722 | 13722 |
| 13723 | 13723 |
| 13724 } } // namespace v8::internal | 13724 } } // namespace v8::internal |
| OLD | NEW |