Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(408)

Side by Side Diff: src/runtime/runtime-maths.cc

Issue 1828253002: [builtins] Provide Math.floor as TurboFan builtin. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE. Address feedback. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/runtime/runtime.h ('k') | test/cctest/compiler/test-code-stub-assembler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | test/cctest/compiler/test-code-stub-assembler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698