Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(928)

Side by Side Diff: runtime/vm/intermediate_language_arm64.cc

Issue 513213002: Generate some intrinsics using our IR. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 1470 matching lines...) Expand 10 before | Expand all | Expand 10 after
1568 __ CompareImmediate(TMP, Smi::RawValue(field().guarded_list_length()), PP); 1575 __ CompareImmediate(TMP, Smi::RawValue(field().guarded_list_length()), PP);
1569 __ b(deopt, NE); 1576 __ b(deopt, NE);
1570 } 1577 }
1571 } 1578 }
1572 1579
1573 1580
1574 class BoxAllocationSlowPath : public SlowPathCode { 1581 class BoxAllocationSlowPath : public SlowPathCode {
1575 public: 1582 public:
1576 BoxAllocationSlowPath(Instruction* instruction, 1583 BoxAllocationSlowPath(Instruction* instruction,
1577 const Class& cls, 1584 const Class& cls,
1578 Register result) 1585 Register result,
1586 bool is_intrinsic)
1579 : instruction_(instruction), 1587 : instruction_(instruction),
1580 cls_(cls), 1588 cls_(cls),
1581 result_(result) { } 1589 result_(result),
1590 is_intrinsic_(is_intrinsic) { }
1582 1591
1583 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { 1592 virtual void EmitNativeCode(FlowGraphCompiler* compiler) {
1584 Isolate* isolate = compiler->isolate(); 1593 Isolate* isolate = compiler->isolate();
1585 StubCode* stub_code = isolate->stub_code(); 1594 StubCode* stub_code = isolate->stub_code();
1586 1595
1587 if (Assembler::EmittingComments()) { 1596 if (Assembler::EmittingComments()) {
1588 __ Comment("%s slow path allocation of %s", 1597 __ Comment("%s slow path allocation of %s",
1589 instruction_->DebugName(), 1598 instruction_->DebugName(),
1590 String::Handle(cls_.PrettyName()).ToCString()); 1599 String::Handle(cls_.PrettyName()).ToCString());
1591 } 1600 }
1592 __ Bind(entry_label()); 1601 __ Bind(entry_label());
1593 1602
1603 if (is_intrinsic_) {
1604 __ EnterStubFrame(true);
1605 }
1606
1594 const Code& stub = 1607 const Code& stub =
1595 Code::Handle(isolate, stub_code->GetAllocationStubForClass(cls_)); 1608 Code::Handle(isolate, stub_code->GetAllocationStubForClass(cls_));
1596 const ExternalLabel label(stub.EntryPoint()); 1609 const ExternalLabel label(stub.EntryPoint());
1597 1610
1598 LocationSummary* locs = instruction_->locs(); 1611 LocationSummary* locs = instruction_->locs();
1599 1612
1600 locs->live_registers()->Remove(Location::RegisterLocation(result_)); 1613 locs->live_registers()->Remove(Location::RegisterLocation(result_));
1601 1614
1602 compiler->SaveLiveRegisters(locs); 1615 compiler->SaveLiveRegisters(locs);
1603 compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. 1616 compiler->GenerateCall(Scanner::kNoSourcePos, // No token position.
1604 &label, 1617 &label,
1605 RawPcDescriptors::kOther, 1618 RawPcDescriptors::kOther,
1606 locs); 1619 locs);
1607 __ mov(result_, R0); 1620 __ mov(result_, R0);
1608 compiler->RestoreLiveRegisters(locs); 1621 compiler->RestoreLiveRegisters(locs);
1609 1622
1623 if (is_intrinsic_) {
1624 __ LeaveStubFrame();
1625 }
1610 __ b(exit_label()); 1626 __ b(exit_label());
1611 } 1627 }
1612 1628
1613 static void Allocate(FlowGraphCompiler* compiler, 1629 static void Allocate(FlowGraphCompiler* compiler,
1614 Instruction* instruction, 1630 Instruction* instruction,
1615 const Class& cls, 1631 const Class& cls,
1616 Register result, 1632 Register result,
1617 Register temp) { 1633 Register temp) {
1618 BoxAllocationSlowPath* slow_path = 1634 BoxAllocationSlowPath* slow_path =
1619 new BoxAllocationSlowPath(instruction, cls, result); 1635 new BoxAllocationSlowPath(instruction, cls, result,
1636 compiler->intrinsic_mode());
1620 compiler->AddSlowPathCode(slow_path); 1637 compiler->AddSlowPathCode(slow_path);
1621 1638
1622 __ TryAllocate(cls, 1639 __ TryAllocate(cls,
1623 slow_path->entry_label(), 1640 slow_path->entry_label(),
1624 result, 1641 result,
1625 temp, 1642 temp,
1626 PP); 1643 PP);
1627 __ Bind(slow_path->exit_label()); 1644 __ Bind(slow_path->exit_label());
1628 } 1645 }
1629 1646
1630 private: 1647 private:
1631 Instruction* instruction_; 1648 Instruction* instruction_;
1632 const Class& cls_; 1649 const Class& cls_;
1633 Register result_; 1650 Register result_;
1651 bool is_intrinsic_;
1634 }; 1652 };
1635 1653
1636 1654
1637 static void EnsureMutableBox(FlowGraphCompiler* compiler, 1655 static void EnsureMutableBox(FlowGraphCompiler* compiler,
1638 StoreInstanceFieldInstr* instruction, 1656 StoreInstanceFieldInstr* instruction,
1639 Register box_reg, 1657 Register box_reg,
1640 const Class& cls, 1658 const Class& cls,
1641 Register instance_reg, 1659 Register instance_reg,
1642 intptr_t offset, 1660 intptr_t offset,
1643 Register temp) { 1661 Register temp) {
(...skipping 3783 matching lines...) Expand 10 before | Expand all | Expand 10 after
5427 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); 5445 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs());
5428 #if defined(DEBUG) 5446 #if defined(DEBUG)
5429 __ LoadImmediate(R4, kInvalidObjectPointer, kNoPP); 5447 __ LoadImmediate(R4, kInvalidObjectPointer, kNoPP);
5430 __ LoadImmediate(R5, kInvalidObjectPointer, kNoPP); 5448 __ LoadImmediate(R5, kInvalidObjectPointer, kNoPP);
5431 #endif 5449 #endif
5432 } 5450 }
5433 5451
5434 } // namespace dart 5452 } // namespace dart
5435 5453
5436 #endif // defined TARGET_ARCH_ARM64 5454 #endif // defined TARGET_ARCH_ARM64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698