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

Unified Diff: Source/bindings/dart/DartUtilities.cpp

Issue 27767003: Convert serialized values to ints if they are whole and less than 53 bits. (Closed) Base URL: svn://svn.chromium.org/multivm/trunk/webkit
Patch Set: Created 7 years, 2 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/dart/DartUtilities.h ('k') | Source/bindings/dart/V8Converter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/dart/DartUtilities.cpp
diff --git a/Source/bindings/dart/DartUtilities.cpp b/Source/bindings/dart/DartUtilities.cpp
index 8c39f886e158c51bf040faff84a42906d1587582..b9d86f76f3285cd4d4404a43aaf4223431bcbe45 100644
--- a/Source/bindings/dart/DartUtilities.cpp
+++ b/Source/bindings/dart/DartUtilities.cpp
@@ -40,6 +40,7 @@
#include "bindings/dart/V8Converter.h"
#include "bindings/v8/ScriptController.h"
#include "bindings/v8/SerializedScriptValue.h"
+#include "bindings/v8/V8Binding.h"
#include "bindings/v8/V8PerIsolateData.h"
#include "core/dom/Document.h"
#include "core/html/canvas/DataView.h"
@@ -296,9 +297,12 @@ unsigned long long DartUtilities::dartToUnsignedLongLong(Dart_Handle object, Dar
Dart_Handle DartUtilities::numberToDart(double value)
{
- int intValue = static_cast<int>(value);
- if (value == intValue)
- return intToDart(intValue);
+ // JS can store integer values that are no greater than 2^53 - 1.
+ if (-kJSMaxInteger <= value && value <= kJSMaxInteger) {
+ int64_t intValue = static_cast<int64_t>(value);
+ if (value == intValue)
+ return intToDart(intValue);
+ }
return doubleToDart(value);
}
« no previous file with comments | « Source/bindings/dart/DartUtilities.h ('k') | Source/bindings/dart/V8Converter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698