| 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_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/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 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 // type check runtime call is the checked value. | 735 // type check runtime call is the checked value. |
| 736 __ Drop(6); | 736 __ Drop(6); |
| 737 __ popl(EAX); | 737 __ popl(EAX); |
| 738 | 738 |
| 739 __ Bind(&is_assignable); | 739 __ Bind(&is_assignable); |
| 740 __ popl(EDX); // Remove pushed instantiator type arguments. | 740 __ popl(EDX); // Remove pushed instantiator type arguments. |
| 741 __ popl(ECX); // Remove pushed instantiator. | 741 __ popl(ECX); // Remove pushed instantiator. |
| 742 } | 742 } |
| 743 | 743 |
| 744 | 744 |
| 745 void FlowGraphCompiler::EmitTrySyncMove(intptr_t dest_offset, | |
| 746 Location loc, | |
| 747 bool* push_emitted) { | |
| 748 const Address dest(EBP, dest_offset); | |
| 749 if (loc.IsConstant()) { | |
| 750 if (!*push_emitted) { | |
| 751 __ pushl(EAX); | |
| 752 *push_emitted = true; | |
| 753 } | |
| 754 __ LoadObject(EAX, loc.constant()); | |
| 755 __ movl(dest, EAX); | |
| 756 } else if (loc.IsRegister()) { | |
| 757 if (*push_emitted && loc.reg() == EAX) { | |
| 758 __ movl(EAX, Address(ESP, 0)); | |
| 759 __ movl(dest, EAX); | |
| 760 } else { | |
| 761 __ movl(dest, loc.reg()); | |
| 762 } | |
| 763 } else { | |
| 764 Address src = loc.ToStackSlotAddress(); | |
| 765 if (!src.Equals(dest)) { | |
| 766 if (!*push_emitted) { | |
| 767 __ pushl(EAX); | |
| 768 *push_emitted = true; | |
| 769 } | |
| 770 __ movl(EAX, src); | |
| 771 __ movl(dest, EAX); | |
| 772 } | |
| 773 } | |
| 774 } | |
| 775 | |
| 776 | |
| 777 void FlowGraphCompiler::EmitTrySync(Instruction* instr, intptr_t try_index) { | |
| 778 ASSERT(is_optimizing()); | |
| 779 Environment* env = instr->env(); | |
| 780 CatchBlockEntryInstr* catch_block = | |
| 781 flow_graph().graph_entry()->GetCatchEntry(try_index); | |
| 782 const GrowableArray<Definition*>* idefs = catch_block->initial_definitions(); | |
| 783 // Parameters. | |
| 784 intptr_t i = 0; | |
| 785 bool push_emitted = false; | |
| 786 const intptr_t num_non_copied_params = flow_graph().num_non_copied_params(); | |
| 787 const intptr_t param_base = | |
| 788 kParamEndSlotFromFp + num_non_copied_params; | |
| 789 for (; i < num_non_copied_params; ++i) { | |
| 790 if ((*idefs)[i]->IsConstant()) continue; // Common constants | |
| 791 Location loc = env->LocationAt(i); | |
| 792 EmitTrySyncMove((param_base - i) * kWordSize, loc, &push_emitted); | |
| 793 } | |
| 794 | |
| 795 // Process locals. Skip exception_var and stacktrace_var. | |
| 796 intptr_t local_base = kFirstLocalSlotFromFp + num_non_copied_params; | |
| 797 intptr_t ex_idx = local_base - catch_block->exception_var().index(); | |
| 798 intptr_t st_idx = local_base - catch_block->stacktrace_var().index(); | |
| 799 for (; i < flow_graph().variable_count(); ++i) { | |
| 800 if (i == ex_idx || i == st_idx) continue; | |
| 801 if ((*idefs)[i]->IsConstant()) continue; | |
| 802 Location loc = env->LocationAt(i); | |
| 803 EmitTrySyncMove((local_base - i) * kWordSize, loc, &push_emitted); | |
| 804 // Update safepoint bitmap to indicate that the target location | |
| 805 // now contains a pointer. | |
| 806 instr->locs()->stack_bitmap()->Set(i - num_non_copied_params, true); | |
| 807 } | |
| 808 if (push_emitted) { | |
| 809 __ popl(EAX); | |
| 810 } | |
| 811 } | |
| 812 | |
| 813 | |
| 814 void FlowGraphCompiler::EmitInstructionEpilogue(Instruction* instr) { | 745 void FlowGraphCompiler::EmitInstructionEpilogue(Instruction* instr) { |
| 815 if (is_optimizing()) return; | 746 if (is_optimizing()) return; |
| 816 Definition* defn = instr->AsDefinition(); | 747 Definition* defn = instr->AsDefinition(); |
| 817 if ((defn != NULL) && defn->is_used()) { | 748 if ((defn != NULL) && defn->is_used()) { |
| 818 __ pushl(defn->locs()->out().reg()); | 749 __ pushl(defn->locs()->out().reg()); |
| 819 } | 750 } |
| 820 } | 751 } |
| 821 | 752 |
| 822 | 753 |
| 823 void FlowGraphCompiler::CopyParameters() { | 754 void FlowGraphCompiler::CopyParameters() { |
| (...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1889 __ movups(reg, Address(ESP, 0)); | 1820 __ movups(reg, Address(ESP, 0)); |
| 1890 __ addl(ESP, Immediate(kFpuRegisterSize)); | 1821 __ addl(ESP, Immediate(kFpuRegisterSize)); |
| 1891 } | 1822 } |
| 1892 | 1823 |
| 1893 | 1824 |
| 1894 #undef __ | 1825 #undef __ |
| 1895 | 1826 |
| 1896 } // namespace dart | 1827 } // namespace dart |
| 1897 | 1828 |
| 1898 #endif // defined TARGET_ARCH_IA32 | 1829 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |