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

Side by Side Diff: runtime/vm/object.cc

Issue 732573002: Fix overflow check in the Smi::ShiftOp. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 15885 matching lines...) Expand 10 before | Expand all | Expand 10 after
15896 intptr_t result = 0; 15896 intptr_t result = 0;
15897 const intptr_t left_value = Value(); 15897 const intptr_t left_value = Value();
15898 const intptr_t right_value = other.Value(); 15898 const intptr_t right_value = other.Value();
15899 ASSERT(right_value >= 0); 15899 ASSERT(right_value >= 0);
15900 switch (kind) { 15900 switch (kind) {
15901 case Token::kSHL: { 15901 case Token::kSHL: {
15902 if ((left_value == 0) || (right_value == 0)) { 15902 if ((left_value == 0) || (right_value == 0)) {
15903 return raw(); 15903 return raw();
15904 } 15904 }
15905 { // Check for overflow. 15905 { // Check for overflow.
15906 int cnt = Utils::HighestBit(left_value); 15906 int cnt = Utils::BitLength(left_value);
15907 if ((cnt + right_value) >= Smi::kBits) { 15907 if ((cnt + right_value) > Smi::kBits) {
15908 if ((cnt + right_value) >= Mint::kBits) { 15908 if ((cnt + right_value) > Mint::kBits) {
15909 return Bigint::NewFromShiftedInt64(left_value, right_value); 15909 return Bigint::NewFromShiftedInt64(left_value, right_value);
15910 } else { 15910 } else {
15911 int64_t left_64 = left_value; 15911 int64_t left_64 = left_value;
15912 return Integer::New(left_64 << right_value, Heap::kNew, silent); 15912 return Integer::New(left_64 << right_value, Heap::kNew, silent);
15913 } 15913 }
15914 } 15914 }
15915 } 15915 }
15916 result = left_value << right_value; 15916 result = left_value << right_value;
15917 break; 15917 break;
15918 } 15918 }
(...skipping 4497 matching lines...) Expand 10 before | Expand all | Expand 10 after
20416 return tag_label.ToCString(); 20416 return tag_label.ToCString();
20417 } 20417 }
20418 20418
20419 20419
20420 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 20420 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
20421 Instance::PrintJSONImpl(stream, ref); 20421 Instance::PrintJSONImpl(stream, ref);
20422 } 20422 }
20423 20423
20424 20424
20425 } // namespace dart 20425 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698