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