| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
| 6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 7 | 7 |
| 8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
| 9 | 9 |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 return locs; | 77 return locs; |
| 78 } | 78 } |
| 79 | 79 |
| 80 | 80 |
| 81 // Attempt optimized compilation at return instruction instead of at the entry. | 81 // Attempt optimized compilation at return instruction instead of at the entry. |
| 82 // The entry needs to be patchable, no inlined objects are allowed in the area | 82 // The entry needs to be patchable, no inlined objects are allowed in the area |
| 83 // that will be overwritten by the patch instruction: a jump). | 83 // that will be overwritten by the patch instruction: a jump). |
| 84 void ReturnInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 84 void ReturnInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 85 Register result = locs()->in(0).reg(); | 85 Register result = locs()->in(0).reg(); |
| 86 ASSERT(result == EAX); | 86 ASSERT(result == EAX); |
| 87 |
| 88 if (compiler->intrinsic_mode()) { |
| 89 // Intrinsics don't have a frame. |
| 90 __ ret(); |
| 91 return; |
| 92 } |
| 93 |
| 87 #if defined(DEBUG) | 94 #if defined(DEBUG) |
| 88 __ Comment("Stack Check"); | 95 __ Comment("Stack Check"); |
| 89 Label done; | 96 Label done; |
| 90 const intptr_t fp_sp_dist = | 97 const intptr_t fp_sp_dist = |
| 91 (kFirstLocalSlotFromFp + 1 - compiler->StackSize()) * kWordSize; | 98 (kFirstLocalSlotFromFp + 1 - compiler->StackSize()) * kWordSize; |
| 92 ASSERT(fp_sp_dist <= 0); | 99 ASSERT(fp_sp_dist <= 0); |
| 93 __ movl(EDI, ESP); | 100 __ movl(EDI, ESP); |
| 94 __ subl(EDI, EBP); | 101 __ subl(EDI, EBP); |
| 95 __ cmpl(EDI, Immediate(fp_sp_dist)); | 102 __ cmpl(EDI, Immediate(fp_sp_dist)); |
| 96 __ j(EQUAL, &done, Assembler::kNearJump); | 103 __ j(EQUAL, &done, Assembler::kNearJump); |
| (...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 ICData::Handle()); | 930 ICData::Handle()); |
| 924 ASSERT(locs()->out(0).reg() == EAX); | 931 ASSERT(locs()->out(0).reg() == EAX); |
| 925 } | 932 } |
| 926 | 933 |
| 927 | 934 |
| 928 LocationSummary* LoadUntaggedInstr::MakeLocationSummary(Isolate* isolate, | 935 LocationSummary* LoadUntaggedInstr::MakeLocationSummary(Isolate* isolate, |
| 929 bool opt) const { | 936 bool opt) const { |
| 930 const intptr_t kNumInputs = 1; | 937 const intptr_t kNumInputs = 1; |
| 931 return LocationSummary::Make(isolate, | 938 return LocationSummary::Make(isolate, |
| 932 kNumInputs, | 939 kNumInputs, |
| 933 Location::RequiresRegister(), | 940 Location::SameAsFirstInput(), |
| 934 LocationSummary::kNoCall); | 941 LocationSummary::kNoCall); |
| 935 } | 942 } |
| 936 | 943 |
| 937 | 944 |
| 938 void LoadUntaggedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 945 void LoadUntaggedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 939 Register object = locs()->in(0).reg(); | 946 Register object = locs()->in(0).reg(); |
| 940 Register result = locs()->out(0).reg(); | 947 Register result = locs()->out(0).reg(); |
| 941 __ movl(result, FieldAddress(object, offset())); | 948 __ movl(result, FieldAddress(object, offset())); |
| 942 } | 949 } |
| 943 | 950 |
| (...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1667 Immediate(Smi::RawValue(field().guarded_list_length()))); | 1674 Immediate(Smi::RawValue(field().guarded_list_length()))); |
| 1668 __ j(NOT_EQUAL, deopt); | 1675 __ j(NOT_EQUAL, deopt); |
| 1669 } | 1676 } |
| 1670 } | 1677 } |
| 1671 | 1678 |
| 1672 | 1679 |
| 1673 class BoxAllocationSlowPath : public SlowPathCode { | 1680 class BoxAllocationSlowPath : public SlowPathCode { |
| 1674 public: | 1681 public: |
| 1675 BoxAllocationSlowPath(Instruction* instruction, | 1682 BoxAllocationSlowPath(Instruction* instruction, |
| 1676 const Class& cls, | 1683 const Class& cls, |
| 1677 Register result) | 1684 Register result, |
| 1685 bool is_intrinsic) |
| 1678 : instruction_(instruction), | 1686 : instruction_(instruction), |
| 1679 cls_(cls), | 1687 cls_(cls), |
| 1680 result_(result) { } | 1688 result_(result), |
| 1689 is_intrinsic_(is_intrinsic) { } |
| 1681 | 1690 |
| 1682 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { | 1691 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { |
| 1683 Isolate* isolate = compiler->isolate(); | 1692 Isolate* isolate = compiler->isolate(); |
| 1684 StubCode* stub_code = isolate->stub_code(); | 1693 StubCode* stub_code = isolate->stub_code(); |
| 1685 | 1694 |
| 1686 if (Assembler::EmittingComments()) { | 1695 if (Assembler::EmittingComments()) { |
| 1687 __ Comment("%s slow path allocation of %s", | 1696 __ Comment("%s slow path allocation of %s", |
| 1688 instruction_->DebugName(), | 1697 instruction_->DebugName(), |
| 1689 String::Handle(cls_.PrettyName()).ToCString()); | 1698 String::Handle(cls_.PrettyName()).ToCString()); |
| 1690 } | 1699 } |
| 1691 __ Bind(entry_label()); | 1700 __ Bind(entry_label()); |
| 1692 | 1701 |
| 1702 if (is_intrinsic_) { |
| 1703 __ EnterStubFrame(); |
| 1704 } |
| 1705 |
| 1693 const Code& stub = | 1706 const Code& stub = |
| 1694 Code::Handle(isolate, stub_code->GetAllocationStubForClass(cls_)); | 1707 Code::Handle(isolate, stub_code->GetAllocationStubForClass(cls_)); |
| 1695 const ExternalLabel label(stub.EntryPoint()); | 1708 const ExternalLabel label(stub.EntryPoint()); |
| 1696 | 1709 |
| 1697 LocationSummary* locs = instruction_->locs(); | 1710 LocationSummary* locs = instruction_->locs(); |
| 1698 | 1711 |
| 1699 locs->live_registers()->Remove(Location::RegisterLocation(result_)); | 1712 locs->live_registers()->Remove(Location::RegisterLocation(result_)); |
| 1700 | 1713 |
| 1701 compiler->SaveLiveRegisters(locs); | 1714 compiler->SaveLiveRegisters(locs); |
| 1702 compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. | 1715 compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. |
| 1703 &label, | 1716 &label, |
| 1704 RawPcDescriptors::kOther, | 1717 RawPcDescriptors::kOther, |
| 1705 locs); | 1718 locs); |
| 1706 __ MoveRegister(result_, EAX); | 1719 __ MoveRegister(result_, EAX); |
| 1707 compiler->RestoreLiveRegisters(locs); | 1720 compiler->RestoreLiveRegisters(locs); |
| 1721 if (is_intrinsic_) { |
| 1722 __ LeaveFrame(); |
| 1723 } |
| 1708 __ jmp(exit_label()); | 1724 __ jmp(exit_label()); |
| 1709 } | 1725 } |
| 1710 | 1726 |
| 1711 static void Allocate(FlowGraphCompiler* compiler, | 1727 static void Allocate(FlowGraphCompiler* compiler, |
| 1712 Instruction* instruction, | 1728 Instruction* instruction, |
| 1713 const Class& cls, | 1729 const Class& cls, |
| 1714 Register result, | 1730 Register result, |
| 1715 Register temp) { | 1731 Register temp) { |
| 1716 BoxAllocationSlowPath* slow_path = | 1732 BoxAllocationSlowPath* slow_path = |
| 1717 new BoxAllocationSlowPath(instruction, cls, result); | 1733 new BoxAllocationSlowPath(instruction, cls, result, |
| 1734 compiler->intrinsic_mode()); |
| 1718 compiler->AddSlowPathCode(slow_path); | 1735 compiler->AddSlowPathCode(slow_path); |
| 1719 | 1736 |
| 1720 __ TryAllocate(cls, | 1737 __ TryAllocate(cls, |
| 1721 slow_path->entry_label(), | 1738 slow_path->entry_label(), |
| 1722 Assembler::kFarJump, | 1739 Assembler::kFarJump, |
| 1723 result, | 1740 result, |
| 1724 temp); | 1741 temp); |
| 1725 __ Bind(slow_path->exit_label()); | 1742 __ Bind(slow_path->exit_label()); |
| 1726 } | 1743 } |
| 1727 | 1744 |
| 1728 private: | 1745 private: |
| 1729 Instruction* instruction_; | 1746 Instruction* instruction_; |
| 1730 const Class& cls_; | 1747 const Class& cls_; |
| 1731 Register result_; | 1748 const Register result_; |
| 1749 const bool is_intrinsic_; |
| 1732 }; | 1750 }; |
| 1733 | 1751 |
| 1734 | 1752 |
| 1735 LocationSummary* StoreInstanceFieldInstr::MakeLocationSummary(Isolate* isolate, | 1753 LocationSummary* StoreInstanceFieldInstr::MakeLocationSummary(Isolate* isolate, |
| 1736 bool opt) const { | 1754 bool opt) const { |
| 1737 const intptr_t kNumInputs = 2; | 1755 const intptr_t kNumInputs = 2; |
| 1738 const intptr_t kNumTemps = | 1756 const intptr_t kNumTemps = |
| 1739 (IsUnboxedStore() && opt) ? 2 : | 1757 (IsUnboxedStore() && opt) ? 2 : |
| 1740 ((IsPotentialUnboxedStore()) ? 3 : 0); | 1758 ((IsPotentialUnboxedStore()) ? 3 : 0); |
| 1741 LocationSummary* summary = new(isolate) LocationSummary( | 1759 LocationSummary* summary = new(isolate) LocationSummary( |
| (...skipping 5295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7037 __ movl(EDX, Immediate(kInvalidObjectPointer)); | 7055 __ movl(EDX, Immediate(kInvalidObjectPointer)); |
| 7038 __ movl(EDX, Immediate(kInvalidObjectPointer)); | 7056 __ movl(EDX, Immediate(kInvalidObjectPointer)); |
| 7039 #endif | 7057 #endif |
| 7040 } | 7058 } |
| 7041 | 7059 |
| 7042 } // namespace dart | 7060 } // namespace dart |
| 7043 | 7061 |
| 7044 #undef __ | 7062 #undef __ |
| 7045 | 7063 |
| 7046 #endif // defined TARGET_ARCH_IA32 | 7064 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |