| 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_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 | 9 |
| 10 #include "vm/ast_printer.h" | 10 #include "vm/ast_printer.h" |
| (...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 const Class& cls = Class::Handle(function.signature_class()); | 582 const Class& cls = Class::Handle(function.signature_class()); |
| 583 if (cls.HasTypeArguments()) { | 583 if (cls.HasTypeArguments()) { |
| 584 __ popq(RCX); // Discard type arguments. | 584 __ popq(RCX); // Discard type arguments. |
| 585 } | 585 } |
| 586 if (function.IsImplicitInstanceClosureFunction()) { | 586 if (function.IsImplicitInstanceClosureFunction()) { |
| 587 __ popq(RCX); // Discard receiver. | 587 __ popq(RCX); // Discard receiver. |
| 588 } | 588 } |
| 589 } | 589 } |
| 590 | 590 |
| 591 | 591 |
| 592 void FlowGraphCompiler::VisitNativeLoadField(NativeLoadFieldComp* comp) { |
| 593 __ popq(RAX); |
| 594 __ movq(RAX, FieldAddress(RAX, comp->offset_in_bytes())); |
| 595 } |
| 596 |
| 597 |
| 598 void FlowGraphCompiler::VisitExtractTypeArguments( |
| 599 ExtractTypeArgumentsComp* comp) { |
| 600 __ popq(RAX); // Instantiator. |
| 601 if (!comp->constructor().IsFactory()) { |
| 602 __ popq(RBX); // Discard placeholder. |
| 603 } |
| 604 |
| 605 // RAX is the instantiator AbstractTypeArguments object (or null). |
| 606 // If RAX is null, no need to instantiate the type arguments, use null, and |
| 607 // allocate an object of a raw type. |
| 608 const Immediate raw_null = |
| 609 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 610 Label type_arguments_instantiated, type_arguments_uninstantiated; |
| 611 __ cmpq(RAX, raw_null); |
| 612 __ j(EQUAL, &type_arguments_instantiated, Assembler::kNearJump); |
| 613 |
| 614 // Instantiate non-null type arguments. |
| 615 if (comp->type_arguments().IsUninstantiatedIdentity()) { |
| 616 // Check if the instantiator type argument vector is a TypeArguments of a |
| 617 // matching length and, if so, use it as the instantiated type_arguments. |
| 618 __ LoadObject(RCX, Class::ZoneHandle(Object::type_arguments_class())); |
| 619 __ cmpq(RCX, FieldAddress(RAX, Object::class_offset())); |
| 620 __ j(NOT_EQUAL, &type_arguments_uninstantiated, Assembler::kNearJump); |
| 621 Immediate arguments_length = Immediate(reinterpret_cast<int64_t>( |
| 622 Smi::New(comp->type_arguments().Length()))); |
| 623 __ cmpq(FieldAddress(RAX, TypeArguments::length_offset()), |
| 624 arguments_length); |
| 625 __ j(EQUAL, &type_arguments_instantiated, Assembler::kNearJump); |
| 626 } |
| 627 __ Bind(&type_arguments_uninstantiated); |
| 628 if (comp->constructor().IsFactory()) { |
| 629 // A runtime call to instantiate the type arguments is required before |
| 630 // calling the factory. |
| 631 __ PushObject(Object::ZoneHandle()); // Make room for the result. |
| 632 __ PushObject(comp->type_arguments()); |
| 633 __ pushq(RAX); // Push instantiator type arguments. |
| 634 GenerateCallRuntime(comp->node_id(), |
| 635 comp->token_index(), |
| 636 kInstantiateTypeArgumentsRuntimeEntry); |
| 637 __ popq(RAX); // Pop instantiator type arguments. |
| 638 __ popq(RAX); // Pop uninstantiated type arguments. |
| 639 __ popq(RAX); // Pop instantiated type arguments. |
| 640 __ Bind(&type_arguments_instantiated); |
| 641 // RAX: Instantiated type arguments. |
| 642 } else { |
| 643 // In the non-factory case, we rely on the allocation stub to |
| 644 // instantiate the type arguments. |
| 645 __ PushObject(comp->type_arguments()); |
| 646 // RAX: Instantiator type arguments. |
| 647 Label type_arguments_pushed; |
| 648 __ jmp(&type_arguments_pushed, Assembler::kNearJump); |
| 649 |
| 650 __ Bind(&type_arguments_instantiated); |
| 651 __ pushq(RAX); // Instantiated type arguments. |
| 652 __ movq(RAX, raw_null); // Null instantiator. |
| 653 __ Bind(&type_arguments_pushed); |
| 654 } |
| 655 } |
| 656 |
| 657 |
| 592 void FlowGraphCompiler::VisitBlocks( | 658 void FlowGraphCompiler::VisitBlocks( |
| 593 const GrowableArray<BlockEntryInstr*>& blocks) { | 659 const GrowableArray<BlockEntryInstr*>& blocks) { |
| 594 for (intptr_t i = blocks.length() - 1; i >= 0; --i) { | 660 for (intptr_t i = blocks.length() - 1; i >= 0; --i) { |
| 595 // Compile the block entry. | 661 // Compile the block entry. |
| 596 current_block_ = blocks[i]; | 662 current_block_ = blocks[i]; |
| 597 Instruction* instr = current_block()->Accept(this); | 663 Instruction* instr = current_block()->Accept(this); |
| 598 // Compile all successors until an exit, branch, or a block entry. | 664 // Compile all successors until an exit, branch, or a block entry. |
| 599 while ((instr != NULL) && !instr->IsBlockEntry()) { | 665 while ((instr != NULL) && !instr->IsBlockEntry()) { |
| 600 instr = instr->Accept(this); | 666 instr = instr->Accept(this); |
| 601 } | 667 } |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1035 void FlowGraphCompiler::FinalizeExceptionHandlers(const Code& code) { | 1101 void FlowGraphCompiler::FinalizeExceptionHandlers(const Code& code) { |
| 1036 // We don't compile exception handlers yet. | 1102 // We don't compile exception handlers yet. |
| 1037 code.set_exception_handlers( | 1103 code.set_exception_handlers( |
| 1038 ExceptionHandlers::Handle(ExceptionHandlers::New(0))); | 1104 ExceptionHandlers::Handle(ExceptionHandlers::New(0))); |
| 1039 } | 1105 } |
| 1040 | 1106 |
| 1041 | 1107 |
| 1042 } // namespace dart | 1108 } // namespace dart |
| 1043 | 1109 |
| 1044 #endif // defined TARGET_ARCH_X64 | 1110 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |