| 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_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 "lib/error.h" | 10 #include "lib/error.h" |
| (...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 797 // RBP : points to previous frame pointer. | 797 // RBP : points to previous frame pointer. |
| 798 // RBP + 8 : points to return address. | 798 // RBP + 8 : points to return address. |
| 799 // RBP + 16 : address of last argument (arg n-1). | 799 // RBP + 16 : address of last argument (arg n-1). |
| 800 // RSP + 16 + 8*(n-1) : address of first argument (arg 0). | 800 // RSP + 16 + 8*(n-1) : address of first argument (arg 0). |
| 801 // RBX : ic-data. | 801 // RBX : ic-data. |
| 802 // R10 : arguments descriptor array. | 802 // R10 : arguments descriptor array. |
| 803 __ call(&StubCode::CallNoSuchMethodFunctionLabel()); | 803 __ call(&StubCode::CallNoSuchMethodFunctionLabel()); |
| 804 } | 804 } |
| 805 if (is_optimizing()) { | 805 if (is_optimizing()) { |
| 806 stackmap_table_builder_->AddEntry(assembler()->CodeSize(), | 806 stackmap_table_builder_->AddEntry(assembler()->CodeSize(), |
| 807 empty_stack_bitmap); | 807 empty_stack_bitmap, |
| 808 0); |
| 808 } | 809 } |
| 809 | 810 |
| 810 if (FLAG_trace_functions) { | 811 if (FLAG_trace_functions) { |
| 811 __ pushq(RAX); // Preserve result. | 812 __ pushq(RAX); // Preserve result. |
| 812 __ PushObject(Function::ZoneHandle(function.raw())); | 813 __ PushObject(Function::ZoneHandle(function.raw())); |
| 813 // We do not use GenerateCallRuntime because of the non-standard (empty) | 814 // We do not use GenerateCallRuntime because of the non-standard (empty) |
| 814 // stackmap used here. | 815 // stackmap used here. |
| 815 __ CallRuntime(kTraceFunctionExitRuntimeEntry); | 816 __ CallRuntime(kTraceFunctionExitRuntimeEntry); |
| 816 AddCurrentDescriptor(PcDescriptors::kOther, | 817 AddCurrentDescriptor(PcDescriptors::kOther, |
| 817 Isolate::kNoDeoptId, | 818 Isolate::kNoDeoptId, |
| 818 0, // No token position. | 819 0, // No token position. |
| 819 CatchClauseNode::kInvalidTryIndex); | 820 CatchClauseNode::kInvalidTryIndex); |
| 820 if (is_optimizing()) { | 821 if (is_optimizing()) { |
| 821 stackmap_table_builder_->AddEntry(assembler()->CodeSize(), | 822 stackmap_table_builder_->AddEntry(assembler()->CodeSize(), |
| 822 empty_stack_bitmap); | 823 empty_stack_bitmap, |
| 824 0); |
| 823 } | 825 } |
| 824 __ popq(RAX); // Remove argument. | 826 __ popq(RAX); // Remove argument. |
| 825 __ popq(RAX); // Restore result. | 827 __ popq(RAX); // Restore result. |
| 826 } | 828 } |
| 827 __ LeaveFrame(); | 829 __ LeaveFrame(); |
| 828 __ ret(); | 830 __ ret(); |
| 829 | 831 |
| 830 __ Bind(&all_arguments_processed); | 832 __ Bind(&all_arguments_processed); |
| 831 // Nullify originally passed arguments only after they have been copied and | 833 // Nullify originally passed arguments only after they have been copied and |
| 832 // checked, otherwise noSuchMethod would not see their original values. | 834 // checked, otherwise noSuchMethod would not see their original values. |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1115 __ Bind(&is_smi); | 1117 __ Bind(&is_smi); |
| 1116 __ movq(temp, reg); | 1118 __ movq(temp, reg); |
| 1117 __ SmiUntag(temp); | 1119 __ SmiUntag(temp); |
| 1118 __ cvtsi2sd(result, temp); | 1120 __ cvtsi2sd(result, temp); |
| 1119 __ Bind(&done); | 1121 __ Bind(&done); |
| 1120 } | 1122 } |
| 1121 | 1123 |
| 1122 | 1124 |
| 1123 void FlowGraphCompiler::SaveLiveRegisters(LocationSummary* locs) { | 1125 void FlowGraphCompiler::SaveLiveRegisters(LocationSummary* locs) { |
| 1124 // TODO(vegorov): consider saving only caller save (volatile) registers. | 1126 // TODO(vegorov): consider saving only caller save (volatile) registers. |
| 1125 const intptr_t xmm_regs_count = locs->live_registers()->xmm_regs_count(); | 1127 intptr_t xmm_regs_count = locs->live_registers()->xmm_regs_count(); |
| 1126 if (xmm_regs_count > 0) { | 1128 if (xmm_regs_count > 0) { |
| 1127 // Pointer maps don't support pushed untagged values so we reserve spill | 1129 __ subq(RSP, Immediate(xmm_regs_count * kDoubleSize)); |
| 1128 // slots at the top of the spill slot area for live XMM registers. | 1130 intptr_t offset = 0; |
| 1129 intptr_t stack_offs = (StackSize() + 1) * kWordSize; | |
| 1130 for (intptr_t reg_idx = 0; reg_idx < kNumberOfXmmRegisters; ++reg_idx) { | 1131 for (intptr_t reg_idx = 0; reg_idx < kNumberOfXmmRegisters; ++reg_idx) { |
| 1131 XmmRegister xmm_reg = static_cast<XmmRegister>(reg_idx); | 1132 XmmRegister xmm_reg = static_cast<XmmRegister>(reg_idx); |
| 1132 if (locs->live_registers()->ContainsXmmRegister(xmm_reg)) { | 1133 if (locs->live_registers()->ContainsXmmRegister(xmm_reg)) { |
| 1133 __ movsd(Address(RBP, -stack_offs), xmm_reg); | 1134 __ movsd(Address(RSP, offset), xmm_reg); |
| 1134 stack_offs += kDoubleSize; | 1135 offset += kDoubleSize; |
| 1135 } | 1136 } |
| 1136 } | 1137 } |
| 1138 ASSERT(offset == (xmm_regs_count * kDoubleSize)); |
| 1137 } | 1139 } |
| 1138 | 1140 |
| 1139 for (intptr_t reg_idx = 0; reg_idx < kNumberOfCpuRegisters; ++reg_idx) { | 1141 for (intptr_t reg_idx = 0; reg_idx < kNumberOfCpuRegisters; ++reg_idx) { |
| 1140 Register reg = static_cast<Register>(reg_idx); | 1142 Register reg = static_cast<Register>(reg_idx); |
| 1141 if (locs->live_registers()->ContainsRegister(reg)) { | 1143 if (locs->live_registers()->ContainsRegister(reg)) { |
| 1142 __ pushq(reg); | 1144 __ pushq(reg); |
| 1143 } | 1145 } |
| 1144 } | 1146 } |
| 1145 } | 1147 } |
| 1146 | 1148 |
| 1147 | 1149 |
| 1148 void FlowGraphCompiler::RestoreLiveRegisters(LocationSummary* locs) { | 1150 void FlowGraphCompiler::RestoreLiveRegisters(LocationSummary* locs) { |
| 1149 for (intptr_t reg_idx = kNumberOfCpuRegisters - 1; reg_idx >= 0; --reg_idx) { | 1151 for (intptr_t reg_idx = kNumberOfCpuRegisters - 1; reg_idx >= 0; --reg_idx) { |
| 1150 Register reg = static_cast<Register>(reg_idx); | 1152 Register reg = static_cast<Register>(reg_idx); |
| 1151 if (locs->live_registers()->ContainsRegister(reg)) { | 1153 if (locs->live_registers()->ContainsRegister(reg)) { |
| 1152 __ popq(reg); | 1154 __ popq(reg); |
| 1153 } | 1155 } |
| 1154 } | 1156 } |
| 1155 | 1157 |
| 1156 const intptr_t xmm_regs_count = locs->live_registers()->xmm_regs_count(); | 1158 const intptr_t xmm_regs_count = locs->live_registers()->xmm_regs_count(); |
| 1157 if (xmm_regs_count > 0) { | 1159 if (xmm_regs_count > 0) { |
| 1158 // Pointer maps don't support pushed untagged values so we reserve spill | 1160 intptr_t offset = 0; |
| 1159 // slots at the top of the spill slot area for live XMM registers. | |
| 1160 intptr_t stack_offs = (StackSize() + 1) * kWordSize; | |
| 1161 for (intptr_t reg_idx = 0; reg_idx < kNumberOfXmmRegisters; ++reg_idx) { | 1161 for (intptr_t reg_idx = 0; reg_idx < kNumberOfXmmRegisters; ++reg_idx) { |
| 1162 XmmRegister xmm_reg = static_cast<XmmRegister>(reg_idx); | 1162 XmmRegister xmm_reg = static_cast<XmmRegister>(reg_idx); |
| 1163 if (locs->live_registers()->ContainsXmmRegister(xmm_reg)) { | 1163 if (locs->live_registers()->ContainsXmmRegister(xmm_reg)) { |
| 1164 __ movsd(xmm_reg, Address(RBP, -stack_offs)); | 1164 __ movsd(xmm_reg, Address(RSP, offset)); |
| 1165 stack_offs += kDoubleSize; | 1165 offset += kDoubleSize; |
| 1166 } | 1166 } |
| 1167 } | 1167 } |
| 1168 ASSERT(offset == (xmm_regs_count * kDoubleSize)); |
| 1169 __ addq(RSP, Immediate(offset)); |
| 1168 } | 1170 } |
| 1169 } | 1171 } |
| 1170 | 1172 |
| 1171 | 1173 |
| 1172 #undef __ | 1174 #undef __ |
| 1173 #define __ compiler_->assembler()-> | 1175 #define __ compiler_->assembler()-> |
| 1174 | 1176 |
| 1175 | 1177 |
| 1176 static Address ToStackSlotAddress(Location loc) { | 1178 static Address ToStackSlotAddress(Location loc) { |
| 1177 const intptr_t index = loc.stack_index(); | 1179 const intptr_t index = loc.stack_index(); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1305 void ParallelMoveResolver::Exchange(const Address& mem1, const Address& mem2) { | 1307 void ParallelMoveResolver::Exchange(const Address& mem1, const Address& mem2) { |
| 1306 __ Exchange(mem1, mem2); | 1308 __ Exchange(mem1, mem2); |
| 1307 } | 1309 } |
| 1308 | 1310 |
| 1309 | 1311 |
| 1310 #undef __ | 1312 #undef __ |
| 1311 | 1313 |
| 1312 } // namespace dart | 1314 } // namespace dart |
| 1313 | 1315 |
| 1314 #endif // defined TARGET_ARCH_X64 | 1316 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |