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

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

Issue 1247783002: Make array allocation stub shared between isolates. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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
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 800 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 bool opt) const { 811 bool opt) const {
812 return MakeCallSummary(zone); 812 return MakeCallSummary(zone);
813 } 813 }
814 814
815 815
816 void NativeCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 816 void NativeCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
817 Register result = locs()->out(0).reg(); 817 Register result = locs()->out(0).reg();
818 const intptr_t argc_tag = NativeArguments::ComputeArgcTag(function()); 818 const intptr_t argc_tag = NativeArguments::ComputeArgcTag(function());
819 const bool is_leaf_call = 819 const bool is_leaf_call =
820 (argc_tag & NativeArguments::AutoSetupScopeMask()) == 0; 820 (argc_tag & NativeArguments::AutoSetupScopeMask()) == 0;
821 StubCode* stub_code = compiler->isolate()->stub_code();
822 821
823 // Push the result place holder initialized to NULL. 822 // Push the result place holder initialized to NULL.
824 __ PushObject(Object::null_object()); 823 __ PushObject(Object::null_object());
825 // Pass a pointer to the first argument in EAX. 824 // Pass a pointer to the first argument in EAX.
826 if (!function().HasOptionalParameters()) { 825 if (!function().HasOptionalParameters()) {
827 __ leal(EAX, Address(EBP, (kParamEndSlotFromFp + 826 __ leal(EAX, Address(EBP, (kParamEndSlotFromFp +
828 function().NumParameters()) * kWordSize)); 827 function().NumParameters()) * kWordSize));
829 } else { 828 } else {
830 __ leal(EAX, Address(EBP, kFirstLocalSlotFromFp * kWordSize)); 829 __ leal(EAX, Address(EBP, kFirstLocalSlotFromFp * kWordSize));
831 } 830 }
832 __ movl(ECX, Immediate(reinterpret_cast<uword>(native_c_function()))); 831 __ movl(ECX, Immediate(reinterpret_cast<uword>(native_c_function())));
833 __ movl(EDX, Immediate(argc_tag)); 832 __ movl(EDX, Immediate(argc_tag));
834 const ExternalLabel* stub_entry = (is_bootstrap_native() || is_leaf_call) ? 833 const ExternalLabel* stub_entry = (is_bootstrap_native() || is_leaf_call) ?
835 &stub_code->CallBootstrapCFunctionLabel() : 834 &StubCode::CallBootstrapCFunctionLabel() :
836 &stub_code->CallNativeCFunctionLabel(); 835 &StubCode::CallNativeCFunctionLabel();
837 compiler->GenerateCall(token_pos(), 836 compiler->GenerateCall(token_pos(),
838 stub_entry, 837 stub_entry,
839 RawPcDescriptors::kOther, 838 RawPcDescriptors::kOther,
840 locs()); 839 locs());
841 __ popl(result); 840 __ popl(result);
842 } 841 }
843 842
844 843
845 static bool CanBeImmediateIndex(Value* value, intptr_t cid) { 844 static bool CanBeImmediateIndex(Value* value, intptr_t cid) {
846 ConstantInstr* constant = value->definition()->AsConstant(); 845 ConstantInstr* constant = value->definition()->AsConstant();
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after
1643 public: 1642 public:
1644 BoxAllocationSlowPath(Instruction* instruction, 1643 BoxAllocationSlowPath(Instruction* instruction,
1645 const Class& cls, 1644 const Class& cls,
1646 Register result) 1645 Register result)
1647 : instruction_(instruction), 1646 : instruction_(instruction),
1648 cls_(cls), 1647 cls_(cls),
1649 result_(result) { } 1648 result_(result) { }
1650 1649
1651 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { 1650 virtual void EmitNativeCode(FlowGraphCompiler* compiler) {
1652 Isolate* isolate = compiler->isolate(); 1651 Isolate* isolate = compiler->isolate();
1653 StubCode* stub_code = isolate->stub_code();
1654 1652
1655 if (Assembler::EmittingComments()) { 1653 if (Assembler::EmittingComments()) {
1656 __ Comment("%s slow path allocation of %s", 1654 __ Comment("%s slow path allocation of %s",
1657 instruction_->DebugName(), 1655 instruction_->DebugName(),
1658 String::Handle(cls_.PrettyName()).ToCString()); 1656 String::Handle(cls_.PrettyName()).ToCString());
1659 } 1657 }
1660 __ Bind(entry_label()); 1658 __ Bind(entry_label());
1661 const Code& stub = 1659 const Code& stub =
1662 Code::Handle(isolate, stub_code->GetAllocationStubForClass(cls_)); 1660 Code::Handle(isolate, StubCode::GetAllocationStubForClass(cls_));
1663 const ExternalLabel label(stub.EntryPoint()); 1661 const ExternalLabel label(stub.EntryPoint());
1664 1662
1665 LocationSummary* locs = instruction_->locs(); 1663 LocationSummary* locs = instruction_->locs();
1666 1664
1667 locs->live_registers()->Remove(Location::RegisterLocation(result_)); 1665 locs->live_registers()->Remove(Location::RegisterLocation(result_));
1668 1666
1669 compiler->SaveLiveRegisters(locs); 1667 compiler->SaveLiveRegisters(locs);
1670 compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. 1668 compiler->GenerateCall(Scanner::kNoSourcePos, // No token position.
1671 &label, 1669 &label,
1672 RawPcDescriptors::kOther, 1670 RawPcDescriptors::kOther,
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
2121 2, 2119 2,
2122 locs()); 2120 locs());
2123 __ Drop(2); 2121 __ Drop(2);
2124 __ popl(kResultReg); 2122 __ popl(kResultReg);
2125 __ Bind(&done); 2123 __ Bind(&done);
2126 return; 2124 return;
2127 } 2125 }
2128 } 2126 }
2129 2127
2130 __ Bind(&slow_path); 2128 __ Bind(&slow_path);
2131 Isolate* isolate = compiler->isolate(); 2129 const ExternalLabel label(StubCode::AllocateArrayEntryPoint());
2132 const Code& stub = Code::Handle(
2133 isolate, isolate->stub_code()->GetAllocateArrayStub());
2134 const ExternalLabel label(stub.EntryPoint());
2135 compiler->GenerateCall(token_pos(), 2130 compiler->GenerateCall(token_pos(),
2136 &label, 2131 &label,
2137 RawPcDescriptors::kOther, 2132 RawPcDescriptors::kOther,
2138 locs()); 2133 locs());
2139 compiler->AddStubCallTarget(stub);
2140 __ Bind(&done); 2134 __ Bind(&done);
2141 ASSERT(locs()->out(0).reg() == kResultReg); 2135 ASSERT(locs()->out(0).reg() == kResultReg);
2142 } 2136 }
2143 2137
2144 2138
2145 LocationSummary* LoadFieldInstr::MakeLocationSummary(Zone* zone, 2139 LocationSummary* LoadFieldInstr::MakeLocationSummary(Zone* zone,
2146 bool opt) const { 2140 bool opt) const {
2147 const intptr_t kNumInputs = 1; 2141 const intptr_t kNumInputs = 1;
2148 const intptr_t kNumTemps = 2142 const intptr_t kNumTemps =
2149 (IsUnboxedLoad() && opt) ? 1 : 2143 (IsUnboxedLoad() && opt) ? 1 :
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
2397 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { 2391 virtual void EmitNativeCode(FlowGraphCompiler* compiler) {
2398 __ Comment("AllocateContextSlowPath"); 2392 __ Comment("AllocateContextSlowPath");
2399 __ Bind(entry_label()); 2393 __ Bind(entry_label());
2400 2394
2401 LocationSummary* locs = instruction_->locs(); 2395 LocationSummary* locs = instruction_->locs();
2402 ASSERT(!locs->live_registers()->Contains(locs->out(0))); 2396 ASSERT(!locs->live_registers()->Contains(locs->out(0)));
2403 2397
2404 compiler->SaveLiveRegisters(locs); 2398 compiler->SaveLiveRegisters(locs);
2405 2399
2406 __ movl(EDX, Immediate(instruction_->num_context_variables())); 2400 __ movl(EDX, Immediate(instruction_->num_context_variables()));
2407 StubCode* stub_code = compiler->isolate()->stub_code(); 2401 const ExternalLabel label(StubCode::AllocateContextEntryPoint());
2408 const ExternalLabel label(stub_code->AllocateContextEntryPoint());
2409 compiler->GenerateCall(instruction_->token_pos(), 2402 compiler->GenerateCall(instruction_->token_pos(),
2410 &label, 2403 &label,
2411 RawPcDescriptors::kOther, 2404 RawPcDescriptors::kOther,
2412 locs); 2405 locs);
2413 ASSERT(instruction_->locs()->out(0).reg() == EAX); 2406 ASSERT(instruction_->locs()->out(0).reg() == EAX);
2414 compiler->RestoreLiveRegisters(instruction_->locs()); 2407 compiler->RestoreLiveRegisters(instruction_->locs());
2415 __ jmp(exit_label()); 2408 __ jmp(exit_label());
2416 } 2409 }
2417 2410
2418 private: 2411 private:
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2453 locs->set_out(0, Location::RegisterLocation(EAX)); 2446 locs->set_out(0, Location::RegisterLocation(EAX));
2454 return locs; 2447 return locs;
2455 } 2448 }
2456 2449
2457 2450
2458 void AllocateContextInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 2451 void AllocateContextInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
2459 ASSERT(locs()->temp(0).reg() == EDX); 2452 ASSERT(locs()->temp(0).reg() == EDX);
2460 ASSERT(locs()->out(0).reg() == EAX); 2453 ASSERT(locs()->out(0).reg() == EAX);
2461 2454
2462 __ movl(EDX, Immediate(num_context_variables())); 2455 __ movl(EDX, Immediate(num_context_variables()));
2463 StubCode* stub_code = compiler->isolate()->stub_code(); 2456 const ExternalLabel label(StubCode::AllocateContextEntryPoint());
2464 const ExternalLabel label(stub_code->AllocateContextEntryPoint());
2465 compiler->GenerateCall(token_pos(), 2457 compiler->GenerateCall(token_pos(),
2466 &label, 2458 &label,
2467 RawPcDescriptors::kOther, 2459 RawPcDescriptors::kOther,
2468 locs()); 2460 locs());
2469 } 2461 }
2470 2462
2471 2463
2472 LocationSummary* InitStaticFieldInstr::MakeLocationSummary(Zone* zone, 2464 LocationSummary* InitStaticFieldInstr::MakeLocationSummary(Zone* zone,
2473 bool opt) const { 2465 bool opt) const {
2474 const intptr_t kNumInputs = 1; 2466 const intptr_t kNumInputs = 1;
(...skipping 4320 matching lines...) Expand 10 before | Expand all | Expand 10 after
6795 6787
6796 6788
6797 LocationSummary* AllocateObjectInstr::MakeLocationSummary(Zone* zone, 6789 LocationSummary* AllocateObjectInstr::MakeLocationSummary(Zone* zone,
6798 bool opt) const { 6790 bool opt) const {
6799 return MakeCallSummary(zone); 6791 return MakeCallSummary(zone);
6800 } 6792 }
6801 6793
6802 6794
6803 void AllocateObjectInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 6795 void AllocateObjectInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
6804 Isolate* isolate = compiler->isolate(); 6796 Isolate* isolate = compiler->isolate();
6805 StubCode* stub_code = isolate->stub_code();
6806 const Code& stub = Code::Handle(isolate, 6797 const Code& stub = Code::Handle(isolate,
6807 stub_code->GetAllocationStubForClass(cls())); 6798 StubCode::GetAllocationStubForClass(cls()));
6808 const ExternalLabel label(stub.EntryPoint()); 6799 const ExternalLabel label(stub.EntryPoint());
6809 compiler->GenerateCall(token_pos(), 6800 compiler->GenerateCall(token_pos(),
6810 &label, 6801 &label,
6811 RawPcDescriptors::kOther, 6802 RawPcDescriptors::kOther,
6812 locs()); 6803 locs());
6813 compiler->AddStubCallTarget(stub); 6804 compiler->AddStubCallTarget(stub);
6814 __ Drop(ArgumentCount()); // Discard arguments. 6805 __ Drop(ArgumentCount()); // Discard arguments.
6815 } 6806 }
6816 6807
6817 6808
6818 void DebugStepCheckInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 6809 void DebugStepCheckInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
6819 ASSERT(!compiler->is_optimizing()); 6810 ASSERT(!compiler->is_optimizing());
6820 StubCode* stub_code = compiler->isolate()->stub_code(); 6811 const ExternalLabel label(StubCode::DebugStepCheckEntryPoint());
6821 const ExternalLabel label(stub_code->DebugStepCheckEntryPoint());
6822 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); 6812 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs());
6823 } 6813 }
6824 6814
6825 6815
6826 LocationSummary* GrowRegExpStackInstr::MakeLocationSummary( 6816 LocationSummary* GrowRegExpStackInstr::MakeLocationSummary(
6827 Zone* zone, bool opt) const { 6817 Zone* zone, bool opt) const {
6828 const intptr_t kNumInputs = 1; 6818 const intptr_t kNumInputs = 1;
6829 const intptr_t kNumTemps = 0; 6819 const intptr_t kNumTemps = 0;
6830 LocationSummary* locs = new(zone) LocationSummary( 6820 LocationSummary* locs = new(zone) LocationSummary(
6831 zone, kNumInputs, kNumTemps, LocationSummary::kCall); 6821 zone, kNumInputs, kNumTemps, LocationSummary::kCall);
(...skipping 16 matching lines...) Expand all
6848 __ Drop(1); 6838 __ Drop(1);
6849 __ popl(result); 6839 __ popl(result);
6850 } 6840 }
6851 6841
6852 6842
6853 } // namespace dart 6843 } // namespace dart
6854 6844
6855 #undef __ 6845 #undef __
6856 6846
6857 #endif // defined TARGET_ARCH_IA32 6847 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698