OLD | NEW |
1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
2 // All Rights Reserved. | 2 // All Rights Reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
10 // | 10 // |
(...skipping 21 matching lines...) Expand all Loading... |
32 // modified significantly by Google Inc. | 32 // modified significantly by Google Inc. |
33 // Copyright 2012 the V8 project authors. All rights reserved. | 33 // Copyright 2012 the V8 project authors. All rights reserved. |
34 | 34 |
35 #include "src/assembler.h" | 35 #include "src/assembler.h" |
36 | 36 |
37 #include <math.h> | 37 #include <math.h> |
38 #include <cmath> | 38 #include <cmath> |
39 #include "src/api.h" | 39 #include "src/api.h" |
40 #include "src/base/cpu.h" | 40 #include "src/base/cpu.h" |
41 #include "src/base/functional.h" | 41 #include "src/base/functional.h" |
| 42 #include "src/base/ieee754.h" |
42 #include "src/base/lazy-instance.h" | 43 #include "src/base/lazy-instance.h" |
43 #include "src/base/platform/platform.h" | 44 #include "src/base/platform/platform.h" |
44 #include "src/base/utils/random-number-generator.h" | 45 #include "src/base/utils/random-number-generator.h" |
45 #include "src/builtins.h" | 46 #include "src/builtins.h" |
46 #include "src/codegen.h" | 47 #include "src/codegen.h" |
47 #include "src/counters.h" | 48 #include "src/counters.h" |
48 #include "src/debug/debug.h" | 49 #include "src/debug/debug.h" |
49 #include "src/deoptimizer.h" | 50 #include "src/deoptimizer.h" |
50 #include "src/disassembler.h" | 51 #include "src/disassembler.h" |
51 #include "src/execution.h" | 52 #include "src/execution.h" |
(...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1020 | 1021 |
1021 math_exp_constants_array = new double[9]; | 1022 math_exp_constants_array = new double[9]; |
1022 // Input values smaller than this always return 0. | 1023 // Input values smaller than this always return 0. |
1023 math_exp_constants_array[0] = -708.39641853226408; | 1024 math_exp_constants_array[0] = -708.39641853226408; |
1024 // Input values larger than this always return +Infinity. | 1025 // Input values larger than this always return +Infinity. |
1025 math_exp_constants_array[1] = 709.78271289338397; | 1026 math_exp_constants_array[1] = 709.78271289338397; |
1026 math_exp_constants_array[2] = V8_INFINITY; | 1027 math_exp_constants_array[2] = V8_INFINITY; |
1027 // The rest is black magic. Do not attempt to understand it. It is | 1028 // The rest is black magic. Do not attempt to understand it. It is |
1028 // loosely based on the "expd" function published at: | 1029 // loosely based on the "expd" function published at: |
1029 // http://herumi.blogspot.com/2011/08/fast-double-precision-exponential.html | 1030 // http://herumi.blogspot.com/2011/08/fast-double-precision-exponential.html |
1030 const double constant3 = (1 << kTableSizeBits) / std::log(2.0); | 1031 const double constant3 = (1 << kTableSizeBits) / base::ieee754::log(2.0); |
1031 math_exp_constants_array[3] = constant3; | 1032 math_exp_constants_array[3] = constant3; |
1032 math_exp_constants_array[4] = | 1033 math_exp_constants_array[4] = |
1033 static_cast<double>(static_cast<int64_t>(3) << 51); | 1034 static_cast<double>(static_cast<int64_t>(3) << 51); |
1034 math_exp_constants_array[5] = 1 / constant3; | 1035 math_exp_constants_array[5] = 1 / constant3; |
1035 math_exp_constants_array[6] = 3.0000000027955394; | 1036 math_exp_constants_array[6] = 3.0000000027955394; |
1036 math_exp_constants_array[7] = 0.16666666685227835; | 1037 math_exp_constants_array[7] = 0.16666666685227835; |
1037 math_exp_constants_array[8] = 1; | 1038 math_exp_constants_array[8] = 1; |
1038 | 1039 |
1039 math_exp_log_table_array = new double[kTableSize]; | 1040 math_exp_log_table_array = new double[kTableSize]; |
1040 for (int i = 0; i < kTableSize; i++) { | 1041 for (int i = 0; i < kTableSize; i++) { |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1640 isolate->regexp_stack()->memory_address()); | 1641 isolate->regexp_stack()->memory_address()); |
1641 } | 1642 } |
1642 | 1643 |
1643 ExternalReference ExternalReference::address_of_regexp_stack_memory_size( | 1644 ExternalReference ExternalReference::address_of_regexp_stack_memory_size( |
1644 Isolate* isolate) { | 1645 Isolate* isolate) { |
1645 return ExternalReference(isolate->regexp_stack()->memory_size_address()); | 1646 return ExternalReference(isolate->regexp_stack()->memory_size_address()); |
1646 } | 1647 } |
1647 | 1648 |
1648 #endif // V8_INTERPRETED_REGEXP | 1649 #endif // V8_INTERPRETED_REGEXP |
1649 | 1650 |
1650 | 1651 ExternalReference ExternalReference::ieee754_log_function(Isolate* isolate) { |
1651 ExternalReference ExternalReference::math_log_double_function( | 1652 return ExternalReference( |
1652 Isolate* isolate) { | 1653 Redirect(isolate, FUNCTION_ADDR(base::ieee754::log), BUILTIN_FP_CALL)); |
1653 typedef double (*d2d)(double x); | |
1654 return ExternalReference(Redirect(isolate, | |
1655 FUNCTION_ADDR(static_cast<d2d>(std::log)), | |
1656 BUILTIN_FP_CALL)); | |
1657 } | 1654 } |
1658 | 1655 |
1659 | 1656 |
1660 ExternalReference ExternalReference::math_exp_constants(int constant_index) { | 1657 ExternalReference ExternalReference::math_exp_constants(int constant_index) { |
1661 DCHECK(math_exp_data_initialized); | 1658 DCHECK(math_exp_data_initialized); |
1662 return ExternalReference( | 1659 return ExternalReference( |
1663 reinterpret_cast<void*>(math_exp_constants_array + constant_index)); | 1660 reinterpret_cast<void*>(math_exp_constants_array + constant_index)); |
1664 } | 1661 } |
1665 | 1662 |
1666 | 1663 |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2116 | 2113 |
2117 | 2114 |
2118 void Assembler::DataAlign(int m) { | 2115 void Assembler::DataAlign(int m) { |
2119 DCHECK(m >= 2 && base::bits::IsPowerOfTwo32(m)); | 2116 DCHECK(m >= 2 && base::bits::IsPowerOfTwo32(m)); |
2120 while ((pc_offset() & (m - 1)) != 0) { | 2117 while ((pc_offset() & (m - 1)) != 0) { |
2121 db(0); | 2118 db(0); |
2122 } | 2119 } |
2123 } | 2120 } |
2124 } // namespace internal | 2121 } // namespace internal |
2125 } // namespace v8 | 2122 } // namespace v8 |
OLD | NEW |