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
parent 11cc4dcf
...@@ -1050,107 +1050,97 @@ LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { ...@@ -1050,107 +1050,97 @@ LInstruction* LChunkBuilder::DoGoto(HGoto* instr) {
LInstruction* LChunkBuilder::DoTest(HTest* instr) { LInstruction* LChunkBuilder::DoTest(HTest* instr) {
HValue* v = instr->value(); HValue* v = instr->value();
if (v->EmitAtUses()) { if (!v->EmitAtUses()) {
if (v->IsClassOfTest()) { return new LBranch(UseRegisterAtStart(v));
HClassOfTest* compare = HClassOfTest::cast(v); } else if (v->IsClassOfTest()) {
ASSERT(compare->value()->representation().IsTagged()); HClassOfTest* compare = HClassOfTest::cast(v);
ASSERT(compare->value()->representation().IsTagged());
return new LClassOfTestAndBranch(UseTempRegister(compare->value()), return new LClassOfTestAndBranch(UseTempRegister(compare->value()),
TempRegister()); TempRegister());
} else if (v->IsCompare()) { } else if (v->IsCompare()) {
HCompare* compare = HCompare::cast(v); HCompare* compare = HCompare::cast(v);
Token::Value op = compare->token(); Token::Value op = compare->token();
HValue* left = compare->left(); HValue* left = compare->left();
HValue* right = compare->right(); HValue* right = compare->right();
Representation r = compare->GetInputRepresentation(); Representation r = compare->GetInputRepresentation();
if (r.IsInteger32()) { if (r.IsInteger32()) {
ASSERT(left->representation().IsInteger32()); ASSERT(left->representation().IsInteger32());
ASSERT(right->representation().IsInteger32()); ASSERT(right->representation().IsInteger32());
return new LCmpIDAndBranch(UseRegisterAtStart(left), return new LCmpIDAndBranch(UseRegisterAtStart(left),
UseRegisterAtStart(right)); UseRegisterAtStart(right));
} else if (r.IsDouble()) { } else if (r.IsDouble()) {
ASSERT(left->representation().IsDouble()); ASSERT(left->representation().IsDouble());
ASSERT(right->representation().IsDouble()); ASSERT(right->representation().IsDouble());
return new LCmpIDAndBranch(UseRegisterAtStart(left), return new LCmpIDAndBranch(UseRegisterAtStart(left),
UseRegisterAtStart(right)); 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());
} else { } else {
if (v->IsConstant()) { ASSERT(left->representation().IsTagged());
if (HConstant::cast(v)->ToBoolean()) { ASSERT(right->representation().IsTagged());
return new LGoto(instr->FirstSuccessor()->block_id()); bool reversed = op == Token::GT || op == Token::LTE;
} else { LOperand* left_operand = UseFixed(left, reversed ? r0 : r1);
return new LGoto(instr->SecondSuccessor()->block_id()); LOperand* right_operand = UseFixed(right, reversed ? r1 : r0);
} LInstruction* result = new LCmpTAndBranch(left_operand, right_operand);
} return MarkAsCall(result, instr);
Abort("Undefined compare before branch");
return NULL;
} }
} 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) { LInstruction* LChunkBuilder::DoCompareMap(HCompareMap* instr) {
ASSERT(instr->value()->representation().IsTagged()); ASSERT(instr->value()->representation().IsTagged());
LOperand* value = UseRegisterAtStart(instr->value()); LOperand* value = UseRegisterAtStart(instr->value());
......
...@@ -1046,116 +1046,102 @@ LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { ...@@ -1046,116 +1046,102 @@ LInstruction* LChunkBuilder::DoGoto(HGoto* instr) {
LInstruction* LChunkBuilder::DoTest(HTest* instr) { LInstruction* LChunkBuilder::DoTest(HTest* instr) {
HValue* v = instr->value(); HValue* v = instr->value();
if (v->EmitAtUses()) { if (!v->EmitAtUses()) {
if (v->IsClassOfTest()) { return new LBranch(UseRegisterAtStart(v));
HClassOfTest* compare = HClassOfTest::cast(v); } else if (v->IsClassOfTest()) {
ASSERT(compare->value()->representation().IsTagged()); HClassOfTest* compare = HClassOfTest::cast(v);
ASSERT(compare->value()->representation().IsTagged());
return new LClassOfTestAndBranch(UseTempRegister(compare->value()), return new LClassOfTestAndBranch(UseTempRegister(compare->value()),
TempRegister(), TempRegister(),
TempRegister()); TempRegister());
} else if (v->IsCompare()) { } else if (v->IsCompare()) {
HCompare* compare = HCompare::cast(v); HCompare* compare = HCompare::cast(v);
Token::Value op = compare->token(); Token::Value op = compare->token();
HValue* left = compare->left(); HValue* left = compare->left();
HValue* right = compare->right(); HValue* right = compare->right();
Representation r = compare->GetInputRepresentation(); Representation r = compare->GetInputRepresentation();
if (r.IsInteger32()) { if (r.IsInteger32()) {
ASSERT(left->representation().IsInteger32()); ASSERT(left->representation().IsInteger32());
ASSERT(right->representation().IsInteger32()); ASSERT(right->representation().IsInteger32());
return new LCmpIDAndBranch(UseRegisterAtStart(left),
return new LCmpIDAndBranch(UseRegisterAtStart(left), UseOrConstantAtStart(right));
UseOrConstantAtStart(right)); } else if (r.IsDouble()) {
} else if (r.IsDouble()) { ASSERT(left->representation().IsDouble());
ASSERT(left->representation().IsDouble()); ASSERT(right->representation().IsDouble());
ASSERT(right->representation().IsDouble()); return new LCmpIDAndBranch(UseRegisterAtStart(left),
UseRegisterAtStart(right));
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());
} else { } else {
if (v->IsConstant()) { ASSERT(left->representation().IsTagged());
if (HConstant::cast(v)->ToBoolean()) { ASSERT(right->representation().IsTagged());
return new LGoto(instr->FirstSuccessor()->block_id()); bool reversed = op == Token::GT || op == Token::LTE;
} else { LOperand* left_operand = UseFixed(left, reversed ? eax : edx);
return new LGoto(instr->SecondSuccessor()->block_id()); LOperand* right_operand = UseFixed(right, reversed ? edx : eax);
} LCmpTAndBranch* result = new LCmpTAndBranch(left_operand, right_operand);
} return MarkAsCall(result, instr);
Abort("Undefined compare before branch");
return NULL;
} }
} 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) { ...@@ -1046,108 +1046,94 @@ LInstruction* LChunkBuilder::DoGoto(HGoto* instr) {
LInstruction* LChunkBuilder::DoTest(HTest* instr) { LInstruction* LChunkBuilder::DoTest(HTest* instr) {
HValue* v = instr->value(); HValue* v = instr->value();
if (v->EmitAtUses()) { if (!v->EmitAtUses()) {
if (v->IsClassOfTest()) { return new LBranch(UseRegisterAtStart(v));
HClassOfTest* compare = HClassOfTest::cast(v); } else if (v->IsClassOfTest()) {
ASSERT(compare->value()->representation().IsTagged()); HClassOfTest* compare = HClassOfTest::cast(v);
ASSERT(compare->value()->representation().IsTagged());
return new LClassOfTestAndBranch(UseTempRegister(compare->value()), return new LClassOfTestAndBranch(UseTempRegister(compare->value()),
TempRegister()); TempRegister());
} else if (v->IsCompare()) { } else if (v->IsCompare()) {
HCompare* compare = HCompare::cast(v); HCompare* compare = HCompare::cast(v);
Token::Value op = compare->token(); Token::Value op = compare->token();
HValue* left = compare->left(); HValue* left = compare->left();
HValue* right = compare->right(); HValue* right = compare->right();
Representation r = compare->GetInputRepresentation(); Representation r = compare->GetInputRepresentation();
if (r.IsInteger32()) { if (r.IsInteger32()) {
ASSERT(left->representation().IsInteger32()); ASSERT(left->representation().IsInteger32());
ASSERT(right->representation().IsInteger32()); ASSERT(right->representation().IsInteger32());
return new LCmpIDAndBranch(UseRegisterAtStart(left),
return new LCmpIDAndBranch(UseRegisterAtStart(left), UseOrConstantAtStart(right));
UseOrConstantAtStart(right)); } else if (r.IsDouble()) {
} else if (r.IsDouble()) { ASSERT(left->representation().IsDouble());
ASSERT(left->representation().IsDouble()); ASSERT(right->representation().IsDouble());
ASSERT(right->representation().IsDouble()); return new LCmpIDAndBranch(UseRegisterAtStart(left),
UseRegisterAtStart(right));
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());
} else { } else {
if (v->IsConstant()) { ASSERT(left->representation().IsTagged());
if (HConstant::cast(v)->ToBoolean()) { ASSERT(right->representation().IsTagged());
return new LGoto(instr->FirstSuccessor()->block_id()); bool reversed = op == Token::GT || op == Token::LTE;
} else { LOperand* left_operand = UseFixed(left, reversed ? rax : rdx);
return new LGoto(instr->SecondSuccessor()->block_id()); LOperand* right_operand = UseFixed(right, reversed ? rdx : rax);
} LCmpTAndBranch* result = new LCmpTAndBranch(left_operand, right_operand);
} return MarkAsCall(result, instr);
Abort("Undefined compare before branch");
return NULL;
} }
} 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));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment