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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/bindings/dart/DartUtilities.h ('k') | Source/bindings/dart/V8Converter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011, Google Inc. 1 // Copyright 2011, Google Inc.
2 // All rights reserved. 2 // 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "core/dom/Document.h" 43 #include "core/dom/Document.h"
44 #include "core/html/canvas/DataView.h" 44 #include "core/html/canvas/DataView.h"
45 #include "core/inspector/ScriptArguments.h" 45 #include "core/inspector/ScriptArguments.h"
46 #include "core/inspector/ScriptCallStack.h" 46 #include "core/inspector/ScriptCallStack.h"
47 #include "core/loader/FrameLoader.h" 47 #include "core/loader/FrameLoader.h"
48 #include "core/page/DOMWindow.h" 48 #include "core/page/DOMWindow.h"
49 #include "core/page/Frame.h" 49 #include "core/page/Frame.h"
50 #include "core/platform/network/ResourceRequest.h" 50 #include "core/platform/network/ResourceRequest.h"
51 #include "core/platform/sql/SQLValue.h" 51 #include "core/platform/sql/SQLValue.h"
52 52
53 #include <math.h>
54
53 #include <wtf/ArrayBufferView.h> 55 #include <wtf/ArrayBufferView.h>
54 #include <wtf/Float32Array.h> 56 #include <wtf/Float32Array.h>
55 #include <wtf/Float64Array.h> 57 #include <wtf/Float64Array.h>
56 #include <wtf/Int16Array.h> 58 #include <wtf/Int16Array.h>
57 #include <wtf/Int32Array.h> 59 #include <wtf/Int32Array.h>
58 #include <wtf/Int8Array.h> 60 #include <wtf/Int8Array.h>
59 #include <wtf/RefCounted.h> 61 #include <wtf/RefCounted.h>
60 #include <wtf/Uint16Array.h> 62 #include <wtf/Uint16Array.h>
61 #include <wtf/Uint32Array.h> 63 #include <wtf/Uint32Array.h>
62 #include <wtf/Uint8Array.h> 64 #include <wtf/Uint8Array.h>
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 return 0; 276 return 0;
275 if (value < 0) { 277 if (value < 0) {
276 exception = Dart_NewStringFromCString("value out of range"); 278 exception = Dart_NewStringFromCString("value out of range");
277 return 0; 279 return 0;
278 } 280 }
279 return value; 281 return value;
280 } 282 }
281 283
282 Dart_Handle DartUtilities::numberToDart(double value) 284 Dart_Handle DartUtilities::numberToDart(double value)
283 { 285 {
284 int intValue = static_cast<int>(value); 286 int64_t intValue = static_cast<int64_t>(value);
285 if (value == intValue) 287 // JS can store integer values that are no greater than 2^53.
288 if (value == intValue && abs(intValue) <= pow(2, 53))
sra1 2013/10/17 21:40:31 I would avoid calling pow and define a constant kM
Emily Fortuna 2013/10/17 22:42:51 Gotcha. Sorry I was going off of this: http://ecma
286 return intToDart(intValue); 289 return intToDart(intValue);
287 return doubleToDart(value); 290 return doubleToDart(value);
288 } 291 }
289 292
290 ScriptValue DartUtilities::dartToScriptValue(Dart_Handle object, Dart_Handle& ex ception) 293 ScriptValue DartUtilities::dartToScriptValue(Dart_Handle object, Dart_Handle& ex ception)
291 { 294 {
292 return ScriptValue(V8Converter::toV8(object, exception)); 295 return ScriptValue(V8Converter::toV8(object, exception));
293 } 296 }
294 297
295 Dart_Handle DartUtilities::scriptValueToDart(const ScriptValue& value) 298 Dart_Handle DartUtilities::scriptValueToDart(const ScriptValue& value)
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after
1099 Dart_PersistentHandle library = domData->htmlLibrary(); 1102 Dart_PersistentHandle library = domData->htmlLibrary();
1100 ASSERT(!Dart_IsError(library)); 1103 ASSERT(!Dart_IsError(library));
1101 1104
1102 Dart_Handle utilsClass = Dart_GetType(library, Dart_NewStringFromCString("_U tils"), 0, 0); 1105 Dart_Handle utilsClass = Dart_GetType(library, Dart_NewStringFromCString("_U tils"), 0, 0);
1103 ASSERT(!Dart_IsError(utilsClass)); 1106 ASSERT(!Dart_IsError(utilsClass));
1104 1107
1105 return Dart_Invoke(utilsClass, Dart_NewStringFromCString(methodName), argCou nt, args); 1108 return Dart_Invoke(utilsClass, Dart_NewStringFromCString(methodName), argCou nt, args);
1106 } 1109 }
1107 1110
1108 } 1111 }
OLDNEW
« 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