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

Side by Side Diff: vm/intermediate_language_x64.cc

Issue 10412043: Make it less verbose to declare instructions that use LocationSummary-based code generation. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 7 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
« vm/intermediate_language.h ('K') | « vm/intermediate_language_ia32.cc ('k') | no next file » | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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/flow_graph_compiler.h" 8 #include "vm/flow_graph_compiler.h"
9 #include "vm/locations.h" 9 #include "vm/locations.h"
10 #include "vm/stub_code.h" 10 #include "vm/stub_code.h"
(...skipping 28 matching lines...) Expand all
39 intptr_t input_count, Location out) { 39 intptr_t input_count, Location out) {
40 LocationSummary* summary = new LocationSummary(input_count); 40 LocationSummary* summary = new LocationSummary(input_count);
41 for (intptr_t i = 0; i < input_count; i++) { 41 for (intptr_t i = 0; i < input_count; i++) {
42 summary->set_in(i, Location::RequiresRegister()); 42 summary->set_in(i, Location::RequiresRegister());
43 } 43 }
44 summary->set_out(out); 44 summary->set_out(out);
45 return summary; 45 return summary;
46 } 46 }
47 47
48 48
49 LocationSummary* CurrentContextComp::MakeLocationSummary() { 49 LocationSummary* CurrentContextComp::MakeLocationSummary() const {
50 return MakeSimpleLocationSummary(0, Location::RequiresRegister()); 50 return MakeSimpleLocationSummary(0, Location::RequiresRegister());
51 } 51 }
52 52
53 53
54 void CurrentContextComp::EmitNativeCode(FlowGraphCompiler* compiler) { 54 void CurrentContextComp::EmitNativeCode(FlowGraphCompiler* compiler) {
55 __ movq(locs()->out().reg(), CTX); 55 __ movq(locs()->out().reg(), CTX);
56 } 56 }
57 57
58 58
59 LocationSummary* StoreContextComp::MakeLocationSummary() { 59 LocationSummary* StoreContextComp::MakeLocationSummary() const {
60 LocationSummary* summary = new LocationSummary(1); 60 LocationSummary* summary = new LocationSummary(1);
61 summary->set_in(0, Location::RegisterLocation(CTX)); 61 summary->set_in(0, Location::RegisterLocation(CTX));
62 return summary; 62 return summary;
63 } 63 }
64 64
65 65
66 void StoreContextComp::EmitNativeCode(FlowGraphCompiler* compiler) { 66 void StoreContextComp::EmitNativeCode(FlowGraphCompiler* compiler) {
67 // Nothing to do. Context register were loaded by register allocator. 67 // Nothing to do. Context register were loaded by register allocator.
68 ASSERT(locs()->in(0).reg() == CTX); 68 ASSERT(locs()->in(0).reg() == CTX);
69 } 69 }
70 70
71 71
72 LocationSummary* StrictCompareComp::MakeLocationSummary() { 72 LocationSummary* StrictCompareComp::MakeLocationSummary() const {
73 return MakeSimpleLocationSummary(2, Location::SameAsFirstInput()); 73 return MakeSimpleLocationSummary(2, Location::SameAsFirstInput());
74 } 74 }
75 75
76 76
77 void StrictCompareComp::EmitNativeCode(FlowGraphCompiler* compiler) { 77 void StrictCompareComp::EmitNativeCode(FlowGraphCompiler* compiler) {
78 const Bool& bool_true = Bool::ZoneHandle(Bool::True()); 78 const Bool& bool_true = Bool::ZoneHandle(Bool::True());
79 const Bool& bool_false = Bool::ZoneHandle(Bool::False()); 79 const Bool& bool_false = Bool::ZoneHandle(Bool::False());
80 80
81 Register left = locs()->in(0).reg(); 81 Register left = locs()->in(0).reg();
82 Register right = locs()->in(1).reg(); 82 Register right = locs()->in(1).reg();
(...skipping 16 matching lines...) Expand all
99 99
100 // Generic summary for call instructions that have all arguments pushed 100 // Generic summary for call instructions that have all arguments pushed
101 // on the stack and return the result in a fixed register RAX. 101 // on the stack and return the result in a fixed register RAX.
102 static LocationSummary* MakeCallSummary() { 102 static LocationSummary* MakeCallSummary() {
103 LocationSummary* result = new LocationSummary(0); 103 LocationSummary* result = new LocationSummary(0);
104 result->set_out(Location::RegisterLocation(RAX)); 104 result->set_out(Location::RegisterLocation(RAX));
105 return result; 105 return result;
106 } 106 }
107 107
108 108
109 LocationSummary* ClosureCallComp::MakeLocationSummary() { 109 LocationSummary* ClosureCallComp::MakeLocationSummary() const {
110 return MakeCallSummary(); 110 return MakeCallSummary();
111 } 111 }
112 112
113 113
114 void ClosureCallComp::EmitNativeCode(FlowGraphCompiler* compiler) { 114 void ClosureCallComp::EmitNativeCode(FlowGraphCompiler* compiler) {
115 ASSERT(VerifyCallComputation(this)); 115 ASSERT(VerifyCallComputation(this));
116 // The arguments to the stub include the closure. The arguments 116 // The arguments to the stub include the closure. The arguments
117 // descriptor describes the closure's arguments (and so does not include 117 // descriptor describes the closure's arguments (and so does not include
118 // the closure). 118 // the closure).
119 int argument_count = ArgumentCount(); 119 int argument_count = ArgumentCount();
120 const Array& arguments_descriptor = 120 const Array& arguments_descriptor =
121 CodeGenerator::ArgumentsDescriptor(argument_count - 1, 121 CodeGenerator::ArgumentsDescriptor(argument_count - 1,
122 argument_names()); 122 argument_names());
123 __ LoadObject(R10, arguments_descriptor); 123 __ LoadObject(R10, arguments_descriptor);
124 124
125 compiler->GenerateCall(token_index(), 125 compiler->GenerateCall(token_index(),
126 try_index(), 126 try_index(),
127 &StubCode::CallClosureFunctionLabel(), 127 &StubCode::CallClosureFunctionLabel(),
128 PcDescriptors::kOther); 128 PcDescriptors::kOther);
129 __ Drop(argument_count); 129 __ Drop(argument_count);
130 } 130 }
131 131
132 132
133 LocationSummary* InstanceCallComp::MakeLocationSummary() { 133 LocationSummary* InstanceCallComp::MakeLocationSummary() const {
134 return MakeCallSummary(); 134 return MakeCallSummary();
135 } 135 }
136 136
137 137
138 void InstanceCallComp::EmitNativeCode(FlowGraphCompiler* compiler) { 138 void InstanceCallComp::EmitNativeCode(FlowGraphCompiler* compiler) {
139 ASSERT(VerifyCallComputation(this)); 139 ASSERT(VerifyCallComputation(this));
140 compiler->EmitInstanceCall(cid(), 140 compiler->EmitInstanceCall(cid(),
141 token_index(), 141 token_index(),
142 try_index(), 142 try_index(),
143 function_name(), 143 function_name(),
144 ArgumentCount(), 144 ArgumentCount(),
145 argument_names(), 145 argument_names(),
146 checked_argument_count()); 146 checked_argument_count());
147 } 147 }
148 148
149 149
150 LocationSummary* StaticCallComp::MakeLocationSummary() { 150 LocationSummary* StaticCallComp::MakeLocationSummary() const {
151 return MakeCallSummary(); 151 return MakeCallSummary();
152 } 152 }
153 153
154 154
155 void StaticCallComp::EmitNativeCode(FlowGraphCompiler* compiler) { 155 void StaticCallComp::EmitNativeCode(FlowGraphCompiler* compiler) {
156 ASSERT(VerifyCallComputation(this)); 156 ASSERT(VerifyCallComputation(this));
157 compiler->EmitStaticCall(token_index(), 157 compiler->EmitStaticCall(token_index(),
158 try_index(), 158 try_index(),
159 function(), 159 function(),
160 ArgumentCount(), 160 ArgumentCount(),
161 argument_names()); 161 argument_names());
162 } 162 }
163 163
164 164
165 LocationSummary* LoadLocalComp::MakeLocationSummary() { 165 LocationSummary* LoadLocalComp::MakeLocationSummary() const {
166 return MakeSimpleLocationSummary(0, Location::RequiresRegister()); 166 return MakeSimpleLocationSummary(0, Location::RequiresRegister());
167 } 167 }
168 168
169 169
170 void LoadLocalComp::EmitNativeCode(FlowGraphCompiler* compiler) { 170 void LoadLocalComp::EmitNativeCode(FlowGraphCompiler* compiler) {
171 Register result = locs()->out().reg(); 171 Register result = locs()->out().reg();
172 __ movq(result, Address(RBP, local().index() * kWordSize)); 172 __ movq(result, Address(RBP, local().index() * kWordSize));
173 } 173 }
174 174
175 175
176 LocationSummary* StoreLocalComp::MakeLocationSummary() { 176 LocationSummary* StoreLocalComp::MakeLocationSummary() const {
177 return MakeSimpleLocationSummary(1, Location::SameAsFirstInput()); 177 return MakeSimpleLocationSummary(1, Location::SameAsFirstInput());
178 } 178 }
179 179
180 180
181 void StoreLocalComp::EmitNativeCode(FlowGraphCompiler* compiler) { 181 void StoreLocalComp::EmitNativeCode(FlowGraphCompiler* compiler) {
182 Register value = locs()->in(0).reg(); 182 Register value = locs()->in(0).reg();
183 Register result = locs()->out().reg(); 183 Register result = locs()->out().reg();
184 ASSERT(result == value); // Assert that register assignment is correct. 184 ASSERT(result == value); // Assert that register assignment is correct.
185 __ movq(Address(RBP, local().index() * kWordSize), value); 185 __ movq(Address(RBP, local().index() * kWordSize), value);
186 } 186 }
187 187
188 188
189 void BindInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 189 void BindInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
190 computation()->EmitNativeCode(compiler); 190 computation()->EmitNativeCode(compiler);
191 __ pushq(locs()->out().reg()); 191 __ pushq(locs()->out().reg());
192 } 192 }
193 193
194 194
195 LocationSummary* ConstantVal::MakeLocationSummary() { 195 LocationSummary* ConstantVal::MakeLocationSummary() const {
196 return MakeSimpleLocationSummary(0, Location::RequiresRegister()); 196 return MakeSimpleLocationSummary(0, Location::RequiresRegister());
197 } 197 }
198 198
199 199
200 void ConstantVal::EmitNativeCode(FlowGraphCompiler* compiler) { 200 void ConstantVal::EmitNativeCode(FlowGraphCompiler* compiler) {
201 Register result = locs()->out().reg(); 201 Register result = locs()->out().reg();
202 if (value().IsSmi()) { 202 if (value().IsSmi()) {
203 int64_t imm = reinterpret_cast<int64_t>(value().raw()); 203 int64_t imm = reinterpret_cast<int64_t>(value().raw());
204 __ movq(result, Immediate(imm)); 204 __ movq(result, Immediate(imm));
205 } else { 205 } else {
206 __ LoadObject(result, value()); 206 __ LoadObject(result, value());
207 } 207 }
208 } 208 }
209 209
210 210
211 } // namespace dart 211 } // namespace dart
212 212
213 #undef __ 213 #undef __
214 214
215 #endif // defined TARGET_ARCH_X64 215 #endif // defined TARGET_ARCH_X64
OLDNEW
« vm/intermediate_language.h ('K') | « vm/intermediate_language_ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698