Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 1581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1592 Register reg = ToRegister(instr->InputAt(0)); | 1592 Register reg = ToRegister(instr->InputAt(0)); |
| 1593 int true_block = instr->true_block_id(); | 1593 int true_block = instr->true_block_id(); |
| 1594 int false_block = instr->false_block_id(); | 1594 int false_block = instr->false_block_id(); |
| 1595 | 1595 |
| 1596 __ Cmp(FieldOperand(reg, HeapObject::kMapOffset), instr->map()); | 1596 __ Cmp(FieldOperand(reg, HeapObject::kMapOffset), instr->map()); |
| 1597 EmitBranch(true_block, false_block, equal); | 1597 EmitBranch(true_block, false_block, equal); |
| 1598 } | 1598 } |
| 1599 | 1599 |
| 1600 | 1600 |
| 1601 void LCodeGen::DoInstanceOf(LInstanceOf* instr) { | 1601 void LCodeGen::DoInstanceOf(LInstanceOf* instr) { |
| 1602 Abort("Unimplemented: %s", "DoInstanceOf"); | 1602 InstanceofStub stub(InstanceofStub::kNoFlags); |
| 1603 __ push(ToRegister(instr->InputAt(0))); | |
| 1604 __ push(ToRegister(instr->InputAt(1))); | |
| 1605 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); | |
| 1606 __ testq(rax, rax); | |
| 1607 NearLabel true_value, done; | |
|
Rico
2011/02/16 14:43:25
Maybe put labels above the testq minimize diff to
William Hesse
2011/02/16 15:15:06
Done.
| |
| 1608 __ j(zero, &true_value); | |
| 1609 __ LoadRoot(ToRegister(instr->result()), Heap::kFalseValueRootIndex); | |
| 1610 __ jmp(&done); | |
| 1611 __ bind(&true_value); | |
| 1612 __ LoadRoot(ToRegister(instr->result()), Heap::kTrueValueRootIndex); | |
| 1613 __ bind(&done); | |
| 1603 } | 1614 } |
| 1604 | 1615 |
| 1605 | 1616 |
| 1606 void LCodeGen::DoInstanceOfAndBranch(LInstanceOfAndBranch* instr) { | 1617 void LCodeGen::DoInstanceOfAndBranch(LInstanceOfAndBranch* instr) { |
| 1607 int true_block = chunk_->LookupDestination(instr->true_block_id()); | 1618 int true_block = chunk_->LookupDestination(instr->true_block_id()); |
| 1608 int false_block = chunk_->LookupDestination(instr->false_block_id()); | 1619 int false_block = chunk_->LookupDestination(instr->false_block_id()); |
| 1609 | 1620 |
| 1610 InstanceofStub stub(InstanceofStub::kArgsInRegisters); | 1621 InstanceofStub stub(InstanceofStub::kNoFlags); |
| 1622 __ push(ToRegister(instr->InputAt(0))); | |
| 1623 __ push(ToRegister(instr->InputAt(1))); | |
| 1611 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); | 1624 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
| 1612 __ testq(rax, rax); | 1625 __ testq(rax, rax); |
| 1613 EmitBranch(true_block, false_block, zero); | 1626 EmitBranch(true_block, false_block, zero); |
| 1614 } | 1627 } |
| 1615 | 1628 |
| 1616 | 1629 |
| 1617 void LCodeGen::DoInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr) { | 1630 void LCodeGen::DoInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr) { |
| 1618 Abort("Unimplemented: %s", "DoInstanceOfKnowGLobal"); | 1631 class DeferredInstanceOfKnownGlobal: public LDeferredCode { |
| 1632 public: | |
| 1633 DeferredInstanceOfKnownGlobal(LCodeGen* codegen, | |
| 1634 LInstanceOfKnownGlobal* instr) | |
| 1635 : LDeferredCode(codegen), instr_(instr) { } | |
| 1636 virtual void Generate() { | |
| 1637 codegen()->DoDeferredLInstanceOfKnownGlobal(instr_); | |
| 1638 } | |
| 1639 | |
| 1640 private: | |
| 1641 LInstanceOfKnownGlobal* instr_; | |
| 1642 }; | |
| 1643 | |
| 1644 | |
| 1645 DeferredInstanceOfKnownGlobal* deferred; | |
| 1646 deferred = new DeferredInstanceOfKnownGlobal(this, instr); | |
| 1647 | |
| 1648 Label false_result; | |
| 1649 Register object = ToRegister(instr->InputAt(0)); | |
| 1650 | |
| 1651 // A Smi is not an instance of anything. | |
| 1652 __ JumpIfSmi(object, &false_result); | |
| 1653 | |
| 1654 // Null is not an instance of anything. | |
| 1655 __ CompareRoot(object, Heap::kNullValueRootIndex); | |
| 1656 __ j(equal, &false_result); | |
| 1657 | |
| 1658 // String values are not instances of anything. | |
| 1659 __ JumpIfNotString(object, kScratchRegister, deferred->entry()); | |
| 1660 | |
| 1661 __ bind(&false_result); | |
| 1662 __ LoadRoot(ToRegister(instr->result()), Heap::kFalseValueRootIndex); | |
| 1663 | |
| 1664 // Here result has either true or false. Deferred code also produces true or | |
|
Rico
2011/02/16 14:43:25
it never has true here does it?
William Hesse
2011/02/16 15:15:06
Comment deleted.
On 2011/02/16 14:43:25, Rico wro
| |
| 1665 // false object. | |
| 1666 __ bind(deferred->exit()); | |
| 1619 } | 1667 } |
| 1620 | 1668 |
| 1621 | 1669 |
| 1622 void LCodeGen::DoDeferredLInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr, | 1670 void LCodeGen::DoDeferredLInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr) { |
| 1623 Label* map_check) { | 1671 __ PushSafepointRegisters(); |
| 1624 Abort("Unimplemented: %s", "DoDeferredLInstanceOfKnownGlobakl"); | 1672 |
| 1673 InstanceofStub stub(InstanceofStub::kNoFlags); | |
| 1674 | |
| 1675 __ push(ToRegister(instr->InputAt(0))); | |
| 1676 __ Push(instr->function()); | |
| 1677 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | |
| 1678 __ Call(stub.GetCode(), RelocInfo::CODE_TARGET); | |
| 1679 RecordSafepointWithRegisters( | |
| 1680 instr->pointer_map(), 0, Safepoint::kNoDeoptimizationIndex); | |
| 1681 __ movq(kScratchRegister, rax); | |
| 1682 __ PopSafepointRegisters(); | |
| 1683 __ testq(kScratchRegister, kScratchRegister); | |
| 1684 Label load_false; | |
| 1685 Label done; | |
| 1686 __ j(not_zero, &load_false); | |
| 1687 __ LoadRoot(rax, Heap::kTrueValueRootIndex); | |
| 1688 __ jmp(&done); | |
| 1689 __ bind(&load_false); | |
| 1690 __ LoadRoot(rax, Heap::kFalseValueRootIndex); | |
| 1691 __ bind(&done); | |
| 1625 } | 1692 } |
| 1626 | 1693 |
| 1627 | 1694 |
| 1628 void LCodeGen::DoCmpT(LCmpT* instr) { | 1695 void LCodeGen::DoCmpT(LCmpT* instr) { |
| 1629 Token::Value op = instr->op(); | 1696 Token::Value op = instr->op(); |
| 1630 | 1697 |
| 1631 Handle<Code> ic = CompareIC::GetUninitialized(op); | 1698 Handle<Code> ic = CompareIC::GetUninitialized(op); |
| 1632 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 1699 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
| 1633 | 1700 |
| 1634 Condition condition = TokenToCondition(op, false); | 1701 Condition condition = TokenToCondition(op, false); |
| (...skipping 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2754 RegisterEnvironmentForDeoptimization(environment); | 2821 RegisterEnvironmentForDeoptimization(environment); |
| 2755 ASSERT(osr_pc_offset_ == -1); | 2822 ASSERT(osr_pc_offset_ == -1); |
| 2756 osr_pc_offset_ = masm()->pc_offset(); | 2823 osr_pc_offset_ = masm()->pc_offset(); |
| 2757 } | 2824 } |
| 2758 | 2825 |
| 2759 #undef __ | 2826 #undef __ |
| 2760 | 2827 |
| 2761 } } // namespace v8::internal | 2828 } } // namespace v8::internal |
| 2762 | 2829 |
| 2763 #endif // V8_TARGET_ARCH_X64 | 2830 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |