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

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

Issue 1275013004: [runtime] Simplify TO_INT32/TO_UINT32 abstract operations. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 4 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') | src/v8natives.js » ('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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/base/bits.h" 8 #include "src/base/bits.h"
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 264
265 CONVERT_DOUBLE_ARG_CHECKED(number, 0); 265 CONVERT_DOUBLE_ARG_CHECKED(number, 0);
266 double double_value = DoubleToInteger(number); 266 double double_value = DoubleToInteger(number);
267 // Map both -0 and +0 to +0. 267 // Map both -0 and +0 to +0.
268 if (double_value == 0) double_value = 0; 268 if (double_value == 0) double_value = 0;
269 269
270 return *isolate->factory()->NewNumber(double_value); 270 return *isolate->factory()->NewNumber(double_value);
271 } 271 }
272 272
273 273
274 RUNTIME_FUNCTION(Runtime_NumberToJSUint32) {
275 HandleScope scope(isolate);
276 DCHECK(args.length() == 1);
277
278 CONVERT_NUMBER_CHECKED(int32_t, number, Uint32, args[0]);
279 return *isolate->factory()->NewNumberFromUint(number);
280 }
281
282
283 RUNTIME_FUNCTION(Runtime_NumberToJSInt32) {
284 HandleScope scope(isolate);
285 DCHECK(args.length() == 1);
286
287 CONVERT_DOUBLE_ARG_CHECKED(number, 0);
288 return *isolate->factory()->NewNumberFromInt(DoubleToInt32(number));
289 }
290
291
292 // Converts a Number to a Smi, if possible. Returns NaN if the number is not 274 // Converts a Number to a Smi, if possible. Returns NaN if the number is not
293 // a small integer. 275 // a small integer.
294 RUNTIME_FUNCTION(Runtime_NumberToSmi) { 276 RUNTIME_FUNCTION(Runtime_NumberToSmi) {
295 SealHandleScope shs(isolate); 277 SealHandleScope shs(isolate);
296 DCHECK(args.length() == 1); 278 DCHECK(args.length() == 1);
297 CONVERT_ARG_CHECKED(Object, obj, 0); 279 CONVERT_ARG_CHECKED(Object, obj, 0);
298 if (obj->IsSmi()) { 280 if (obj->IsSmi()) {
299 return obj; 281 return obj;
300 } 282 }
301 if (obj->IsHeapNumber()) { 283 if (obj->IsHeapNumber()) {
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 } 557 }
576 558
577 559
578 RUNTIME_FUNCTION(Runtime_GetRootNaN) { 560 RUNTIME_FUNCTION(Runtime_GetRootNaN) {
579 SealHandleScope shs(isolate); 561 SealHandleScope shs(isolate);
580 DCHECK(args.length() == 0); 562 DCHECK(args.length() == 0);
581 return isolate->heap()->nan_value(); 563 return isolate->heap()->nan_value();
582 } 564 }
583 } // namespace internal 565 } // namespace internal
584 } // namespace v8 566 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | src/v8natives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698