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

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

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/bindings/core/v8/V8Binding.cpp » ('j') | 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 73270d981dd48c399bd09c99e2e38445940aa3f8..0adfedbc007620fb25591113e671b90a54aa2585 100644
--- a/Source/bindings/core/v8/V8Binding.h
+++ b/Source/bindings/core/v8/V8Binding.h
@@ -465,10 +465,23 @@ inline uint32_t toUInt32(v8::Handle<v8::Value> value, ExceptionState& exceptionS
// Convert a value to a 32-bit unsigned integer assuming the conversion cannot fail.
uint32_t toUInt32(v8::Handle<v8::Value>);
+CORE_EXPORT int64_t toInt64Slow(v8::Handle<v8::Value>, IntegerConversionConfiguration, ExceptionState&);
+
// Convert a value to a 64-bit signed integer. The conversion fails if the
// value cannot be converted to a number or the range violated per WebIDL:
// http://www.w3.org/TR/WebIDL/#es-long-long
-CORE_EXPORT int64_t toInt64(v8::Handle<v8::Value>, IntegerConversionConfiguration, ExceptionState&);
+inline int64_t toInt64(v8::Handle<v8::Value> value, IntegerConversionConfiguration configuration, ExceptionState& exceptionState)
+{
+ // Clamping not supported for int64_t/long long int. See Source/wtf/MathExtras.h.
+ ASSERT(configuration != Clamp);
+
+ // Fast case. The value is a 32-bit integer.
+ if (value->IsInt32())
+ return value->Int32Value();
+
+ return toInt64Slow(value, configuration, exceptionState);
+}
+
inline int64_t toInt64(v8::Handle<v8::Value> value, ExceptionState& exceptionState)
{
return toInt64(value, NormalConversion, exceptionState);
« no previous file with comments | « no previous file | Source/bindings/core/v8/V8Binding.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698