| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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_ARM64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM64. |
| 6 #if defined(TARGET_ARCH_ARM64) | 6 #if defined(TARGET_ARCH_ARM64) |
| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 // where PushArgument is handled by BindInstr::EmitNativeCode. | 54 // where PushArgument is handled by BindInstr::EmitNativeCode. |
| 55 if (compiler->is_optimizing()) { | 55 if (compiler->is_optimizing()) { |
| 56 Location value = locs()->in(0); | 56 Location value = locs()->in(0); |
| 57 if (value.IsRegister()) { | 57 if (value.IsRegister()) { |
| 58 __ Push(value.reg()); | 58 __ Push(value.reg()); |
| 59 } else if (value.IsConstant()) { | 59 } else if (value.IsConstant()) { |
| 60 __ PushObject(value.constant(), PP); | 60 __ PushObject(value.constant(), PP); |
| 61 } else { | 61 } else { |
| 62 ASSERT(value.IsStackSlot()); | 62 ASSERT(value.IsStackSlot()); |
| 63 const intptr_t value_offset = value.ToStackSlotOffset(); | 63 const intptr_t value_offset = value.ToStackSlotOffset(); |
| 64 __ LoadFromOffset(TMP, FP, value_offset, PP); | 64 __ LoadFromOffset(TMP, value.base_reg(), value_offset, PP); |
| 65 __ Push(TMP); | 65 __ Push(TMP); |
| 66 } | 66 } |
| 67 } | 67 } |
| 68 } | 68 } |
| 69 | 69 |
| 70 | 70 |
| 71 LocationSummary* ReturnInstr::MakeLocationSummary(Isolate* isolate, | 71 LocationSummary* ReturnInstr::MakeLocationSummary(Isolate* isolate, |
| 72 bool opt) const { | 72 bool opt) const { |
| 73 const intptr_t kNumInputs = 1; | 73 const intptr_t kNumInputs = 1; |
| 74 const intptr_t kNumTemps = 0; | 74 const intptr_t kNumTemps = 0; |
| 75 LocationSummary* locs = new(isolate) LocationSummary( | 75 LocationSummary* locs = new(isolate) LocationSummary( |
| 76 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); | 76 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 77 locs->set_in(0, Location::RegisterLocation(R0)); | 77 locs->set_in(0, Location::RegisterLocation(R0)); |
| 78 return locs; | 78 return locs; |
| 79 } | 79 } |
| 80 | 80 |
| 81 | 81 |
| 82 // Attempt optimized compilation at return instruction instead of at the entry. | 82 // Attempt optimized compilation at return instruction instead of at the entry. |
| 83 // The entry needs to be patchable, no inlined objects are allowed in the area | 83 // The entry needs to be patchable, no inlined objects are allowed in the area |
| 84 // that will be overwritten by the patch instructions: a branch macro sequence. | 84 // that will be overwritten by the patch instructions: a branch macro sequence. |
| 85 void ReturnInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 85 void ReturnInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 86 const Register result = locs()->in(0).reg(); | 86 const Register result = locs()->in(0).reg(); |
| 87 ASSERT(result == R0); | 87 ASSERT(result == R0); |
| 88 |
| 89 if (compiler->intrinsic_mode()) { |
| 90 // Intrinsics don't have a frame. |
| 91 __ ret(); |
| 92 return; |
| 93 } |
| 94 |
| 88 #if defined(DEBUG) | 95 #if defined(DEBUG) |
| 89 Label stack_ok; | 96 Label stack_ok; |
| 90 __ Comment("Stack Check"); | 97 __ Comment("Stack Check"); |
| 91 const intptr_t fp_sp_dist = | 98 const intptr_t fp_sp_dist = |
| 92 (kFirstLocalSlotFromFp + 1 - compiler->StackSize()) * kWordSize; | 99 (kFirstLocalSlotFromFp + 1 - compiler->StackSize()) * kWordSize; |
| 93 ASSERT(fp_sp_dist <= 0); | 100 ASSERT(fp_sp_dist <= 0); |
| 94 __ sub(R2, SP, Operand(FP)); | 101 __ sub(R2, SP, Operand(FP)); |
| 95 __ CompareImmediate(R2, fp_sp_dist, PP); | 102 __ CompareImmediate(R2, fp_sp_dist, PP); |
| 96 __ b(&stack_ok, EQ); | 103 __ b(&stack_ok, EQ); |
| 97 __ brk(0); | 104 __ brk(0); |
| (...skipping 1485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1583 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { | 1590 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { |
| 1584 Isolate* isolate = compiler->isolate(); | 1591 Isolate* isolate = compiler->isolate(); |
| 1585 StubCode* stub_code = isolate->stub_code(); | 1592 StubCode* stub_code = isolate->stub_code(); |
| 1586 | 1593 |
| 1587 if (Assembler::EmittingComments()) { | 1594 if (Assembler::EmittingComments()) { |
| 1588 __ Comment("%s slow path allocation of %s", | 1595 __ Comment("%s slow path allocation of %s", |
| 1589 instruction_->DebugName(), | 1596 instruction_->DebugName(), |
| 1590 String::Handle(cls_.PrettyName()).ToCString()); | 1597 String::Handle(cls_.PrettyName()).ToCString()); |
| 1591 } | 1598 } |
| 1592 __ Bind(entry_label()); | 1599 __ Bind(entry_label()); |
| 1593 | |
| 1594 const Code& stub = | 1600 const Code& stub = |
| 1595 Code::Handle(isolate, stub_code->GetAllocationStubForClass(cls_)); | 1601 Code::Handle(isolate, stub_code->GetAllocationStubForClass(cls_)); |
| 1596 const ExternalLabel label(stub.EntryPoint()); | 1602 const ExternalLabel label(stub.EntryPoint()); |
| 1597 | 1603 |
| 1598 LocationSummary* locs = instruction_->locs(); | 1604 LocationSummary* locs = instruction_->locs(); |
| 1599 | 1605 |
| 1600 locs->live_registers()->Remove(Location::RegisterLocation(result_)); | 1606 locs->live_registers()->Remove(Location::RegisterLocation(result_)); |
| 1601 | 1607 |
| 1602 compiler->SaveLiveRegisters(locs); | 1608 compiler->SaveLiveRegisters(locs); |
| 1603 compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. | 1609 compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. |
| 1604 &label, | 1610 &label, |
| 1605 RawPcDescriptors::kOther, | 1611 RawPcDescriptors::kOther, |
| 1606 locs); | 1612 locs); |
| 1607 __ mov(result_, R0); | 1613 __ mov(result_, R0); |
| 1608 compiler->RestoreLiveRegisters(locs); | 1614 compiler->RestoreLiveRegisters(locs); |
| 1609 | |
| 1610 __ b(exit_label()); | 1615 __ b(exit_label()); |
| 1611 } | 1616 } |
| 1612 | 1617 |
| 1613 static void Allocate(FlowGraphCompiler* compiler, | 1618 static void Allocate(FlowGraphCompiler* compiler, |
| 1614 Instruction* instruction, | 1619 Instruction* instruction, |
| 1615 const Class& cls, | 1620 const Class& cls, |
| 1616 Register result, | 1621 Register result, |
| 1617 Register temp) { | 1622 Register temp) { |
| 1618 BoxAllocationSlowPath* slow_path = | 1623 if (compiler->intrinsic_mode()) { |
| 1619 new BoxAllocationSlowPath(instruction, cls, result); | 1624 __ TryAllocate(cls, |
| 1620 compiler->AddSlowPathCode(slow_path); | 1625 compiler->intrinsic_slow_path_label(), |
| 1626 result, |
| 1627 temp, |
| 1628 PP); |
| 1629 } else { |
| 1630 BoxAllocationSlowPath* slow_path = |
| 1631 new BoxAllocationSlowPath(instruction, cls, result, |
| 1632 compiler->intrinsic_mode()); |
| 1633 compiler->AddSlowPathCode(slow_path); |
| 1621 | 1634 |
| 1622 __ TryAllocate(cls, | 1635 __ TryAllocate(cls, |
| 1623 slow_path->entry_label(), | 1636 slow_path->entry_label(), |
| 1624 result, | 1637 result, |
| 1625 temp, | 1638 temp, |
| 1626 PP); | 1639 PP); |
| 1627 __ Bind(slow_path->exit_label()); | 1640 __ Bind(slow_path->exit_label()); |
| 1641 } |
| 1628 } | 1642 } |
| 1629 | 1643 |
| 1630 private: | 1644 private: |
| 1631 Instruction* instruction_; | 1645 Instruction* instruction_; |
| 1632 const Class& cls_; | 1646 const Class& cls_; |
| 1633 Register result_; | 1647 const Register result_; |
| 1634 }; | 1648 }; |
| 1635 | 1649 |
| 1636 | 1650 |
| 1637 static void EnsureMutableBox(FlowGraphCompiler* compiler, | 1651 static void EnsureMutableBox(FlowGraphCompiler* compiler, |
| 1638 StoreInstanceFieldInstr* instruction, | 1652 StoreInstanceFieldInstr* instruction, |
| 1639 Register box_reg, | 1653 Register box_reg, |
| 1640 const Class& cls, | 1654 const Class& cls, |
| 1641 Register instance_reg, | 1655 Register instance_reg, |
| 1642 intptr_t offset, | 1656 intptr_t offset, |
| 1643 Register temp) { | 1657 Register temp) { |
| (...skipping 3783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5427 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); | 5441 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); |
| 5428 #if defined(DEBUG) | 5442 #if defined(DEBUG) |
| 5429 __ LoadImmediate(R4, kInvalidObjectPointer, kNoPP); | 5443 __ LoadImmediate(R4, kInvalidObjectPointer, kNoPP); |
| 5430 __ LoadImmediate(R5, kInvalidObjectPointer, kNoPP); | 5444 __ LoadImmediate(R5, kInvalidObjectPointer, kNoPP); |
| 5431 #endif | 5445 #endif |
| 5432 } | 5446 } |
| 5433 | 5447 |
| 5434 } // namespace dart | 5448 } // namespace dart |
| 5435 | 5449 |
| 5436 #endif // defined TARGET_ARCH_ARM64 | 5450 #endif // defined TARGET_ARCH_ARM64 |
| OLD | NEW |