Index: src/x64/lithium-x64.cc |
diff --git a/src/x64/lithium-x64.cc b/src/x64/lithium-x64.cc |
index d42d3824e2f37d2b9ee94888e0d4c8bbcc8eb286..6eda0fcb6703314b2398cf73c029b98be88d7350 100644 |
--- a/src/x64/lithium-x64.cc |
+++ b/src/x64/lithium-x64.cc |
@@ -175,6 +175,19 @@ bool LGoto::HasInterestingComment(LCodeGen* gen) const { |
} |
+template<int R> |
+bool LTemplateResultInstruction<R>::MustSignExtendResult( |
+ LPlatformChunk* chunk) const { |
+ HValue* hvalue = this->hydrogen_value(); |
+ |
+ if (hvalue == NULL) return false; |
+ if (!hvalue->representation().IsInteger32()) return false; |
+ if (hvalue->HasRange() && !hvalue->range()->CanBeNegative()) return false; |
+ |
+ return chunk->GetDehoistedKeyIds()->Contains(hvalue->id()); |
+} |
+ |
+ |
void LGoto::PrintDataTo(StringStream* stream) { |
stream->Add("B%d", block_id()); |
} |
@@ -1964,12 +1977,27 @@ LInstruction* LChunkBuilder::DoLoadRoot(HLoadRoot* instr) { |
} |
+void LChunkBuilder::FindDehoistedKeyDefinitions(HValue* candidate) { |
+ BitVector* dehoisted_key_ids = chunk_->GetDehoistedKeyIds(); |
+ if (dehoisted_key_ids->Contains(candidate->id())) return; |
+ dehoisted_key_ids->Add(candidate->id()); |
+ if (!candidate->IsPhi()) return; |
+ for (int i = 0; i < candidate->OperandCount(); ++i) { |
+ FindDehoistedKeyDefinitions(candidate->OperandAt(i)); |
+ } |
+} |
+ |
+ |
LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) { |
ASSERT(instr->key()->representation().IsInteger32()); |
ElementsKind elements_kind = instr->elements_kind(); |
LOperand* key = UseRegisterOrConstantAtStart(instr->key()); |
LLoadKeyed* result = NULL; |
+ if (instr->IsDehoisted()) { |
+ FindDehoistedKeyDefinitions(instr->key()); |
+ } |
+ |
if (!instr->is_typed_elements()) { |
LOperand* obj = UseRegisterAtStart(instr->elements()); |
result = new(zone()) LLoadKeyed(obj, key); |
@@ -2007,6 +2035,10 @@ LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) { |
LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) { |
ElementsKind elements_kind = instr->elements_kind(); |
+ if (instr->IsDehoisted()) { |
+ FindDehoistedKeyDefinitions(instr->key()); |
+ } |
+ |
if (!instr->is_typed_elements()) { |
ASSERT(instr->elements()->representation().IsTagged()); |
bool needs_write_barrier = instr->NeedsWriteBarrier(); |
@@ -2017,7 +2049,7 @@ LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) { |
Representation value_representation = instr->value()->representation(); |
if (value_representation.IsDouble()) { |
object = UseRegisterAtStart(instr->elements()); |
- val = UseTempRegister(instr->value()); |
+ val = UseRegisterAtStart(instr->value()); |
key = UseRegisterOrConstantAtStart(instr->key()); |
} else { |
ASSERT(value_representation.IsSmiOrTagged() || |