| OLD | NEW |
| 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 Loading... |
| 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 } | 301 } |
| 303 | 302 |
| 304 | 303 |
| 305 void InstanceSetterComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 304 void InstanceSetterComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 306 Register receiver = locs()->in(0).reg(); | 305 Register receiver = locs()->in(0).reg(); |
| 307 Register value = locs()->in(1).reg(); | 306 Register value = locs()->in(1).reg(); |
| 308 Register result = locs()->out().reg(); | |
| 309 | 307 |
| 310 // Preserve the value (second argument) under the arguments as the result | 308 // Preserve the value (second argument) under the arguments as the result |
| 311 // of the computation, then call the setter. | 309 // of the computation, then call the setter. |
| 312 const String& function_name = | 310 const String& function_name = |
| 313 String::ZoneHandle(Field::SetterSymbol(field_name())); | 311 String::ZoneHandle(Field::SetterSymbol(field_name())); |
| 314 | 312 |
| 315 // Insert a copy of the second (last) argument under the arguments. | |
| 316 // TODO(fschneider): Avoid preserving the value if the result is not used. | |
| 317 __ pushl(value); | |
| 318 __ pushl(receiver); | 313 __ pushl(receiver); |
| 319 __ pushl(value); | 314 __ pushl(value); |
| 315 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, |
| 316 cid(), |
| 317 token_index(), |
| 318 try_index()); |
| 320 const intptr_t kArgumentCount = 2; | 319 const intptr_t kArgumentCount = 2; |
| 321 const intptr_t kCheckedArgumentCount = 1; | 320 const intptr_t kCheckedArgumentCount = 1; |
| 322 compiler->GenerateInstanceCall(cid(), | 321 compiler->GenerateInstanceCall(cid(), |
| 323 token_index(), | 322 token_index(), |
| 324 try_index(), | 323 try_index(), |
| 325 function_name, | 324 function_name, |
| 326 kArgumentCount, | 325 kArgumentCount, |
| 327 Array::ZoneHandle(), | 326 Array::ZoneHandle(), |
| 328 kCheckedArgumentCount); | 327 kCheckedArgumentCount); |
| 329 __ popl(result); | |
| 330 } | 328 } |
| 331 | 329 |
| 332 | 330 |
| 333 LocationSummary* StaticSetterComp::MakeLocationSummary() const { | 331 LocationSummary* StaticSetterComp::MakeLocationSummary() const { |
| 334 const intptr_t kNumInputs = 1; | 332 const intptr_t kNumInputs = 1; |
| 335 return LocationSummary::Make(kNumInputs, Location::RequiresRegister()); | 333 return LocationSummary::Make(kNumInputs, Location::RequiresRegister()); |
| 336 } | 334 } |
| 337 | 335 |
| 338 | 336 |
| 339 void StaticSetterComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 337 void StaticSetterComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 363 // is not used after the result is defined. We should consider adding | 361 // is not used after the result is defined. We should consider adding |
| 364 // this information to the input policy. | 362 // this information to the input policy. |
| 365 return LocationSummary::Make(1, Location::RequiresRegister()); | 363 return LocationSummary::Make(1, Location::RequiresRegister()); |
| 366 } | 364 } |
| 367 | 365 |
| 368 | 366 |
| 369 void LoadInstanceFieldComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 367 void LoadInstanceFieldComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 370 Register instance = locs()->in(0).reg(); | 368 Register instance = locs()->in(0).reg(); |
| 371 Register result = locs()->out().reg(); | 369 Register result = locs()->out().reg(); |
| 372 | 370 |
| 371 if (class_ids() != NULL) { |
| 372 ASSERT(original() != NULL); |
| 373 Label* deopt = compiler->AddDeoptStub(original()->cid(), |
| 374 original()->token_index(), |
| 375 original()->try_index(), |
| 376 kDeoptInstanceGetterSameTarget, |
| 377 instance, |
| 378 kNoRegister); |
| 379 // Smis do not have instance fields (Smi class is always first). |
| 380 // Use 'result' as temporary register. |
| 381 ASSERT(result != instance); |
| 382 compiler->EmitClassChecksNoSmi(*class_ids(), instance, result, deopt); |
| 383 } |
| 373 __ movl(result, FieldAddress(instance, field().Offset())); | 384 __ movl(result, FieldAddress(instance, field().Offset())); |
| 374 } | 385 } |
| 375 | 386 |
| 376 | 387 |
| 377 LocationSummary* LoadStaticFieldComp::MakeLocationSummary() const { | 388 LocationSummary* LoadStaticFieldComp::MakeLocationSummary() const { |
| 378 return LocationSummary::Make(0, Location::RequiresRegister()); | 389 return LocationSummary::Make(0, Location::RequiresRegister()); |
| 379 } | 390 } |
| 380 | 391 |
| 381 | 392 |
| 382 void LoadStaticFieldComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 393 void LoadStaticFieldComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 875 UNREACHABLE(); | 886 UNREACHABLE(); |
| 876 } | 887 } |
| 877 } | 888 } |
| 878 | 889 |
| 879 | 890 |
| 880 } // namespace dart | 891 } // namespace dart |
| 881 | 892 |
| 882 #undef __ | 893 #undef __ |
| 883 | 894 |
| 884 #endif // defined TARGET_ARCH_X64 | 895 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |