| 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 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 777 // Pass a pointer to the first argument in RAX. | 777 // Pass a pointer to the first argument in RAX. |
| 778 if (!function().HasOptionalParameters()) { | 778 if (!function().HasOptionalParameters()) { |
| 779 __ leaq(RAX, Address(RBP, (kParamEndSlotFromFp + | 779 __ leaq(RAX, Address(RBP, (kParamEndSlotFromFp + |
| 780 function().NumParameters()) * kWordSize)); | 780 function().NumParameters()) * kWordSize)); |
| 781 } else { | 781 } else { |
| 782 __ leaq(RAX, Address(RBP, kFirstLocalSlotFromFp * kWordSize)); | 782 __ leaq(RAX, Address(RBP, kFirstLocalSlotFromFp * kWordSize)); |
| 783 } | 783 } |
| 784 __ LoadImmediate( | 784 __ LoadImmediate( |
| 785 RBX, Immediate(reinterpret_cast<uword>(native_c_function()))); | 785 RBX, Immediate(reinterpret_cast<uword>(native_c_function()))); |
| 786 __ LoadImmediate(R10, Immediate(argc_tag)); | 786 __ LoadImmediate(R10, Immediate(argc_tag)); |
| 787 const ExternalLabel* stub_entry = (is_bootstrap_native() || is_leaf_call) ? | 787 const StubEntry& stub_entry = (is_bootstrap_native() || is_leaf_call) ? |
| 788 &StubCode::CallBootstrapCFunctionLabel() : | 788 *StubCode::CallBootstrapCFunction_entry() : |
| 789 &StubCode::CallNativeCFunctionLabel(); | 789 *StubCode::CallNativeCFunction_entry(); |
| 790 compiler->GenerateCall(token_pos(), | 790 compiler->GenerateCall(token_pos(), |
| 791 stub_entry, | 791 stub_entry, |
| 792 RawPcDescriptors::kOther, | 792 RawPcDescriptors::kOther, |
| 793 locs()); | 793 locs()); |
| 794 __ popq(result); | 794 __ popq(result); |
| 795 } | 795 } |
| 796 | 796 |
| 797 | 797 |
| 798 static bool CanBeImmediateIndex(Value* index, intptr_t cid) { | 798 static bool CanBeImmediateIndex(Value* index, intptr_t cid) { |
| 799 if (!index->definition()->IsConstant()) return false; | 799 if (!index->definition()->IsConstant()) return false; |
| (...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1660 Isolate* isolate = compiler->isolate(); | 1660 Isolate* isolate = compiler->isolate(); |
| 1661 | 1661 |
| 1662 if (Assembler::EmittingComments()) { | 1662 if (Assembler::EmittingComments()) { |
| 1663 __ Comment("%s slow path allocation of %s", | 1663 __ Comment("%s slow path allocation of %s", |
| 1664 instruction_->DebugName(), | 1664 instruction_->DebugName(), |
| 1665 String::Handle(cls_.PrettyName()).ToCString()); | 1665 String::Handle(cls_.PrettyName()).ToCString()); |
| 1666 } | 1666 } |
| 1667 __ Bind(entry_label()); | 1667 __ Bind(entry_label()); |
| 1668 const Code& stub = | 1668 const Code& stub = |
| 1669 Code::Handle(isolate, StubCode::GetAllocationStubForClass(cls_)); | 1669 Code::Handle(isolate, StubCode::GetAllocationStubForClass(cls_)); |
| 1670 const ExternalLabel label(stub.EntryPoint()); | 1670 const StubEntry stub_entry(stub); |
| 1671 | 1671 |
| 1672 LocationSummary* locs = instruction_->locs(); | 1672 LocationSummary* locs = instruction_->locs(); |
| 1673 | 1673 |
| 1674 locs->live_registers()->Remove(Location::RegisterLocation(result_)); | 1674 locs->live_registers()->Remove(Location::RegisterLocation(result_)); |
| 1675 | 1675 |
| 1676 compiler->SaveLiveRegisters(locs); | 1676 compiler->SaveLiveRegisters(locs); |
| 1677 compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. | 1677 compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. |
| 1678 &label, | 1678 stub_entry, |
| 1679 RawPcDescriptors::kOther, | 1679 RawPcDescriptors::kOther, |
| 1680 locs); | 1680 locs); |
| 1681 compiler->AddStubCallTarget(stub); | 1681 compiler->AddStubCallTarget(stub); |
| 1682 __ MoveRegister(result_, RAX); | 1682 __ MoveRegister(result_, RAX); |
| 1683 compiler->RestoreLiveRegisters(locs); | 1683 compiler->RestoreLiveRegisters(locs); |
| 1684 __ jmp(exit_label()); | 1684 __ jmp(exit_label()); |
| 1685 } | 1685 } |
| 1686 | 1686 |
| 1687 static void Allocate(FlowGraphCompiler* compiler, | 1687 static void Allocate(FlowGraphCompiler* compiler, |
| 1688 Instruction* instruction, | 1688 Instruction* instruction, |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2120 2, | 2120 2, |
| 2121 locs()); | 2121 locs()); |
| 2122 __ Drop(2); | 2122 __ Drop(2); |
| 2123 __ popq(kResultReg); | 2123 __ popq(kResultReg); |
| 2124 __ Bind(&done); | 2124 __ Bind(&done); |
| 2125 return; | 2125 return; |
| 2126 } | 2126 } |
| 2127 } | 2127 } |
| 2128 | 2128 |
| 2129 __ Bind(&slow_path); | 2129 __ Bind(&slow_path); |
| 2130 const ExternalLabel label(StubCode::AllocateArrayEntryPoint()); | |
| 2131 compiler->GenerateCall(token_pos(), | 2130 compiler->GenerateCall(token_pos(), |
| 2132 &label, | 2131 *StubCode::AllocateArray_entry(), |
| 2133 RawPcDescriptors::kOther, | 2132 RawPcDescriptors::kOther, |
| 2134 locs()); | 2133 locs()); |
| 2135 __ Bind(&done); | 2134 __ Bind(&done); |
| 2136 ASSERT(locs()->out(0).reg() == kResultReg); | 2135 ASSERT(locs()->out(0).reg() == kResultReg); |
| 2137 } | 2136 } |
| 2138 | 2137 |
| 2139 | 2138 |
| 2140 LocationSummary* LoadFieldInstr::MakeLocationSummary(Zone* zone, | 2139 LocationSummary* LoadFieldInstr::MakeLocationSummary(Zone* zone, |
| 2141 bool opt) const { | 2140 bool opt) const { |
| 2142 const intptr_t kNumInputs = 1; | 2141 const intptr_t kNumInputs = 1; |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2391 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { | 2390 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { |
| 2392 __ Comment("AllocateContextSlowPath"); | 2391 __ Comment("AllocateContextSlowPath"); |
| 2393 __ Bind(entry_label()); | 2392 __ Bind(entry_label()); |
| 2394 | 2393 |
| 2395 LocationSummary* locs = instruction_->locs(); | 2394 LocationSummary* locs = instruction_->locs(); |
| 2396 locs->live_registers()->Remove(locs->out(0)); | 2395 locs->live_registers()->Remove(locs->out(0)); |
| 2397 | 2396 |
| 2398 compiler->SaveLiveRegisters(locs); | 2397 compiler->SaveLiveRegisters(locs); |
| 2399 | 2398 |
| 2400 __ LoadImmediate(R10, Immediate(instruction_->num_context_variables())); | 2399 __ LoadImmediate(R10, Immediate(instruction_->num_context_variables())); |
| 2401 const ExternalLabel label(StubCode::AllocateContextEntryPoint()); | |
| 2402 compiler->GenerateCall(instruction_->token_pos(), | 2400 compiler->GenerateCall(instruction_->token_pos(), |
| 2403 &label, | 2401 *StubCode::AllocateContext_entry(), |
| 2404 RawPcDescriptors::kOther, | 2402 RawPcDescriptors::kOther, |
| 2405 locs); | 2403 locs); |
| 2406 ASSERT(instruction_->locs()->out(0).reg() == RAX); | 2404 ASSERT(instruction_->locs()->out(0).reg() == RAX); |
| 2407 compiler->RestoreLiveRegisters(instruction_->locs()); | 2405 compiler->RestoreLiveRegisters(instruction_->locs()); |
| 2408 __ jmp(exit_label()); | 2406 __ jmp(exit_label()); |
| 2409 } | 2407 } |
| 2410 | 2408 |
| 2411 private: | 2409 private: |
| 2412 AllocateUninitializedContextInstr* instruction_; | 2410 AllocateUninitializedContextInstr* instruction_; |
| 2413 }; | 2411 }; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2447 locs->set_out(0, Location::RegisterLocation(RAX)); | 2445 locs->set_out(0, Location::RegisterLocation(RAX)); |
| 2448 return locs; | 2446 return locs; |
| 2449 } | 2447 } |
| 2450 | 2448 |
| 2451 | 2449 |
| 2452 void AllocateContextInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 2450 void AllocateContextInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 2453 ASSERT(locs()->temp(0).reg() == R10); | 2451 ASSERT(locs()->temp(0).reg() == R10); |
| 2454 ASSERT(locs()->out(0).reg() == RAX); | 2452 ASSERT(locs()->out(0).reg() == RAX); |
| 2455 | 2453 |
| 2456 __ LoadImmediate(R10, Immediate(num_context_variables())); | 2454 __ LoadImmediate(R10, Immediate(num_context_variables())); |
| 2457 const ExternalLabel label(StubCode::AllocateContextEntryPoint()); | |
| 2458 compiler->GenerateCall(token_pos(), | 2455 compiler->GenerateCall(token_pos(), |
| 2459 &label, | 2456 *StubCode::AllocateContext_entry(), |
| 2460 RawPcDescriptors::kOther, | 2457 RawPcDescriptors::kOther, |
| 2461 locs()); | 2458 locs()); |
| 2462 } | 2459 } |
| 2463 | 2460 |
| 2464 | 2461 |
| 2465 LocationSummary* InitStaticFieldInstr::MakeLocationSummary(Zone* zone, | 2462 LocationSummary* InitStaticFieldInstr::MakeLocationSummary(Zone* zone, |
| 2466 bool opt) const { | 2463 bool opt) const { |
| 2467 const intptr_t kNumInputs = 1; | 2464 const intptr_t kNumInputs = 1; |
| 2468 const intptr_t kNumTemps = 1; | 2465 const intptr_t kNumTemps = 1; |
| 2469 LocationSummary* locs = new(zone) LocationSummary( | 2466 LocationSummary* locs = new(zone) LocationSummary( |
| (...skipping 3913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6383 LocationSummary* AllocateObjectInstr::MakeLocationSummary(Zone* zone, | 6380 LocationSummary* AllocateObjectInstr::MakeLocationSummary(Zone* zone, |
| 6384 bool opt) const { | 6381 bool opt) const { |
| 6385 return MakeCallSummary(zone); | 6382 return MakeCallSummary(zone); |
| 6386 } | 6383 } |
| 6387 | 6384 |
| 6388 | 6385 |
| 6389 void AllocateObjectInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 6386 void AllocateObjectInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 6390 Isolate* isolate = compiler->isolate(); | 6387 Isolate* isolate = compiler->isolate(); |
| 6391 const Code& stub = Code::Handle(isolate, | 6388 const Code& stub = Code::Handle(isolate, |
| 6392 StubCode::GetAllocationStubForClass(cls())); | 6389 StubCode::GetAllocationStubForClass(cls())); |
| 6393 const ExternalLabel label(stub.EntryPoint()); | 6390 const StubEntry stub_entry(stub); |
| 6394 compiler->GenerateCall(token_pos(), | 6391 compiler->GenerateCall(token_pos(), |
| 6395 &label, | 6392 stub_entry, |
| 6396 RawPcDescriptors::kOther, | 6393 RawPcDescriptors::kOther, |
| 6397 locs()); | 6394 locs()); |
| 6398 compiler->AddStubCallTarget(stub); | 6395 compiler->AddStubCallTarget(stub); |
| 6399 __ Drop(ArgumentCount()); // Discard arguments. | 6396 __ Drop(ArgumentCount()); // Discard arguments. |
| 6400 } | 6397 } |
| 6401 | 6398 |
| 6402 | 6399 |
| 6403 void DebugStepCheckInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 6400 void DebugStepCheckInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 6404 ASSERT(!compiler->is_optimizing()); | 6401 ASSERT(!compiler->is_optimizing()); |
| 6405 const ExternalLabel label(StubCode::DebugStepCheckEntryPoint()); | 6402 __ CallPatchable(*StubCode::DebugStepCheck_entry()); |
| 6406 __ CallPatchable(&label); | |
| 6407 compiler->AddCurrentDescriptor(stub_kind_, Isolate::kNoDeoptId, token_pos()); | 6403 compiler->AddCurrentDescriptor(stub_kind_, Isolate::kNoDeoptId, token_pos()); |
| 6408 compiler->RecordSafepoint(locs()); | 6404 compiler->RecordSafepoint(locs()); |
| 6409 } | 6405 } |
| 6410 | 6406 |
| 6411 | 6407 |
| 6412 LocationSummary* GrowRegExpStackInstr::MakeLocationSummary( | 6408 LocationSummary* GrowRegExpStackInstr::MakeLocationSummary( |
| 6413 Zone* zone, bool opt) const { | 6409 Zone* zone, bool opt) const { |
| 6414 const intptr_t kNumInputs = 1; | 6410 const intptr_t kNumInputs = 1; |
| 6415 const intptr_t kNumTemps = 0; | 6411 const intptr_t kNumTemps = 0; |
| 6416 LocationSummary* locs = new(zone) LocationSummary( | 6412 LocationSummary* locs = new(zone) LocationSummary( |
| (...skipping 17 matching lines...) Expand all Loading... |
| 6434 __ Drop(1); | 6430 __ Drop(1); |
| 6435 __ popq(result); | 6431 __ popq(result); |
| 6436 } | 6432 } |
| 6437 | 6433 |
| 6438 | 6434 |
| 6439 } // namespace dart | 6435 } // namespace dart |
| 6440 | 6436 |
| 6441 #undef __ | 6437 #undef __ |
| 6442 | 6438 |
| 6443 #endif // defined TARGET_ARCH_X64 | 6439 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |