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

Unified Diff: runtime/vm/object.cc

Issue 21876005: Fixes obo error in javascript int checking. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 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 | « runtime/vm/intermediate_language_x64.cc ('k') | tests/standalone/javascript_int_overflow_literal_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
===================================================================
--- runtime/vm/object.cc (revision 25732)
+++ runtime/vm/object.cc (working copy)
@@ -11407,7 +11407,7 @@
// This is called from LiteralToken::New() in the parser, so we can't
-// raise an exception for 54-bit overflow here. Instead we do it in
+// raise an exception for javascript overflow here. Instead we do it in
// Parser::CurrentIntegerLiteral(), which is the point in the parser where
// integer literals escape, so we can call Parser::ErrorMsg().
RawInteger* Integer::NewCanonical(const String& str) {
@@ -11427,13 +11427,10 @@
}
-// dart2js represents integers as double precision floats. It does this using
-// a sign bit and 53 fraction bits. This gives us the range
-// -2^54 - 1 ... 2^54 - 1, i.e. the same as a 54-bit signed integer
-// without the most negative number. Thus, here we check if the value is
-// a 54-bit signed integer and not -2^54
-static bool Is54BitNoMinInt(int64_t value) {
- return (Utils::IsInt(54, value)) && (value != (-0x1FFFFFFFFFFFFFLL - 1));
+// dart2js represents integers as double precision floats, which can represent
+// anything in the range -2^53 ... 2^53.
+static bool IsJavascriptInt(int64_t value) {
+ return ((-0x20000000000000LL <= value) && (value <= 0x20000000000000LL));
}
@@ -11441,7 +11438,7 @@
if ((value <= Smi::kMaxValue) && (value >= Smi::kMinValue)) {
return Smi::New(value);
}
- if (FLAG_throw_on_javascript_int_overflow && !Is54BitNoMinInt(value)) {
+ if (FLAG_throw_on_javascript_int_overflow && !IsJavascriptInt(value)) {
const Integer &i = Integer::Handle(Mint::New(value));
ThrowJavascriptIntegerOverflow(i);
}
@@ -11482,7 +11479,7 @@
// Returns true if the signed Integer does not fit into a
-// Javascript (54-bit) integer.
+// Javascript integer.
bool Integer::CheckJavascriptIntegerOverflow() const {
// Always overflow if the value doesn't fit into an int64_t.
int64_t value = 1ULL << 63;
@@ -11500,7 +11497,7 @@
value = BigintOperations::ToInt64(big_value);
}
}
- return !Is54BitNoMinInt(value);
+ return !IsJavascriptInt(value);
}
« no previous file with comments | « runtime/vm/intermediate_language_x64.cc ('k') | tests/standalone/javascript_int_overflow_literal_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698