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

Unified Diff: runtime/vm/intermediate_language_ia32.cc

Issue 731943004: Box values of LoadCodeUnits that fall outside of smi range on 32bit platforms. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: might_box 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/intermediate_language_arm64.cc ('k') | runtime/vm/intermediate_language_mips.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intermediate_language_ia32.cc
diff --git a/runtime/vm/intermediate_language_ia32.cc b/runtime/vm/intermediate_language_ia32.cc
index 0f0deb20e7889ed56f1e951ac329328cdec9f20b..192dd5c14bb95130750a3ee1cffd0c80a74e3088 100644
--- a/runtime/vm/intermediate_language_ia32.cc
+++ b/runtime/vm/intermediate_language_ia32.cc
@@ -1199,106 +1199,6 @@ void LoadIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
}
-Representation LoadCodeUnitsInstr::representation() const {
- switch (class_id()) {
- case kOneByteStringCid:
- case kExternalOneByteStringCid:
- case kTwoByteStringCid:
- case kExternalTwoByteStringCid:
- // TODO(zerny): kUnboxedUint32 could be a better choice.
- return can_pack_into_smi() ? kTagged : kUnboxedMint;
- default:
- UNIMPLEMENTED();
- return kTagged;
- }
-}
-
-
-LocationSummary* LoadCodeUnitsInstr::MakeLocationSummary(Isolate* isolate,
- bool opt) const {
- const intptr_t kNumInputs = 2;
- const intptr_t kNumTemps = 0;
- LocationSummary* summary = new(isolate) LocationSummary(
- isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall);
- summary->set_in(0, Location::RequiresRegister());
- // The smi index is either untagged (element size == 1), or it is left smi
- // tagged (for all element sizes > 1).
- summary->set_in(1, (index_scale() == 1) ? Location::WritableRegister()
- : Location::RequiresRegister());
-
- if (representation() == kUnboxedMint) {
- summary->set_out(0, Location::Pair(Location::RequiresRegister(),
- Location::RequiresRegister()));
- } else {
- ASSERT(representation() == kTagged);
- summary->set_out(0, Location::RequiresRegister());
- }
-
- return summary;
-}
-
-
-void LoadCodeUnitsInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
- const Register array = locs()->in(0).reg();
- const Location index = locs()->in(1);
-
- Address element_address = Assembler::ElementAddressForRegIndex(
- IsExternal(), class_id(), index_scale(), array, index.reg());
-
- if ((index_scale() == 1)) {
- __ SmiUntag(index.reg());
- }
-
- if (representation() == kUnboxedMint) {
- ASSERT(locs()->out(0).IsPairLocation());
- PairLocation* result_pair = locs()->out(0).AsPairLocation();
- Register result1 = result_pair->At(0).reg();
- Register result2 = result_pair->At(1).reg();
- switch (class_id()) {
- case kOneByteStringCid:
- case kExternalOneByteStringCid:
- ASSERT(element_count() == 4);
- __ movl(result1, element_address);
- __ xorl(result2, result2);
- break;
- case kTwoByteStringCid:
- case kExternalTwoByteStringCid:
- ASSERT(element_count() == 2);
- __ movl(result1, element_address);
- __ xorl(result2, result2);
- break;
- default:
- UNREACHABLE();
- }
- } else {
- ASSERT(representation() == kTagged);
- Register result = locs()->out(0).reg();
- switch (class_id()) {
- case kOneByteStringCid:
- case kExternalOneByteStringCid:
- switch (element_count()) {
- case 1: __ movzxb(result, element_address); break;
- case 2: __ movzxw(result, element_address); break;
- default: UNREACHABLE();
- }
- __ SmiTag(result);
- break;
- case kTwoByteStringCid:
- case kExternalTwoByteStringCid:
- switch (element_count()) {
- case 1: __ movzxw(result, element_address); break;
- default: UNREACHABLE();
- }
- __ SmiTag(result);
- break;
- default:
- UNREACHABLE();
- break;
- }
- }
-}
-
-
Representation StoreIndexedInstr::RequiredInputRepresentation(
intptr_t idx) const {
// Array can be a Dart object or a pointer to external data.
@@ -3795,6 +3695,117 @@ void UnboxInteger32Instr::EmitNativeCode(FlowGraphCompiler* compiler) {
}
+LocationSummary* LoadCodeUnitsInstr::MakeLocationSummary(Isolate* isolate,
+ bool opt) const {
+ const bool might_box = (representation() == kTagged) && !can_pack_into_smi();
+ const intptr_t kNumInputs = 2;
+ const intptr_t kNumTemps = might_box ? 1 : 0;
+ LocationSummary* summary = new(isolate) LocationSummary(
+ isolate, kNumInputs, kNumTemps,
+ might_box ? LocationSummary::kCallOnSlowPath : LocationSummary::kNoCall);
+ summary->set_in(0, Location::RequiresRegister());
+ // The smi index is either untagged (element size == 1), or it is left smi
+ // tagged (for all element sizes > 1).
+ summary->set_in(1, (index_scale() == 1) ? Location::WritableRegister()
+ : Location::RequiresRegister());
+ if (might_box) {
+ summary->set_temp(0, Location::RequiresRegister());
+ }
+
+ if (representation() == kUnboxedMint) {
+ summary->set_out(0, Location::Pair(Location::RequiresRegister(),
+ Location::RequiresRegister()));
+ } else {
+ ASSERT(representation() == kTagged);
+ summary->set_out(0, Location::RequiresRegister());
+ }
+
+ return summary;
+}
+
+
+void LoadCodeUnitsInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
+ const Register array = locs()->in(0).reg();
+ const Location index = locs()->in(1);
+
+ Address element_address = Assembler::ElementAddressForRegIndex(
+ IsExternal(), class_id(), index_scale(), array, index.reg());
+
+ if ((index_scale() == 1)) {
+ __ SmiUntag(index.reg());
+ }
+
+ if (representation() == kUnboxedMint) {
+ ASSERT(compiler->is_optimizing());
+ ASSERT(locs()->out(0).IsPairLocation());
+ PairLocation* result_pair = locs()->out(0).AsPairLocation();
+ Register result1 = result_pair->At(0).reg();
+ Register result2 = result_pair->At(1).reg();
+
+ switch (class_id()) {
+ case kOneByteStringCid:
+ case kExternalOneByteStringCid:
+ ASSERT(element_count() == 4);
+ __ movl(result1, element_address);
+ __ xorl(result2, result2);
+ break;
+ case kTwoByteStringCid:
+ case kExternalTwoByteStringCid:
+ ASSERT(element_count() == 2);
+ __ movl(result1, element_address);
+ __ xorl(result2, result2);
+ break;
+ default:
+ UNREACHABLE();
+ }
+ } else {
+ ASSERT(representation() == kTagged);
+ Register result = locs()->out(0).reg();
+ switch (class_id()) {
+ case kOneByteStringCid:
+ case kExternalOneByteStringCid:
+ switch (element_count()) {
+ case 1: __ movzxb(result, element_address); break;
+ case 2: __ movzxw(result, element_address); break;
+ case 4: __ movl(result, element_address); break;
+ default: UNREACHABLE();
+ }
+ break;
+ case kTwoByteStringCid:
+ case kExternalTwoByteStringCid:
+ switch (element_count()) {
+ case 1: __ movzxw(result, element_address); break;
+ case 2: __ movl(result, element_address); break;
+ default: UNREACHABLE();
+ }
+ break;
+ default:
+ UNREACHABLE();
+ break;
+ }
+ if (can_pack_into_smi()) {
+ __ SmiTag(result);
+ } else {
+ // If the value cannot fit in a smi then allocate a mint box for it.
+ Register temp = locs()->temp(0).reg();
+ ASSERT(temp != result);
+ __ MoveRegister(temp, result);
+ __ SmiTag(result);
+
+ Label done;
+ __ testl(temp, Immediate(0xC0000000));
+ __ j(ZERO, &done);
+ BoxAllocationSlowPath::Allocate(
+ compiler, this, compiler->mint_class(), result, kNoRegister);
+ __ movl(FieldAddress(result, Mint::value_offset()), temp);
+ __ movl(FieldAddress(result, Mint::value_offset() + kWordSize),
+ Immediate(0));
+ __ Bind(&done);
+ }
+ }
+}
+
+
LocationSummary* BinaryDoubleOpInstr::MakeLocationSummary(Isolate* isolate,
bool opt) const {
const intptr_t kNumInputs = 2;
« no previous file with comments | « runtime/vm/intermediate_language_arm64.cc ('k') | runtime/vm/intermediate_language_mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698