OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stdlib.h> | 5 #include <stdlib.h> |
6 #include <limits> | 6 #include <limits> |
7 | 7 |
8 #include "v8.h" | 8 #include "v8.h" |
9 | 9 |
10 #include "accessors.h" | 10 #include "accessors.h" |
(...skipping 7827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7838 int multiplier = (x < 0) ? -1 : 1; | 7838 int multiplier = (x < 0) ? -1 : 1; |
7839 if (y < 0) multiplier *= 3; | 7839 if (y < 0) multiplier *= 3; |
7840 result = multiplier * kPiDividedBy4; | 7840 result = multiplier * kPiDividedBy4; |
7841 } else { | 7841 } else { |
7842 result = std::atan2(x, y); | 7842 result = std::atan2(x, y); |
7843 } | 7843 } |
7844 return *isolate->factory()->NewNumber(result); | 7844 return *isolate->factory()->NewNumber(result); |
7845 } | 7845 } |
7846 | 7846 |
7847 | 7847 |
7848 RUNTIME_FUNCTION(Runtime_MathExp) { | 7848 RUNTIME_FUNCTION(Runtime_MathExpRT) { |
7849 HandleScope scope(isolate); | 7849 HandleScope scope(isolate); |
7850 ASSERT(args.length() == 1); | 7850 ASSERT(args.length() == 1); |
7851 isolate->counters()->math_exp()->Increment(); | 7851 isolate->counters()->math_exp()->Increment(); |
7852 | 7852 |
7853 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7853 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7854 lazily_initialize_fast_exp(); | 7854 lazily_initialize_fast_exp(); |
7855 return *isolate->factory()->NewNumber(fast_exp(x)); | 7855 return *isolate->factory()->NewNumber(fast_exp(x)); |
7856 } | 7856 } |
7857 | 7857 |
7858 | 7858 |
7859 RUNTIME_FUNCTION(Runtime_MathFloor) { | 7859 RUNTIME_FUNCTION(Runtime_MathFloorRT) { |
7860 HandleScope scope(isolate); | 7860 HandleScope scope(isolate); |
7861 ASSERT(args.length() == 1); | 7861 ASSERT(args.length() == 1); |
7862 isolate->counters()->math_floor()->Increment(); | 7862 isolate->counters()->math_floor()->Increment(); |
7863 | 7863 |
7864 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7864 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7865 return *isolate->factory()->NewNumber(std::floor(x)); | 7865 return *isolate->factory()->NewNumber(std::floor(x)); |
7866 } | 7866 } |
7867 | 7867 |
7868 | 7868 |
7869 // Slow version of Math.pow. We check for fast paths for special cases. | 7869 // Slow version of Math.pow. We check for fast paths for special cases. |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7944 return *number; | 7944 return *number; |
7945 } | 7945 } |
7946 | 7946 |
7947 if (sign && value >= -0.5) return isolate->heap()->minus_zero_value(); | 7947 if (sign && value >= -0.5) return isolate->heap()->minus_zero_value(); |
7948 | 7948 |
7949 // Do not call NumberFromDouble() to avoid extra checks. | 7949 // Do not call NumberFromDouble() to avoid extra checks. |
7950 return *isolate->factory()->NewNumber(std::floor(value + 0.5)); | 7950 return *isolate->factory()->NewNumber(std::floor(value + 0.5)); |
7951 } | 7951 } |
7952 | 7952 |
7953 | 7953 |
7954 RUNTIME_FUNCTION(Runtime_MathSqrt) { | 7954 RUNTIME_FUNCTION(Runtime_MathSqrtRT) { |
7955 HandleScope scope(isolate); | 7955 HandleScope scope(isolate); |
7956 ASSERT(args.length() == 1); | 7956 ASSERT(args.length() == 1); |
7957 isolate->counters()->math_sqrt()->Increment(); | 7957 isolate->counters()->math_sqrt()->Increment(); |
7958 | 7958 |
7959 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7959 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7960 return *isolate->factory()->NewNumber(fast_sqrt(x)); | 7960 return *isolate->factory()->NewNumber(fast_sqrt(x)); |
7961 } | 7961 } |
7962 | 7962 |
7963 | 7963 |
7964 RUNTIME_FUNCTION(Runtime_MathFround) { | 7964 RUNTIME_FUNCTION(Runtime_MathFround) { |
(...skipping 7258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15223 } | 15223 } |
15224 return NULL; | 15224 return NULL; |
15225 } | 15225 } |
15226 | 15226 |
15227 | 15227 |
15228 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { | 15228 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { |
15229 return &(kIntrinsicFunctions[static_cast<int>(id)]); | 15229 return &(kIntrinsicFunctions[static_cast<int>(id)]); |
15230 } | 15230 } |
15231 | 15231 |
15232 } } // namespace v8::internal | 15232 } } // namespace v8::internal |
OLD | NEW |