| Index: src/x64/lithium-x64.cc
|
| ===================================================================
|
| --- src/x64/lithium-x64.cc (revision 7967)
|
| +++ src/x64/lithium-x64.cc (working copy)
|
| @@ -1046,108 +1046,94 @@
|
|
|
| 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));
|
| }
|
|
|
|
|
|
|