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

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

Issue 365983002: Make isolate specific stub code accessors instance methods instead (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/intermediate_language_mips.cc ('k') | runtime/vm/stub_code.h » ('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_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 709 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 720
721 721
722 void NativeCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 722 void NativeCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
723 ASSERT(locs()->temp(0).reg() == RAX); 723 ASSERT(locs()->temp(0).reg() == RAX);
724 ASSERT(locs()->temp(1).reg() == RBX); 724 ASSERT(locs()->temp(1).reg() == RBX);
725 ASSERT(locs()->temp(2).reg() == R10); 725 ASSERT(locs()->temp(2).reg() == R10);
726 Register result = locs()->out(0).reg(); 726 Register result = locs()->out(0).reg();
727 const intptr_t argc_tag = NativeArguments::ComputeArgcTag(function()); 727 const intptr_t argc_tag = NativeArguments::ComputeArgcTag(function());
728 const bool is_leaf_call = 728 const bool is_leaf_call =
729 (argc_tag & NativeArguments::AutoSetupScopeMask()) == 0; 729 (argc_tag & NativeArguments::AutoSetupScopeMask()) == 0;
730 StubCode* stub_code = compiler->isolate()->stub_code();
730 731
731 // Push the result place holder initialized to NULL. 732 // Push the result place holder initialized to NULL.
732 __ PushObject(Object::ZoneHandle(), PP); 733 __ PushObject(Object::ZoneHandle(), PP);
733 // Pass a pointer to the first argument in RAX. 734 // Pass a pointer to the first argument in RAX.
734 if (!function().HasOptionalParameters()) { 735 if (!function().HasOptionalParameters()) {
735 __ leaq(RAX, Address(RBP, (kParamEndSlotFromFp + 736 __ leaq(RAX, Address(RBP, (kParamEndSlotFromFp +
736 function().NumParameters()) * kWordSize)); 737 function().NumParameters()) * kWordSize));
737 } else { 738 } else {
738 __ leaq(RAX, 739 __ leaq(RAX,
739 Address(RBP, kFirstLocalSlotFromFp * kWordSize)); 740 Address(RBP, kFirstLocalSlotFromFp * kWordSize));
740 } 741 }
741 __ LoadImmediate( 742 __ LoadImmediate(
742 RBX, Immediate(reinterpret_cast<uword>(native_c_function())), PP); 743 RBX, Immediate(reinterpret_cast<uword>(native_c_function())), PP);
743 __ LoadImmediate( 744 __ LoadImmediate(
744 R10, Immediate(argc_tag), PP); 745 R10, Immediate(argc_tag), PP);
745 const ExternalLabel* stub_entry = (is_bootstrap_native() || is_leaf_call) ? 746 const ExternalLabel* stub_entry = (is_bootstrap_native() || is_leaf_call) ?
746 &StubCode::CallBootstrapCFunctionLabel() : 747 &stub_code->CallBootstrapCFunctionLabel() :
747 &StubCode::CallNativeCFunctionLabel(); 748 &stub_code->CallNativeCFunctionLabel();
748 compiler->GenerateCall(token_pos(), 749 compiler->GenerateCall(token_pos(),
749 stub_entry, 750 stub_entry,
750 PcDescriptors::kOther, 751 PcDescriptors::kOther,
751 locs()); 752 locs());
752 __ popq(result); 753 __ popq(result);
753 } 754 }
754 755
755 756
756 static bool CanBeImmediateIndex(Value* index, intptr_t cid) { 757 static bool CanBeImmediateIndex(Value* index, intptr_t cid) {
757 if (!index->definition()->IsConstant()) return false; 758 if (!index->definition()->IsConstant()) return false;
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after
1543 1544
1544 class StoreInstanceFieldSlowPath : public SlowPathCode { 1545 class StoreInstanceFieldSlowPath : public SlowPathCode {
1545 public: 1546 public:
1546 StoreInstanceFieldSlowPath(StoreInstanceFieldInstr* instruction, 1547 StoreInstanceFieldSlowPath(StoreInstanceFieldInstr* instruction,
1547 const Class& cls) 1548 const Class& cls)
1548 : instruction_(instruction), cls_(cls) { } 1549 : instruction_(instruction), cls_(cls) { }
1549 1550
1550 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { 1551 virtual void EmitNativeCode(FlowGraphCompiler* compiler) {
1551 __ Comment("StoreInstanceFieldSlowPath"); 1552 __ Comment("StoreInstanceFieldSlowPath");
1552 __ Bind(entry_label()); 1553 __ Bind(entry_label());
1553 const Code& stub = 1554 Isolate* isolate = compiler->isolate();
1554 Code::Handle(StubCode::GetAllocationStubForClass(cls_)); 1555 StubCode* stub_code = isolate->stub_code();
1556 const Code& stub = Code::Handle(isolate,
1557 stub_code->GetAllocationStubForClass(cls_));
1555 const ExternalLabel label(stub.EntryPoint()); 1558 const ExternalLabel label(stub.EntryPoint());
1556 1559
1557 LocationSummary* locs = instruction_->locs(); 1560 LocationSummary* locs = instruction_->locs();
1558 locs->live_registers()->Remove(locs->out(0)); 1561 locs->live_registers()->Remove(locs->out(0));
1559 1562
1560 compiler->SaveLiveRegisters(locs); 1563 compiler->SaveLiveRegisters(locs);
1561 compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. 1564 compiler->GenerateCall(Scanner::kNoSourcePos, // No token position.
1562 &label, 1565 &label,
1563 PcDescriptors::kOther, 1566 PcDescriptors::kOther,
1564 locs); 1567 locs);
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
2010 2, 2013 2,
2011 locs()); 2014 locs());
2012 __ Drop(2); 2015 __ Drop(2);
2013 __ popq(kResultReg); 2016 __ popq(kResultReg);
2014 __ Bind(&done); 2017 __ Bind(&done);
2015 return; 2018 return;
2016 } 2019 }
2017 } 2020 }
2018 2021
2019 __ Bind(&slow_path); 2022 __ Bind(&slow_path);
2023 StubCode* stub_code = compiler->isolate()->stub_code();
2020 compiler->GenerateCall(token_pos(), 2024 compiler->GenerateCall(token_pos(),
2021 &StubCode::AllocateArrayLabel(), 2025 &stub_code->AllocateArrayLabel(),
2022 PcDescriptors::kOther, 2026 PcDescriptors::kOther,
2023 locs()); 2027 locs());
2024 __ Bind(&done); 2028 __ Bind(&done);
2025 ASSERT(locs()->out(0).reg() == kResultReg); 2029 ASSERT(locs()->out(0).reg() == kResultReg);
2026 } 2030 }
2027 2031
2028 2032
2029 class BoxDoubleSlowPath : public SlowPathCode { 2033 class BoxDoubleSlowPath : public SlowPathCode {
2030 public: 2034 public:
2031 explicit BoxDoubleSlowPath(Instruction* instruction) 2035 explicit BoxDoubleSlowPath(Instruction* instruction)
2032 : instruction_(instruction) { } 2036 : instruction_(instruction) { }
2033 2037
2034 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { 2038 virtual void EmitNativeCode(FlowGraphCompiler* compiler) {
2035 __ Comment("BoxDoubleSlowPath"); 2039 __ Comment("BoxDoubleSlowPath");
2036 __ Bind(entry_label()); 2040 __ Bind(entry_label());
2041 Isolate* isolate = compiler->isolate();
2042 StubCode* stub_code = isolate->stub_code();
2037 const Class& double_class = compiler->double_class(); 2043 const Class& double_class = compiler->double_class();
2038 const Code& stub = 2044 const Code& stub =
2039 Code::Handle(StubCode::GetAllocationStubForClass(double_class)); 2045 Code::Handle(isolate,
2046 stub_code->GetAllocationStubForClass(double_class));
2040 const ExternalLabel label(stub.EntryPoint()); 2047 const ExternalLabel label(stub.EntryPoint());
2041 2048
2042 LocationSummary* locs = instruction_->locs(); 2049 LocationSummary* locs = instruction_->locs();
2043 locs->live_registers()->Remove(locs->out(0)); 2050 locs->live_registers()->Remove(locs->out(0));
2044 2051
2045 compiler->SaveLiveRegisters(locs); 2052 compiler->SaveLiveRegisters(locs);
2046 compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. 2053 compiler->GenerateCall(Scanner::kNoSourcePos, // No token position.
2047 &label, 2054 &label,
2048 PcDescriptors::kOther, 2055 PcDescriptors::kOther,
2049 locs); 2056 locs);
2050 __ MoveRegister(locs->out(0).reg(), RAX); 2057 __ MoveRegister(locs->out(0).reg(), RAX);
2051 compiler->RestoreLiveRegisters(locs); 2058 compiler->RestoreLiveRegisters(locs);
2052 2059
2053 __ jmp(exit_label()); 2060 __ jmp(exit_label());
2054 } 2061 }
2055 2062
2056 private: 2063 private:
2057 Instruction* instruction_; 2064 Instruction* instruction_;
2058 }; 2065 };
2059 2066
2060 2067
2061 class BoxFloat32x4SlowPath : public SlowPathCode { 2068 class BoxFloat32x4SlowPath : public SlowPathCode {
2062 public: 2069 public:
2063 explicit BoxFloat32x4SlowPath(Instruction* instruction) 2070 explicit BoxFloat32x4SlowPath(Instruction* instruction)
2064 : instruction_(instruction) { } 2071 : instruction_(instruction) { }
2065 2072
2066 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { 2073 virtual void EmitNativeCode(FlowGraphCompiler* compiler) {
2067 __ Comment("BoxFloat32x4SlowPath"); 2074 __ Comment("BoxFloat32x4SlowPath");
2068 __ Bind(entry_label()); 2075 __ Bind(entry_label());
2076 Isolate* isolate = compiler->isolate();
2077 StubCode* stub_code = isolate->stub_code();
2069 const Class& float32x4_class = compiler->float32x4_class(); 2078 const Class& float32x4_class = compiler->float32x4_class();
2070 const Code& stub = 2079 const Code& stub =
2071 Code::Handle(StubCode::GetAllocationStubForClass(float32x4_class)); 2080 Code::Handle(isolate,
2081 stub_code->GetAllocationStubForClass(float32x4_class));
2072 const ExternalLabel label(stub.EntryPoint()); 2082 const ExternalLabel label(stub.EntryPoint());
2073 2083
2074 LocationSummary* locs = instruction_->locs(); 2084 LocationSummary* locs = instruction_->locs();
2075 locs->live_registers()->Remove(locs->out(0)); 2085 locs->live_registers()->Remove(locs->out(0));
2076 2086
2077 compiler->SaveLiveRegisters(locs); 2087 compiler->SaveLiveRegisters(locs);
2078 compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. 2088 compiler->GenerateCall(Scanner::kNoSourcePos, // No token position.
2079 &label, 2089 &label,
2080 PcDescriptors::kOther, 2090 PcDescriptors::kOther,
2081 locs); 2091 locs);
2082 __ MoveRegister(locs->out(0).reg(), RAX); 2092 __ MoveRegister(locs->out(0).reg(), RAX);
2083 compiler->RestoreLiveRegisters(locs); 2093 compiler->RestoreLiveRegisters(locs);
2084 2094
2085 __ jmp(exit_label()); 2095 __ jmp(exit_label());
2086 } 2096 }
2087 2097
2088 private: 2098 private:
2089 Instruction* instruction_; 2099 Instruction* instruction_;
2090 }; 2100 };
2091 2101
2092 2102
2093 class BoxFloat64x2SlowPath : public SlowPathCode { 2103 class BoxFloat64x2SlowPath : public SlowPathCode {
2094 public: 2104 public:
2095 explicit BoxFloat64x2SlowPath(Instruction* instruction) 2105 explicit BoxFloat64x2SlowPath(Instruction* instruction)
2096 : instruction_(instruction) { } 2106 : instruction_(instruction) { }
2097 2107
2098 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { 2108 virtual void EmitNativeCode(FlowGraphCompiler* compiler) {
2099 __ Comment("BoxFloat64x2SlowPath"); 2109 __ Comment("BoxFloat64x2SlowPath");
2100 __ Bind(entry_label()); 2110 __ Bind(entry_label());
2111 Isolate* isolate = compiler->isolate();
2112 StubCode* stub_code = isolate->stub_code();
2101 const Class& float64x2_class = compiler->float64x2_class(); 2113 const Class& float64x2_class = compiler->float64x2_class();
2102 const Code& stub = 2114 const Code& stub =
2103 Code::Handle(StubCode::GetAllocationStubForClass(float64x2_class)); 2115 Code::Handle(isolate,
2116 stub_code->GetAllocationStubForClass(float64x2_class));
2104 const ExternalLabel label(stub.EntryPoint()); 2117 const ExternalLabel label(stub.EntryPoint());
2105 2118
2106 LocationSummary* locs = instruction_->locs(); 2119 LocationSummary* locs = instruction_->locs();
2107 locs->live_registers()->Remove(locs->out(0)); 2120 locs->live_registers()->Remove(locs->out(0));
2108 2121
2109 compiler->SaveLiveRegisters(locs); 2122 compiler->SaveLiveRegisters(locs);
2110 compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. 2123 compiler->GenerateCall(Scanner::kNoSourcePos, // No token position.
2111 &label, 2124 &label,
2112 PcDescriptors::kOther, 2125 PcDescriptors::kOther,
2113 locs); 2126 locs);
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
2380 isolate, kNumInputs, kNumTemps, LocationSummary::kCall); 2393 isolate, kNumInputs, kNumTemps, LocationSummary::kCall);
2381 locs->set_temp(0, Location::RegisterLocation(R10)); 2394 locs->set_temp(0, Location::RegisterLocation(R10));
2382 locs->set_out(0, Location::RegisterLocation(RAX)); 2395 locs->set_out(0, Location::RegisterLocation(RAX));
2383 return locs; 2396 return locs;
2384 } 2397 }
2385 2398
2386 2399
2387 void AllocateContextInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 2400 void AllocateContextInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
2388 ASSERT(locs()->temp(0).reg() == R10); 2401 ASSERT(locs()->temp(0).reg() == R10);
2389 ASSERT(locs()->out(0).reg() == RAX); 2402 ASSERT(locs()->out(0).reg() == RAX);
2403 StubCode* stub_code = compiler->isolate()->stub_code();
2390 2404
2391 __ LoadImmediate(R10, Immediate(num_context_variables()), PP); 2405 __ LoadImmediate(R10, Immediate(num_context_variables()), PP);
2392 const ExternalLabel label(StubCode::AllocateContextEntryPoint()); 2406 const ExternalLabel label(stub_code->AllocateContextEntryPoint());
2393 compiler->GenerateCall(token_pos(), 2407 compiler->GenerateCall(token_pos(),
2394 &label, 2408 &label,
2395 PcDescriptors::kOther, 2409 PcDescriptors::kOther,
2396 locs()); 2410 locs());
2397 } 2411 }
2398 2412
2399 2413
2400 LocationSummary* CloneContextInstr::MakeLocationSummary(Isolate* isolate, 2414 LocationSummary* CloneContextInstr::MakeLocationSummary(Isolate* isolate,
2401 bool opt) const { 2415 bool opt) const {
2402 const intptr_t kNumInputs = 1; 2416 const intptr_t kNumInputs = 1;
(...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after
3421 3435
3422 3436
3423 class BoxInt32x4SlowPath : public SlowPathCode { 3437 class BoxInt32x4SlowPath : public SlowPathCode {
3424 public: 3438 public:
3425 explicit BoxInt32x4SlowPath(BoxInt32x4Instr* instruction) 3439 explicit BoxInt32x4SlowPath(BoxInt32x4Instr* instruction)
3426 : instruction_(instruction) { } 3440 : instruction_(instruction) { }
3427 3441
3428 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { 3442 virtual void EmitNativeCode(FlowGraphCompiler* compiler) {
3429 __ Comment("BoxInt32x4SlowPath"); 3443 __ Comment("BoxInt32x4SlowPath");
3430 __ Bind(entry_label()); 3444 __ Bind(entry_label());
3445 Isolate* isolate = compiler->isolate();
3446 StubCode* stub_code = isolate->stub_code();
3431 const Class& int32x4_class = compiler->int32x4_class(); 3447 const Class& int32x4_class = compiler->int32x4_class();
3432 const Code& stub = 3448 const Code& stub =
3433 Code::Handle(StubCode::GetAllocationStubForClass(int32x4_class)); 3449 Code::Handle(isolate,
3450 stub_code->GetAllocationStubForClass(int32x4_class));
3434 const ExternalLabel label(stub.EntryPoint()); 3451 const ExternalLabel label(stub.EntryPoint());
3435 3452
3436 LocationSummary* locs = instruction_->locs(); 3453 LocationSummary* locs = instruction_->locs();
3437 locs->live_registers()->Remove(locs->out(0)); 3454 locs->live_registers()->Remove(locs->out(0));
3438 3455
3439 compiler->SaveLiveRegisters(locs); 3456 compiler->SaveLiveRegisters(locs);
3440 compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. 3457 compiler->GenerateCall(Scanner::kNoSourcePos, // No token position.
3441 &label, 3458 &label,
3442 PcDescriptors::kOther, 3459 PcDescriptors::kOther,
3443 locs); 3460 locs);
(...skipping 2370 matching lines...) Expand 10 before | Expand all | Expand 10 after
5814 } 5831 }
5815 5832
5816 5833
5817 LocationSummary* AllocateObjectInstr::MakeLocationSummary(Isolate* isolate, 5834 LocationSummary* AllocateObjectInstr::MakeLocationSummary(Isolate* isolate,
5818 bool opt) const { 5835 bool opt) const {
5819 return MakeCallSummary(); 5836 return MakeCallSummary();
5820 } 5837 }
5821 5838
5822 5839
5823 void AllocateObjectInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 5840 void AllocateObjectInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
5824 const Code& stub = Code::Handle(StubCode::GetAllocationStubForClass(cls())); 5841 Isolate* isolate = compiler->isolate();
5842 StubCode* stub_code = isolate->stub_code();
5843 const Code& stub = Code::Handle(isolate,
5844 stub_code->GetAllocationStubForClass(cls()));
5825 const ExternalLabel label(stub.EntryPoint()); 5845 const ExternalLabel label(stub.EntryPoint());
5826 compiler->GenerateCall(token_pos(), 5846 compiler->GenerateCall(token_pos(),
5827 &label, 5847 &label,
5828 PcDescriptors::kOther, 5848 PcDescriptors::kOther,
5829 locs()); 5849 locs());
5830 __ Drop(ArgumentCount()); // Discard arguments. 5850 __ Drop(ArgumentCount()); // Discard arguments.
5831 } 5851 }
5832 5852
5833 5853
5834 void DebugStepCheckInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 5854 void DebugStepCheckInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
5835 ASSERT(!compiler->is_optimizing()); 5855 ASSERT(!compiler->is_optimizing());
5836 const ExternalLabel label(StubCode::DebugStepCheckEntryPoint()); 5856 StubCode* stub_code = compiler->isolate()->stub_code();
5857 const ExternalLabel label(stub_code->DebugStepCheckEntryPoint());
5837 __ movq(R10, Immediate(0)); 5858 __ movq(R10, Immediate(0));
5838 __ movq(RBX, Immediate(0)); 5859 __ movq(RBX, Immediate(0));
5839 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); 5860 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs());
5840 #if defined(DEBUG) 5861 #if defined(DEBUG)
5841 __ movq(R10, Immediate(kInvalidObjectPointer)); 5862 __ movq(R10, Immediate(kInvalidObjectPointer));
5842 __ movq(RBX, Immediate(kInvalidObjectPointer)); 5863 __ movq(RBX, Immediate(kInvalidObjectPointer));
5843 #endif 5864 #endif
5844 } 5865 }
5845 5866
5846 } // namespace dart 5867 } // namespace dart
5847 5868
5848 #undef __ 5869 #undef __
5849 5870
5850 #endif // defined TARGET_ARCH_X64 5871 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_mips.cc ('k') | runtime/vm/stub_code.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698