| 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_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
| 6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 return locs; | 76 return locs; |
| 77 } | 77 } |
| 78 | 78 |
| 79 | 79 |
| 80 // Attempt optimized compilation at return instruction instead of at the entry. | 80 // Attempt optimized compilation at return instruction instead of at the entry. |
| 81 // The entry needs to be patchable, no inlined objects are allowed in the area | 81 // The entry needs to be patchable, no inlined objects are allowed in the area |
| 82 // that will be overwritten by the patch instruction: a jump). | 82 // that will be overwritten by the patch instruction: a jump). |
| 83 void ReturnInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 83 void ReturnInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 84 Register result = locs()->in(0).reg(); | 84 Register result = locs()->in(0).reg(); |
| 85 ASSERT(result == RAX); | 85 ASSERT(result == RAX); |
| 86 |
| 87 if (compiler->intrinsic_mode()) { |
| 88 // Intrinsics don't have a frame. |
| 89 __ ret(); |
| 90 return; |
| 91 } |
| 92 |
| 86 #if defined(DEBUG) | 93 #if defined(DEBUG) |
| 87 __ Comment("Stack Check"); | 94 __ Comment("Stack Check"); |
| 88 Label done; | 95 Label done; |
| 89 const intptr_t fp_sp_dist = | 96 const intptr_t fp_sp_dist = |
| 90 (kFirstLocalSlotFromFp + 1 - compiler->StackSize()) * kWordSize; | 97 (kFirstLocalSlotFromFp + 1 - compiler->StackSize()) * kWordSize; |
| 91 ASSERT(fp_sp_dist <= 0); | 98 ASSERT(fp_sp_dist <= 0); |
| 92 __ movq(RDI, RSP); | 99 __ movq(RDI, RSP); |
| 93 __ subq(RDI, RBP); | 100 __ subq(RDI, RBP); |
| 94 __ CompareImmediate(RDI, Immediate(fp_sp_dist), PP); | 101 __ CompareImmediate(RDI, Immediate(fp_sp_dist), PP); |
| 95 __ j(EQUAL, &done, Assembler::kNearJump); | 102 __ j(EQUAL, &done, Assembler::kNearJump); |
| (...skipping 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1501 PP); | 1508 PP); |
| 1502 __ j(NOT_EQUAL, deopt); | 1509 __ j(NOT_EQUAL, deopt); |
| 1503 } | 1510 } |
| 1504 } | 1511 } |
| 1505 | 1512 |
| 1506 | 1513 |
| 1507 class BoxAllocationSlowPath : public SlowPathCode { | 1514 class BoxAllocationSlowPath : public SlowPathCode { |
| 1508 public: | 1515 public: |
| 1509 BoxAllocationSlowPath(Instruction* instruction, | 1516 BoxAllocationSlowPath(Instruction* instruction, |
| 1510 const Class& cls, | 1517 const Class& cls, |
| 1511 Register result) | 1518 Register result, |
| 1519 bool is_intrinsic) |
| 1512 : instruction_(instruction), | 1520 : instruction_(instruction), |
| 1513 cls_(cls), | 1521 cls_(cls), |
| 1514 result_(result) { } | 1522 result_(result), |
| 1523 is_intrinsic_(is_intrinsic) { } |
| 1515 | 1524 |
| 1516 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { | 1525 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { |
| 1517 Isolate* isolate = compiler->isolate(); | 1526 Isolate* isolate = compiler->isolate(); |
| 1518 StubCode* stub_code = isolate->stub_code(); | 1527 StubCode* stub_code = isolate->stub_code(); |
| 1519 | 1528 |
| 1520 if (Assembler::EmittingComments()) { | 1529 if (Assembler::EmittingComments()) { |
| 1521 __ Comment("%s slow path allocation of %s", | 1530 __ Comment("%s slow path allocation of %s", |
| 1522 instruction_->DebugName(), | 1531 instruction_->DebugName(), |
| 1523 String::Handle(cls_.PrettyName()).ToCString()); | 1532 String::Handle(cls_.PrettyName()).ToCString()); |
| 1524 } | 1533 } |
| 1525 __ Bind(entry_label()); | 1534 __ Bind(entry_label()); |
| 1526 | 1535 |
| 1536 if (is_intrinsic_) { |
| 1537 __ EnterStubFrame(true); |
| 1538 } |
| 1539 |
| 1527 const Code& stub = | 1540 const Code& stub = |
| 1528 Code::Handle(isolate, stub_code->GetAllocationStubForClass(cls_)); | 1541 Code::Handle(isolate, stub_code->GetAllocationStubForClass(cls_)); |
| 1529 const ExternalLabel label(stub.EntryPoint()); | 1542 const ExternalLabel label(stub.EntryPoint()); |
| 1530 | 1543 |
| 1531 LocationSummary* locs = instruction_->locs(); | 1544 LocationSummary* locs = instruction_->locs(); |
| 1532 | 1545 |
| 1533 locs->live_registers()->Remove(Location::RegisterLocation(result_)); | 1546 locs->live_registers()->Remove(Location::RegisterLocation(result_)); |
| 1534 | 1547 |
| 1535 compiler->SaveLiveRegisters(locs); | 1548 compiler->SaveLiveRegisters(locs); |
| 1536 compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. | 1549 compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. |
| 1537 &label, | 1550 &label, |
| 1538 RawPcDescriptors::kOther, | 1551 RawPcDescriptors::kOther, |
| 1539 locs); | 1552 locs); |
| 1540 __ MoveRegister(result_, RAX); | 1553 __ MoveRegister(result_, RAX); |
| 1541 compiler->RestoreLiveRegisters(locs); | 1554 compiler->RestoreLiveRegisters(locs); |
| 1555 if (is_intrinsic_) { |
| 1556 __ LeaveStubFrame(); |
| 1557 } |
| 1542 __ jmp(exit_label()); | 1558 __ jmp(exit_label()); |
| 1543 } | 1559 } |
| 1544 | 1560 |
| 1545 static void Allocate(FlowGraphCompiler* compiler, | 1561 static void Allocate(FlowGraphCompiler* compiler, |
| 1546 Instruction* instruction, | 1562 Instruction* instruction, |
| 1547 const Class& cls, | 1563 const Class& cls, |
| 1548 Register result) { | 1564 Register result) { |
| 1549 BoxAllocationSlowPath* slow_path = | 1565 BoxAllocationSlowPath* slow_path = |
| 1550 new BoxAllocationSlowPath(instruction, cls, result); | 1566 new BoxAllocationSlowPath(instruction, cls, result, |
| 1567 compiler->intrinsic_mode()); |
| 1551 compiler->AddSlowPathCode(slow_path); | 1568 compiler->AddSlowPathCode(slow_path); |
| 1552 | 1569 |
| 1553 __ TryAllocate(cls, | 1570 __ TryAllocate(cls, |
| 1554 slow_path->entry_label(), | 1571 slow_path->entry_label(), |
| 1555 Assembler::kFarJump, | 1572 Assembler::kFarJump, |
| 1556 result, | 1573 result, |
| 1557 PP); | 1574 PP); |
| 1558 __ Bind(slow_path->exit_label()); | 1575 __ Bind(slow_path->exit_label()); |
| 1559 } | 1576 } |
| 1560 | 1577 |
| 1561 private: | 1578 private: |
| 1562 Instruction* instruction_; | 1579 Instruction* instruction_; |
| 1563 const Class& cls_; | 1580 const Class& cls_; |
| 1564 Register result_; | 1581 Register result_; |
| 1582 bool is_intrinsic_; |
| 1565 }; | 1583 }; |
| 1566 | 1584 |
| 1567 | 1585 |
| 1568 LocationSummary* StoreInstanceFieldInstr::MakeLocationSummary(Isolate* isolate, | 1586 LocationSummary* StoreInstanceFieldInstr::MakeLocationSummary(Isolate* isolate, |
| 1569 bool opt) const { | 1587 bool opt) const { |
| 1570 const intptr_t kNumInputs = 2; | 1588 const intptr_t kNumInputs = 2; |
| 1571 const intptr_t kNumTemps = | 1589 const intptr_t kNumTemps = |
| 1572 (IsUnboxedStore() && opt) ? 2 : | 1590 (IsUnboxedStore() && opt) ? 2 : |
| 1573 ((IsPotentialUnboxedStore()) ? 3 : 0); | 1591 ((IsPotentialUnboxedStore()) ? 3 : 0); |
| 1574 LocationSummary* summary = new(isolate) LocationSummary( | 1592 LocationSummary* summary = new(isolate) LocationSummary( |
| (...skipping 4269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5844 __ movq(R10, Immediate(kInvalidObjectPointer)); | 5862 __ movq(R10, Immediate(kInvalidObjectPointer)); |
| 5845 __ movq(RBX, Immediate(kInvalidObjectPointer)); | 5863 __ movq(RBX, Immediate(kInvalidObjectPointer)); |
| 5846 #endif | 5864 #endif |
| 5847 } | 5865 } |
| 5848 | 5866 |
| 5849 } // namespace dart | 5867 } // namespace dart |
| 5850 | 5868 |
| 5851 #undef __ | 5869 #undef __ |
| 5852 | 5870 |
| 5853 #endif // defined TARGET_ARCH_X64 | 5871 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |