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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 HandleScope scope(isolate); | 112 HandleScope scope(isolate); |
113 DCHECK(args.length() == 1); | 113 DCHECK(args.length() == 1); |
114 isolate->counters()->math_clz32_runtime()->Increment(); | 114 isolate->counters()->math_clz32_runtime()->Increment(); |
115 | 115 |
116 CONVERT_NUMBER_CHECKED(uint32_t, x, Uint32, args[0]); | 116 CONVERT_NUMBER_CHECKED(uint32_t, x, Uint32, args[0]); |
117 return *isolate->factory()->NewNumberFromUint( | 117 return *isolate->factory()->NewNumberFromUint( |
118 base::bits::CountLeadingZeros32(x)); | 118 base::bits::CountLeadingZeros32(x)); |
119 } | 119 } |
120 | 120 |
121 | 121 |
122 RUNTIME_FUNCTION(Runtime_MathFloor) { | |
123 HandleScope scope(isolate); | |
124 DCHECK(args.length() == 1); | |
125 isolate->counters()->math_floor_runtime()->Increment(); | |
126 | |
127 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | |
128 return *isolate->factory()->NewNumber(Floor(x)); | |
129 } | |
130 | |
131 | |
132 // Slow version of Math.pow. We check for fast paths for special cases. | 122 // Slow version of Math.pow. We check for fast paths for special cases. |
133 // Used if VFP3 is not available. | 123 // Used if VFP3 is not available. |
134 RUNTIME_FUNCTION(Runtime_MathPow) { | 124 RUNTIME_FUNCTION(Runtime_MathPow) { |
135 HandleScope scope(isolate); | 125 HandleScope scope(isolate); |
136 DCHECK(args.length() == 2); | 126 DCHECK(args.length() == 2); |
137 isolate->counters()->math_pow_runtime()->Increment(); | 127 isolate->counters()->math_pow_runtime()->Increment(); |
138 | 128 |
139 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 129 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
140 | 130 |
141 // If the second argument is a smi, it is much faster to call the | 131 // If the second argument is a smi, it is much faster to call the |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 base::RandomNumberGenerator::XorShift128(&state0, &state1); | 254 base::RandomNumberGenerator::XorShift128(&state0, &state1); |
265 array[i] = base::RandomNumberGenerator::ToDouble(state0, state1); | 255 array[i] = base::RandomNumberGenerator::ToDouble(state0, state1); |
266 } | 256 } |
267 // Persist current state. | 257 // Persist current state. |
268 array[kState0Offset] = uint64_to_double(state0); | 258 array[kState0Offset] = uint64_to_double(state0); |
269 array[kState1Offset] = uint64_to_double(state1); | 259 array[kState1Offset] = uint64_to_double(state1); |
270 return *typed_array; | 260 return *typed_array; |
271 } | 261 } |
272 } // namespace internal | 262 } // namespace internal |
273 } // namespace v8 | 263 } // namespace v8 |
OLD | NEW |