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 7662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7673 : StringCharacterStreamCompare(isolate->runtime_state(), x, y); | 7673 : StringCharacterStreamCompare(isolate->runtime_state(), x, y); |
7674 } | 7674 } |
7675 | 7675 |
7676 | 7676 |
7677 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_acos) { | 7677 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_acos) { |
7678 SealHandleScope shs(isolate); | 7678 SealHandleScope shs(isolate); |
7679 ASSERT(args.length() == 1); | 7679 ASSERT(args.length() == 1); |
7680 isolate->counters()->math_acos()->Increment(); | 7680 isolate->counters()->math_acos()->Increment(); |
7681 | 7681 |
7682 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7682 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7683 return isolate->heap()->AllocateHeapNumber(acos(x)); | 7683 return isolate->heap()->AllocateHeapNumber(std::acos(x)); |
7684 } | 7684 } |
7685 | 7685 |
7686 | 7686 |
7687 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_asin) { | 7687 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_asin) { |
7688 SealHandleScope shs(isolate); | 7688 SealHandleScope shs(isolate); |
7689 ASSERT(args.length() == 1); | 7689 ASSERT(args.length() == 1); |
7690 isolate->counters()->math_asin()->Increment(); | 7690 isolate->counters()->math_asin()->Increment(); |
7691 | 7691 |
7692 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7692 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7693 return isolate->heap()->AllocateHeapNumber(asin(x)); | 7693 return isolate->heap()->AllocateHeapNumber(std::asin(x)); |
7694 } | 7694 } |
7695 | 7695 |
7696 | 7696 |
7697 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan) { | 7697 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan) { |
7698 SealHandleScope shs(isolate); | 7698 SealHandleScope shs(isolate); |
7699 ASSERT(args.length() == 1); | 7699 ASSERT(args.length() == 1); |
7700 isolate->counters()->math_atan()->Increment(); | 7700 isolate->counters()->math_atan()->Increment(); |
7701 | 7701 |
7702 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7702 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7703 return isolate->heap()->AllocateHeapNumber(atan(x)); | 7703 return isolate->heap()->AllocateHeapNumber(std::atan(x)); |
7704 } | 7704 } |
7705 | 7705 |
7706 | 7706 |
7707 static const double kPiDividedBy4 = 0.78539816339744830962; | 7707 static const double kPiDividedBy4 = 0.78539816339744830962; |
7708 | 7708 |
7709 | 7709 |
7710 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan2) { | 7710 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan2) { |
7711 SealHandleScope shs(isolate); | 7711 SealHandleScope shs(isolate); |
7712 ASSERT(args.length() == 2); | 7712 ASSERT(args.length() == 2); |
7713 isolate->counters()->math_atan2()->Increment(); | 7713 isolate->counters()->math_atan2()->Increment(); |
7714 | 7714 |
7715 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7715 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7716 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 7716 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
7717 double result; | 7717 double result; |
7718 if (std::isinf(x) && std::isinf(y)) { | 7718 if (std::isinf(x) && std::isinf(y)) { |
7719 // Make sure that the result in case of two infinite arguments | 7719 // Make sure that the result in case of two infinite arguments |
7720 // is a multiple of Pi / 4. The sign of the result is determined | 7720 // is a multiple of Pi / 4. The sign of the result is determined |
7721 // by the first argument (x) and the sign of the second argument | 7721 // by the first argument (x) and the sign of the second argument |
7722 // determines the multiplier: one or three. | 7722 // determines the multiplier: one or three. |
7723 int multiplier = (x < 0) ? -1 : 1; | 7723 int multiplier = (x < 0) ? -1 : 1; |
7724 if (y < 0) multiplier *= 3; | 7724 if (y < 0) multiplier *= 3; |
7725 result = multiplier * kPiDividedBy4; | 7725 result = multiplier * kPiDividedBy4; |
7726 } else { | 7726 } else { |
7727 result = atan2(x, y); | 7727 result = std::atan2(x, y); |
7728 } | 7728 } |
7729 return isolate->heap()->AllocateHeapNumber(result); | 7729 return isolate->heap()->AllocateHeapNumber(result); |
7730 } | 7730 } |
7731 | 7731 |
7732 | 7732 |
7733 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_exp) { | 7733 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_exp) { |
7734 SealHandleScope shs(isolate); | 7734 SealHandleScope shs(isolate); |
7735 ASSERT(args.length() == 1); | 7735 ASSERT(args.length() == 1); |
7736 isolate->counters()->math_exp()->Increment(); | 7736 isolate->counters()->math_exp()->Increment(); |
7737 | 7737 |
7738 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7738 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7739 lazily_initialize_fast_exp(); | 7739 lazily_initialize_fast_exp(); |
7740 return isolate->heap()->NumberFromDouble(fast_exp(x)); | 7740 return isolate->heap()->NumberFromDouble(fast_exp(x)); |
7741 } | 7741 } |
7742 | 7742 |
7743 | 7743 |
7744 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_floor) { | 7744 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_floor) { |
7745 SealHandleScope shs(isolate); | 7745 SealHandleScope shs(isolate); |
7746 ASSERT(args.length() == 1); | 7746 ASSERT(args.length() == 1); |
7747 isolate->counters()->math_floor()->Increment(); | 7747 isolate->counters()->math_floor()->Increment(); |
7748 | 7748 |
7749 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7749 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7750 return isolate->heap()->NumberFromDouble(floor(x)); | 7750 return isolate->heap()->NumberFromDouble(std::floor(x)); |
7751 } | 7751 } |
7752 | 7752 |
7753 | 7753 |
7754 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_log) { | 7754 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_log) { |
7755 SealHandleScope shs(isolate); | 7755 SealHandleScope shs(isolate); |
7756 ASSERT(args.length() == 1); | 7756 ASSERT(args.length() == 1); |
7757 isolate->counters()->math_log()->Increment(); | 7757 isolate->counters()->math_log()->Increment(); |
7758 | 7758 |
7759 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7759 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7760 return isolate->heap()->AllocateHeapNumber(log(x)); | 7760 return isolate->heap()->AllocateHeapNumber(std::log(x)); |
7761 } | 7761 } |
7762 | 7762 |
7763 | 7763 |
7764 // Slow version of Math.pow. We check for fast paths for special cases. | 7764 // Slow version of Math.pow. We check for fast paths for special cases. |
7765 // Used if SSE2/VFP3 is not available. | 7765 // Used if SSE2/VFP3 is not available. |
7766 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_pow) { | 7766 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_pow) { |
7767 SealHandleScope shs(isolate); | 7767 SealHandleScope shs(isolate); |
7768 ASSERT(args.length() == 2); | 7768 ASSERT(args.length() == 2); |
7769 isolate->counters()->math_pow()->Increment(); | 7769 isolate->counters()->math_pow()->Increment(); |
7770 | 7770 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7835 | 7835 |
7836 // If the magnitude is big enough, there's no place for fraction part. If we | 7836 // If the magnitude is big enough, there's no place for fraction part. If we |
7837 // try to add 0.5 to this number, 1.0 will be added instead. | 7837 // try to add 0.5 to this number, 1.0 will be added instead. |
7838 if (exponent >= 52) { | 7838 if (exponent >= 52) { |
7839 return number; | 7839 return number; |
7840 } | 7840 } |
7841 | 7841 |
7842 if (sign && value >= -0.5) return isolate->heap()->minus_zero_value(); | 7842 if (sign && value >= -0.5) return isolate->heap()->minus_zero_value(); |
7843 | 7843 |
7844 // Do not call NumberFromDouble() to avoid extra checks. | 7844 // Do not call NumberFromDouble() to avoid extra checks. |
7845 return isolate->heap()->AllocateHeapNumber(floor(value + 0.5)); | 7845 return isolate->heap()->AllocateHeapNumber(std::floor(value + 0.5)); |
7846 } | 7846 } |
7847 | 7847 |
7848 | 7848 |
7849 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_sqrt) { | 7849 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_sqrt) { |
7850 SealHandleScope shs(isolate); | 7850 SealHandleScope shs(isolate); |
7851 ASSERT(args.length() == 1); | 7851 ASSERT(args.length() == 1); |
7852 isolate->counters()->math_sqrt()->Increment(); | 7852 isolate->counters()->math_sqrt()->Increment(); |
7853 | 7853 |
7854 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7854 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7855 return isolate->heap()->AllocateHeapNumber(fast_sqrt(x)); | 7855 return isolate->heap()->AllocateHeapNumber(fast_sqrt(x)); |
(...skipping 1694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9550 | 9550 |
9551 | 9551 |
9552 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateCurrentTime) { | 9552 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateCurrentTime) { |
9553 SealHandleScope shs(isolate); | 9553 SealHandleScope shs(isolate); |
9554 ASSERT(args.length() == 0); | 9554 ASSERT(args.length() == 0); |
9555 | 9555 |
9556 // According to ECMA-262, section 15.9.1, page 117, the precision of | 9556 // According to ECMA-262, section 15.9.1, page 117, the precision of |
9557 // the number in a Date object representing a particular instant in | 9557 // the number in a Date object representing a particular instant in |
9558 // time is milliseconds. Therefore, we floor the result of getting | 9558 // time is milliseconds. Therefore, we floor the result of getting |
9559 // the OS time. | 9559 // the OS time. |
9560 double millis = floor(OS::TimeCurrentMillis()); | 9560 double millis = std::floor(OS::TimeCurrentMillis()); |
9561 return isolate->heap()->NumberFromDouble(millis); | 9561 return isolate->heap()->NumberFromDouble(millis); |
9562 } | 9562 } |
9563 | 9563 |
9564 | 9564 |
9565 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateParseString) { | 9565 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateParseString) { |
9566 HandleScope scope(isolate); | 9566 HandleScope scope(isolate); |
9567 ASSERT(args.length() == 2); | 9567 ASSERT(args.length() == 2); |
9568 | 9568 |
9569 CONVERT_ARG_HANDLE_CHECKED(String, str, 0); | 9569 CONVERT_ARG_HANDLE_CHECKED(String, str, 0); |
9570 FlattenString(str); | 9570 FlattenString(str); |
(...skipping 5320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14891 // Handle last resort GC and make sure to allow future allocations | 14891 // Handle last resort GC and make sure to allow future allocations |
14892 // to grow the heap without causing GCs (if possible). | 14892 // to grow the heap without causing GCs (if possible). |
14893 isolate->counters()->gc_last_resort_from_js()->Increment(); | 14893 isolate->counters()->gc_last_resort_from_js()->Increment(); |
14894 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 14894 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
14895 "Runtime::PerformGC"); | 14895 "Runtime::PerformGC"); |
14896 } | 14896 } |
14897 } | 14897 } |
14898 | 14898 |
14899 | 14899 |
14900 } } // namespace v8::internal | 14900 } } // namespace v8::internal |
OLD | NEW |