| 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 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 bool opt) const { | 760 bool opt) const { |
| 761 return MakeCallSummary(zone); | 761 return MakeCallSummary(zone); |
| 762 } | 762 } |
| 763 | 763 |
| 764 | 764 |
| 765 void NativeCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 765 void NativeCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 766 Register result = locs()->out(0).reg(); | 766 Register result = locs()->out(0).reg(); |
| 767 const intptr_t argc_tag = NativeArguments::ComputeArgcTag(function()); | 767 const intptr_t argc_tag = NativeArguments::ComputeArgcTag(function()); |
| 768 const bool is_leaf_call = | 768 const bool is_leaf_call = |
| 769 (argc_tag & NativeArguments::AutoSetupScopeMask()) == 0; | 769 (argc_tag & NativeArguments::AutoSetupScopeMask()) == 0; |
| 770 StubCode* stub_code = compiler->isolate()->stub_code(); | |
| 771 | 770 |
| 772 // Push the result place holder initialized to NULL. | 771 // Push the result place holder initialized to NULL. |
| 773 __ PushObject(Object::null_object(), PP); | 772 __ PushObject(Object::null_object(), PP); |
| 774 // Pass a pointer to the first argument in RAX. | 773 // Pass a pointer to the first argument in RAX. |
| 775 if (!function().HasOptionalParameters()) { | 774 if (!function().HasOptionalParameters()) { |
| 776 __ leaq(RAX, Address(RBP, (kParamEndSlotFromFp + | 775 __ leaq(RAX, Address(RBP, (kParamEndSlotFromFp + |
| 777 function().NumParameters()) * kWordSize)); | 776 function().NumParameters()) * kWordSize)); |
| 778 } else { | 777 } else { |
| 779 __ leaq(RAX, | 778 __ leaq(RAX, |
| 780 Address(RBP, kFirstLocalSlotFromFp * kWordSize)); | 779 Address(RBP, kFirstLocalSlotFromFp * kWordSize)); |
| 781 } | 780 } |
| 782 __ LoadImmediate( | 781 __ LoadImmediate( |
| 783 RBX, Immediate(reinterpret_cast<uword>(native_c_function())), PP); | 782 RBX, Immediate(reinterpret_cast<uword>(native_c_function())), PP); |
| 784 __ LoadImmediate( | 783 __ LoadImmediate( |
| 785 R10, Immediate(argc_tag), PP); | 784 R10, Immediate(argc_tag), PP); |
| 786 const ExternalLabel* stub_entry = (is_bootstrap_native() || is_leaf_call) ? | 785 const ExternalLabel* stub_entry = (is_bootstrap_native() || is_leaf_call) ? |
| 787 &stub_code->CallBootstrapCFunctionLabel() : | 786 &StubCode::CallBootstrapCFunctionLabel() : |
| 788 &stub_code->CallNativeCFunctionLabel(); | 787 &StubCode::CallNativeCFunctionLabel(); |
| 789 compiler->GenerateCall(token_pos(), | 788 compiler->GenerateCall(token_pos(), |
| 790 stub_entry, | 789 stub_entry, |
| 791 RawPcDescriptors::kOther, | 790 RawPcDescriptors::kOther, |
| 792 locs()); | 791 locs()); |
| 793 __ popq(result); | 792 __ popq(result); |
| 794 } | 793 } |
| 795 | 794 |
| 796 | 795 |
| 797 static bool CanBeImmediateIndex(Value* index, intptr_t cid) { | 796 static bool CanBeImmediateIndex(Value* index, intptr_t cid) { |
| 798 if (!index->definition()->IsConstant()) return false; | 797 if (!index->definition()->IsConstant()) return false; |
| (...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1650 public: | 1649 public: |
| 1651 BoxAllocationSlowPath(Instruction* instruction, | 1650 BoxAllocationSlowPath(Instruction* instruction, |
| 1652 const Class& cls, | 1651 const Class& cls, |
| 1653 Register result) | 1652 Register result) |
| 1654 : instruction_(instruction), | 1653 : instruction_(instruction), |
| 1655 cls_(cls), | 1654 cls_(cls), |
| 1656 result_(result) { } | 1655 result_(result) { } |
| 1657 | 1656 |
| 1658 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { | 1657 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { |
| 1659 Isolate* isolate = compiler->isolate(); | 1658 Isolate* isolate = compiler->isolate(); |
| 1660 StubCode* stub_code = isolate->stub_code(); | |
| 1661 | 1659 |
| 1662 if (Assembler::EmittingComments()) { | 1660 if (Assembler::EmittingComments()) { |
| 1663 __ Comment("%s slow path allocation of %s", | 1661 __ Comment("%s slow path allocation of %s", |
| 1664 instruction_->DebugName(), | 1662 instruction_->DebugName(), |
| 1665 String::Handle(cls_.PrettyName()).ToCString()); | 1663 String::Handle(cls_.PrettyName()).ToCString()); |
| 1666 } | 1664 } |
| 1667 __ Bind(entry_label()); | 1665 __ Bind(entry_label()); |
| 1668 const Code& stub = | 1666 const Code& stub = |
| 1669 Code::Handle(isolate, stub_code->GetAllocationStubForClass(cls_)); | 1667 Code::Handle(isolate, StubCode::GetAllocationStubForClass(cls_)); |
| 1670 const ExternalLabel label(stub.EntryPoint()); | 1668 const ExternalLabel label(stub.EntryPoint()); |
| 1671 | 1669 |
| 1672 LocationSummary* locs = instruction_->locs(); | 1670 LocationSummary* locs = instruction_->locs(); |
| 1673 | 1671 |
| 1674 locs->live_registers()->Remove(Location::RegisterLocation(result_)); | 1672 locs->live_registers()->Remove(Location::RegisterLocation(result_)); |
| 1675 | 1673 |
| 1676 compiler->SaveLiveRegisters(locs); | 1674 compiler->SaveLiveRegisters(locs); |
| 1677 compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. | 1675 compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. |
| 1678 &label, | 1676 &label, |
| 1679 RawPcDescriptors::kOther, | 1677 RawPcDescriptors::kOther, |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2118 2, | 2116 2, |
| 2119 locs()); | 2117 locs()); |
| 2120 __ Drop(2); | 2118 __ Drop(2); |
| 2121 __ popq(kResultReg); | 2119 __ popq(kResultReg); |
| 2122 __ Bind(&done); | 2120 __ Bind(&done); |
| 2123 return; | 2121 return; |
| 2124 } | 2122 } |
| 2125 } | 2123 } |
| 2126 | 2124 |
| 2127 __ Bind(&slow_path); | 2125 __ Bind(&slow_path); |
| 2128 Isolate* isolate = compiler->isolate(); | 2126 const ExternalLabel label(StubCode::AllocateArrayEntryPoint()); |
| 2129 const Code& stub = Code::Handle( | |
| 2130 isolate, isolate->stub_code()->GetAllocateArrayStub()); | |
| 2131 const ExternalLabel label(stub.EntryPoint()); | |
| 2132 compiler->GenerateCall(token_pos(), | 2127 compiler->GenerateCall(token_pos(), |
| 2133 &label, | 2128 &label, |
| 2134 RawPcDescriptors::kOther, | 2129 RawPcDescriptors::kOther, |
| 2135 locs()); | 2130 locs()); |
| 2136 compiler->AddStubCallTarget(stub); | |
| 2137 __ Bind(&done); | 2131 __ Bind(&done); |
| 2138 ASSERT(locs()->out(0).reg() == kResultReg); | 2132 ASSERT(locs()->out(0).reg() == kResultReg); |
| 2139 } | 2133 } |
| 2140 | 2134 |
| 2141 | 2135 |
| 2142 LocationSummary* LoadFieldInstr::MakeLocationSummary(Zone* zone, | 2136 LocationSummary* LoadFieldInstr::MakeLocationSummary(Zone* zone, |
| 2143 bool opt) const { | 2137 bool opt) const { |
| 2144 const intptr_t kNumInputs = 1; | 2138 const intptr_t kNumInputs = 1; |
| 2145 const intptr_t kNumTemps = | 2139 const intptr_t kNumTemps = |
| 2146 (IsUnboxedLoad() && opt) ? 1 : | 2140 (IsUnboxedLoad() && opt) ? 1 : |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2392 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { | 2386 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { |
| 2393 __ Comment("AllocateContextSlowPath"); | 2387 __ Comment("AllocateContextSlowPath"); |
| 2394 __ Bind(entry_label()); | 2388 __ Bind(entry_label()); |
| 2395 | 2389 |
| 2396 LocationSummary* locs = instruction_->locs(); | 2390 LocationSummary* locs = instruction_->locs(); |
| 2397 locs->live_registers()->Remove(locs->out(0)); | 2391 locs->live_registers()->Remove(locs->out(0)); |
| 2398 | 2392 |
| 2399 compiler->SaveLiveRegisters(locs); | 2393 compiler->SaveLiveRegisters(locs); |
| 2400 | 2394 |
| 2401 __ LoadImmediate(R10, Immediate(instruction_->num_context_variables()), PP); | 2395 __ LoadImmediate(R10, Immediate(instruction_->num_context_variables()), PP); |
| 2402 StubCode* stub_code = compiler->isolate()->stub_code(); | 2396 const ExternalLabel label(StubCode::AllocateContextEntryPoint()); |
| 2403 const ExternalLabel label(stub_code->AllocateContextEntryPoint()); | |
| 2404 compiler->GenerateCall(instruction_->token_pos(), | 2397 compiler->GenerateCall(instruction_->token_pos(), |
| 2405 &label, | 2398 &label, |
| 2406 RawPcDescriptors::kOther, | 2399 RawPcDescriptors::kOther, |
| 2407 locs); | 2400 locs); |
| 2408 ASSERT(instruction_->locs()->out(0).reg() == RAX); | 2401 ASSERT(instruction_->locs()->out(0).reg() == RAX); |
| 2409 compiler->RestoreLiveRegisters(instruction_->locs()); | 2402 compiler->RestoreLiveRegisters(instruction_->locs()); |
| 2410 __ jmp(exit_label()); | 2403 __ jmp(exit_label()); |
| 2411 } | 2404 } |
| 2412 | 2405 |
| 2413 private: | 2406 private: |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2446 zone, kNumInputs, kNumTemps, LocationSummary::kCall); | 2439 zone, kNumInputs, kNumTemps, LocationSummary::kCall); |
| 2447 locs->set_temp(0, Location::RegisterLocation(R10)); | 2440 locs->set_temp(0, Location::RegisterLocation(R10)); |
| 2448 locs->set_out(0, Location::RegisterLocation(RAX)); | 2441 locs->set_out(0, Location::RegisterLocation(RAX)); |
| 2449 return locs; | 2442 return locs; |
| 2450 } | 2443 } |
| 2451 | 2444 |
| 2452 | 2445 |
| 2453 void AllocateContextInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 2446 void AllocateContextInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 2454 ASSERT(locs()->temp(0).reg() == R10); | 2447 ASSERT(locs()->temp(0).reg() == R10); |
| 2455 ASSERT(locs()->out(0).reg() == RAX); | 2448 ASSERT(locs()->out(0).reg() == RAX); |
| 2456 StubCode* stub_code = compiler->isolate()->stub_code(); | |
| 2457 | 2449 |
| 2458 __ LoadImmediate(R10, Immediate(num_context_variables()), PP); | 2450 __ LoadImmediate(R10, Immediate(num_context_variables()), PP); |
| 2459 const ExternalLabel label(stub_code->AllocateContextEntryPoint()); | 2451 const ExternalLabel label(StubCode::AllocateContextEntryPoint()); |
| 2460 compiler->GenerateCall(token_pos(), | 2452 compiler->GenerateCall(token_pos(), |
| 2461 &label, | 2453 &label, |
| 2462 RawPcDescriptors::kOther, | 2454 RawPcDescriptors::kOther, |
| 2463 locs()); | 2455 locs()); |
| 2464 } | 2456 } |
| 2465 | 2457 |
| 2466 | 2458 |
| 2467 LocationSummary* InitStaticFieldInstr::MakeLocationSummary(Zone* zone, | 2459 LocationSummary* InitStaticFieldInstr::MakeLocationSummary(Zone* zone, |
| 2468 bool opt) const { | 2460 bool opt) const { |
| 2469 const intptr_t kNumInputs = 1; | 2461 const intptr_t kNumInputs = 1; |
| (...skipping 3901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6371 | 6363 |
| 6372 | 6364 |
| 6373 LocationSummary* AllocateObjectInstr::MakeLocationSummary(Zone* zone, | 6365 LocationSummary* AllocateObjectInstr::MakeLocationSummary(Zone* zone, |
| 6374 bool opt) const { | 6366 bool opt) const { |
| 6375 return MakeCallSummary(zone); | 6367 return MakeCallSummary(zone); |
| 6376 } | 6368 } |
| 6377 | 6369 |
| 6378 | 6370 |
| 6379 void AllocateObjectInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 6371 void AllocateObjectInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 6380 Isolate* isolate = compiler->isolate(); | 6372 Isolate* isolate = compiler->isolate(); |
| 6381 StubCode* stub_code = isolate->stub_code(); | |
| 6382 const Code& stub = Code::Handle(isolate, | 6373 const Code& stub = Code::Handle(isolate, |
| 6383 stub_code->GetAllocationStubForClass(cls())); | 6374 StubCode::GetAllocationStubForClass(cls())); |
| 6384 const ExternalLabel label(stub.EntryPoint()); | 6375 const ExternalLabel label(stub.EntryPoint()); |
| 6385 compiler->GenerateCall(token_pos(), | 6376 compiler->GenerateCall(token_pos(), |
| 6386 &label, | 6377 &label, |
| 6387 RawPcDescriptors::kOther, | 6378 RawPcDescriptors::kOther, |
| 6388 locs()); | 6379 locs()); |
| 6389 compiler->AddStubCallTarget(stub); | 6380 compiler->AddStubCallTarget(stub); |
| 6390 __ Drop(ArgumentCount()); // Discard arguments. | 6381 __ Drop(ArgumentCount()); // Discard arguments. |
| 6391 } | 6382 } |
| 6392 | 6383 |
| 6393 | 6384 |
| 6394 void DebugStepCheckInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 6385 void DebugStepCheckInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 6395 ASSERT(!compiler->is_optimizing()); | 6386 ASSERT(!compiler->is_optimizing()); |
| 6396 StubCode* stub_code = compiler->isolate()->stub_code(); | 6387 const ExternalLabel label(StubCode::DebugStepCheckEntryPoint()); |
| 6397 const ExternalLabel label(stub_code->DebugStepCheckEntryPoint()); | |
| 6398 __ CallPatchable(&label); | 6388 __ CallPatchable(&label); |
| 6399 compiler->AddCurrentDescriptor(stub_kind_, Isolate::kNoDeoptId, token_pos()); | 6389 compiler->AddCurrentDescriptor(stub_kind_, Isolate::kNoDeoptId, token_pos()); |
| 6400 compiler->RecordSafepoint(locs()); | 6390 compiler->RecordSafepoint(locs()); |
| 6401 } | 6391 } |
| 6402 | 6392 |
| 6403 | 6393 |
| 6404 LocationSummary* GrowRegExpStackInstr::MakeLocationSummary( | 6394 LocationSummary* GrowRegExpStackInstr::MakeLocationSummary( |
| 6405 Zone* zone, bool opt) const { | 6395 Zone* zone, bool opt) const { |
| 6406 const intptr_t kNumInputs = 1; | 6396 const intptr_t kNumInputs = 1; |
| 6407 const intptr_t kNumTemps = 0; | 6397 const intptr_t kNumTemps = 0; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 6426 __ Drop(1); | 6416 __ Drop(1); |
| 6427 __ popq(result); | 6417 __ popq(result); |
| 6428 } | 6418 } |
| 6429 | 6419 |
| 6430 | 6420 |
| 6431 } // namespace dart | 6421 } // namespace dart |
| 6432 | 6422 |
| 6433 #undef __ | 6423 #undef __ |
| 6434 | 6424 |
| 6435 #endif // defined TARGET_ARCH_X64 | 6425 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |