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

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

Issue 1270803003: VM: More abstract interface for generating stub calls. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « runtime/vm/intermediate_language_arm64.cc ('k') | runtime/vm/intermediate_language_mips.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_IA32. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32.
6 #if defined(TARGET_ARCH_IA32) 6 #if defined(TARGET_ARCH_IA32)
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 812 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 __ PushObject(Object::null_object()); 823 __ PushObject(Object::null_object());
824 // Pass a pointer to the first argument in EAX. 824 // Pass a pointer to the first argument in EAX.
825 if (!function().HasOptionalParameters()) { 825 if (!function().HasOptionalParameters()) {
826 __ leal(EAX, Address(EBP, (kParamEndSlotFromFp + 826 __ leal(EAX, Address(EBP, (kParamEndSlotFromFp +
827 function().NumParameters()) * kWordSize)); 827 function().NumParameters()) * kWordSize));
828 } else { 828 } else {
829 __ leal(EAX, Address(EBP, kFirstLocalSlotFromFp * kWordSize)); 829 __ leal(EAX, Address(EBP, kFirstLocalSlotFromFp * kWordSize));
830 } 830 }
831 __ movl(ECX, Immediate(reinterpret_cast<uword>(native_c_function()))); 831 __ movl(ECX, Immediate(reinterpret_cast<uword>(native_c_function())));
832 __ movl(EDX, Immediate(argc_tag)); 832 __ movl(EDX, Immediate(argc_tag));
833 const ExternalLabel* stub_entry = (is_bootstrap_native() || is_leaf_call) ? 833 const StubEntry* stub_entry = (is_bootstrap_native() || is_leaf_call) ?
834 &StubCode::CallBootstrapCFunctionLabel() : 834 StubCode::CallBootstrapCFunction_entry() :
835 &StubCode::CallNativeCFunctionLabel(); 835 StubCode::CallNativeCFunction_entry();
836 compiler->GenerateCall(token_pos(), 836 compiler->GenerateCall(token_pos(),
837 stub_entry, 837 *stub_entry,
838 RawPcDescriptors::kOther, 838 RawPcDescriptors::kOther,
839 locs()); 839 locs());
840 __ popl(result); 840 __ popl(result);
841 } 841 }
842 842
843 843
844 static bool CanBeImmediateIndex(Value* value, intptr_t cid) { 844 static bool CanBeImmediateIndex(Value* value, intptr_t cid) {
845 ConstantInstr* constant = value->definition()->AsConstant(); 845 ConstantInstr* constant = value->definition()->AsConstant();
846 if ((constant == NULL) || !Assembler::IsSafeSmi(constant->value())) { 846 if ((constant == NULL) || !Assembler::IsSafeSmi(constant->value())) {
847 return false; 847 return false;
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after
1651 Isolate* isolate = compiler->isolate(); 1651 Isolate* isolate = compiler->isolate();
1652 1652
1653 if (Assembler::EmittingComments()) { 1653 if (Assembler::EmittingComments()) {
1654 __ Comment("%s slow path allocation of %s", 1654 __ Comment("%s slow path allocation of %s",
1655 instruction_->DebugName(), 1655 instruction_->DebugName(),
1656 String::Handle(cls_.PrettyName()).ToCString()); 1656 String::Handle(cls_.PrettyName()).ToCString());
1657 } 1657 }
1658 __ Bind(entry_label()); 1658 __ Bind(entry_label());
1659 const Code& stub = 1659 const Code& stub =
1660 Code::Handle(isolate, StubCode::GetAllocationStubForClass(cls_)); 1660 Code::Handle(isolate, StubCode::GetAllocationStubForClass(cls_));
1661 const ExternalLabel label(stub.EntryPoint()); 1661 const StubEntry stub_entry(stub);
1662 1662
1663 LocationSummary* locs = instruction_->locs(); 1663 LocationSummary* locs = instruction_->locs();
1664 1664
1665 locs->live_registers()->Remove(Location::RegisterLocation(result_)); 1665 locs->live_registers()->Remove(Location::RegisterLocation(result_));
1666 1666
1667 compiler->SaveLiveRegisters(locs); 1667 compiler->SaveLiveRegisters(locs);
1668 compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. 1668 compiler->GenerateCall(Scanner::kNoSourcePos, // No token position.
1669 &label, 1669 stub_entry,
1670 RawPcDescriptors::kOther, 1670 RawPcDescriptors::kOther,
1671 locs); 1671 locs);
1672 compiler->AddStubCallTarget(stub); 1672 compiler->AddStubCallTarget(stub);
1673 __ MoveRegister(result_, EAX); 1673 __ MoveRegister(result_, EAX);
1674 compiler->RestoreLiveRegisters(locs); 1674 compiler->RestoreLiveRegisters(locs);
1675 __ jmp(exit_label()); 1675 __ jmp(exit_label());
1676 } 1676 }
1677 1677
1678 static void Allocate(FlowGraphCompiler* compiler, 1678 static void Allocate(FlowGraphCompiler* compiler,
1679 Instruction* instruction, 1679 Instruction* instruction,
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
2121 2, 2121 2,
2122 locs()); 2122 locs());
2123 __ Drop(2); 2123 __ Drop(2);
2124 __ popl(kResultReg); 2124 __ popl(kResultReg);
2125 __ Bind(&done); 2125 __ Bind(&done);
2126 return; 2126 return;
2127 } 2127 }
2128 } 2128 }
2129 2129
2130 __ Bind(&slow_path); 2130 __ Bind(&slow_path);
2131 const ExternalLabel label(StubCode::AllocateArrayEntryPoint());
2132 compiler->GenerateCall(token_pos(), 2131 compiler->GenerateCall(token_pos(),
2133 &label, 2132 *StubCode::AllocateArray_entry(),
2134 RawPcDescriptors::kOther, 2133 RawPcDescriptors::kOther,
2135 locs()); 2134 locs());
2136 __ Bind(&done); 2135 __ Bind(&done);
2137 ASSERT(locs()->out(0).reg() == kResultReg); 2136 ASSERT(locs()->out(0).reg() == kResultReg);
2138 } 2137 }
2139 2138
2140 2139
2141 LocationSummary* LoadFieldInstr::MakeLocationSummary(Zone* zone, 2140 LocationSummary* LoadFieldInstr::MakeLocationSummary(Zone* zone,
2142 bool opt) const { 2141 bool opt) const {
2143 const intptr_t kNumInputs = 1; 2142 const intptr_t kNumInputs = 1;
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
2394 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { 2393 virtual void EmitNativeCode(FlowGraphCompiler* compiler) {
2395 __ Comment("AllocateContextSlowPath"); 2394 __ Comment("AllocateContextSlowPath");
2396 __ Bind(entry_label()); 2395 __ Bind(entry_label());
2397 2396
2398 LocationSummary* locs = instruction_->locs(); 2397 LocationSummary* locs = instruction_->locs();
2399 ASSERT(!locs->live_registers()->Contains(locs->out(0))); 2398 ASSERT(!locs->live_registers()->Contains(locs->out(0)));
2400 2399
2401 compiler->SaveLiveRegisters(locs); 2400 compiler->SaveLiveRegisters(locs);
2402 2401
2403 __ movl(EDX, Immediate(instruction_->num_context_variables())); 2402 __ movl(EDX, Immediate(instruction_->num_context_variables()));
2404 const ExternalLabel label(StubCode::AllocateContextEntryPoint());
2405 compiler->GenerateCall(instruction_->token_pos(), 2403 compiler->GenerateCall(instruction_->token_pos(),
2406 &label, 2404 *StubCode::AllocateContext_entry(),
2407 RawPcDescriptors::kOther, 2405 RawPcDescriptors::kOther,
2408 locs); 2406 locs);
2409 ASSERT(instruction_->locs()->out(0).reg() == EAX); 2407 ASSERT(instruction_->locs()->out(0).reg() == EAX);
2410 compiler->RestoreLiveRegisters(instruction_->locs()); 2408 compiler->RestoreLiveRegisters(instruction_->locs());
2411 __ jmp(exit_label()); 2409 __ jmp(exit_label());
2412 } 2410 }
2413 2411
2414 private: 2412 private:
2415 AllocateUninitializedContextInstr* instruction_; 2413 AllocateUninitializedContextInstr* instruction_;
2416 }; 2414 };
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2451 locs->set_out(0, Location::RegisterLocation(EAX)); 2449 locs->set_out(0, Location::RegisterLocation(EAX));
2452 return locs; 2450 return locs;
2453 } 2451 }
2454 2452
2455 2453
2456 void AllocateContextInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 2454 void AllocateContextInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
2457 ASSERT(locs()->temp(0).reg() == EDX); 2455 ASSERT(locs()->temp(0).reg() == EDX);
2458 ASSERT(locs()->out(0).reg() == EAX); 2456 ASSERT(locs()->out(0).reg() == EAX);
2459 2457
2460 __ movl(EDX, Immediate(num_context_variables())); 2458 __ movl(EDX, Immediate(num_context_variables()));
2461 const ExternalLabel label(StubCode::AllocateContextEntryPoint());
2462 compiler->GenerateCall(token_pos(), 2459 compiler->GenerateCall(token_pos(),
2463 &label, 2460 *StubCode::AllocateContext_entry(),
2464 RawPcDescriptors::kOther, 2461 RawPcDescriptors::kOther,
2465 locs()); 2462 locs());
2466 } 2463 }
2467 2464
2468 2465
2469 LocationSummary* InitStaticFieldInstr::MakeLocationSummary(Zone* zone, 2466 LocationSummary* InitStaticFieldInstr::MakeLocationSummary(Zone* zone,
2470 bool opt) const { 2467 bool opt) const {
2471 const intptr_t kNumInputs = 1; 2468 const intptr_t kNumInputs = 1;
2472 const intptr_t kNumTemps = 1; 2469 const intptr_t kNumTemps = 1;
2473 LocationSummary* locs = new(zone) LocationSummary( 2470 LocationSummary* locs = new(zone) LocationSummary(
(...skipping 4334 matching lines...) Expand 10 before | Expand all | Expand 10 after
6808 LocationSummary* AllocateObjectInstr::MakeLocationSummary(Zone* zone, 6805 LocationSummary* AllocateObjectInstr::MakeLocationSummary(Zone* zone,
6809 bool opt) const { 6806 bool opt) const {
6810 return MakeCallSummary(zone); 6807 return MakeCallSummary(zone);
6811 } 6808 }
6812 6809
6813 6810
6814 void AllocateObjectInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 6811 void AllocateObjectInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
6815 Isolate* isolate = compiler->isolate(); 6812 Isolate* isolate = compiler->isolate();
6816 const Code& stub = Code::Handle(isolate, 6813 const Code& stub = Code::Handle(isolate,
6817 StubCode::GetAllocationStubForClass(cls())); 6814 StubCode::GetAllocationStubForClass(cls()));
6818 const ExternalLabel label(stub.EntryPoint()); 6815 const StubEntry stub_entry(stub);
6819 compiler->GenerateCall(token_pos(), 6816 compiler->GenerateCall(token_pos(),
6820 &label, 6817 stub_entry,
6821 RawPcDescriptors::kOther, 6818 RawPcDescriptors::kOther,
6822 locs()); 6819 locs());
6823 compiler->AddStubCallTarget(stub); 6820 compiler->AddStubCallTarget(stub);
6824 __ Drop(ArgumentCount()); // Discard arguments. 6821 __ Drop(ArgumentCount()); // Discard arguments.
6825 } 6822 }
6826 6823
6827 6824
6828 void DebugStepCheckInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 6825 void DebugStepCheckInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
6829 ASSERT(!compiler->is_optimizing()); 6826 ASSERT(!compiler->is_optimizing());
6830 const ExternalLabel label(StubCode::DebugStepCheckEntryPoint()); 6827 compiler->GenerateCall(token_pos(),
6831 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); 6828 *StubCode::DebugStepCheck_entry(),
6829 stub_kind_,
6830 locs());
6832 } 6831 }
6833 6832
6834 6833
6835 LocationSummary* GrowRegExpStackInstr::MakeLocationSummary( 6834 LocationSummary* GrowRegExpStackInstr::MakeLocationSummary(
6836 Zone* zone, bool opt) const { 6835 Zone* zone, bool opt) const {
6837 const intptr_t kNumInputs = 1; 6836 const intptr_t kNumInputs = 1;
6838 const intptr_t kNumTemps = 0; 6837 const intptr_t kNumTemps = 0;
6839 LocationSummary* locs = new(zone) LocationSummary( 6838 LocationSummary* locs = new(zone) LocationSummary(
6840 zone, kNumInputs, kNumTemps, LocationSummary::kCall); 6839 zone, kNumInputs, kNumTemps, LocationSummary::kCall);
6841 locs->set_in(0, Location::RegisterLocation(EAX)); 6840 locs->set_in(0, Location::RegisterLocation(EAX));
(...skipping 15 matching lines...) Expand all
6857 __ Drop(1); 6856 __ Drop(1);
6858 __ popl(result); 6857 __ popl(result);
6859 } 6858 }
6860 6859
6861 6860
6862 } // namespace dart 6861 } // namespace dart
6863 6862
6864 #undef __ 6863 #undef __
6865 6864
6866 #endif // defined TARGET_ARCH_IA32 6865 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_arm64.cc ('k') | runtime/vm/intermediate_language_mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698