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

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

Issue 353513002: Use range information for optimizing integer boxing and fix bug in range analysis. (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
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 15223 matching lines...) Expand 10 before | Expand all | Expand 10 after
15234 15234
15235 RawInteger* Integer::AsValidInteger() const { 15235 RawInteger* Integer::AsValidInteger() const {
15236 if (FLAG_throw_on_javascript_int_overflow && 15236 if (FLAG_throw_on_javascript_int_overflow &&
15237 CheckJavascriptIntegerOverflow()) { 15237 CheckJavascriptIntegerOverflow()) {
15238 ThrowJavascriptIntegerOverflow(*this); 15238 ThrowJavascriptIntegerOverflow(*this);
15239 } 15239 }
15240 if (IsSmi()) return raw(); 15240 if (IsSmi()) return raw();
15241 if (IsMint()) { 15241 if (IsMint()) {
15242 Mint& mint = Mint::Handle(); 15242 Mint& mint = Mint::Handle();
15243 mint ^= raw(); 15243 mint ^= raw();
15244 if (Smi::IsValid64(mint.value())) { 15244 if (Smi::IsValid(mint.value())) {
15245 return Smi::New(mint.value()); 15245 return Smi::New(mint.value());
15246 } else { 15246 } else {
15247 return raw(); 15247 return raw();
15248 } 15248 }
15249 } 15249 }
15250 ASSERT(IsBigint()); 15250 ASSERT(IsBigint());
15251 Bigint& big_value = Bigint::Handle(); 15251 Bigint& big_value = Bigint::Handle();
15252 big_value ^= raw(); 15252 big_value ^= raw();
15253 if (BigintOperations::FitsIntoSmi(big_value)) { 15253 if (BigintOperations::FitsIntoSmi(big_value)) {
15254 return BigintOperations::ToSmi(big_value); 15254 return BigintOperations::ToSmi(big_value);
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
15476 return this->Value() & 0xFFFFFFFF; 15476 return this->Value() & 0xFFFFFFFF;
15477 } 15477 }
15478 15478
15479 15479
15480 static bool FitsIntoSmi(const Integer& integer) { 15480 static bool FitsIntoSmi(const Integer& integer) {
15481 if (integer.IsSmi()) { 15481 if (integer.IsSmi()) {
15482 return true; 15482 return true;
15483 } 15483 }
15484 if (integer.IsMint()) { 15484 if (integer.IsMint()) {
15485 int64_t mint_value = integer.AsInt64Value(); 15485 int64_t mint_value = integer.AsInt64Value();
15486 return Smi::IsValid64(mint_value); 15486 return Smi::IsValid(mint_value);
15487 } 15487 }
15488 if (integer.IsBigint()) { 15488 if (integer.IsBigint()) {
15489 return BigintOperations::FitsIntoSmi(Bigint::Cast(integer)); 15489 return BigintOperations::FitsIntoSmi(Bigint::Cast(integer));
15490 } 15490 }
15491 UNREACHABLE(); 15491 UNREACHABLE();
15492 return false; 15492 return false;
15493 } 15493 }
15494 15494
15495 15495
15496 int Smi::CompareWith(const Integer& other) const { 15496 int Smi::CompareWith(const Integer& other) const {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
15539 } 15539 }
15540 15540
15541 15541
15542 void Mint::set_value(int64_t value) const { 15542 void Mint::set_value(int64_t value) const {
15543 raw_ptr()->value_ = value; 15543 raw_ptr()->value_ = value;
15544 } 15544 }
15545 15545
15546 15546
15547 RawMint* Mint::New(int64_t val, Heap::Space space) { 15547 RawMint* Mint::New(int64_t val, Heap::Space space) {
15548 // Do not allocate a Mint if Smi would do. 15548 // Do not allocate a Mint if Smi would do.
15549 ASSERT(!Smi::IsValid64(val)); 15549 ASSERT(!Smi::IsValid(val));
15550 ASSERT(Isolate::Current()->object_store()->mint_class() != Class::null()); 15550 ASSERT(Isolate::Current()->object_store()->mint_class() != Class::null());
15551 Mint& result = Mint::Handle(); 15551 Mint& result = Mint::Handle();
15552 { 15552 {
15553 RawObject* raw = Object::Allocate(Mint::kClassId, 15553 RawObject* raw = Object::Allocate(Mint::kClassId,
15554 Mint::InstanceSize(), 15554 Mint::InstanceSize(),
15555 space); 15555 space);
15556 NoGCScope no_gc; 15556 NoGCScope no_gc;
15557 result ^= raw; 15557 result ^= raw;
15558 } 15558 }
15559 result.set_value(val); 15559 result.set_value(val);
15560 return result.raw(); 15560 return result.raw();
15561 } 15561 }
15562 15562
15563 15563
15564 RawMint* Mint::NewCanonical(int64_t value) { 15564 RawMint* Mint::NewCanonical(int64_t value) {
15565 // Do not allocate a Mint if Smi would do. 15565 // Do not allocate a Mint if Smi would do.
15566 ASSERT(!Smi::IsValid64(value)); 15566 ASSERT(!Smi::IsValid(value));
15567 const Class& cls = 15567 const Class& cls =
15568 Class::Handle(Isolate::Current()->object_store()->mint_class()); 15568 Class::Handle(Isolate::Current()->object_store()->mint_class());
15569 const Array& constants = Array::Handle(cls.constants()); 15569 const Array& constants = Array::Handle(cls.constants());
15570 const intptr_t constants_len = constants.Length(); 15570 const intptr_t constants_len = constants.Length();
15571 // Linear search to see whether this value is already present in the 15571 // Linear search to see whether this value is already present in the
15572 // list of canonicalized constants. 15572 // list of canonicalized constants.
15573 Mint& canonical_value = Mint::Handle(); 15573 Mint& canonical_value = Mint::Handle();
15574 intptr_t index = 0; 15574 intptr_t index = 0;
15575 while (index < constants_len) { 15575 while (index < constants_len) {
15576 canonical_value ^= constants.At(index); 15576 canonical_value ^= constants.At(index);
(...skipping 3478 matching lines...) Expand 10 before | Expand all | Expand 10 after
19055 return tag_label.ToCString(); 19055 return tag_label.ToCString();
19056 } 19056 }
19057 19057
19058 19058
19059 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 19059 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
19060 Instance::PrintJSONImpl(stream, ref); 19060 Instance::PrintJSONImpl(stream, ref);
19061 } 19061 }
19062 19062
19063 19063
19064 } // namespace dart 19064 } // namespace dart
OLDNEW
« runtime/vm/object.h ('K') | « runtime/vm/object.h ('k') | runtime/vm/object_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698