Skip to content

Commit

Permalink
[vm] Cleanup int overflow checking
Browse files Browse the repository at this point in the history
This corner case was needed by old VM parser.
Now that old VM parser is gone we can remove it.

Closes dart-lang/sdk#31600

Change-Id: I59631102230156f6480a27e6d43d5e3fa5551c8b
Reviewed-on: https://dart-review.googlesource.com/c/81338
Commit-Queue: Zach Anderson <zra@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
  • Loading branch information
alexmarkov authored and commit-bot@chromium.org committed Oct 25, 2018
1 parent 9e9746a commit d3498a8
Showing 1 changed file with 0 additions and 19 deletions.
19 changes: 0 additions & 19 deletions runtime/vm/object.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19424,23 +19424,12 @@ const char* Integer::ToCString() const {
return "NULL Integer";
}

// String representation of kMaxInt64 + 1.
static const char* kMaxInt64Plus1 = "9223372036854775808";

RawInteger* Integer::New(const String& str, Heap::Space space) {
// We are not supposed to have integers represented as two byte strings.
ASSERT(str.IsOneByteString());
int64_t value = 0;
const char* cstr = str.ToCString();
if (!OS::StringToInt64(cstr, &value)) {
// TODO(T31600): Remove overflow checking code when 64-bit ints semantics
// are only supported through the Kernel FE.
if (strcmp(cstr, kMaxInt64Plus1) == 0) {
// Allow MAX_INT64 + 1 integer literal as it can be used as an argument
// of unary minus to produce MIN_INT64 value. The value is automatically
// wrapped to MIN_INT64.
return Integer::New(kMinInt64, space);
}
// Out of range.
return Integer::null();
}
Expand All @@ -19453,14 +19442,6 @@ RawInteger* Integer::NewCanonical(const String& str) {
int64_t value = 0;
const char* cstr = str.ToCString();
if (!OS::StringToInt64(cstr, &value)) {
// TODO(T31600): Remove overflow checking code when 64-bit ints semantics
// are only supported through the Kernel FE.
if (strcmp(cstr, kMaxInt64Plus1) == 0) {
// Allow MAX_INT64 + 1 integer literal as it can be used as an argument
// of unary minus to produce MIN_INT64 value. The value is automatically
// wrapped to MIN_INT64.
return Mint::NewCanonical(kMinInt64);
}
// Out of range.
return Integer::null();
}
Expand Down

0 comments on commit d3498a8

Please sign in to comment.