| 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" |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 function_name, | 292 function_name, |
| 293 kNumArguments, | 293 kNumArguments, |
| 294 Array::ZoneHandle(), // No optional arguments. | 294 Array::ZoneHandle(), // No optional arguments. |
| 295 kNumArgsChecked); | 295 kNumArgsChecked); |
| 296 } | 296 } |
| 297 | 297 |
| 298 | 298 |
| 299 LocationSummary* InstanceSetterComp::MakeLocationSummary() const { | 299 LocationSummary* InstanceSetterComp::MakeLocationSummary() const { |
| 300 const intptr_t kNumInputs = 2; | 300 const intptr_t kNumInputs = 2; |
| 301 return LocationSummary::Make(kNumInputs, Location::RequiresRegister()); | 301 return LocationSummary::Make(kNumInputs, Location::RequiresRegister()); |
| 302 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(); | 308 Register result = locs()->out().reg(); |
| 310 | 309 |
| 311 // Preserve the value (second argument) under the arguments as the result | 310 // Preserve the value (second argument) under the arguments as the result |
| 312 // of the computation, then call the setter. | 311 // of the computation, then call the setter. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 325 try_index(), | 324 try_index(), |
| 326 function_name, | 325 function_name, |
| 327 kArgumentCount, | 326 kArgumentCount, |
| 328 Array::ZoneHandle(), | 327 Array::ZoneHandle(), |
| 329 kCheckedArgumentCount); | 328 kCheckedArgumentCount); |
| 330 __ popl(result); | 329 __ popl(result); |
| 331 } | 330 } |
| 332 | 331 |
| 333 | 332 |
| 334 LocationSummary* StaticSetterComp::MakeLocationSummary() const { | 333 LocationSummary* StaticSetterComp::MakeLocationSummary() const { |
| 335 return NULL; | 334 const intptr_t kNumInputs = 1; |
| 335 return LocationSummary::Make(kNumInputs, Location::RequiresRegister()); |
| 336 } | 336 } |
| 337 | 337 |
| 338 | 338 |
| 339 void StaticSetterComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 339 void StaticSetterComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 340 UNIMPLEMENTED(); | 340 Register value = locs()->in(0).reg(); |
| 341 Register result = locs()->out().reg(); |
| 342 |
| 343 // Preserve the argument as the result of the computation, |
| 344 // then call the setter. |
| 345 |
| 346 // Duplicate the argument. |
| 347 // TODO(fschneider): Avoid preserving the value if the result is not used. |
| 348 __ pushl(value); |
| 349 __ pushl(value); |
| 350 compiler->GenerateStaticCall(cid(), |
| 351 token_index(), |
| 352 try_index(), |
| 353 setter_function(), |
| 354 1, |
| 355 Array::ZoneHandle()); |
| 356 __ popl(result); |
| 341 } | 357 } |
| 342 | 358 |
| 343 | 359 |
| 344 LocationSummary* LoadInstanceFieldComp::MakeLocationSummary() const { | 360 LocationSummary* LoadInstanceFieldComp::MakeLocationSummary() const { |
| 345 return NULL; | 361 // TODO(fschneider): For this instruction the input register may be |
| 362 // reused for the result (but is not required to) because the input |
| 363 // is not used after the result is defined. We should consider adding |
| 364 // this information to the input policy. |
| 365 return LocationSummary::Make(1, Location::RequiresRegister()); |
| 346 } | 366 } |
| 347 | 367 |
| 348 | 368 |
| 349 void LoadInstanceFieldComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 369 void LoadInstanceFieldComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 350 UNIMPLEMENTED(); | 370 Register instance = locs()->in(0).reg(); |
| 371 Register result = locs()->out().reg(); |
| 372 |
| 373 __ movl(result, FieldAddress(instance, field().Offset())); |
| 351 } | 374 } |
| 352 | 375 |
| 353 | 376 |
| 354 LocationSummary* LoadStaticFieldComp::MakeLocationSummary() const { | 377 LocationSummary* LoadStaticFieldComp::MakeLocationSummary() const { |
| 355 return LocationSummary::Make(0, Location::RequiresRegister()); | 378 return LocationSummary::Make(0, Location::RequiresRegister()); |
| 356 } | 379 } |
| 357 | 380 |
| 358 | 381 |
| 359 void LoadStaticFieldComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 382 void LoadStaticFieldComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 360 Register result = locs()->out().reg(); | 383 Register result = locs()->out().reg(); |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 compiler->GenerateCallRuntime(cid(), | 709 compiler->GenerateCallRuntime(cid(), |
| 687 token_index(), | 710 token_index(), |
| 688 try_index(), | 711 try_index(), |
| 689 kCloneContextRuntimeEntry); | 712 kCloneContextRuntimeEntry); |
| 690 __ popl(result); // Remove argument. | 713 __ popl(result); // Remove argument. |
| 691 __ popl(result); // Get result (cloned context). | 714 __ popl(result); // Get result (cloned context). |
| 692 } | 715 } |
| 693 | 716 |
| 694 | 717 |
| 695 LocationSummary* CatchEntryComp::MakeLocationSummary() const { | 718 LocationSummary* CatchEntryComp::MakeLocationSummary() const { |
| 696 return NULL; | 719 return LocationSummary::Make(0, Location::NoLocation()); |
| 697 } | 720 } |
| 698 | 721 |
| 699 | 722 |
| 723 // Restore stack and initialize the two exception variables: |
| 724 // exception and stack trace variables. |
| 700 void CatchEntryComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 725 void CatchEntryComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 701 UNIMPLEMENTED(); | 726 // Restore RSP from RBP as we are coming from a throw and the code for |
| 727 // popping arguments has not been run. |
| 728 const intptr_t locals_space_size = compiler->StackSize() * kWordSize; |
| 729 ASSERT(locals_space_size >= 0); |
| 730 const intptr_t offset_size = |
| 731 -locals_space_size + FlowGraphCompiler::kLocalsOffsetFromFP; |
| 732 __ leal(ESP, Address(EBP, offset_size)); |
| 733 |
| 734 ASSERT(!exception_var().is_captured()); |
| 735 ASSERT(!stacktrace_var().is_captured()); |
| 736 __ movl(Address(EBP, exception_var().index() * kWordSize), |
| 737 kExceptionObjectReg); |
| 738 __ movl(Address(EBP, stacktrace_var().index() * kWordSize), |
| 739 kStackTraceObjectReg); |
| 702 } | 740 } |
| 703 | 741 |
| 704 | 742 |
| 705 LocationSummary* BinaryOpComp::MakeLocationSummary() const { | 743 LocationSummary* BinaryOpComp::MakeLocationSummary() const { |
| 706 const intptr_t kNumInputs = 2; | 744 const intptr_t kNumInputs = 2; |
| 707 const intptr_t kNumTemps = 0; | 745 const intptr_t kNumTemps = 0; |
| 708 LocationSummary* summary = new LocationSummary(kNumInputs, kNumTemps); | 746 LocationSummary* summary = new LocationSummary(kNumInputs, kNumTemps); |
| 709 summary->set_in(0, Location::RequiresRegister()); | 747 summary->set_in(0, Location::RequiresRegister()); |
| 710 summary->set_in(1, Location::RequiresRegister()); | 748 summary->set_in(1, Location::RequiresRegister()); |
| 711 summary->set_out(Location::SameAsFirstInput()); | 749 summary->set_out(Location::SameAsFirstInput()); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 837 UNREACHABLE(); | 875 UNREACHABLE(); |
| 838 } | 876 } |
| 839 } | 877 } |
| 840 | 878 |
| 841 | 879 |
| 842 } // namespace dart | 880 } // namespace dart |
| 843 | 881 |
| 844 #undef __ | 882 #undef __ |
| 845 | 883 |
| 846 #endif // defined TARGET_ARCH_X64 | 884 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |