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

Unified Diff: runtime/vm/intermediate_language_ia32.cc

Issue 12114008: Avoid re-tagging of the index register in optimized byte array access. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/flow_graph_compiler_x64.cc ('k') | runtime/vm/intermediate_language_x64.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
===================================================================
--- runtime/vm/intermediate_language_ia32.cc (revision 18444)
+++ runtime/vm/intermediate_language_ia32.cc (working copy)
@@ -1163,12 +1163,19 @@
LocationSummary* locs =
new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
locs->set_in(0, Location::RequiresRegister());
- // The smi index is either untagged and tagged again at the end of the
- // operation (element size == 1), or it is left smi tagged (for all element
- // sizes > 1).
- locs->set_in(1, CanBeImmediateIndex(index(), class_id())
- ? Location::RegisterOrSmiConstant(index())
- : Location::RequiresRegister());
+ // The smi index is either untagged (element size == 1), or it is left smi
+ // tagged (for all element sizes > 1).
+ if (index_scale() == 1) {
+ locs->set_in(1, CanBeImmediateIndex(index(), class_id())
+ ? Location::Constant(
+ index()->definition()->AsConstant()->value())
+ : Location::WritableRegister());
+ } else {
+ locs->set_in(1, CanBeImmediateIndex(index(), class_id())
+ ? Location::Constant(
+ index()->definition()->AsConstant()->value())
+ : Location::RequiresRegister());
+ }
if (representation() == kUnboxedDouble) {
locs->set_out(Location::RequiresFpuRegister());
} else {
@@ -1199,9 +1206,6 @@
FieldAddress(array, ExternalUint8Array::data_offset()));
__ movzxb(result, element_address);
__ SmiTag(result);
- if (index.IsRegister()) {
- __ SmiTag(index.reg()); // Re-tag.
- }
return;
}
@@ -1236,9 +1240,6 @@
__ movsd(result, element_address);
break;
}
- if ((index_scale() == 1) && index.IsRegister()) {
- __ SmiTag(index.reg()); // Re-tag.
- }
return;
}
@@ -1291,9 +1292,6 @@
__ movl(result, element_address);
break;
}
- if ((index_scale() == 1) && index.IsRegister()) {
- __ SmiTag(index.reg()); // Re-tag.
- }
}
@@ -1328,12 +1326,20 @@
LocationSummary* locs =
new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
locs->set_in(0, Location::RequiresRegister());
- // The smi index is either untagged and tagged again at the end of the
- // operation (element size == 1), or it is left smi tagged (for all element
- // sizes > 1).
- locs->set_in(1, CanBeImmediateIndex(index(), class_id())
- ? Location::RegisterOrSmiConstant(index())
- : Location::RequiresRegister());
+ // The smi index is either untagged (element size == 1), or it is left smi
+ // tagged (for all element sizes > 1).
+ intptr_t index_scale = FlowGraphCompiler::ElementSizeFor(class_id());
+ if (index_scale == 1) {
+ locs->set_in(1, CanBeImmediateIndex(index(), class_id())
+ ? Location::Constant(
+ index()->definition()->AsConstant()->value())
+ : Location::WritableRegister());
+ } else {
+ locs->set_in(1, CanBeImmediateIndex(index(), class_id())
+ ? Location::Constant(
+ index()->definition()->AsConstant()->value())
+ : Location::RequiresRegister());
+ }
switch (class_id()) {
case kArrayCid:
locs->set_in(2, ShouldEmitStoreBarrier()
@@ -1409,9 +1415,6 @@
__ SmiUntag(EAX);
__ movb(element_address, AL);
}
- if (index.IsRegister()) {
- __ SmiTag(index.reg()); // Re-tag.
- }
break;
case kUint8ClampedArrayCid: {
if (index.IsRegister()) {
@@ -1443,9 +1446,6 @@
__ Bind(&store_value);
__ movb(element_address, AL);
}
- if (index.IsRegister()) {
- __ SmiTag(index.reg()); // Re-tag.
- }
break;
}
case kInt16ArrayCid:
@@ -2354,11 +2354,16 @@
LocationSummary* UnboxDoubleInstr::MakeLocationSummary() const {
const intptr_t kNumInputs = 1;
- const intptr_t kNumTemps = CanDeoptimize() ? 1 : 0;
+ const intptr_t value_cid = value()->ResultCid();
+ const bool needs_temp = ((value_cid != kSmiCid) && (value_cid != kDoubleCid));
+ const bool needs_writable_input = (value_cid == kSmiCid);
+ const intptr_t kNumTemps = needs_temp ? 1 : 0;
LocationSummary* summary =
new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
- summary->set_in(0, Location::RequiresRegister());
- if (CanDeoptimize()) summary->set_temp(0, Location::RequiresRegister());
+ summary->set_in(0, needs_writable_input
+ ? Location::WritableRegister()
+ : Location::RequiresRegister());
+ if (needs_temp) summary->set_temp(0, Location::RequiresRegister());
summary->set_out(Location::RequiresFpuRegister());
return summary;
}
@@ -2374,13 +2379,21 @@
} else if (value_cid == kSmiCid) {
__ SmiUntag(value); // Untag input before conversion.
__ cvtsi2sd(result, value);
- __ SmiTag(value); // Restore input register.
} else {
Label* deopt = compiler->AddDeoptStub(deopt_id_, kDeoptBinaryDoubleOp);
- compiler->LoadDoubleOrSmiToFpu(result,
- value,
- locs()->temp(0).reg(),
- deopt);
+ Register temp = locs()->temp(0).reg();
+ Label is_smi, done;
+ __ testl(value, Immediate(kSmiTagMask));
+ __ j(ZERO, &is_smi);
+ __ CompareClassId(value, kDoubleCid, temp);
+ __ j(NOT_EQUAL, deopt);
+ __ movsd(result, FieldAddress(value, Double::value_offset()));
+ __ jmp(&done);
+ __ Bind(&is_smi);
+ __ movl(temp, value);
+ __ SmiUntag(temp);
+ __ cvtsi2sd(result, temp);
+ __ Bind(&done);
}
}
@@ -2809,11 +2822,16 @@
LocationSummary* UnboxIntegerInstr::MakeLocationSummary() const {
const intptr_t kNumInputs = 1;
- const intptr_t kNumTemps = CanDeoptimize() ? 1 : 0;
+ const intptr_t value_cid = value()->ResultCid();
+ const bool needs_temp = ((value_cid != kSmiCid) && (value_cid != kMintCid));
+ const bool needs_writable_input = (value_cid == kSmiCid);
+ const intptr_t kNumTemps = needs_temp ? 1 : 0;
LocationSummary* summary =
new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
- summary->set_in(0, Location::RequiresRegister());
- if (CanDeoptimize()) summary->set_temp(0, Location::RequiresRegister());
+ summary->set_in(0, needs_writable_input
+ ? Location::WritableRegister()
+ : Location::RequiresRegister());
+ if (needs_temp) summary->set_temp(0, Location::RequiresRegister());
summary->set_out(Location::RequiresFpuRegister());
return summary;
}
@@ -2830,7 +2848,6 @@
__ SmiUntag(value); // Untag input before conversion.
__ movd(result, value);
__ pmovsxdq(result, result);
- __ SmiTag(value); // Restore input register.
} else {
Register temp = locs()->temp(0).reg();
Label* deopt = compiler->AddDeoptStub(deopt_id_, kDeoptUnboxInteger);
« no previous file with comments | « runtime/vm/flow_graph_compiler_x64.cc ('k') | runtime/vm/intermediate_language_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698