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 7646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7657 return isolate->heap()->AllocateHeapNumber(std::NAME(x)); \ | 7657 return isolate->heap()->AllocateHeapNumber(std::NAME(x)); \ |
7658 } | 7658 } |
7659 | 7659 |
7660 RUNTIME_UNARY_MATH(acos) | 7660 RUNTIME_UNARY_MATH(acos) |
7661 RUNTIME_UNARY_MATH(asin) | 7661 RUNTIME_UNARY_MATH(asin) |
7662 RUNTIME_UNARY_MATH(atan) | 7662 RUNTIME_UNARY_MATH(atan) |
7663 RUNTIME_UNARY_MATH(log) | 7663 RUNTIME_UNARY_MATH(log) |
7664 #undef RUNTIME_UNARY_MATH | 7664 #undef RUNTIME_UNARY_MATH |
7665 | 7665 |
7666 | 7666 |
7667 RUNTIME_FUNCTION(MaybeObject*, Runtime_DoubleHi) { | |
7668 SealHandleScope shs(isolate); | |
7669 ASSERT(args.length() == 1); | |
7670 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | |
7671 return isolate->heap()->NumberFromDouble( | |
7672 static_cast<int32_t>(double_to_uint64(x) >> 32)); | |
7673 } | |
7674 | |
7675 | |
7676 RUNTIME_FUNCTION(MaybeObject*, Runtime_DoubleLo) { | |
7677 SealHandleScope shs(isolate); | |
7678 ASSERT(args.length() == 1); | |
7679 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | |
7680 return isolate->heap()->NumberFromDouble( | |
7681 static_cast<int32_t>(double_to_uint64(x) & 0xFFFFFFFFu)); | |
7682 } | |
7683 | |
7684 | |
7685 RUNTIME_FUNCTION(MaybeObject*, Runtime_ConstructDouble) { | |
7686 SealHandleScope shs(isolate); | |
7687 ASSERT(args.length() == 2); | |
7688 CONVERT_NUMBER_CHECKED(uint32_t, hi, Uint32, args[0]); | |
7689 CONVERT_NUMBER_CHECKED(uint32_t, lo, Uint32, args[1]); | |
7690 uint64_t result = (static_cast<uint64_t>(hi) << 32) | lo; | |
7691 return isolate->heap()->AllocateHeapNumber(uint64_to_double(result)); | |
7692 } | |
7693 | |
7694 | |
7695 // Cube root approximation, refer to: http://metamerist.com/cbrt/cbrt.htm | 7667 // Cube root approximation, refer to: http://metamerist.com/cbrt/cbrt.htm |
7696 // Using initial approximation adapted from Kahan's cbrt and 4 iterations | 7668 // Using initial approximation adapted from Kahan's cbrt and 4 iterations |
7697 // of Newton's method. | 7669 // of Newton's method. |
7698 inline double CubeRootNewtonIteration(double approx, double x) { | 7670 inline double CubeRootNewtonIteration(double approx, double x) { |
7699 return (1.0 / 3.0) * (x / (approx * approx) + 2 * approx); | 7671 return (1.0 / 3.0) * (x / (approx * approx) + 2 * approx); |
7700 } | 7672 } |
7701 | 7673 |
7702 | 7674 |
7703 inline double CubeRoot(double x) { | 7675 inline double CubeRoot(double x) { |
7704 static const uint64_t magic = V8_2PART_UINT64_C(0x2A9F7893, 00000000); | 7676 static const uint64_t magic = V8_2PART_UINT64_C(0x2A9F7893, 00000000); |
(...skipping 7240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14945 // Handle last resort GC and make sure to allow future allocations | 14917 // Handle last resort GC and make sure to allow future allocations |
14946 // to grow the heap without causing GCs (if possible). | 14918 // to grow the heap without causing GCs (if possible). |
14947 isolate->counters()->gc_last_resort_from_js()->Increment(); | 14919 isolate->counters()->gc_last_resort_from_js()->Increment(); |
14948 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 14920 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
14949 "Runtime::PerformGC"); | 14921 "Runtime::PerformGC"); |
14950 } | 14922 } |
14951 } | 14923 } |
14952 | 14924 |
14953 | 14925 |
14954 } } // namespace v8::internal | 14926 } } // namespace v8::internal |
OLD | NEW |