| 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_MIPS. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS. |
| 6 #if defined(TARGET_ARCH_MIPS) | 6 #if defined(TARGET_ARCH_MIPS) |
| 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 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 734 __ addiu(SP, SP, Immediate(7 * kWordSize)); | 734 __ addiu(SP, SP, Immediate(7 * kWordSize)); |
| 735 | 735 |
| 736 __ Bind(&is_assignable); | 736 __ Bind(&is_assignable); |
| 737 // Restore instantiator and its type arguments. | 737 // Restore instantiator and its type arguments. |
| 738 __ lw(A1, Address(SP, 0 * kWordSize)); | 738 __ lw(A1, Address(SP, 0 * kWordSize)); |
| 739 __ lw(A2, Address(SP, 1 * kWordSize)); | 739 __ lw(A2, Address(SP, 1 * kWordSize)); |
| 740 __ addiu(SP, SP, Immediate(2 * kWordSize)); | 740 __ addiu(SP, SP, Immediate(2 * kWordSize)); |
| 741 } | 741 } |
| 742 | 742 |
| 743 | 743 |
| 744 void FlowGraphCompiler::EmitTrySyncMove(intptr_t dest_offset, | |
| 745 Location loc, | |
| 746 bool* push_emitted) { | |
| 747 if (loc.IsConstant()) { | |
| 748 if (!*push_emitted) { | |
| 749 __ Push(T0); | |
| 750 *push_emitted = true; | |
| 751 } | |
| 752 __ LoadObject(T0, loc.constant()); | |
| 753 __ StoreToOffset(T0, FP, dest_offset); | |
| 754 } else if (loc.IsRegister()) { | |
| 755 if (*push_emitted && loc.reg() == T0) { | |
| 756 __ lw(T0, Address(SP, 0)); | |
| 757 __ StoreToOffset(T0, FP, dest_offset); | |
| 758 } else { | |
| 759 __ StoreToOffset(loc.reg(), FP, dest_offset); | |
| 760 } | |
| 761 } else { | |
| 762 const intptr_t src_offset = loc.ToStackSlotOffset(); | |
| 763 if (src_offset != dest_offset) { | |
| 764 if (!*push_emitted) { | |
| 765 __ Push(T0); | |
| 766 *push_emitted = true; | |
| 767 } | |
| 768 __ LoadFromOffset(T0, FP, src_offset); | |
| 769 __ StoreToOffset(T0, FP, dest_offset); | |
| 770 } | |
| 771 } | |
| 772 } | |
| 773 | |
| 774 | |
| 775 void FlowGraphCompiler::EmitTrySync(Instruction* instr, intptr_t try_index) { | |
| 776 ASSERT(is_optimizing()); | |
| 777 Environment* env = instr->env(); | |
| 778 CatchBlockEntryInstr* catch_block = | |
| 779 flow_graph().graph_entry()->GetCatchEntry(try_index); | |
| 780 const GrowableArray<Definition*>* idefs = catch_block->initial_definitions(); | |
| 781 // Parameters. | |
| 782 intptr_t i = 0; | |
| 783 bool push_emitted = false; | |
| 784 const intptr_t num_non_copied_params = flow_graph().num_non_copied_params(); | |
| 785 const intptr_t param_base = | |
| 786 kParamEndSlotFromFp + num_non_copied_params; | |
| 787 for (; i < num_non_copied_params; ++i) { | |
| 788 if ((*idefs)[i]->IsConstant()) continue; // Common constants | |
| 789 Location loc = env->LocationAt(i); | |
| 790 EmitTrySyncMove((param_base - i) * kWordSize, loc, &push_emitted); | |
| 791 } | |
| 792 | |
| 793 // Process locals. Skip exception_var and stacktrace_var. | |
| 794 intptr_t local_base = kFirstLocalSlotFromFp + num_non_copied_params; | |
| 795 intptr_t ex_idx = local_base - catch_block->exception_var().index(); | |
| 796 intptr_t st_idx = local_base - catch_block->stacktrace_var().index(); | |
| 797 for (; i < flow_graph().variable_count(); ++i) { | |
| 798 if (i == ex_idx || i == st_idx) continue; | |
| 799 if ((*idefs)[i]->IsConstant()) continue; | |
| 800 Location loc = env->LocationAt(i); | |
| 801 EmitTrySyncMove((local_base - i) * kWordSize, loc, &push_emitted); | |
| 802 // Update safepoint bitmap to indicate that the target location | |
| 803 // now contains a pointer. | |
| 804 instr->locs()->stack_bitmap()->Set(i - num_non_copied_params, true); | |
| 805 } | |
| 806 if (push_emitted) { | |
| 807 __ Pop(T0); | |
| 808 } | |
| 809 } | |
| 810 | |
| 811 | |
| 812 void FlowGraphCompiler::EmitInstructionEpilogue(Instruction* instr) { | 744 void FlowGraphCompiler::EmitInstructionEpilogue(Instruction* instr) { |
| 813 if (is_optimizing()) return; | 745 if (is_optimizing()) return; |
| 814 Definition* defn = instr->AsDefinition(); | 746 Definition* defn = instr->AsDefinition(); |
| 815 if ((defn != NULL) && defn->is_used()) { | 747 if ((defn != NULL) && defn->is_used()) { |
| 816 __ Push(defn->locs()->out().reg()); | 748 __ Push(defn->locs()->out().reg()); |
| 817 } | 749 } |
| 818 } | 750 } |
| 819 | 751 |
| 820 | 752 |
| 821 // Input parameters: | 753 // Input parameters: |
| (...skipping 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1937 __ AddImmediate(SP, kDoubleSize); | 1869 __ AddImmediate(SP, kDoubleSize); |
| 1938 } | 1870 } |
| 1939 | 1871 |
| 1940 | 1872 |
| 1941 #undef __ | 1873 #undef __ |
| 1942 | 1874 |
| 1943 | 1875 |
| 1944 } // namespace dart | 1876 } // namespace dart |
| 1945 | 1877 |
| 1946 #endif // defined TARGET_ARCH_MIPS | 1878 #endif // defined TARGET_ARCH_MIPS |
| OLD | NEW |