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

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

Issue 10540040: Inline setters, getters, various cleanups & restructuring. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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
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_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 "lib/error.h" 10 #include "lib/error.h"
11 #include "vm/flow_graph_compiler.h" 11 #include "vm/flow_graph_compiler.h"
12 #include "vm/locations.h" 12 #include "vm/locations.h"
13 #include "vm/object_store.h" 13 #include "vm/object_store.h"
14 #include "vm/stub_code.h" 14 #include "vm/stub_code.h"
15 15
16 #define __ compiler->assembler()-> 16 #define __ compiler->assembler()->
17 17
18 namespace dart { 18 namespace dart {
19 19
20 DECLARE_FLAG(int, optimization_counter_threshold); 20 DECLARE_FLAG(int, optimization_counter_threshold);
21 DECLARE_FLAG(bool, trace_functions); 21 DECLARE_FLAG(bool, trace_functions);
22 22
23
24 // Generic summary for call instructions that have all arguments pushed 23 // Generic summary for call instructions that have all arguments pushed
25 // on the stack and return the result in a fixed register EAX. 24 // on the stack and return the result in a fixed register EAX.
26 LocationSummary* Computation::MakeCallSummary() { 25 LocationSummary* Computation::MakeCallSummary() {
27 LocationSummary* result = new LocationSummary(0, 0); 26 LocationSummary* result = new LocationSummary(0, 0);
28 result->set_out(Location::RegisterLocation(EAX)); 27 result->set_out(Location::RegisterLocation(EAX));
29 return result; 28 return result;
30 } 29 }
31 30
32 31
33 void BindInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 32 void BindInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 try_index(), 290 try_index(),
292 function_name, 291 function_name,
293 kNumArguments, 292 kNumArguments,
294 Array::ZoneHandle(), // No optional arguments. 293 Array::ZoneHandle(), // No optional arguments.
295 kNumArgsChecked); 294 kNumArgsChecked);
296 } 295 }
297 296
298 297
299 LocationSummary* InstanceSetterComp::MakeLocationSummary() const { 298 LocationSummary* InstanceSetterComp::MakeLocationSummary() const {
300 const intptr_t kNumInputs = 2; 299 const intptr_t kNumInputs = 2;
301 return LocationSummary::Make(kNumInputs, Location::RequiresRegister()); 300 return LocationSummary::Make(kNumInputs, Location::NoLocation());
302 return NULL; 301 return NULL;
303 } 302 }
304 303
305 304
306 void InstanceSetterComp::EmitNativeCode(FlowGraphCompiler* compiler) { 305 void InstanceSetterComp::EmitNativeCode(FlowGraphCompiler* compiler) {
307 Register receiver = locs()->in(0).reg(); 306 Register receiver = locs()->in(0).reg();
308 Register value = locs()->in(1).reg(); 307 Register value = locs()->in(1).reg();
309 Register result = locs()->out().reg();
310 308
311 // Preserve the value (second argument) under the arguments as the result 309 // Preserve the value (second argument) under the arguments as the result
312 // of the computation, then call the setter. 310 // of the computation, then call the setter.
313 const String& function_name = 311 const String& function_name =
314 String::ZoneHandle(Field::SetterSymbol(field_name())); 312 String::ZoneHandle(Field::SetterSymbol(field_name()));
315 313
316 // Insert a copy of the second (last) argument under the arguments.
317 // TODO(fschneider): Avoid preserving the value if the result is not used.
318 __ pushl(value);
319 __ pushl(receiver); 314 __ pushl(receiver);
320 __ pushl(value); 315 __ pushl(value);
321 const intptr_t kArgumentCount = 2; 316 const intptr_t kArgumentCount = 2;
322 const intptr_t kCheckedArgumentCount = 1; 317 const intptr_t kCheckedArgumentCount = 1;
323 compiler->GenerateInstanceCall(cid(), 318 compiler->GenerateInstanceCall(cid(),
324 token_index(), 319 token_index(),
325 try_index(), 320 try_index(),
326 function_name, 321 function_name,
327 kArgumentCount, 322 kArgumentCount,
328 Array::ZoneHandle(), 323 Array::ZoneHandle(),
329 kCheckedArgumentCount); 324 kCheckedArgumentCount);
330 __ popl(result);
331 } 325 }
332 326
333 327
334 LocationSummary* StaticSetterComp::MakeLocationSummary() const { 328 LocationSummary* StaticSetterComp::MakeLocationSummary() const {
335 return NULL; 329 return NULL;
336 } 330 }
337 331
338 332
339 void StaticSetterComp::EmitNativeCode(FlowGraphCompiler* compiler) { 333 void StaticSetterComp::EmitNativeCode(FlowGraphCompiler* compiler) {
340 UNIMPLEMENTED(); 334 UNIMPLEMENTED();
341 } 335 }
342 336
343 337
344 LocationSummary* LoadInstanceFieldComp::MakeLocationSummary() const { 338 LocationSummary* LoadInstanceFieldComp::MakeLocationSummary() const {
345 return NULL; 339 // TODO(fschneider): For this instruction the input register may be
340 // reused for the result (but is not required to) because the input
341 // is not used after the result is defined. We should consider adding
342 // this information to the input policy.
343 return LocationSummary::Make(1, Location::RequiresRegister());
346 } 344 }
347 345
348 346
349 void LoadInstanceFieldComp::EmitNativeCode(FlowGraphCompiler* compiler) { 347 void LoadInstanceFieldComp::EmitNativeCode(FlowGraphCompiler* compiler) {
350 UNIMPLEMENTED(); 348 Register instance = locs()->in(0).reg();
349 Register result = locs()->out().reg();
350
351 if (class_ids() != NULL) {
352 ASSERT(original() != NULL);
353 Label* deopt = compiler->AddDeoptStub(original()->cid(),
354 original()->token_index(),
355 original()->try_index(),
356 kDeoptInstanceGetterSameTarget,
357 instance,
358 kNoRegister);
359 // Smis do not have instance fields (Smi class is always first).
360 // Use 'result' as temporary register.
361 ASSERT(result != instance);
362 compiler->EmitClassChecksNoSmi(*class_ids(), instance, result, deopt);
363 }
364 __ movl(result, FieldAddress(instance, field().Offset()));
351 } 365 }
352 366
353 367
354 LocationSummary* LoadStaticFieldComp::MakeLocationSummary() const { 368 LocationSummary* LoadStaticFieldComp::MakeLocationSummary() const {
355 return LocationSummary::Make(0, Location::RequiresRegister()); 369 return LocationSummary::Make(0, Location::RequiresRegister());
356 } 370 }
357 371
358 372
359 void LoadStaticFieldComp::EmitNativeCode(FlowGraphCompiler* compiler) { 373 void LoadStaticFieldComp::EmitNativeCode(FlowGraphCompiler* compiler) {
360 Register result = locs()->out().reg(); 374 Register result = locs()->out().reg();
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 UNREACHABLE(); 851 UNREACHABLE();
838 } 852 }
839 } 853 }
840 854
841 855
842 } // namespace dart 856 } // namespace dart
843 857
844 #undef __ 858 #undef __
845 859
846 #endif // defined TARGET_ARCH_X64 860 #endif // defined TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698