| 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 "lib/error.h" | 10 #include "lib/error.h" |
| (...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 AddCurrentDescriptor(PcDescriptors::kDeopt, | 739 AddCurrentDescriptor(PcDescriptors::kDeopt, |
| 740 assert->deopt_id(), | 740 assert->deopt_id(), |
| 741 assert->token_pos()); | 741 assert->token_pos()); |
| 742 } else if (instr->IsGuardField() || | 742 } else if (instr->IsGuardField() || |
| 743 instr->CanBecomeDeoptimizationTarget()) { | 743 instr->CanBecomeDeoptimizationTarget()) { |
| 744 AddCurrentDescriptor(PcDescriptors::kDeopt, | 744 AddCurrentDescriptor(PcDescriptors::kDeopt, |
| 745 instr->deopt_id(), | 745 instr->deopt_id(), |
| 746 Scanner::kDummyTokenIndex); | 746 Scanner::kDummyTokenIndex); |
| 747 } | 747 } |
| 748 AllocateRegistersLocally(instr); | 748 AllocateRegistersLocally(instr); |
| 749 } else if (instr->MayThrow() && |
| 750 (CurrentTryIndex() != CatchClauseNode::kInvalidTryIndex)) { |
| 751 // Optimized try-block: Sync locals to fixed stack locations. |
| 752 EmitTrySync(instr, CurrentTryIndex()); |
| 753 } |
| 754 } |
| 755 |
| 756 |
| 757 // TODO(regis): Pass an offset instead of an Address to avoid addressing |
| 758 // mode restrictions and remove Operand::Equals() on IA32/X64 and |
| 759 // Address::Equals() on ARM/MIPS. |
| 760 void FlowGraphCompiler::EmitTrySyncMove(Address dest, |
| 761 Location loc, |
| 762 bool* push_emitted) { |
| 763 if (loc.IsConstant()) { |
| 764 if (!*push_emitted) { |
| 765 __ Push(T0); |
| 766 *push_emitted = true; |
| 767 } |
| 768 __ LoadObject(T0, loc.constant()); |
| 769 __ sw(T0, dest); |
| 770 } else if (loc.IsRegister()) { |
| 771 if (*push_emitted && loc.reg() == T0) { |
| 772 __ lw(T0, Address(SP, 0)); |
| 773 __ sw(T0, dest); |
| 774 } else { |
| 775 __ sw(loc.reg(), dest); |
| 776 } |
| 777 } else { |
| 778 Address src = loc.ToStackSlotAddress(); |
| 779 if (!src.Equals(dest)) { |
| 780 if (!*push_emitted) { |
| 781 __ Push(T0); |
| 782 *push_emitted = true; |
| 783 } |
| 784 __ lw(T0, src); |
| 785 __ sw(T0, dest); |
| 786 } |
| 787 } |
| 788 } |
| 789 |
| 790 |
| 791 void FlowGraphCompiler::EmitTrySync(Instruction* instr, intptr_t try_index) { |
| 792 ASSERT(is_optimizing()); |
| 793 Environment* env = instr->env(); |
| 794 CatchBlockEntryInstr* catch_block = |
| 795 flow_graph().graph_entry()->GetCatchEntry(try_index); |
| 796 const GrowableArray<Definition*>* idefs = catch_block->initial_definitions(); |
| 797 // Parameters. |
| 798 intptr_t i = 0; |
| 799 bool push_emitted = false; |
| 800 const intptr_t num_non_copied_params = flow_graph().num_non_copied_params(); |
| 801 const intptr_t param_base = |
| 802 kParamEndSlotFromFp + num_non_copied_params; |
| 803 for (; i < num_non_copied_params; ++i) { |
| 804 if ((*idefs)[i]->IsConstant()) continue; // Common constants |
| 805 Location loc = env->LocationAt(i); |
| 806 Address dest(FP, (param_base - i) * kWordSize); |
| 807 EmitTrySyncMove(dest, loc, &push_emitted); |
| 808 } |
| 809 |
| 810 // Process locals. Skip exception_var and stacktrace_var. |
| 811 CatchEntryInstr* catch_entry = catch_block->next()->AsCatchEntry(); |
| 812 intptr_t local_base = kFirstLocalSlotFromFp + num_non_copied_params; |
| 813 intptr_t ex_idx = local_base - catch_entry->exception_var().index(); |
| 814 intptr_t st_idx = local_base - catch_entry->stacktrace_var().index(); |
| 815 for (; i < flow_graph().variable_count(); ++i) { |
| 816 if (i == ex_idx || i == st_idx) continue; |
| 817 if ((*idefs)[i]->IsConstant()) continue; |
| 818 Location loc = env->LocationAt(i); |
| 819 Address dest(FP, (local_base - i) * kWordSize); |
| 820 EmitTrySyncMove(dest, loc, &push_emitted); |
| 821 // Update safepoint bitmap to indicate that the target location |
| 822 // now contains a pointer. |
| 823 instr->locs()->stack_bitmap()->Set(i - num_non_copied_params, true); |
| 824 } |
| 825 if (push_emitted) { |
| 826 __ Pop(T0); |
| 749 } | 827 } |
| 750 } | 828 } |
| 751 | 829 |
| 752 | 830 |
| 753 void FlowGraphCompiler::EmitInstructionEpilogue(Instruction* instr) { | 831 void FlowGraphCompiler::EmitInstructionEpilogue(Instruction* instr) { |
| 754 if (is_optimizing()) return; | 832 if (is_optimizing()) return; |
| 755 Definition* defn = instr->AsDefinition(); | 833 Definition* defn = instr->AsDefinition(); |
| 756 if ((defn != NULL) && defn->is_used()) { | 834 if ((defn != NULL) && defn->is_used()) { |
| 757 __ Push(defn->locs()->out().reg()); | 835 __ Push(defn->locs()->out().reg()); |
| 758 } | 836 } |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1051 __ Branch(&StubCode::OptimizeFunctionLabel()); | 1129 __ Branch(&StubCode::OptimizeFunctionLabel()); |
| 1052 | 1130 |
| 1053 __ Bind(&dont_branch); | 1131 __ Bind(&dont_branch); |
| 1054 } | 1132 } |
| 1055 } else { | 1133 } else { |
| 1056 AddCurrentDescriptor(PcDescriptors::kEntryPatch, | 1134 AddCurrentDescriptor(PcDescriptors::kEntryPatch, |
| 1057 Isolate::kNoDeoptId, | 1135 Isolate::kNoDeoptId, |
| 1058 0); // No token position. | 1136 0); // No token position. |
| 1059 } | 1137 } |
| 1060 __ Comment("Enter frame"); | 1138 __ Comment("Enter frame"); |
| 1061 __ EnterDartFrame((StackSize() * kWordSize)); | 1139 __ EnterDartFrame(StackSize() * kWordSize); |
| 1062 } | 1140 } |
| 1063 | 1141 |
| 1064 | 1142 |
| 1065 // Input parameters: | 1143 // Input parameters: |
| 1066 // RA: return address. | 1144 // RA: return address. |
| 1067 // SP: address of last argument. | 1145 // SP: address of last argument. |
| 1068 // FP: caller's frame pointer. | 1146 // FP: caller's frame pointer. |
| 1069 // PP: caller's pool pointer. | 1147 // PP: caller's pool pointer. |
| 1070 // S5: ic-data. | 1148 // S5: ic-data. |
| 1071 // S4: arguments descriptor array. | 1149 // S4: arguments descriptor array. |
| (...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1919 __ AddImmediate(SP, kDoubleSize); | 1997 __ AddImmediate(SP, kDoubleSize); |
| 1920 } | 1998 } |
| 1921 | 1999 |
| 1922 | 2000 |
| 1923 #undef __ | 2001 #undef __ |
| 1924 | 2002 |
| 1925 | 2003 |
| 1926 } // namespace dart | 2004 } // namespace dart |
| 1927 | 2005 |
| 1928 #endif // defined TARGET_ARCH_MIPS | 2006 #endif // defined TARGET_ARCH_MIPS |
| OLD | NEW |