Chromium Code Reviews| Index: src/x64/lithium-x64.cc |
| diff --git a/src/x64/lithium-x64.cc b/src/x64/lithium-x64.cc |
| index a38451066965927ee50dd971bfea7d30d4beb50c..205fa646a004e054950b8ea4ba673632384fc0a5 100644 |
| --- a/src/x64/lithium-x64.cc |
| +++ b/src/x64/lithium-x64.cc |
| @@ -902,8 +902,104 @@ LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { |
| LInstruction* LChunkBuilder::DoBranch(HBranch* instr) { |
| - Abort("Unimplemented: %s", "DoBranch"); |
| - return NULL; |
| + 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), |
|
William Hesse
2011/01/18 14:01:50
I think Integer32 can be handled by the CmpIAndBra
Lasse Reichstein
2011/01/19 09:20:35
I don't believe there is a CmpIAndBranch, only a C
|
| + 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->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->IsInstanceOf()) { |
| + HInstanceOf* instance_of = HInstanceOf::cast(v); |
| + LInstanceOfAndBranch* result = |
| + new LInstanceOfAndBranch( |
| + UseFixed(instance_of->left(), InstanceofStub::left()), |
| + UseFixed(instance_of->right(), InstanceofStub::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->IsConstant()) { |
| + if (HConstant::cast(v)->handle()->IsTrue()) { |
| + return new LGoto(instr->FirstSuccessor()->block_id()); |
| + } else if (HConstant::cast(v)->handle()->IsFalse()) { |
| + return new LGoto(instr->SecondSuccessor()->block_id()); |
| + } |
| + } |
| + Abort("Undefined compare before branch"); |
| + return NULL; |
| + } |
| + } |
| + return new LBranch(UseRegisterAtStart(v)); |
| } |
| @@ -1097,8 +1193,29 @@ LInstruction* LChunkBuilder::DoPower(HPower* instr) { |
| LInstruction* LChunkBuilder::DoCompare(HCompare* instr) { |
| - Abort("Unimplemented: %s", "DoCompare"); |
| - return NULL; |
| + Token::Value op = instr->token(); |
| + Representation r = instr->GetInputRepresentation(); |
| + if (r.IsInteger32()) { |
| + ASSERT(instr->left()->representation().IsInteger32()); |
| + ASSERT(instr->right()->representation().IsInteger32()); |
| + LOperand* left = UseRegisterAtStart(instr->left()); |
| + LOperand* right = UseOrConstantAtStart(instr->right()); |
| + return DefineAsRegister(new LCmpID(left, right)); |
| + } else if (r.IsDouble()) { |
| + ASSERT(instr->left()->representation().IsDouble()); |
| + ASSERT(instr->right()->representation().IsDouble()); |
| + LOperand* left = UseRegisterAtStart(instr->left()); |
| + LOperand* right = UseRegisterAtStart(instr->right()); |
| + return DefineAsRegister(new LCmpID(left, right)); |
| + } else { |
| + ASSERT(instr->left()->representation().IsTagged()); |
| + ASSERT(instr->right()->representation().IsTagged()); |
| + bool reversed = (op == Token::GT || op == Token::LTE); |
| + LOperand* left = UseFixed(instr->left(), reversed ? rax : rdx); |
| + LOperand* right = UseFixed(instr->right(), reversed ? rdx : rax); |
| + LCmpT* result = new LCmpT(left, right); |
| + return MarkAsCall(DefineFixed(result, rax), instr); |
| + } |
| } |