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

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

Issue 1077083002: [bindings] Utilize branch prediction macro LIKELY for V8 to native value conversion. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | 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.h
diff --git a/Source/bindings/core/v8/V8Binding.h b/Source/bindings/core/v8/V8Binding.h
index 9b6b2fdf371356204a539ee315c72835bd7dab68..1851600602e15bdd5c951d9e8ecdfadd1253994d 100644
--- a/Source/bindings/core/v8/V8Binding.h
+++ b/Source/bindings/core/v8/V8Binding.h
@@ -414,7 +414,7 @@ CORE_EXPORT int32_t toInt32Slow(v8::Isolate*, v8::Handle<v8::Value>, IntegerConv
inline int32_t toInt32(v8::Isolate* isolate, v8::Handle<v8::Value> value, IntegerConversionConfiguration configuration, ExceptionState& exceptionState)
{
// Fast case. The value is already a 32-bit integer.
- if (value->IsInt32())
+ if (LIKELY(value->IsInt32()))
return value.As<v8::Int32>()->Value();
return toInt32Slow(isolate, value, configuration, exceptionState);
}
@@ -426,11 +426,11 @@ CORE_EXPORT uint32_t toUInt32Slow(v8::Isolate*, v8::Handle<v8::Value>, IntegerCo
inline uint32_t toUInt32(v8::Isolate* isolate, v8::Handle<v8::Value> value, IntegerConversionConfiguration configuration, ExceptionState& exceptionState)
{
// Fast case. The value is already a 32-bit unsigned integer.
- if (value->IsUint32())
+ if (LIKELY(value->IsUint32()))
return value.As<v8::Uint32>()->Value();
// Fast case. The value is a 32-bit signed integer with NormalConversion configuration.
- if (value->IsInt32() && configuration == NormalConversion)
+ if (LIKELY(value->IsInt32() && configuration == NormalConversion))
return value.As<v8::Int32>()->Value();
return toUInt32Slow(isolate, value, configuration, exceptionState);
@@ -446,7 +446,7 @@ inline int64_t toInt64(v8::Isolate* isolate, v8::Handle<v8::Value> value, Intege
ASSERT(configuration != Clamp);
// Fast case. The value is a 32-bit integer.
- if (value->IsInt32())
+ if (LIKELY(value->IsInt32()))
return value.As<v8::Int32>()->Value();
return toInt64Slow(isolate, value, configuration, exceptionState);
@@ -459,10 +459,10 @@ CORE_EXPORT uint64_t toUInt64Slow(v8::Isolate*, v8::Handle<v8::Value>, IntegerCo
inline uint64_t toUInt64(v8::Isolate* isolate, v8::Handle<v8::Value> value, IntegerConversionConfiguration configuration, ExceptionState& exceptionState)
{
// Fast case. The value is a 32-bit unsigned integer.
- if (value->IsUint32())
+ if (LIKELY(value->IsUint32()))
return value.As<v8::Uint32>()->Value();
- if (value->IsInt32() && configuration == NormalConversion)
+ if (LIKELY(value->IsInt32() && configuration == NormalConversion))
return value.As<v8::Int32>()->Value();
return toUInt64Slow(isolate, value, configuration, exceptionState);
@@ -472,7 +472,7 @@ inline uint64_t toUInt64(v8::Isolate* isolate, v8::Handle<v8::Value> value, Inte
CORE_EXPORT double toDoubleSlow(v8::Isolate*, v8::Handle<v8::Value>, ExceptionState&);
inline double toDouble(v8::Isolate* isolate, v8::Handle<v8::Value> value, ExceptionState& exceptionState)
{
- if (value->IsNumber())
+ if (LIKELY(value->IsNumber()))
return value.As<v8::Number>()->Value();
return toDoubleSlow(isolate, value, exceptionState);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698