| 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_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 "lib/error.h" | 10 #include "lib/error.h" |
| (...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 // EBP : points to previous frame pointer. | 791 // EBP : points to previous frame pointer. |
| 792 // EBP + 4 : points to return address. | 792 // EBP + 4 : points to return address. |
| 793 // EBP + 8 : address of last argument (arg n-1). | 793 // EBP + 8 : address of last argument (arg n-1). |
| 794 // ESP + 8 + 4*(n-1) : address of first argument (arg 0). | 794 // ESP + 8 + 4*(n-1) : address of first argument (arg 0). |
| 795 // ECX : ic-data. | 795 // ECX : ic-data. |
| 796 // EDX : arguments descriptor array. | 796 // EDX : arguments descriptor array. |
| 797 __ call(&StubCode::CallNoSuchMethodFunctionLabel()); | 797 __ call(&StubCode::CallNoSuchMethodFunctionLabel()); |
| 798 } | 798 } |
| 799 if (is_optimizing()) { | 799 if (is_optimizing()) { |
| 800 stackmap_table_builder_->AddEntry(assembler()->CodeSize(), | 800 stackmap_table_builder_->AddEntry(assembler()->CodeSize(), |
| 801 empty_stack_bitmap); | 801 empty_stack_bitmap, |
| 802 0); // No registers. |
| 802 } | 803 } |
| 803 | 804 |
| 804 | 805 |
| 805 if (FLAG_trace_functions) { | 806 if (FLAG_trace_functions) { |
| 806 __ pushl(EAX); // Preserve result. | 807 __ pushl(EAX); // Preserve result. |
| 807 __ PushObject(Function::ZoneHandle(function.raw())); | 808 __ PushObject(Function::ZoneHandle(function.raw())); |
| 808 // We do not use GenerateCallRuntime because of the non-standard (empty) | 809 // We do not use GenerateCallRuntime because of the non-standard (empty) |
| 809 // stackmap used here. | 810 // stackmap used here. |
| 810 __ CallRuntime(kTraceFunctionExitRuntimeEntry); | 811 __ CallRuntime(kTraceFunctionExitRuntimeEntry); |
| 811 AddCurrentDescriptor(PcDescriptors::kOther, | 812 AddCurrentDescriptor(PcDescriptors::kOther, |
| 812 Isolate::kNoDeoptId, | 813 Isolate::kNoDeoptId, |
| 813 0, // No token position. | 814 0, // No token position. |
| 814 CatchClauseNode::kInvalidTryIndex); | 815 CatchClauseNode::kInvalidTryIndex); |
| 815 if (is_optimizing()) { | 816 if (is_optimizing()) { |
| 816 stackmap_table_builder_->AddEntry(assembler()->CodeSize(), | 817 stackmap_table_builder_->AddEntry(assembler()->CodeSize(), |
| 817 empty_stack_bitmap); | 818 empty_stack_bitmap, |
| 819 0); // No registers. |
| 818 } | 820 } |
| 819 __ popl(EAX); // Remove argument. | 821 __ popl(EAX); // Remove argument. |
| 820 __ popl(EAX); // Restore result. | 822 __ popl(EAX); // Restore result. |
| 821 } | 823 } |
| 822 __ LeaveFrame(); | 824 __ LeaveFrame(); |
| 823 __ ret(); | 825 __ ret(); |
| 824 | 826 |
| 825 __ Bind(&all_arguments_processed); | 827 __ Bind(&all_arguments_processed); |
| 826 // Nullify originally passed arguments only after they have been copied and | 828 // Nullify originally passed arguments only after they have been copied and |
| 827 // checked, otherwise noSuchMethod would not see their original values. | 829 // checked, otherwise noSuchMethod would not see their original values. |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1109 __ SmiUntag(temp); | 1111 __ SmiUntag(temp); |
| 1110 __ cvtsi2sd(result, temp); | 1112 __ cvtsi2sd(result, temp); |
| 1111 __ Bind(&done); | 1113 __ Bind(&done); |
| 1112 } | 1114 } |
| 1113 | 1115 |
| 1114 | 1116 |
| 1115 void FlowGraphCompiler::SaveLiveRegisters(LocationSummary* locs) { | 1117 void FlowGraphCompiler::SaveLiveRegisters(LocationSummary* locs) { |
| 1116 // TODO(vegorov): consider saving only caller save (volatile) registers. | 1118 // TODO(vegorov): consider saving only caller save (volatile) registers. |
| 1117 const intptr_t xmm_regs_count = locs->live_registers()->xmm_regs_count(); | 1119 const intptr_t xmm_regs_count = locs->live_registers()->xmm_regs_count(); |
| 1118 if (xmm_regs_count > 0) { | 1120 if (xmm_regs_count > 0) { |
| 1119 intptr_t stack_offs = (StackSize() + 1) * kWordSize; | 1121 __ subl(ESP, Immediate(xmm_regs_count * kDoubleSize)); |
| 1122 intptr_t offset = 0; |
| 1120 for (intptr_t reg_idx = 0; reg_idx < kNumberOfXmmRegisters; ++reg_idx) { | 1123 for (intptr_t reg_idx = 0; reg_idx < kNumberOfXmmRegisters; ++reg_idx) { |
| 1121 XmmRegister xmm_reg = static_cast<XmmRegister>(reg_idx); | 1124 XmmRegister xmm_reg = static_cast<XmmRegister>(reg_idx); |
| 1122 if (locs->live_registers()->ContainsXmmRegister(xmm_reg)) { | 1125 if (locs->live_registers()->ContainsXmmRegister(xmm_reg)) { |
| 1123 __ movsd(Address(EBP, -stack_offs), xmm_reg); | 1126 __ movsd(Address(ESP, offset), xmm_reg); |
| 1124 stack_offs += kDoubleSize; | 1127 offset += kDoubleSize; |
| 1125 } | 1128 } |
| 1126 } | 1129 } |
| 1130 ASSERT(offset == (xmm_regs_count * kDoubleSize)); |
| 1127 } | 1131 } |
| 1128 | 1132 |
| 1129 for (intptr_t reg_idx = 0; reg_idx < kNumberOfCpuRegisters; ++reg_idx) { | 1133 for (intptr_t reg_idx = 0; reg_idx < kNumberOfCpuRegisters; ++reg_idx) { |
| 1130 Register reg = static_cast<Register>(reg_idx); | 1134 Register reg = static_cast<Register>(reg_idx); |
| 1131 if (locs->live_registers()->ContainsRegister(reg)) { | 1135 if (locs->live_registers()->ContainsRegister(reg)) { |
| 1132 __ pushl(reg); | 1136 __ pushl(reg); |
| 1133 } | 1137 } |
| 1134 } | 1138 } |
| 1135 } | 1139 } |
| 1136 | 1140 |
| 1137 | 1141 |
| 1138 void FlowGraphCompiler::RestoreLiveRegisters(LocationSummary* locs) { | 1142 void FlowGraphCompiler::RestoreLiveRegisters(LocationSummary* locs) { |
| 1139 for (intptr_t reg_idx = kNumberOfCpuRegisters - 1; reg_idx >= 0; --reg_idx) { | 1143 for (intptr_t reg_idx = kNumberOfCpuRegisters - 1; reg_idx >= 0; --reg_idx) { |
| 1140 Register reg = static_cast<Register>(reg_idx); | 1144 Register reg = static_cast<Register>(reg_idx); |
| 1141 if (locs->live_registers()->ContainsRegister(reg)) { | 1145 if (locs->live_registers()->ContainsRegister(reg)) { |
| 1142 __ popl(reg); | 1146 __ popl(reg); |
| 1143 } | 1147 } |
| 1144 } | 1148 } |
| 1145 | 1149 |
| 1146 const intptr_t xmm_regs_count = locs->live_registers()->xmm_regs_count(); | 1150 const intptr_t xmm_regs_count = locs->live_registers()->xmm_regs_count(); |
| 1147 if (xmm_regs_count > 0) { | 1151 if (xmm_regs_count > 0) { |
| 1148 intptr_t stack_offs = (StackSize() + 1) * kWordSize; | 1152 intptr_t offset = 0; |
| 1149 for (intptr_t reg_idx = 0; reg_idx < kNumberOfXmmRegisters; ++reg_idx) { | 1153 for (intptr_t reg_idx = 0; reg_idx < kNumberOfXmmRegisters; ++reg_idx) { |
| 1150 XmmRegister xmm_reg = static_cast<XmmRegister>(reg_idx); | 1154 XmmRegister xmm_reg = static_cast<XmmRegister>(reg_idx); |
| 1151 if (locs->live_registers()->ContainsXmmRegister(xmm_reg)) { | 1155 if (locs->live_registers()->ContainsXmmRegister(xmm_reg)) { |
| 1152 __ movsd(xmm_reg, Address(EBP, -stack_offs)); | 1156 __ movsd(xmm_reg, Address(ESP, offset)); |
| 1153 stack_offs += kDoubleSize; | 1157 offset += kDoubleSize; |
| 1154 } | 1158 } |
| 1155 } | 1159 } |
| 1160 ASSERT(offset == (xmm_regs_count * kDoubleSize)); |
| 1161 __ addl(ESP, Immediate(offset)); |
| 1156 } | 1162 } |
| 1157 } | 1163 } |
| 1158 | 1164 |
| 1159 | 1165 |
| 1160 #undef __ | 1166 #undef __ |
| 1161 #define __ compiler_->assembler()-> | 1167 #define __ compiler_->assembler()-> |
| 1162 | 1168 |
| 1163 | 1169 |
| 1164 static Address ToStackSlotAddress(Location loc) { | 1170 static Address ToStackSlotAddress(Location loc) { |
| 1165 const intptr_t index = loc.stack_index(); | 1171 const intptr_t index = loc.stack_index(); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1315 __ popl(ECX); | 1321 __ popl(ECX); |
| 1316 __ popl(EAX); | 1322 __ popl(EAX); |
| 1317 } | 1323 } |
| 1318 | 1324 |
| 1319 | 1325 |
| 1320 #undef __ | 1326 #undef __ |
| 1321 | 1327 |
| 1322 } // namespace dart | 1328 } // namespace dart |
| 1323 | 1329 |
| 1324 #endif // defined TARGET_ARCH_IA32 | 1330 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |