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

Side by Side Diff: Source/bindings/core/v8/V8Binding.cpp

Issue 1009283002: [bindings] Split toInt64 into fast inline vs slow non-inline code paths. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 9 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 | « Source/bindings/core/v8/V8Binding.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. 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 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 400
401 return numberObject->Uint32Value(); 401 return numberObject->Uint32Value();
402 } 402 }
403 403
404 uint32_t toUInt32(v8::Handle<v8::Value> value) 404 uint32_t toUInt32(v8::Handle<v8::Value> value)
405 { 405 {
406 NonThrowableExceptionState exceptionState; 406 NonThrowableExceptionState exceptionState;
407 return toUInt32(value, NormalConversion, exceptionState); 407 return toUInt32(value, NormalConversion, exceptionState);
408 } 408 }
409 409
410 int64_t toInt64(v8::Handle<v8::Value> value, IntegerConversionConfiguration conf iguration, ExceptionState& exceptionState) 410 int64_t toInt64Slow(v8::Handle<v8::Value> value, IntegerConversionConfiguration configuration, ExceptionState& exceptionState)
411 { 411 {
412 // Clamping not supported for int64_t/long long int. See Source/wtf/MathExtr as.h. 412 ASSERT(!value->IsInt32());
413 ASSERT(configuration != Clamp);
414
415 // Fast case. The value is a 32-bit integer.
416 if (value->IsInt32())
417 return value->Int32Value();
418 413
419 v8::Local<v8::Number> numberObject; 414 v8::Local<v8::Number> numberObject;
420 if (value->IsNumber()) { 415 v8::Isolate* isolate = v8::Isolate::GetCurrent();
421 numberObject = value.As<v8::Number>(); 416 // Can the value be converted to a number?
422 } else { 417 v8::TryCatch block(isolate);
423 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 418 numberObject = value->ToNumber(isolate);
424 // Can the value be converted to a number? 419 if (block.HasCaught()) {
425 v8::TryCatch block(isolate); 420 exceptionState.rethrowV8Exception(block.Exception());
426 numberObject = value->ToNumber(isolate); 421 return 0;
427 if (block.HasCaught()) {
428 exceptionState.rethrowV8Exception(block.Exception());
429 return 0;
430 }
431 } 422 }
432 ASSERT(!numberObject.IsEmpty()); 423 ASSERT(!numberObject.IsEmpty());
433 424
434 double numberValue = numberObject->Value(); 425 double numberValue = numberObject->Value();
435 426
436 if (configuration == EnforceRange) 427 if (configuration == EnforceRange)
437 return enforceRange(numberValue, -kJSMaxInteger, kJSMaxInteger, "long lo ng", exceptionState); 428 return enforceRange(numberValue, -kJSMaxInteger, kJSMaxInteger, "long lo ng", exceptionState);
438 429
439 if (std::isnan(numberValue) || std::isinf(numberValue)) 430 if (std::isnan(numberValue) || std::isinf(numberValue))
440 return 0; 431 return 0;
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 { 1042 {
1052 v8ConstructorAttributeGetter(info); 1043 v8ConstructorAttributeGetter(info);
1053 } 1044 }
1054 1045
1055 void v8ConstructorAttributeGetterAsAccessor(const v8::FunctionCallbackInfo<v8::V alue>& info) 1046 void v8ConstructorAttributeGetterAsAccessor(const v8::FunctionCallbackInfo<v8::V alue>& info)
1056 { 1047 {
1057 v8ConstructorAttributeGetter(info); 1048 v8ConstructorAttributeGetter(info);
1058 } 1049 }
1059 1050
1060 } // namespace blink 1051 } // namespace blink
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/V8Binding.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698