OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/assembler.h" | 8 #include "src/assembler.h" |
9 #include "src/base/utils/random-number-generator.h" | 9 #include "src/base/utils/random-number-generator.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 HandleScope scope(isolate); | 101 HandleScope scope(isolate); |
102 DCHECK(args.length() == 1); | 102 DCHECK(args.length() == 1); |
103 isolate->counters()->math_exp_runtime()->Increment(); | 103 isolate->counters()->math_exp_runtime()->Increment(); |
104 | 104 |
105 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 105 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
106 lazily_initialize_fast_exp(isolate); | 106 lazily_initialize_fast_exp(isolate); |
107 return *isolate->factory()->NewNumber(fast_exp(x, isolate)); | 107 return *isolate->factory()->NewNumber(fast_exp(x, isolate)); |
108 } | 108 } |
109 | 109 |
110 | 110 |
111 RUNTIME_FUNCTION(Runtime_MathClz32) { | |
112 HandleScope scope(isolate); | |
113 DCHECK(args.length() == 1); | |
114 isolate->counters()->math_clz32_runtime()->Increment(); | |
115 | |
116 CONVERT_NUMBER_CHECKED(uint32_t, x, Uint32, args[0]); | |
117 return *isolate->factory()->NewNumberFromUint( | |
118 base::bits::CountLeadingZeros32(x)); | |
119 } | |
120 | |
121 | |
122 // Slow version of Math.pow. We check for fast paths for special cases. | 111 // Slow version of Math.pow. We check for fast paths for special cases. |
123 // Used if VFP3 is not available. | 112 // Used if VFP3 is not available. |
124 RUNTIME_FUNCTION(Runtime_MathPow) { | 113 RUNTIME_FUNCTION(Runtime_MathPow) { |
125 HandleScope scope(isolate); | 114 HandleScope scope(isolate); |
126 DCHECK(args.length() == 2); | 115 DCHECK(args.length() == 2); |
127 isolate->counters()->math_pow_runtime()->Increment(); | 116 isolate->counters()->math_pow_runtime()->Increment(); |
128 | 117 |
129 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 118 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
130 | 119 |
131 // If the second argument is a smi, it is much faster to call the | 120 // If the second argument is a smi, it is much faster to call the |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 base::RandomNumberGenerator::XorShift128(&state0, &state1); | 200 base::RandomNumberGenerator::XorShift128(&state0, &state1); |
212 array[i] = base::RandomNumberGenerator::ToDouble(state0, state1); | 201 array[i] = base::RandomNumberGenerator::ToDouble(state0, state1); |
213 } | 202 } |
214 // Persist current state. | 203 // Persist current state. |
215 array[kState0Offset] = uint64_to_double(state0); | 204 array[kState0Offset] = uint64_to_double(state0); |
216 array[kState1Offset] = uint64_to_double(state1); | 205 array[kState1Offset] = uint64_to_double(state1); |
217 return *typed_array; | 206 return *typed_array; |
218 } | 207 } |
219 } // namespace internal | 208 } // namespace internal |
220 } // namespace v8 | 209 } // namespace v8 |
OLD | NEW |