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

Unified Diff: Source/bindings/core/v8/V8Binding.cpp

Issue 947123002: [bindings] Split toUInt32 into faster inline and non-inline slower path. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Patch for landing Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/bindings/core/v8/V8Binding.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/core/v8/V8Binding.cpp
diff --git a/Source/bindings/core/v8/V8Binding.cpp b/Source/bindings/core/v8/V8Binding.cpp
index fd48a502ada3ea0db78f4fb100a94108dd3550de..9df28272da24d8d4f348fd2c8fce6bb4bd95eddc 100644
--- a/Source/bindings/core/v8/V8Binding.cpp
+++ b/Source/bindings/core/v8/V8Binding.cpp
@@ -351,14 +351,11 @@ int32_t toInt32(v8::Handle<v8::Value> value)
return toInt32(value, NormalConversion, exceptionState);
}
-uint32_t toUInt32(v8::Handle<v8::Value> value, IntegerConversionConfiguration configuration, ExceptionState& exceptionState)
+uint32_t toUInt32Slow(v8::Handle<v8::Value> value, IntegerConversionConfiguration configuration, ExceptionState& exceptionState)
{
- // Fast case. The value is already a 32-bit unsigned integer.
- if (value->IsUint32())
- return value->Uint32Value();
-
- // Fast case. The value is a 32-bit signed integer - possibly positive?
+ ASSERT(!value->IsUint32());
if (value->IsInt32()) {
+ ASSERT(configuration != NormalConversion);
int32_t result = value->Int32Value();
if (result >= 0)
return result;
@@ -366,23 +363,17 @@ uint32_t toUInt32(v8::Handle<v8::Value> value, IntegerConversionConfiguration co
exceptionState.throwTypeError("Value is outside the 'unsigned long' value range.");
return 0;
}
- if (configuration == Clamp)
- return clampTo<uint32_t>(result);
- return result;
+ ASSERT(configuration == Clamp);
+ return clampTo<uint32_t>(result);
}
- v8::Local<v8::Number> numberObject;
- if (value->IsNumber()) {
- numberObject = value.As<v8::Number>();
- } else {
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
- // Can the value be converted to a number?
- v8::TryCatch block(isolate);
- numberObject = value->ToNumber(isolate);
- if (block.HasCaught()) {
- exceptionState.rethrowV8Exception(block.Exception());
- return 0;
- }
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ // Can the value be converted to a number?
+ v8::TryCatch block(isolate);
+ v8::Local<v8::Number> numberObject = value->ToNumber(isolate);
+ if (block.HasCaught()) {
+ exceptionState.rethrowV8Exception(block.Exception());
+ return 0;
}
ASSERT(!numberObject.IsEmpty());
« 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