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 return isolate->heap()->AllocateHeapNumber(std::NAME(x)); \ | 7673 return isolate->heap()->AllocateHeapNumber(std::NAME(x)); \ |
7674 } | 7674 } |
7675 | 7675 |
7676 RUNTIME_UNARY_MATH(acos) | 7676 RUNTIME_UNARY_MATH(acos) |
7677 RUNTIME_UNARY_MATH(asin) | 7677 RUNTIME_UNARY_MATH(asin) |
7678 RUNTIME_UNARY_MATH(atan) | 7678 RUNTIME_UNARY_MATH(atan) |
7679 RUNTIME_UNARY_MATH(log) | 7679 RUNTIME_UNARY_MATH(log) |
7680 #undef RUNTIME_UNARY_MATH | 7680 #undef RUNTIME_UNARY_MATH |
7681 | 7681 |
7682 | 7682 |
| 7683 RUNTIME_FUNCTION(MaybeObject*, Runtime_DoubleHi) { |
| 7684 SealHandleScope shs(isolate); |
| 7685 ASSERT(args.length() == 1); |
| 7686 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7687 return isolate->heap()->NumberFromDouble( |
| 7688 static_cast<int32_t>(double_to_uint64(x) >> 32)); |
| 7689 } |
| 7690 |
| 7691 |
| 7692 RUNTIME_FUNCTION(MaybeObject*, Runtime_DoubleLo) { |
| 7693 SealHandleScope shs(isolate); |
| 7694 ASSERT(args.length() == 1); |
| 7695 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7696 return isolate->heap()->NumberFromDouble( |
| 7697 static_cast<int32_t>(double_to_uint64(x) & 0xFFFFFFFFu)); |
| 7698 } |
| 7699 |
| 7700 |
| 7701 RUNTIME_FUNCTION(MaybeObject*, Runtime_ConstructDouble) { |
| 7702 SealHandleScope shs(isolate); |
| 7703 ASSERT(args.length() == 2); |
| 7704 CONVERT_NUMBER_CHECKED(uint32_t, hi, Uint32, args[0]); |
| 7705 CONVERT_NUMBER_CHECKED(uint32_t, lo, Uint32, args[1]); |
| 7706 uint64_t result = (static_cast<uint64_t>(hi) << 32) | lo; |
| 7707 return isolate->heap()->AllocateHeapNumber(uint64_to_double(result)); |
| 7708 } |
| 7709 |
| 7710 |
7683 // Cube root approximation, refer to: http://metamerist.com/cbrt/cbrt.htm | 7711 // Cube root approximation, refer to: http://metamerist.com/cbrt/cbrt.htm |
7684 // Using initial approximation adapted from Kahan's cbrt and 4 iterations | 7712 // Using initial approximation adapted from Kahan's cbrt and 4 iterations |
7685 // of Newton's method. | 7713 // of Newton's method. |
7686 inline double CubeRootNewtonIteration(double approx, double x) { | 7714 inline double CubeRootNewtonIteration(double approx, double x) { |
7687 return (1.0 / 3.0) * (x / (approx * approx) + 2 * approx); | 7715 return (1.0 / 3.0) * (x / (approx * approx) + 2 * approx); |
7688 } | 7716 } |
7689 | 7717 |
7690 | 7718 |
7691 inline double CubeRoot(double x) { | 7719 inline double CubeRoot(double x) { |
7692 static const uint64_t magic = V8_2PART_UINT64_C(0x2A9F7893, 00000000); | 7720 static const uint64_t magic = V8_2PART_UINT64_C(0x2A9F7893, 00000000); |
(...skipping 7300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14993 // Handle last resort GC and make sure to allow future allocations | 15021 // Handle last resort GC and make sure to allow future allocations |
14994 // to grow the heap without causing GCs (if possible). | 15022 // to grow the heap without causing GCs (if possible). |
14995 isolate->counters()->gc_last_resort_from_js()->Increment(); | 15023 isolate->counters()->gc_last_resort_from_js()->Increment(); |
14996 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 15024 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
14997 "Runtime::PerformGC"); | 15025 "Runtime::PerformGC"); |
14998 } | 15026 } |
14999 } | 15027 } |
15000 | 15028 |
15001 | 15029 |
15002 } } // namespace v8::internal | 15030 } } // namespace v8::internal |
OLD | NEW |