Index: src/x64/lithium-x64.cc |
diff --git a/src/x64/lithium-x64.cc b/src/x64/lithium-x64.cc |
index 13df32c660f2f7aa55820a8db0b7318d368bf194..ea0e7e86e0c0b39dfe0a9b01c4d04ef5044edba9 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()); |
} |
@@ -2072,12 +2085,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); |
@@ -2115,6 +2143,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(); |
@@ -2125,7 +2157,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() || |