Chromium Code Reviews| 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 "vm/flow_graph_compiler.h" | 10 #include "vm/flow_graph_compiler.h" |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 483 const Code& stub = Code::Handle( | 483 const Code& stub = Code::Handle( |
| 484 StubCode::GetAllocationStubForClosure(closure_function)); | 484 StubCode::GetAllocationStubForClosure(closure_function)); |
| 485 const ExternalLabel label(closure_function.ToCString(), stub.EntryPoint()); | 485 const ExternalLabel label(closure_function.ToCString(), stub.EntryPoint()); |
| 486 compiler->GenerateCall(token_index(), try_index(), &label, | 486 compiler->GenerateCall(token_index(), try_index(), &label, |
| 487 PcDescriptors::kOther); | 487 PcDescriptors::kOther); |
| 488 __ Drop(2); // Discard type arguments and receiver. | 488 __ Drop(2); // Discard type arguments and receiver. |
| 489 } | 489 } |
| 490 | 490 |
| 491 | 491 |
| 492 LocationSummary* AllocateObjectComp::MakeLocationSummary() const { | 492 LocationSummary* AllocateObjectComp::MakeLocationSummary() const { |
| 493 return NULL; | 493 return MakeCallSummary(); |
| 494 } | 494 } |
| 495 | 495 |
| 496 | 496 |
| 497 void AllocateObjectComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 497 void AllocateObjectComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 498 UNIMPLEMENTED(); | 498 const Class& cls = Class::ZoneHandle(constructor().owner()); |
| 499 const Code& stub = Code::Handle(StubCode::GetAllocationStubForClass(cls)); | |
| 500 const ExternalLabel label(cls.ToCString(), stub.EntryPoint()); | |
| 501 compiler->GenerateCall(token_index(), | |
| 502 try_index(), | |
| 503 &label, | |
| 504 PcDescriptors::kOther); | |
| 505 __ Drop(arguments().length()); // Discard arguments. | |
| 499 } | 506 } |
| 500 | 507 |
| 501 | 508 |
| 502 LocationSummary* | 509 LocationSummary* |
| 503 AllocateObjectWithBoundsCheckComp::MakeLocationSummary() const { | 510 AllocateObjectWithBoundsCheckComp::MakeLocationSummary() const { |
| 504 return NULL; | 511 return LocationSummary::Make(2, Location::RequiresRegister()); |
| 505 } | 512 } |
| 506 | 513 |
| 507 | 514 |
| 508 void AllocateObjectWithBoundsCheckComp::EmitNativeCode( | 515 void AllocateObjectWithBoundsCheckComp::EmitNativeCode( |
| 509 FlowGraphCompiler* compiler) { | 516 FlowGraphCompiler* compiler) { |
| 510 UNIMPLEMENTED(); | 517 const Class& cls = Class::ZoneHandle(constructor().owner()); |
| 518 Register type_arguments = locs()->in(0).reg(); | |
| 519 Register instantiator_type_arguments = locs()->in(1).reg(); | |
| 520 Register result = locs()->out().reg(); | |
| 521 | |
| 522 __ PushObject(Object::ZoneHandle()); | |
| 523 __ pushl(Immediate(Smi::RawValue(token_index()))); | |
| 524 __ PushObject(cls); | |
| 525 __ pushl(type_arguments); | |
| 526 __ pushl(instantiator_type_arguments); | |
| 527 compiler->GenerateCallRuntime(cid(), | |
| 528 token_index(), | |
| 529 try_index(), | |
| 530 kAllocateObjectWithBoundsCheckRuntimeEntry); | |
| 531 // Pop instantiator type arguments, type arguments, class, and | |
| 532 // source location. | |
| 533 __ Drop(4); | |
| 534 __ popl(result); // Pop new instance. | |
| 511 } | 535 } |
| 512 | 536 |
| 513 | 537 |
| 514 LocationSummary* LoadVMFieldComp::MakeLocationSummary() const { | 538 LocationSummary* LoadVMFieldComp::MakeLocationSummary() const { |
| 515 return NULL; | 539 return LocationSummary::Make(1, Location::SameAsFirstInput()); |
|
Florian Schneider
2012/06/04 15:13:14
We don't need to make input and result always the
| |
| 516 } | 540 } |
| 517 | 541 |
| 518 | 542 |
| 519 void LoadVMFieldComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 543 void LoadVMFieldComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 520 UNIMPLEMENTED(); | 544 Register obj = locs()->in(0).reg(); |
| 545 Register result = locs()->out().reg(); | |
| 546 | |
| 547 __ movl(result, FieldAddress(obj, offset_in_bytes())); | |
| 521 } | 548 } |
| 522 | 549 |
| 523 | 550 |
| 524 LocationSummary* StoreVMFieldComp::MakeLocationSummary() const { | 551 LocationSummary* StoreVMFieldComp::MakeLocationSummary() const { |
| 525 return NULL; | 552 return LocationSummary::Make(2, Location::SameAsFirstInput()); |
| 526 } | 553 } |
| 527 | 554 |
| 528 | 555 |
| 529 void StoreVMFieldComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 556 void StoreVMFieldComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 530 UNIMPLEMENTED(); | 557 Register value_reg = locs()->in(0).reg(); |
| 558 Register dest_reg = locs()->in(1).reg(); | |
| 559 ASSERT(value_reg == locs()->out().reg()); | |
| 560 | |
| 561 __ StoreIntoObject(dest_reg, FieldAddress(dest_reg, offset_in_bytes()), | |
| 562 value_reg); | |
| 531 } | 563 } |
| 532 | 564 |
| 533 | 565 |
| 534 LocationSummary* InstantiateTypeArgumentsComp::MakeLocationSummary() const { | 566 LocationSummary* InstantiateTypeArgumentsComp::MakeLocationSummary() const { |
| 535 return NULL; | 567 const intptr_t kNumInputs = 1; |
| 568 const intptr_t kNumTemps = 1; | |
| 569 LocationSummary* locs = new LocationSummary(kNumInputs, kNumTemps); | |
| 570 locs->set_in(0, Location::RequiresRegister()); | |
| 571 locs->set_temp(0, Location::RequiresRegister()); | |
| 572 locs->set_out(Location::SameAsFirstInput()); | |
| 573 return locs; | |
| 536 } | 574 } |
| 537 | 575 |
| 538 | 576 |
| 539 void InstantiateTypeArgumentsComp::EmitNativeCode( | 577 void InstantiateTypeArgumentsComp::EmitNativeCode( |
| 540 FlowGraphCompiler* compiler) { | 578 FlowGraphCompiler* compiler) { |
| 541 UNIMPLEMENTED(); | 579 Register instantiator_reg = locs()->in(0).reg(); |
| 580 Register temp = locs()->temp(0).reg(); | |
| 581 Register result_reg = locs()->out().reg(); | |
| 582 | |
| 583 // 'instantiator_reg' is the instantiator AbstractTypeArguments object | |
| 584 // (or null). | |
| 585 // If the instantiator is null and if the type argument vector | |
| 586 // instantiated from null becomes a vector of Dynamic, then use null as | |
| 587 // the type arguments. | |
| 588 Label type_arguments_instantiated; | |
| 589 const intptr_t len = type_arguments().Length(); | |
| 590 if (type_arguments().IsRawInstantiatedRaw(len)) { | |
| 591 const Immediate raw_null = | |
| 592 Immediate(reinterpret_cast<intptr_t>(Object::null())); | |
| 593 __ cmpl(instantiator_reg, raw_null); | |
| 594 __ j(EQUAL, &type_arguments_instantiated, Assembler::kNearJump); | |
| 595 } | |
| 596 // Instantiate non-null type arguments. | |
| 597 if (type_arguments().IsUninstantiatedIdentity()) { | |
| 598 // Check if the instantiator type argument vector is a TypeArguments of a | |
| 599 // matching length and, if so, use it as the instantiated type_arguments. | |
| 600 // No need to check instantiator for null (again), because a null instance | |
| 601 // will have the wrong class (Null instead of TypeArguments). | |
| 602 Label type_arguments_uninstantiated; | |
| 603 __ CompareClassId(instantiator_reg, kTypeArguments, temp); | |
| 604 __ j(NOT_EQUAL, &type_arguments_uninstantiated, Assembler::kNearJump); | |
| 605 __ cmpl(FieldAddress(instantiator_reg, TypeArguments::length_offset()), | |
| 606 Immediate(Smi::RawValue(len))); | |
| 607 __ j(EQUAL, &type_arguments_instantiated, Assembler::kNearJump); | |
| 608 __ Bind(&type_arguments_uninstantiated); | |
| 609 } | |
| 610 // A runtime call to instantiate the type arguments is required. | |
| 611 __ PushObject(Object::ZoneHandle()); // Make room for the result. | |
| 612 __ PushObject(type_arguments()); | |
| 613 __ pushl(instantiator_reg); // Push instantiator type arguments. | |
| 614 compiler->GenerateCallRuntime(cid(), | |
| 615 token_index(), | |
| 616 try_index(), | |
| 617 kInstantiateTypeArgumentsRuntimeEntry); | |
| 618 __ Drop(2); // Drop instantiator and uninstantiated type arguments. | |
| 619 __ popl(result_reg); // Pop instantiated type arguments. | |
| 620 __ Bind(&type_arguments_instantiated); | |
| 621 ASSERT(instantiator_reg == result_reg); | |
| 542 } | 622 } |
| 543 | 623 |
| 544 | 624 |
| 545 LocationSummary* | 625 LocationSummary* |
| 546 ExtractConstructorTypeArgumentsComp::MakeLocationSummary() const { | 626 ExtractConstructorTypeArgumentsComp::MakeLocationSummary() const { |
| 547 return NULL; | 627 return NULL; |
| 548 } | 628 } |
| 549 | 629 |
| 550 | 630 |
| 551 void ExtractConstructorTypeArgumentsComp::EmitNativeCode( | 631 void ExtractConstructorTypeArgumentsComp::EmitNativeCode( |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 741 UNREACHABLE(); | 821 UNREACHABLE(); |
| 742 } | 822 } |
| 743 } | 823 } |
| 744 | 824 |
| 745 | 825 |
| 746 } // namespace dart | 826 } // namespace dart |
| 747 | 827 |
| 748 #undef __ | 828 #undef __ |
| 749 | 829 |
| 750 #endif // defined TARGET_ARCH_X64 | 830 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |