Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

hir: better input def after phi handling

* lir: handling value to multiple inputs case
  • Loading branch information...
commit 3c859d8217c63f4298c11778cf60faca6aee9966 1 parent 6082cba
@indutny authored
Showing with 26 additions and 7 deletions.
  1. +3 −2 src/hir.cc
  2. +18 −1 src/lir.cc
  3. +5 −4 src/x64/lir-instructions-x64.cc
View
5 src/hir.cc
@@ -142,8 +142,6 @@ void HIRBasicBlock::LiftValues(HIRBasicBlock* block,
}
}
- // If loop detected and there're phis those inputs are defined in this block
- // (i.e. in loop header) - use them as values
if (instructions()->length() != 0) {
// Add non-local variable uses to the end of loop
// to ensure that they will be live after the first loop's pass
@@ -160,6 +158,8 @@ void HIRBasicBlock::LiftValues(HIRBasicBlock* block,
}
}
+ // If loop detected and there're phis those inputs are defined in this block
+ // (i.e. in loop header) - use them as values
HIRPhiList::Item* item = phis()->head();
for (; item != NULL; item = item->next()) {
HIRPhi* phi = item->value();
@@ -377,6 +377,7 @@ void HIRPhi::AddInput(HIRValue* input) {
// Replace all input's uses if Phi appeared in loop
HIRValueList::Item* item = inputs()->head();
for (; item != NULL; item = item->next()) {
+ if (item->value()->block() == block()) continue;
block()->ReplaceVarUse(item->value(), this);
}
View
19 src/lir.cc
@@ -394,13 +394,30 @@ void LIR::GenerateInstruction(Masm* masm, HIRInstruction* hinstr) {
HIRValue* value = item->value();
// Allocate immediate values
- if (value->slot()->is_immediate()) {
+ if (value->slot()->is_immediate() && value->operand() == NULL) {
value->operand(new LIROperand(LIROperand::kImmediate,
value->slot()->value()));
}
if (i < linstr->input_count()) {
if (linstr->inputs[i] != NULL) {
+ // there may be a situation where the same value is used in multiple
+ // inputs with predefined registers - just insert movement in non-first
+ // inputs then.
+ if (value->operand() != NULL) {
+ int j;
+ for (j = 0; j < i; j++) {
+ if (linstr->inputs[j] != NULL &&
+ linstr->inputs[j]->is_equal(value->operand())) {
+ HIRParallelMove::GetBefore(hinstr)->
+ AddMove(linstr->inputs[j], linstr->inputs[i]);
+ HIRParallelMove::GetBefore(hinstr)->Reorder(this);
+ break;
+ }
+ }
+ if (j != i) continue;
+ }
+
// Instruction requires it's input to reside in some specific register
GetRegister(hinstr, value, linstr->inputs[i]);
} else if (value->operand() != NULL && value->operand()->is_immediate()) {
View
9 src/x64/lir-instructions-x64.cc
@@ -142,12 +142,13 @@ void LIRStoreContext::Generate() {
LIRStoreProperty::LIRStoreProperty() {
inputs[0] = ToLIROperand(rax);
inputs[1] = ToLIROperand(rbx);
+ inputs[2] = ToLIROperand(rcx);
}
void LIRStoreProperty::Generate() {
- __ Push(inputs[2]);
- __ Push(inputs[0]);
+ __ push(rcx);
+ __ push(rax);
// rax <- object
// rbx <- property
@@ -164,8 +165,8 @@ void LIRStoreProperty::Generate() {
// Result may be rax
__ Mov(scratches[0], rax);
- __ pop(rbx);
- __ Pop(inputs[2]);
+ __ Pop(rbx);
+ __ Pop(rcx);
__ IsNil(ToRegister(scratches[0]), NULL, &done);
Operand qmap(rbx, HObject::kMapOffset);
Please sign in to comment.
Something went wrong with that request. Please try again.