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

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

Issue 415513002: - Fix a lot of warnings generated by -Wshorten-64-to-32 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/os.h » ('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 (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 15195 matching lines...) Expand 10 before | Expand all | Expand 10 after
15206 RawInteger* Integer::NewCanonical(const String& str) { 15206 RawInteger* Integer::NewCanonical(const String& str) {
15207 // We are not supposed to have integers represented as two byte strings. 15207 // We are not supposed to have integers represented as two byte strings.
15208 ASSERT(str.IsOneByteString()); 15208 ASSERT(str.IsOneByteString());
15209 int64_t value; 15209 int64_t value;
15210 if (!OS::StringToInt64(str.ToCString(), &value)) { 15210 if (!OS::StringToInt64(str.ToCString(), &value)) {
15211 const Bigint& big = Bigint::Handle(Bigint::NewCanonical(str)); 15211 const Bigint& big = Bigint::Handle(Bigint::NewCanonical(str));
15212 ASSERT(!BigintOperations::FitsIntoSmi(big)); 15212 ASSERT(!BigintOperations::FitsIntoSmi(big));
15213 ASSERT(!BigintOperations::FitsIntoInt64(big)); 15213 ASSERT(!BigintOperations::FitsIntoInt64(big));
15214 return big.raw(); 15214 return big.raw();
15215 } 15215 }
15216 if ((value <= Smi::kMaxValue) && (value >= Smi::kMinValue)) { 15216 if (Smi::IsValid(value)) {
15217 return Smi::New(value); 15217 return Smi::New(static_cast<intptr_t>(value));
15218 } 15218 }
15219 return Mint::NewCanonical(value); 15219 return Mint::NewCanonical(value);
15220 } 15220 }
15221 15221
15222 15222
15223 // dart2js represents integers as double precision floats, which can represent 15223 // dart2js represents integers as double precision floats, which can represent
15224 // anything in the range -2^53 ... 2^53. 15224 // anything in the range -2^53 ... 2^53.
15225 static bool IsJavascriptInt(int64_t value) { 15225 static bool IsJavascriptInt(int64_t value) {
15226 return ((-0x20000000000000LL <= value) && (value <= 0x20000000000000LL)); 15226 return ((-0x20000000000000LL <= value) && (value <= 0x20000000000000LL));
15227 } 15227 }
15228 15228
15229 15229
15230 RawInteger* Integer::New(int64_t value, Heap::Space space, const bool silent) { 15230 RawInteger* Integer::New(int64_t value, Heap::Space space, const bool silent) {
15231 const bool is_smi = (value <= Smi::kMaxValue) && (value >= Smi::kMinValue); 15231 const bool is_smi = Smi::IsValid(value);
15232 if (!silent && 15232 if (!silent &&
15233 FLAG_throw_on_javascript_int_overflow && 15233 FLAG_throw_on_javascript_int_overflow &&
15234 !IsJavascriptInt(value)) { 15234 !IsJavascriptInt(value)) {
15235 const Integer& i = is_smi ? Integer::Handle(Smi::New(value)) 15235 const Integer& i = is_smi ?
15236 : Integer::Handle(Mint::New(value)); 15236 Integer::Handle(Smi::New(static_cast<intptr_t>(value))) :
15237 Integer::Handle(Mint::New(value));
15237 ThrowJavascriptIntegerOverflow(i); 15238 ThrowJavascriptIntegerOverflow(i);
15238 } 15239 }
15239 if (is_smi) { 15240 if (is_smi) {
15240 return Smi::New(value); 15241 return Smi::New(static_cast<intptr_t>(value));
15241 } 15242 }
15242 return Mint::New(value, space); 15243 return Mint::New(value, space);
15243 } 15244 }
15244 15245
15245 15246
15246 RawInteger* Integer::NewFromUint64(uint64_t value, Heap::Space space) { 15247 RawInteger* Integer::NewFromUint64(uint64_t value, Heap::Space space) {
15247 if (value > static_cast<uint64_t>(Mint::kMaxValue)) { 15248 if (value > static_cast<uint64_t>(Mint::kMaxValue)) {
15248 if (FLAG_throw_on_javascript_int_overflow) { 15249 if (FLAG_throw_on_javascript_int_overflow) {
15249 const Integer &i = 15250 const Integer &i =
15250 Integer::Handle(BigintOperations::NewFromUint64(value)); 15251 Integer::Handle(BigintOperations::NewFromUint64(value));
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
15307 RawInteger* Integer::AsValidInteger() const { 15308 RawInteger* Integer::AsValidInteger() const {
15308 if (FLAG_throw_on_javascript_int_overflow && 15309 if (FLAG_throw_on_javascript_int_overflow &&
15309 CheckJavascriptIntegerOverflow()) { 15310 CheckJavascriptIntegerOverflow()) {
15310 ThrowJavascriptIntegerOverflow(*this); 15311 ThrowJavascriptIntegerOverflow(*this);
15311 } 15312 }
15312 if (IsSmi()) return raw(); 15313 if (IsSmi()) return raw();
15313 if (IsMint()) { 15314 if (IsMint()) {
15314 Mint& mint = Mint::Handle(); 15315 Mint& mint = Mint::Handle();
15315 mint ^= raw(); 15316 mint ^= raw();
15316 if (Smi::IsValid(mint.value())) { 15317 if (Smi::IsValid(mint.value())) {
15317 return Smi::New(mint.value()); 15318 return Smi::New(static_cast<intptr_t>(mint.value()));
15318 } else { 15319 } else {
15319 return raw(); 15320 return raw();
15320 } 15321 }
15321 } 15322 }
15322 ASSERT(IsBigint()); 15323 ASSERT(IsBigint());
15323 Bigint& big_value = Bigint::Handle(); 15324 Bigint& big_value = Bigint::Handle();
15324 big_value ^= raw(); 15325 big_value ^= raw();
15325 if (BigintOperations::FitsIntoSmi(big_value)) { 15326 if (BigintOperations::FitsIntoSmi(big_value)) {
15326 return BigintOperations::ToSmi(big_value); 15327 return BigintOperations::ToSmi(big_value);
15327 } else if (BigintOperations::FitsIntoInt64(big_value)) { 15328 } else if (BigintOperations::FitsIntoInt64(big_value)) {
(...skipping 3836 matching lines...) Expand 10 before | Expand all | Expand 10 after
19164 return tag_label.ToCString(); 19165 return tag_label.ToCString();
19165 } 19166 }
19166 19167
19167 19168
19168 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 19169 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
19169 Instance::PrintJSONImpl(stream, ref); 19170 Instance::PrintJSONImpl(stream, ref);
19170 } 19171 }
19171 19172
19172 19173
19173 } // namespace dart 19174 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/os.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698