Index: runtime/vm/intermediate_language_ia32.cc |
diff --git a/runtime/vm/intermediate_language_ia32.cc b/runtime/vm/intermediate_language_ia32.cc |
index 4af06d01204ab188dac5cb7cfb9da3019e2fe75e..6daebaff042789c0c2a742d0c3b99571de451d4c 100644 |
--- a/runtime/vm/intermediate_language_ia32.cc |
+++ b/runtime/vm/intermediate_language_ia32.cc |
@@ -150,7 +150,7 @@ void ConstantInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
// The register allocator drops constant definitions that have no uses. |
if (!locs()->out().IsInvalid()) { |
Register result = locs()->out().reg(); |
- __ LoadObjectSafely(result, value()); |
+ __ LoadObject(result, value()); |
} |
} |
@@ -941,16 +941,15 @@ void NativeCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
} |
-static bool CanBeImmediateIndex(Value* value, intptr_t cid) { |
- ConstantInstr* constant = value->definition()->AsConstant(); |
- if ((constant == NULL) || !Assembler::IsSafeSmi(constant->value())) { |
- return false; |
- } |
- const int64_t index = Smi::Cast(constant->value()).AsInt64Value(); |
+static bool CanBeImmediateIndex(Value* index, intptr_t cid) { |
+ if (!index->definition()->IsConstant()) return false; |
+ const Object& constant = index->definition()->AsConstant()->value(); |
+ if (!constant.IsSmi()) return false; |
+ const Smi& smi_const = Smi::Cast(constant); |
const intptr_t scale = FlowGraphCompiler::ElementSizeFor(cid); |
- const intptr_t offset = FlowGraphCompiler::DataOffsetFor(cid); |
- const int64_t displacement = index * scale + offset; |
- return Utils::IsInt(32, displacement); |
+ const intptr_t data_offset = FlowGraphCompiler::DataOffsetFor(cid); |
+ const int64_t disp = smi_const.AsInt64Value() * scale + data_offset; |
+ return Utils::IsInt(32, disp); |
} |
@@ -1114,15 +1113,18 @@ LocationSummary* LoadIndexedInstr::MakeLocationSummary() const { |
LocationSummary* locs = |
new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
locs->set_in(0, Location::RequiresRegister()); |
- if (CanBeImmediateIndex(index(), class_id())) { |
- // CanBeImmediateIndex must return false for unsafe smis. |
- locs->set_in(1, Location::Constant(index()->BoundConstant())); |
+ // 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 { |
- // The index is either untagged (element size == 1) or a smi (for all |
- // element sizes > 1). |
- locs->set_in(1, (index_scale() == 1) |
- ? Location::WritableRegister() |
- : Location::RequiresRegister()); |
+ locs->set_in(1, CanBeImmediateIndex(index(), class_id()) |
+ ? Location::Constant( |
+ index()->definition()->AsConstant()->value()) |
+ : Location::RequiresRegister()); |
} |
if (representation() == kUnboxedDouble) { |
locs->set_out(Location::RequiresFpuRegister()); |
@@ -1277,15 +1279,18 @@ LocationSummary* StoreIndexedInstr::MakeLocationSummary() const { |
LocationSummary* locs = |
new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
locs->set_in(0, Location::RequiresRegister()); |
- if (CanBeImmediateIndex(index(), class_id())) { |
- // CanBeImmediateIndex must return false for unsafe smis. |
- locs->set_in(1, Location::Constant(index()->BoundConstant())); |
+ // 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 { |
- // The index is either untagged (element size == 1) or a smi (for all |
- // element sizes > 1). |
- locs->set_in(1, (index_scale() == 1) |
- ? Location::WritableRegister() |
- : Location::RequiresRegister()); |
+ locs->set_in(1, CanBeImmediateIndex(index(), class_id()) |
+ ? Location::Constant( |
+ index()->definition()->AsConstant()->value()) |
+ : Location::RequiresRegister()); |
} |
switch (class_id()) { |
case kArrayCid: |
@@ -2429,7 +2434,6 @@ LocationSummary* BinarySmiOpInstr::MakeLocationSummary() const { |
if (RightIsPowerOfTwoConstant()) { |
summary->set_in(0, Location::RequiresRegister()); |
ConstantInstr* right_constant = right()->definition()->AsConstant(); |
- // The programmer only controls one bit, so the constant is safe. |
summary->set_in(1, Location::Constant(right_constant->value())); |
summary->set_temp(0, Location::RequiresRegister()); |
summary->set_out(Location::SameAsFirstInput()); |