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 7647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7658 return isolate->heap()->AllocateHeapNumber(std::NAME(x)); \ | 7658 return isolate->heap()->AllocateHeapNumber(std::NAME(x)); \ |
7659 } | 7659 } |
7660 | 7660 |
7661 RUNTIME_UNARY_MATH(acos) | 7661 RUNTIME_UNARY_MATH(acos) |
7662 RUNTIME_UNARY_MATH(asin) | 7662 RUNTIME_UNARY_MATH(asin) |
7663 RUNTIME_UNARY_MATH(atan) | 7663 RUNTIME_UNARY_MATH(atan) |
7664 RUNTIME_UNARY_MATH(log) | 7664 RUNTIME_UNARY_MATH(log) |
7665 #undef RUNTIME_UNARY_MATH | 7665 #undef RUNTIME_UNARY_MATH |
7666 | 7666 |
7667 | 7667 |
| 7668 RUNTIME_FUNCTION(MaybeObject*, Runtime_DoubleHi) { |
| 7669 SealHandleScope shs(isolate); |
| 7670 ASSERT(args.length() == 1); |
| 7671 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7672 uint64_t integer = double_to_uint64(x); |
| 7673 integer = (integer >> 32) & 0xFFFFFFFFu; |
| 7674 return isolate->heap()->NumberFromDouble(static_cast<int32_t>(integer)); |
| 7675 } |
| 7676 |
| 7677 |
| 7678 RUNTIME_FUNCTION(MaybeObject*, Runtime_DoubleLo) { |
| 7679 SealHandleScope shs(isolate); |
| 7680 ASSERT(args.length() == 1); |
| 7681 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7682 return isolate->heap()->NumberFromDouble( |
| 7683 static_cast<int32_t>(double_to_uint64(x) & 0xFFFFFFFFu)); |
| 7684 } |
| 7685 |
| 7686 |
| 7687 RUNTIME_FUNCTION(MaybeObject*, Runtime_ConstructDouble) { |
| 7688 SealHandleScope shs(isolate); |
| 7689 ASSERT(args.length() == 2); |
| 7690 CONVERT_NUMBER_CHECKED(uint32_t, hi, Uint32, args[0]); |
| 7691 CONVERT_NUMBER_CHECKED(uint32_t, lo, Uint32, args[1]); |
| 7692 uint64_t result = (static_cast<uint64_t>(hi) << 32) | lo; |
| 7693 return isolate->heap()->AllocateHeapNumber(uint64_to_double(result)); |
| 7694 } |
| 7695 |
| 7696 |
7668 // Cube root approximation, refer to: http://metamerist.com/cbrt/cbrt.htm | 7697 // Cube root approximation, refer to: http://metamerist.com/cbrt/cbrt.htm |
7669 // Using initial approximation adapted from Kahan's cbrt and 4 iterations | 7698 // Using initial approximation adapted from Kahan's cbrt and 4 iterations |
7670 // of Newton's method. | 7699 // of Newton's method. |
7671 inline double CubeRootNewtonIteration(double approx, double x) { | 7700 inline double CubeRootNewtonIteration(double approx, double x) { |
7672 return (1.0 / 3.0) * (x / (approx * approx) + 2 * approx); | 7701 return (1.0 / 3.0) * (x / (approx * approx) + 2 * approx); |
7673 } | 7702 } |
7674 | 7703 |
7675 | 7704 |
7676 inline double CubeRoot(double x) { | 7705 inline double CubeRoot(double x) { |
7677 static const uint64_t magic = V8_2PART_UINT64_C(0x2A9F7893, 00000000); | 7706 static const uint64_t magic = V8_2PART_UINT64_C(0x2A9F7893, 00000000); |
(...skipping 7288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14966 // Handle last resort GC and make sure to allow future allocations | 14995 // Handle last resort GC and make sure to allow future allocations |
14967 // to grow the heap without causing GCs (if possible). | 14996 // to grow the heap without causing GCs (if possible). |
14968 isolate->counters()->gc_last_resort_from_js()->Increment(); | 14997 isolate->counters()->gc_last_resort_from_js()->Increment(); |
14969 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 14998 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
14970 "Runtime::PerformGC"); | 14999 "Runtime::PerformGC"); |
14971 } | 15000 } |
14972 } | 15001 } |
14973 | 15002 |
14974 | 15003 |
14975 } } // namespace v8::internal | 15004 } } // namespace v8::internal |
OLD | NEW |