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

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

Issue 329793002: Add missing javascript integer overflow check on 64-bit platforms. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 6 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 | « runtime/vm/flow_graph_compiler_ia32.cc ('k') | 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 15112 matching lines...) Expand 10 before | Expand all | Expand 10 after
15123 15123
15124 15124
15125 // dart2js represents integers as double precision floats, which can represent 15125 // dart2js represents integers as double precision floats, which can represent
15126 // anything in the range -2^53 ... 2^53. 15126 // anything in the range -2^53 ... 2^53.
15127 static bool IsJavascriptInt(int64_t value) { 15127 static bool IsJavascriptInt(int64_t value) {
15128 return ((-0x20000000000000LL <= value) && (value <= 0x20000000000000LL)); 15128 return ((-0x20000000000000LL <= value) && (value <= 0x20000000000000LL));
15129 } 15129 }
15130 15130
15131 15131
15132 RawInteger* Integer::New(int64_t value, Heap::Space space, const bool silent) { 15132 RawInteger* Integer::New(int64_t value, Heap::Space space, const bool silent) {
15133 if ((value <= Smi::kMaxValue) && (value >= Smi::kMinValue)) { 15133 const bool is_smi = (value <= Smi::kMaxValue) && (value >= Smi::kMinValue);
15134 return Smi::New(value);
15135 }
15136 if (!silent && 15134 if (!silent &&
15137 FLAG_throw_on_javascript_int_overflow && 15135 FLAG_throw_on_javascript_int_overflow &&
15138 !IsJavascriptInt(value)) { 15136 !IsJavascriptInt(value)) {
15139 const Integer& i = Integer::Handle(Mint::New(value)); 15137 const Integer& i = is_smi ? Integer::Handle(Smi::New(value))
15138 : Integer::Handle(Mint::New(value));
15140 ThrowJavascriptIntegerOverflow(i); 15139 ThrowJavascriptIntegerOverflow(i);
15141 } 15140 }
15141 if (is_smi) {
15142 return Smi::New(value);
15143 }
15142 return Mint::New(value, space); 15144 return Mint::New(value, space);
15143 } 15145 }
15144 15146
15145 15147
15146 RawInteger* Integer::NewFromUint64(uint64_t value, Heap::Space space) { 15148 RawInteger* Integer::NewFromUint64(uint64_t value, Heap::Space space) {
15147 if (value > static_cast<uint64_t>(Mint::kMaxValue)) { 15149 if (value > static_cast<uint64_t>(Mint::kMaxValue)) {
15148 if (FLAG_throw_on_javascript_int_overflow) { 15150 if (FLAG_throw_on_javascript_int_overflow) {
15149 const Integer &i = 15151 const Integer &i =
15150 Integer::Handle(BigintOperations::NewFromUint64(value)); 15152 Integer::Handle(BigintOperations::NewFromUint64(value));
15151 ThrowJavascriptIntegerOverflow(i); 15153 ThrowJavascriptIntegerOverflow(i);
(...skipping 3867 matching lines...) Expand 10 before | Expand all | Expand 10 after
19019 return tag_label.ToCString(); 19021 return tag_label.ToCString();
19020 } 19022 }
19021 19023
19022 19024
19023 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 19025 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
19024 Instance::PrintJSONImpl(stream, ref); 19026 Instance::PrintJSONImpl(stream, ref);
19025 } 19027 }
19026 19028
19027 19029
19028 } // namespace dart 19030 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler_ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698