OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 // type check runtime call is the checked value. | 715 // type check runtime call is the checked value. |
716 __ Drop(6); | 716 __ Drop(6); |
717 __ popq(RAX); | 717 __ popq(RAX); |
718 | 718 |
719 __ Bind(&is_assignable); | 719 __ Bind(&is_assignable); |
720 __ popq(RDX); // Remove pushed instantiator type arguments. | 720 __ popq(RDX); // Remove pushed instantiator type arguments. |
721 __ popq(RCX); // Remove pushed instantiator. | 721 __ popq(RCX); // Remove pushed instantiator. |
722 } | 722 } |
723 | 723 |
724 | 724 |
| 725 void FlowGraphCompiler::EmitTrySyncMove(intptr_t dest_offset, |
| 726 Location loc, |
| 727 bool* push_emitted) { |
| 728 const Address dest(RBP, dest_offset); |
| 729 if (loc.IsConstant()) { |
| 730 if (!*push_emitted) { |
| 731 __ pushq(RAX); |
| 732 *push_emitted = true; |
| 733 } |
| 734 __ LoadObject(RAX, loc.constant(), PP); |
| 735 __ movq(dest, RAX); |
| 736 } else if (loc.IsRegister()) { |
| 737 if (*push_emitted && loc.reg() == RAX) { |
| 738 __ movq(RAX, Address(RSP, 0)); |
| 739 __ movq(dest, RAX); |
| 740 } else { |
| 741 __ movq(dest, loc.reg()); |
| 742 } |
| 743 } else { |
| 744 Address src = loc.ToStackSlotAddress(); |
| 745 if (!src.Equals(dest)) { |
| 746 if (!*push_emitted) { |
| 747 __ pushq(RAX); |
| 748 *push_emitted = true; |
| 749 } |
| 750 __ movq(RAX, src); |
| 751 __ movq(dest, RAX); |
| 752 } |
| 753 } |
| 754 } |
| 755 |
| 756 |
| 757 void FlowGraphCompiler::EmitTrySync(Instruction* instr, intptr_t try_index) { |
| 758 ASSERT(is_optimizing()); |
| 759 Environment* env = instr->env(); |
| 760 CatchBlockEntryInstr* catch_block = |
| 761 flow_graph().graph_entry()->GetCatchEntry(try_index); |
| 762 const GrowableArray<Definition*>* idefs = catch_block->initial_definitions(); |
| 763 // Parameters. |
| 764 intptr_t i = 0; |
| 765 bool push_emitted = false; |
| 766 const intptr_t num_non_copied_params = flow_graph().num_non_copied_params(); |
| 767 const intptr_t param_base = kParamEndSlotFromFp + num_non_copied_params; |
| 768 for (; i < num_non_copied_params; ++i) { |
| 769 if ((*idefs)[i]->IsConstant()) continue; // Common constants |
| 770 Location loc = env->LocationAt(i); |
| 771 EmitTrySyncMove((param_base - i) * kWordSize, loc, &push_emitted); |
| 772 } |
| 773 |
| 774 // Process locals. Skip exception_var and stacktrace_var. |
| 775 intptr_t local_base = kFirstLocalSlotFromFp + num_non_copied_params; |
| 776 intptr_t ex_idx = local_base - catch_block->exception_var().index(); |
| 777 intptr_t st_idx = local_base - catch_block->stacktrace_var().index(); |
| 778 for (; i < flow_graph().variable_count(); ++i) { |
| 779 if (i == ex_idx || i == st_idx) continue; |
| 780 if ((*idefs)[i]->IsConstant()) continue; |
| 781 Location loc = env->LocationAt(i); |
| 782 EmitTrySyncMove((local_base - i) * kWordSize, loc, &push_emitted); |
| 783 // Update safepoint bitmap to indicate that the target location |
| 784 // now contains a pointer. |
| 785 instr->locs()->stack_bitmap()->Set(i - num_non_copied_params, true); |
| 786 } |
| 787 if (push_emitted) { |
| 788 __ popq(RAX); |
| 789 } |
| 790 } |
| 791 |
| 792 |
725 void FlowGraphCompiler::EmitInstructionEpilogue(Instruction* instr) { | 793 void FlowGraphCompiler::EmitInstructionEpilogue(Instruction* instr) { |
726 if (is_optimizing()) return; | 794 if (is_optimizing()) return; |
727 Definition* defn = instr->AsDefinition(); | 795 Definition* defn = instr->AsDefinition(); |
728 if ((defn != NULL) && defn->is_used()) { | 796 if ((defn != NULL) && defn->is_used()) { |
729 __ pushq(defn->locs()->out().reg()); | 797 __ pushq(defn->locs()->out().reg()); |
730 } | 798 } |
731 } | 799 } |
732 | 800 |
733 | 801 |
734 void FlowGraphCompiler::CopyParameters() { | 802 void FlowGraphCompiler::CopyParameters() { |
(...skipping 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1839 __ movups(reg, Address(RSP, 0)); | 1907 __ movups(reg, Address(RSP, 0)); |
1840 __ AddImmediate(RSP, Immediate(kFpuRegisterSize), PP); | 1908 __ AddImmediate(RSP, Immediate(kFpuRegisterSize), PP); |
1841 } | 1909 } |
1842 | 1910 |
1843 | 1911 |
1844 #undef __ | 1912 #undef __ |
1845 | 1913 |
1846 } // namespace dart | 1914 } // namespace dart |
1847 | 1915 |
1848 #endif // defined TARGET_ARCH_X64 | 1916 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |