| 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_ARM. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM. |
| 6 #if defined(TARGET_ARCH_ARM) | 6 #if defined(TARGET_ARCH_ARM) |
| 7 | 7 |
| 8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
| 9 | 9 |
| 10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 // where PushArgument is handled by BindInstr::EmitNativeCode. | 56 // where PushArgument is handled by BindInstr::EmitNativeCode. |
| 57 if (compiler->is_optimizing()) { | 57 if (compiler->is_optimizing()) { |
| 58 Location value = locs()->in(0); | 58 Location value = locs()->in(0); |
| 59 if (value.IsRegister()) { | 59 if (value.IsRegister()) { |
| 60 __ Push(value.reg()); | 60 __ Push(value.reg()); |
| 61 } else if (value.IsConstant()) { | 61 } else if (value.IsConstant()) { |
| 62 __ PushObject(value.constant()); | 62 __ PushObject(value.constant()); |
| 63 } else { | 63 } else { |
| 64 ASSERT(value.IsStackSlot()); | 64 ASSERT(value.IsStackSlot()); |
| 65 const intptr_t value_offset = value.ToStackSlotOffset(); | 65 const intptr_t value_offset = value.ToStackSlotOffset(); |
| 66 __ LoadFromOffset(kWord, IP, FP, value_offset); | 66 __ LoadFromOffset(kWord, IP, value.base_reg(), value_offset); |
| 67 __ Push(IP); | 67 __ Push(IP); |
| 68 } | 68 } |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 | 71 |
| 72 | 72 |
| 73 LocationSummary* ReturnInstr::MakeLocationSummary(Isolate* isolate, | 73 LocationSummary* ReturnInstr::MakeLocationSummary(Isolate* isolate, |
| 74 bool opt) const { | 74 bool opt) const { |
| 75 const intptr_t kNumInputs = 1; | 75 const intptr_t kNumInputs = 1; |
| 76 const intptr_t kNumTemps = 0; | 76 const intptr_t kNumTemps = 0; |
| 77 LocationSummary* locs = new(isolate) LocationSummary( | 77 LocationSummary* locs = new(isolate) LocationSummary( |
| 78 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); | 78 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 79 locs->set_in(0, Location::RegisterLocation(R0)); | 79 locs->set_in(0, Location::RegisterLocation(R0)); |
| 80 return locs; | 80 return locs; |
| 81 } | 81 } |
| 82 | 82 |
| 83 | 83 |
| 84 // Attempt optimized compilation at return instruction instead of at the entry. | 84 // Attempt optimized compilation at return instruction instead of at the entry. |
| 85 // The entry needs to be patchable, no inlined objects are allowed in the area | 85 // The entry needs to be patchable, no inlined objects are allowed in the area |
| 86 // that will be overwritten by the patch instructions: a branch macro sequence. | 86 // that will be overwritten by the patch instructions: a branch macro sequence. |
| 87 void ReturnInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 87 void ReturnInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 88 const Register result = locs()->in(0).reg(); | 88 const Register result = locs()->in(0).reg(); |
| 89 ASSERT(result == R0); | 89 ASSERT(result == R0); |
| 90 |
| 91 if (compiler->intrinsic_mode()) { |
| 92 // Intrinsics don't have a frame. |
| 93 __ Ret(); |
| 94 return; |
| 95 } |
| 96 |
| 90 #if defined(DEBUG) | 97 #if defined(DEBUG) |
| 91 Label stack_ok; | 98 Label stack_ok; |
| 92 __ Comment("Stack Check"); | 99 __ Comment("Stack Check"); |
| 93 const intptr_t fp_sp_dist = | 100 const intptr_t fp_sp_dist = |
| 94 (kFirstLocalSlotFromFp + 1 - compiler->StackSize()) * kWordSize; | 101 (kFirstLocalSlotFromFp + 1 - compiler->StackSize()) * kWordSize; |
| 95 ASSERT(fp_sp_dist <= 0); | 102 ASSERT(fp_sp_dist <= 0); |
| 96 __ sub(R2, SP, Operand(FP)); | 103 __ sub(R2, SP, Operand(FP)); |
| 97 __ CompareImmediate(R2, fp_sp_dist); | 104 __ CompareImmediate(R2, fp_sp_dist); |
| 98 __ b(&stack_ok, EQ); | 105 __ b(&stack_ok, EQ); |
| 99 __ bkpt(0); | 106 __ bkpt(0); |
| (...skipping 1745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1845 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { | 1852 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { |
| 1846 Isolate* isolate = compiler->isolate(); | 1853 Isolate* isolate = compiler->isolate(); |
| 1847 StubCode* stub_code = isolate->stub_code(); | 1854 StubCode* stub_code = isolate->stub_code(); |
| 1848 | 1855 |
| 1849 if (Assembler::EmittingComments()) { | 1856 if (Assembler::EmittingComments()) { |
| 1850 __ Comment("%s slow path allocation of %s", | 1857 __ Comment("%s slow path allocation of %s", |
| 1851 instruction_->DebugName(), | 1858 instruction_->DebugName(), |
| 1852 String::Handle(cls_.PrettyName()).ToCString()); | 1859 String::Handle(cls_.PrettyName()).ToCString()); |
| 1853 } | 1860 } |
| 1854 __ Bind(entry_label()); | 1861 __ Bind(entry_label()); |
| 1855 | |
| 1856 const Code& stub = | 1862 const Code& stub = |
| 1857 Code::Handle(isolate, stub_code->GetAllocationStubForClass(cls_)); | 1863 Code::Handle(isolate, stub_code->GetAllocationStubForClass(cls_)); |
| 1858 const ExternalLabel label(stub.EntryPoint()); | 1864 const ExternalLabel label(stub.EntryPoint()); |
| 1859 | 1865 |
| 1860 LocationSummary* locs = instruction_->locs(); | 1866 LocationSummary* locs = instruction_->locs(); |
| 1861 | 1867 |
| 1862 locs->live_registers()->Remove(Location::RegisterLocation(result_)); | 1868 locs->live_registers()->Remove(Location::RegisterLocation(result_)); |
| 1863 | 1869 |
| 1864 compiler->SaveLiveRegisters(locs); | 1870 compiler->SaveLiveRegisters(locs); |
| 1865 compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. | 1871 compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. |
| 1866 &label, | 1872 &label, |
| 1867 RawPcDescriptors::kOther, | 1873 RawPcDescriptors::kOther, |
| 1868 locs); | 1874 locs); |
| 1869 __ MoveRegister(result_, R0); | 1875 __ MoveRegister(result_, R0); |
| 1870 compiler->RestoreLiveRegisters(locs); | 1876 compiler->RestoreLiveRegisters(locs); |
| 1871 | |
| 1872 __ b(exit_label()); | 1877 __ b(exit_label()); |
| 1873 } | 1878 } |
| 1874 | 1879 |
| 1875 static void Allocate(FlowGraphCompiler* compiler, | 1880 static void Allocate(FlowGraphCompiler* compiler, |
| 1876 Instruction* instruction, | 1881 Instruction* instruction, |
| 1877 const Class& cls, | 1882 const Class& cls, |
| 1878 Register result, | 1883 Register result, |
| 1879 Register temp) { | 1884 Register temp) { |
| 1880 BoxAllocationSlowPath* slow_path = | 1885 if (compiler->intrinsic_mode()) { |
| 1881 new BoxAllocationSlowPath(instruction, cls, result); | 1886 __ TryAllocate(cls, |
| 1882 compiler->AddSlowPathCode(slow_path); | 1887 compiler->intrinsic_slow_path_label(), |
| 1888 result, |
| 1889 temp); |
| 1890 } else { |
| 1891 BoxAllocationSlowPath* slow_path = |
| 1892 new BoxAllocationSlowPath(instruction, cls, result); |
| 1893 compiler->AddSlowPathCode(slow_path); |
| 1883 | 1894 |
| 1884 __ TryAllocate(cls, | 1895 __ TryAllocate(cls, |
| 1885 slow_path->entry_label(), | 1896 slow_path->entry_label(), |
| 1886 result, | 1897 result, |
| 1887 temp); | 1898 temp); |
| 1888 __ Bind(slow_path->exit_label()); | 1899 __ Bind(slow_path->exit_label()); |
| 1900 } |
| 1889 } | 1901 } |
| 1890 | 1902 |
| 1891 private: | 1903 private: |
| 1892 Instruction* instruction_; | 1904 Instruction* instruction_; |
| 1893 const Class& cls_; | 1905 const Class& cls_; |
| 1894 Register result_; | 1906 const Register result_; |
| 1895 }; | 1907 }; |
| 1896 | 1908 |
| 1897 | 1909 |
| 1898 LocationSummary* StoreInstanceFieldInstr::MakeLocationSummary(Isolate* isolate, | 1910 LocationSummary* StoreInstanceFieldInstr::MakeLocationSummary(Isolate* isolate, |
| 1899 bool opt) const { | 1911 bool opt) const { |
| 1900 const intptr_t kNumInputs = 2; | 1912 const intptr_t kNumInputs = 2; |
| 1901 const intptr_t kNumTemps = | 1913 const intptr_t kNumTemps = |
| 1902 (IsUnboxedStore() && opt) ? 2 : | 1914 (IsUnboxedStore() && opt) ? 2 : |
| 1903 ((IsPotentialUnboxedStore()) ? 3 : 0); | 1915 ((IsPotentialUnboxedStore()) ? 3 : 0); |
| 1904 LocationSummary* summary = new(isolate) LocationSummary( | 1916 LocationSummary* summary = new(isolate) LocationSummary( |
| (...skipping 5316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7221 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); | 7233 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); |
| 7222 #if defined(DEBUG) | 7234 #if defined(DEBUG) |
| 7223 __ LoadImmediate(R4, kInvalidObjectPointer); | 7235 __ LoadImmediate(R4, kInvalidObjectPointer); |
| 7224 __ LoadImmediate(R5, kInvalidObjectPointer); | 7236 __ LoadImmediate(R5, kInvalidObjectPointer); |
| 7225 #endif | 7237 #endif |
| 7226 } | 7238 } |
| 7227 | 7239 |
| 7228 } // namespace dart | 7240 } // namespace dart |
| 7229 | 7241 |
| 7230 #endif // defined TARGET_ARCH_ARM | 7242 #endif // defined TARGET_ARCH_ARM |
| OLD | NEW |