Refactoring only: Simplified LChunkBuilder:DoTest a bit, making it a simple if-then-else cascade.
Review URL: http://codereview.chromium.org/7055006 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7968 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
11cc4dcfc6
commit
969a909e3a
@ -1050,107 +1050,97 @@ LInstruction* LChunkBuilder::DoGoto(HGoto* instr) {
|
||||
|
||||
LInstruction* LChunkBuilder::DoTest(HTest* instr) {
|
||||
HValue* v = instr->value();
|
||||
if (v->EmitAtUses()) {
|
||||
if (v->IsClassOfTest()) {
|
||||
HClassOfTest* compare = HClassOfTest::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
|
||||
return new LClassOfTestAndBranch(UseTempRegister(compare->value()),
|
||||
TempRegister());
|
||||
} else if (v->IsCompare()) {
|
||||
HCompare* compare = HCompare::cast(v);
|
||||
Token::Value op = compare->token();
|
||||
HValue* left = compare->left();
|
||||
HValue* right = compare->right();
|
||||
Representation r = compare->GetInputRepresentation();
|
||||
if (r.IsInteger32()) {
|
||||
ASSERT(left->representation().IsInteger32());
|
||||
ASSERT(right->representation().IsInteger32());
|
||||
return new LCmpIDAndBranch(UseRegisterAtStart(left),
|
||||
UseRegisterAtStart(right));
|
||||
} else if (r.IsDouble()) {
|
||||
ASSERT(left->representation().IsDouble());
|
||||
ASSERT(right->representation().IsDouble());
|
||||
return new LCmpIDAndBranch(UseRegisterAtStart(left),
|
||||
UseRegisterAtStart(right));
|
||||
} else {
|
||||
ASSERT(left->representation().IsTagged());
|
||||
ASSERT(right->representation().IsTagged());
|
||||
bool reversed = op == Token::GT || op == Token::LTE;
|
||||
LOperand* left_operand = UseFixed(left, reversed ? r0 : r1);
|
||||
LOperand* right_operand = UseFixed(right, reversed ? r1 : r0);
|
||||
LInstruction* result = new LCmpTAndBranch(left_operand,
|
||||
right_operand);
|
||||
return MarkAsCall(result, instr);
|
||||
}
|
||||
} else if (v->IsIsSmi()) {
|
||||
HIsSmi* compare = HIsSmi::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
|
||||
return new LIsSmiAndBranch(Use(compare->value()));
|
||||
} else if (v->IsIsUndetectable()) {
|
||||
HIsUndetectable* compare = HIsUndetectable::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
|
||||
return new LIsUndetectableAndBranch(UseRegisterAtStart(compare->value()),
|
||||
TempRegister());
|
||||
} else if (v->IsHasInstanceType()) {
|
||||
HHasInstanceType* compare = HHasInstanceType::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
return new LHasInstanceTypeAndBranch(
|
||||
UseRegisterAtStart(compare->value()));
|
||||
} else if (v->IsHasCachedArrayIndex()) {
|
||||
HHasCachedArrayIndex* compare = HHasCachedArrayIndex::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
|
||||
return new LHasCachedArrayIndexAndBranch(
|
||||
UseRegisterAtStart(compare->value()));
|
||||
} else if (v->IsIsNull()) {
|
||||
HIsNull* compare = HIsNull::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
|
||||
return new LIsNullAndBranch(UseRegisterAtStart(compare->value()));
|
||||
} else if (v->IsIsObject()) {
|
||||
HIsObject* compare = HIsObject::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
|
||||
LOperand* temp = TempRegister();
|
||||
return new LIsObjectAndBranch(UseRegisterAtStart(compare->value()), temp);
|
||||
} else if (v->IsCompareJSObjectEq()) {
|
||||
HCompareJSObjectEq* compare = HCompareJSObjectEq::cast(v);
|
||||
return new LCmpJSObjectEqAndBranch(UseRegisterAtStart(compare->left()),
|
||||
UseRegisterAtStart(compare->right()));
|
||||
} else if (v->IsCompareSymbolEq()) {
|
||||
HCompareSymbolEq* compare = HCompareSymbolEq::cast(v);
|
||||
return new LCmpSymbolEqAndBranch(UseRegisterAtStart(compare->left()),
|
||||
UseRegisterAtStart(compare->right()));
|
||||
} else if (v->IsInstanceOf()) {
|
||||
HInstanceOf* instance_of = HInstanceOf::cast(v);
|
||||
LInstruction* result =
|
||||
new LInstanceOfAndBranch(UseFixed(instance_of->left(), r0),
|
||||
UseFixed(instance_of->right(), r1));
|
||||
return MarkAsCall(result, instr);
|
||||
} else if (v->IsTypeofIs()) {
|
||||
HTypeofIs* typeof_is = HTypeofIs::cast(v);
|
||||
return new LTypeofIsAndBranch(UseTempRegister(typeof_is->value()));
|
||||
} else if (v->IsIsConstructCall()) {
|
||||
return new LIsConstructCallAndBranch(TempRegister());
|
||||
if (!v->EmitAtUses()) {
|
||||
return new LBranch(UseRegisterAtStart(v));
|
||||
} else if (v->IsClassOfTest()) {
|
||||
HClassOfTest* compare = HClassOfTest::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
return new LClassOfTestAndBranch(UseTempRegister(compare->value()),
|
||||
TempRegister());
|
||||
} else if (v->IsCompare()) {
|
||||
HCompare* compare = HCompare::cast(v);
|
||||
Token::Value op = compare->token();
|
||||
HValue* left = compare->left();
|
||||
HValue* right = compare->right();
|
||||
Representation r = compare->GetInputRepresentation();
|
||||
if (r.IsInteger32()) {
|
||||
ASSERT(left->representation().IsInteger32());
|
||||
ASSERT(right->representation().IsInteger32());
|
||||
return new LCmpIDAndBranch(UseRegisterAtStart(left),
|
||||
UseRegisterAtStart(right));
|
||||
} else if (r.IsDouble()) {
|
||||
ASSERT(left->representation().IsDouble());
|
||||
ASSERT(right->representation().IsDouble());
|
||||
return new LCmpIDAndBranch(UseRegisterAtStart(left),
|
||||
UseRegisterAtStart(right));
|
||||
} else {
|
||||
if (v->IsConstant()) {
|
||||
if (HConstant::cast(v)->ToBoolean()) {
|
||||
return new LGoto(instr->FirstSuccessor()->block_id());
|
||||
} else {
|
||||
return new LGoto(instr->SecondSuccessor()->block_id());
|
||||
}
|
||||
}
|
||||
Abort("Undefined compare before branch");
|
||||
return NULL;
|
||||
ASSERT(left->representation().IsTagged());
|
||||
ASSERT(right->representation().IsTagged());
|
||||
bool reversed = op == Token::GT || op == Token::LTE;
|
||||
LOperand* left_operand = UseFixed(left, reversed ? r0 : r1);
|
||||
LOperand* right_operand = UseFixed(right, reversed ? r1 : r0);
|
||||
LInstruction* result = new LCmpTAndBranch(left_operand, right_operand);
|
||||
return MarkAsCall(result, instr);
|
||||
}
|
||||
} else if (v->IsIsSmi()) {
|
||||
HIsSmi* compare = HIsSmi::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
return new LIsSmiAndBranch(Use(compare->value()));
|
||||
} else if (v->IsIsUndetectable()) {
|
||||
HIsUndetectable* compare = HIsUndetectable::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
return new LIsUndetectableAndBranch(UseRegisterAtStart(compare->value()),
|
||||
TempRegister());
|
||||
} else if (v->IsHasInstanceType()) {
|
||||
HHasInstanceType* compare = HHasInstanceType::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
return new LHasInstanceTypeAndBranch(UseRegisterAtStart(compare->value()));
|
||||
} else if (v->IsHasCachedArrayIndex()) {
|
||||
HHasCachedArrayIndex* compare = HHasCachedArrayIndex::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
return new LHasCachedArrayIndexAndBranch(
|
||||
UseRegisterAtStart(compare->value()));
|
||||
} else if (v->IsIsNull()) {
|
||||
HIsNull* compare = HIsNull::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
return new LIsNullAndBranch(UseRegisterAtStart(compare->value()));
|
||||
} else if (v->IsIsObject()) {
|
||||
HIsObject* compare = HIsObject::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
LOperand* temp = TempRegister();
|
||||
return new LIsObjectAndBranch(UseRegisterAtStart(compare->value()), temp);
|
||||
} else if (v->IsCompareJSObjectEq()) {
|
||||
HCompareJSObjectEq* compare = HCompareJSObjectEq::cast(v);
|
||||
return new LCmpJSObjectEqAndBranch(UseRegisterAtStart(compare->left()),
|
||||
UseRegisterAtStart(compare->right()));
|
||||
} else if (v->IsCompareSymbolEq()) {
|
||||
HCompareSymbolEq* compare = HCompareSymbolEq::cast(v);
|
||||
return new LCmpSymbolEqAndBranch(UseRegisterAtStart(compare->left()),
|
||||
UseRegisterAtStart(compare->right()));
|
||||
} else if (v->IsInstanceOf()) {
|
||||
HInstanceOf* instance_of = HInstanceOf::cast(v);
|
||||
LInstruction* result =
|
||||
new LInstanceOfAndBranch(UseFixed(instance_of->left(), r0),
|
||||
UseFixed(instance_of->right(), r1));
|
||||
return MarkAsCall(result, instr);
|
||||
} else if (v->IsTypeofIs()) {
|
||||
HTypeofIs* typeof_is = HTypeofIs::cast(v);
|
||||
return new LTypeofIsAndBranch(UseTempRegister(typeof_is->value()));
|
||||
} else if (v->IsIsConstructCall()) {
|
||||
return new LIsConstructCallAndBranch(TempRegister());
|
||||
} else if (v->IsConstant()) {
|
||||
HBasicBlock* successor = HConstant::cast(v)->ToBoolean()
|
||||
? instr->FirstSuccessor()
|
||||
: instr->SecondSuccessor();
|
||||
return new LGoto(successor->block_id());
|
||||
} else {
|
||||
Abort("Undefined compare before branch");
|
||||
return NULL;
|
||||
}
|
||||
return new LBranch(UseRegisterAtStart(v));
|
||||
}
|
||||
|
||||
|
||||
|
||||
LInstruction* LChunkBuilder::DoCompareMap(HCompareMap* instr) {
|
||||
ASSERT(instr->value()->representation().IsTagged());
|
||||
LOperand* value = UseRegisterAtStart(instr->value());
|
||||
|
@ -1046,116 +1046,102 @@ LInstruction* LChunkBuilder::DoGoto(HGoto* instr) {
|
||||
|
||||
LInstruction* LChunkBuilder::DoTest(HTest* instr) {
|
||||
HValue* v = instr->value();
|
||||
if (v->EmitAtUses()) {
|
||||
if (v->IsClassOfTest()) {
|
||||
HClassOfTest* compare = HClassOfTest::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
|
||||
return new LClassOfTestAndBranch(UseTempRegister(compare->value()),
|
||||
TempRegister(),
|
||||
TempRegister());
|
||||
} else if (v->IsCompare()) {
|
||||
HCompare* compare = HCompare::cast(v);
|
||||
Token::Value op = compare->token();
|
||||
HValue* left = compare->left();
|
||||
HValue* right = compare->right();
|
||||
Representation r = compare->GetInputRepresentation();
|
||||
if (r.IsInteger32()) {
|
||||
ASSERT(left->representation().IsInteger32());
|
||||
ASSERT(right->representation().IsInteger32());
|
||||
|
||||
return new LCmpIDAndBranch(UseRegisterAtStart(left),
|
||||
UseOrConstantAtStart(right));
|
||||
} else if (r.IsDouble()) {
|
||||
ASSERT(left->representation().IsDouble());
|
||||
ASSERT(right->representation().IsDouble());
|
||||
|
||||
return new LCmpIDAndBranch(UseRegisterAtStart(left),
|
||||
UseRegisterAtStart(right));
|
||||
} else {
|
||||
ASSERT(left->representation().IsTagged());
|
||||
ASSERT(right->representation().IsTagged());
|
||||
bool reversed = op == Token::GT || op == Token::LTE;
|
||||
LOperand* left_operand = UseFixed(left, reversed ? eax : edx);
|
||||
LOperand* right_operand = UseFixed(right, reversed ? edx : eax);
|
||||
LCmpTAndBranch* result = new LCmpTAndBranch(left_operand,
|
||||
right_operand);
|
||||
return MarkAsCall(result, instr);
|
||||
}
|
||||
} else if (v->IsIsSmi()) {
|
||||
HIsSmi* compare = HIsSmi::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
|
||||
return new LIsSmiAndBranch(Use(compare->value()));
|
||||
} else if (v->IsIsUndetectable()) {
|
||||
HIsUndetectable* compare = HIsUndetectable::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
|
||||
return new LIsUndetectableAndBranch(UseRegisterAtStart(compare->value()),
|
||||
TempRegister());
|
||||
} else if (v->IsHasInstanceType()) {
|
||||
HHasInstanceType* compare = HHasInstanceType::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
|
||||
return new LHasInstanceTypeAndBranch(UseRegisterAtStart(compare->value()),
|
||||
TempRegister());
|
||||
} else if (v->IsHasCachedArrayIndex()) {
|
||||
HHasCachedArrayIndex* compare = HHasCachedArrayIndex::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
|
||||
return new LHasCachedArrayIndexAndBranch(
|
||||
UseRegisterAtStart(compare->value()));
|
||||
} else if (v->IsIsNull()) {
|
||||
HIsNull* compare = HIsNull::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
|
||||
// We only need a temp register for non-strict compare.
|
||||
LOperand* temp = compare->is_strict() ? NULL : TempRegister();
|
||||
return new LIsNullAndBranch(UseRegisterAtStart(compare->value()),
|
||||
temp);
|
||||
} else if (v->IsIsObject()) {
|
||||
HIsObject* compare = HIsObject::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
|
||||
LOperand* temp1 = TempRegister();
|
||||
LOperand* temp2 = TempRegister();
|
||||
return new LIsObjectAndBranch(UseRegisterAtStart(compare->value()),
|
||||
temp1,
|
||||
temp2);
|
||||
} else if (v->IsCompareJSObjectEq()) {
|
||||
HCompareJSObjectEq* compare = HCompareJSObjectEq::cast(v);
|
||||
return new LCmpJSObjectEqAndBranch(UseRegisterAtStart(compare->left()),
|
||||
UseRegisterAtStart(compare->right()));
|
||||
} else if (v->IsCompareSymbolEq()) {
|
||||
HCompareSymbolEq* compare = HCompareSymbolEq::cast(v);
|
||||
return new LCmpSymbolEqAndBranch(UseRegisterAtStart(compare->left()),
|
||||
UseRegisterAtStart(compare->right()));
|
||||
} else if (v->IsInstanceOf()) {
|
||||
HInstanceOf* instance_of = HInstanceOf::cast(v);
|
||||
LOperand* left = UseFixed(instance_of->left(), InstanceofStub::left());
|
||||
LOperand* right = UseFixed(instance_of->right(), InstanceofStub::right());
|
||||
LOperand* context = UseFixed(instance_of->context(), esi);
|
||||
LInstanceOfAndBranch* result =
|
||||
new LInstanceOfAndBranch(context, left, right);
|
||||
return MarkAsCall(result, instr);
|
||||
} else if (v->IsTypeofIs()) {
|
||||
HTypeofIs* typeof_is = HTypeofIs::cast(v);
|
||||
return new LTypeofIsAndBranch(UseTempRegister(typeof_is->value()));
|
||||
} else if (v->IsIsConstructCall()) {
|
||||
return new LIsConstructCallAndBranch(TempRegister());
|
||||
if (!v->EmitAtUses()) {
|
||||
return new LBranch(UseRegisterAtStart(v));
|
||||
} else if (v->IsClassOfTest()) {
|
||||
HClassOfTest* compare = HClassOfTest::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
return new LClassOfTestAndBranch(UseTempRegister(compare->value()),
|
||||
TempRegister(),
|
||||
TempRegister());
|
||||
} else if (v->IsCompare()) {
|
||||
HCompare* compare = HCompare::cast(v);
|
||||
Token::Value op = compare->token();
|
||||
HValue* left = compare->left();
|
||||
HValue* right = compare->right();
|
||||
Representation r = compare->GetInputRepresentation();
|
||||
if (r.IsInteger32()) {
|
||||
ASSERT(left->representation().IsInteger32());
|
||||
ASSERT(right->representation().IsInteger32());
|
||||
return new LCmpIDAndBranch(UseRegisterAtStart(left),
|
||||
UseOrConstantAtStart(right));
|
||||
} else if (r.IsDouble()) {
|
||||
ASSERT(left->representation().IsDouble());
|
||||
ASSERT(right->representation().IsDouble());
|
||||
return new LCmpIDAndBranch(UseRegisterAtStart(left),
|
||||
UseRegisterAtStart(right));
|
||||
} else {
|
||||
if (v->IsConstant()) {
|
||||
if (HConstant::cast(v)->ToBoolean()) {
|
||||
return new LGoto(instr->FirstSuccessor()->block_id());
|
||||
} else {
|
||||
return new LGoto(instr->SecondSuccessor()->block_id());
|
||||
}
|
||||
}
|
||||
Abort("Undefined compare before branch");
|
||||
return NULL;
|
||||
ASSERT(left->representation().IsTagged());
|
||||
ASSERT(right->representation().IsTagged());
|
||||
bool reversed = op == Token::GT || op == Token::LTE;
|
||||
LOperand* left_operand = UseFixed(left, reversed ? eax : edx);
|
||||
LOperand* right_operand = UseFixed(right, reversed ? edx : eax);
|
||||
LCmpTAndBranch* result = new LCmpTAndBranch(left_operand, right_operand);
|
||||
return MarkAsCall(result, instr);
|
||||
}
|
||||
} else if (v->IsIsSmi()) {
|
||||
HIsSmi* compare = HIsSmi::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
return new LIsSmiAndBranch(Use(compare->value()));
|
||||
} else if (v->IsIsUndetectable()) {
|
||||
HIsUndetectable* compare = HIsUndetectable::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
return new LIsUndetectableAndBranch(UseRegisterAtStart(compare->value()),
|
||||
TempRegister());
|
||||
} else if (v->IsHasInstanceType()) {
|
||||
HHasInstanceType* compare = HHasInstanceType::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
return new LHasInstanceTypeAndBranch(UseRegisterAtStart(compare->value()),
|
||||
TempRegister());
|
||||
} else if (v->IsHasCachedArrayIndex()) {
|
||||
HHasCachedArrayIndex* compare = HHasCachedArrayIndex::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
return new LHasCachedArrayIndexAndBranch(
|
||||
UseRegisterAtStart(compare->value()));
|
||||
} else if (v->IsIsNull()) {
|
||||
HIsNull* compare = HIsNull::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
// We only need a temp register for non-strict compare.
|
||||
LOperand* temp = compare->is_strict() ? NULL : TempRegister();
|
||||
return new LIsNullAndBranch(UseRegisterAtStart(compare->value()), temp);
|
||||
} else if (v->IsIsObject()) {
|
||||
HIsObject* compare = HIsObject::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
LOperand* temp1 = TempRegister();
|
||||
LOperand* temp2 = TempRegister();
|
||||
return new LIsObjectAndBranch(UseRegisterAtStart(compare->value()),
|
||||
temp1,
|
||||
temp2);
|
||||
} else if (v->IsCompareJSObjectEq()) {
|
||||
HCompareJSObjectEq* compare = HCompareJSObjectEq::cast(v);
|
||||
return new LCmpJSObjectEqAndBranch(UseRegisterAtStart(compare->left()),
|
||||
UseRegisterAtStart(compare->right()));
|
||||
} else if (v->IsCompareSymbolEq()) {
|
||||
HCompareSymbolEq* compare = HCompareSymbolEq::cast(v);
|
||||
return new LCmpSymbolEqAndBranch(UseRegisterAtStart(compare->left()),
|
||||
UseRegisterAtStart(compare->right()));
|
||||
} else if (v->IsInstanceOf()) {
|
||||
HInstanceOf* instance_of = HInstanceOf::cast(v);
|
||||
LOperand* left = UseFixed(instance_of->left(), InstanceofStub::left());
|
||||
LOperand* right = UseFixed(instance_of->right(), InstanceofStub::right());
|
||||
LOperand* context = UseFixed(instance_of->context(), esi);
|
||||
LInstanceOfAndBranch* result =
|
||||
new LInstanceOfAndBranch(context, left, right);
|
||||
return MarkAsCall(result, instr);
|
||||
} else if (v->IsTypeofIs()) {
|
||||
HTypeofIs* typeof_is = HTypeofIs::cast(v);
|
||||
return new LTypeofIsAndBranch(UseTempRegister(typeof_is->value()));
|
||||
} else if (v->IsIsConstructCall()) {
|
||||
return new LIsConstructCallAndBranch(TempRegister());
|
||||
} else if (v->IsConstant()) {
|
||||
HBasicBlock* successor = HConstant::cast(v)->ToBoolean()
|
||||
? instr->FirstSuccessor()
|
||||
: instr->SecondSuccessor();
|
||||
return new LGoto(successor->block_id());
|
||||
} else {
|
||||
Abort("Undefined compare before branch");
|
||||
return NULL;
|
||||
}
|
||||
return new LBranch(UseRegisterAtStart(v));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1046,108 +1046,94 @@ LInstruction* LChunkBuilder::DoGoto(HGoto* instr) {
|
||||
|
||||
LInstruction* LChunkBuilder::DoTest(HTest* instr) {
|
||||
HValue* v = instr->value();
|
||||
if (v->EmitAtUses()) {
|
||||
if (v->IsClassOfTest()) {
|
||||
HClassOfTest* compare = HClassOfTest::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
|
||||
return new LClassOfTestAndBranch(UseTempRegister(compare->value()),
|
||||
TempRegister());
|
||||
} else if (v->IsCompare()) {
|
||||
HCompare* compare = HCompare::cast(v);
|
||||
Token::Value op = compare->token();
|
||||
HValue* left = compare->left();
|
||||
HValue* right = compare->right();
|
||||
Representation r = compare->GetInputRepresentation();
|
||||
if (r.IsInteger32()) {
|
||||
ASSERT(left->representation().IsInteger32());
|
||||
ASSERT(right->representation().IsInteger32());
|
||||
|
||||
return new LCmpIDAndBranch(UseRegisterAtStart(left),
|
||||
UseOrConstantAtStart(right));
|
||||
} else if (r.IsDouble()) {
|
||||
ASSERT(left->representation().IsDouble());
|
||||
ASSERT(right->representation().IsDouble());
|
||||
|
||||
return new LCmpIDAndBranch(UseRegisterAtStart(left),
|
||||
UseRegisterAtStart(right));
|
||||
} else {
|
||||
ASSERT(left->representation().IsTagged());
|
||||
ASSERT(right->representation().IsTagged());
|
||||
bool reversed = op == Token::GT || op == Token::LTE;
|
||||
LOperand* left_operand = UseFixed(left, reversed ? rax : rdx);
|
||||
LOperand* right_operand = UseFixed(right, reversed ? rdx : rax);
|
||||
LCmpTAndBranch* result = new LCmpTAndBranch(left_operand,
|
||||
right_operand);
|
||||
return MarkAsCall(result, instr);
|
||||
}
|
||||
} else if (v->IsIsSmi()) {
|
||||
HIsSmi* compare = HIsSmi::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
|
||||
return new LIsSmiAndBranch(Use(compare->value()));
|
||||
} else if (v->IsIsUndetectable()) {
|
||||
HIsUndetectable* compare = HIsUndetectable::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
|
||||
return new LIsUndetectableAndBranch(UseRegisterAtStart(compare->value()),
|
||||
TempRegister());
|
||||
} else if (v->IsHasInstanceType()) {
|
||||
HHasInstanceType* compare = HHasInstanceType::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
|
||||
return new LHasInstanceTypeAndBranch(
|
||||
UseRegisterAtStart(compare->value()));
|
||||
} else if (v->IsHasCachedArrayIndex()) {
|
||||
HHasCachedArrayIndex* compare = HHasCachedArrayIndex::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
|
||||
return new LHasCachedArrayIndexAndBranch(
|
||||
UseRegisterAtStart(compare->value()));
|
||||
} else if (v->IsIsNull()) {
|
||||
HIsNull* compare = HIsNull::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
|
||||
// We only need a temp register for non-strict compare.
|
||||
LOperand* temp = compare->is_strict() ? NULL : TempRegister();
|
||||
return new LIsNullAndBranch(UseRegisterAtStart(compare->value()),
|
||||
temp);
|
||||
} else if (v->IsIsObject()) {
|
||||
HIsObject* compare = HIsObject::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
return new LIsObjectAndBranch(UseRegisterAtStart(compare->value()));
|
||||
} else if (v->IsCompareJSObjectEq()) {
|
||||
HCompareJSObjectEq* compare = HCompareJSObjectEq::cast(v);
|
||||
return new LCmpJSObjectEqAndBranch(UseRegisterAtStart(compare->left()),
|
||||
UseRegisterAtStart(compare->right()));
|
||||
} else if (v->IsCompareSymbolEq()) {
|
||||
HCompareSymbolEq* compare = HCompareSymbolEq::cast(v);
|
||||
return new LCmpSymbolEqAndBranch(UseRegisterAtStart(compare->left()),
|
||||
UseRegisterAtStart(compare->right()));
|
||||
} else if (v->IsInstanceOf()) {
|
||||
HInstanceOf* instance_of = HInstanceOf::cast(v);
|
||||
LInstanceOfAndBranch* result =
|
||||
new LInstanceOfAndBranch(UseFixed(instance_of->left(), rax),
|
||||
UseFixed(instance_of->right(), rdx));
|
||||
return MarkAsCall(result, instr);
|
||||
} else if (v->IsTypeofIs()) {
|
||||
HTypeofIs* typeof_is = HTypeofIs::cast(v);
|
||||
return new LTypeofIsAndBranch(UseTempRegister(typeof_is->value()));
|
||||
} else if (v->IsIsConstructCall()) {
|
||||
return new LIsConstructCallAndBranch(TempRegister());
|
||||
if (!v->EmitAtUses()) {
|
||||
return new LBranch(UseRegisterAtStart(v));
|
||||
} else if (v->IsClassOfTest()) {
|
||||
HClassOfTest* compare = HClassOfTest::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
return new LClassOfTestAndBranch(UseTempRegister(compare->value()),
|
||||
TempRegister());
|
||||
} else if (v->IsCompare()) {
|
||||
HCompare* compare = HCompare::cast(v);
|
||||
Token::Value op = compare->token();
|
||||
HValue* left = compare->left();
|
||||
HValue* right = compare->right();
|
||||
Representation r = compare->GetInputRepresentation();
|
||||
if (r.IsInteger32()) {
|
||||
ASSERT(left->representation().IsInteger32());
|
||||
ASSERT(right->representation().IsInteger32());
|
||||
return new LCmpIDAndBranch(UseRegisterAtStart(left),
|
||||
UseOrConstantAtStart(right));
|
||||
} else if (r.IsDouble()) {
|
||||
ASSERT(left->representation().IsDouble());
|
||||
ASSERT(right->representation().IsDouble());
|
||||
return new LCmpIDAndBranch(UseRegisterAtStart(left),
|
||||
UseRegisterAtStart(right));
|
||||
} else {
|
||||
if (v->IsConstant()) {
|
||||
if (HConstant::cast(v)->ToBoolean()) {
|
||||
return new LGoto(instr->FirstSuccessor()->block_id());
|
||||
} else {
|
||||
return new LGoto(instr->SecondSuccessor()->block_id());
|
||||
}
|
||||
}
|
||||
Abort("Undefined compare before branch");
|
||||
return NULL;
|
||||
ASSERT(left->representation().IsTagged());
|
||||
ASSERT(right->representation().IsTagged());
|
||||
bool reversed = op == Token::GT || op == Token::LTE;
|
||||
LOperand* left_operand = UseFixed(left, reversed ? rax : rdx);
|
||||
LOperand* right_operand = UseFixed(right, reversed ? rdx : rax);
|
||||
LCmpTAndBranch* result = new LCmpTAndBranch(left_operand, right_operand);
|
||||
return MarkAsCall(result, instr);
|
||||
}
|
||||
} else if (v->IsIsSmi()) {
|
||||
HIsSmi* compare = HIsSmi::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
return new LIsSmiAndBranch(Use(compare->value()));
|
||||
} else if (v->IsIsUndetectable()) {
|
||||
HIsUndetectable* compare = HIsUndetectable::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
return new LIsUndetectableAndBranch(UseRegisterAtStart(compare->value()),
|
||||
TempRegister());
|
||||
} else if (v->IsHasInstanceType()) {
|
||||
HHasInstanceType* compare = HHasInstanceType::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
return new LHasInstanceTypeAndBranch(UseRegisterAtStart(compare->value()));
|
||||
} else if (v->IsHasCachedArrayIndex()) {
|
||||
HHasCachedArrayIndex* compare = HHasCachedArrayIndex::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
return new LHasCachedArrayIndexAndBranch(
|
||||
UseRegisterAtStart(compare->value()));
|
||||
} else if (v->IsIsNull()) {
|
||||
HIsNull* compare = HIsNull::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
// We only need a temp register for non-strict compare.
|
||||
LOperand* temp = compare->is_strict() ? NULL : TempRegister();
|
||||
return new LIsNullAndBranch(UseRegisterAtStart(compare->value()), temp);
|
||||
} else if (v->IsIsObject()) {
|
||||
HIsObject* compare = HIsObject::cast(v);
|
||||
ASSERT(compare->value()->representation().IsTagged());
|
||||
return new LIsObjectAndBranch(UseRegisterAtStart(compare->value()));
|
||||
} else if (v->IsCompareJSObjectEq()) {
|
||||
HCompareJSObjectEq* compare = HCompareJSObjectEq::cast(v);
|
||||
return new LCmpJSObjectEqAndBranch(UseRegisterAtStart(compare->left()),
|
||||
UseRegisterAtStart(compare->right()));
|
||||
} else if (v->IsCompareSymbolEq()) {
|
||||
HCompareSymbolEq* compare = HCompareSymbolEq::cast(v);
|
||||
return new LCmpSymbolEqAndBranch(UseRegisterAtStart(compare->left()),
|
||||
UseRegisterAtStart(compare->right()));
|
||||
} else if (v->IsInstanceOf()) {
|
||||
HInstanceOf* instance_of = HInstanceOf::cast(v);
|
||||
LInstanceOfAndBranch* result =
|
||||
new LInstanceOfAndBranch(UseFixed(instance_of->left(), rax),
|
||||
UseFixed(instance_of->right(), rdx));
|
||||
return MarkAsCall(result, instr);
|
||||
} else if (v->IsTypeofIs()) {
|
||||
HTypeofIs* typeof_is = HTypeofIs::cast(v);
|
||||
return new LTypeofIsAndBranch(UseTempRegister(typeof_is->value()));
|
||||
} else if (v->IsIsConstructCall()) {
|
||||
return new LIsConstructCallAndBranch(TempRegister());
|
||||
} else if (v->IsConstant()) {
|
||||
HBasicBlock* successor = HConstant::cast(v)->ToBoolean()
|
||||
? instr->FirstSuccessor()
|
||||
: instr->SecondSuccessor();
|
||||
return new LGoto(successor->block_id());
|
||||
} else {
|
||||
Abort("Undefined compare before branch");
|
||||
return NULL;
|
||||
}
|
||||
return new LBranch(UseRegisterAtStart(v));
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user