OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler/code-generator.h" | 5 #include "src/compiler/code-generator.h" |
6 | 6 |
7 #include "src/compiler/code-generator-impl.h" | 7 #include "src/compiler/code-generator-impl.h" |
8 #include "src/compiler/gap-resolver.h" | 8 #include "src/compiler/gap-resolver.h" |
9 #include "src/compiler/node-matchers.h" | 9 #include "src/compiler/node-matchers.h" |
10 #include "src/scopes.h" | 10 #include "src/scopes.h" |
(...skipping 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1171 __ pushq(Register::from_code(i)); | 1171 __ pushq(Register::from_code(i)); |
1172 register_save_area_size += kPointerSize; | 1172 register_save_area_size += kPointerSize; |
1173 } | 1173 } |
1174 frame()->SetRegisterSaveAreaSize(register_save_area_size); | 1174 frame()->SetRegisterSaveAreaSize(register_save_area_size); |
1175 } | 1175 } |
1176 } else if (descriptor->IsJSFunctionCall()) { | 1176 } else if (descriptor->IsJSFunctionCall()) { |
1177 CompilationInfo* info = this->info(); | 1177 CompilationInfo* info = this->info(); |
1178 __ Prologue(info->IsCodePreAgingActive()); | 1178 __ Prologue(info->IsCodePreAgingActive()); |
1179 frame()->SetRegisterSaveAreaSize( | 1179 frame()->SetRegisterSaveAreaSize( |
1180 StandardFrameConstants::kFixedFrameSizeFromFp); | 1180 StandardFrameConstants::kFixedFrameSizeFromFp); |
1181 } else { | 1181 } else if (stack_slots > 0) { |
1182 __ StubPrologue(); | 1182 __ StubPrologue(); |
1183 frame()->SetRegisterSaveAreaSize( | 1183 frame()->SetRegisterSaveAreaSize( |
1184 StandardFrameConstants::kFixedFrameSizeFromFp); | 1184 StandardFrameConstants::kFixedFrameSizeFromFp); |
1185 } | 1185 } |
1186 | 1186 |
1187 if (info()->is_osr()) { | 1187 if (info()->is_osr()) { |
1188 // TurboFan OSR-compiled functions cannot be entered directly. | 1188 // TurboFan OSR-compiled functions cannot be entered directly. |
1189 __ Abort(kShouldNotDirectlyEnterOsrFunction); | 1189 __ Abort(kShouldNotDirectlyEnterOsrFunction); |
1190 | 1190 |
1191 // Unoptimized code jumps directly to this entrypoint while the unoptimized | 1191 // Unoptimized code jumps directly to this entrypoint while the unoptimized |
1192 // frame is still on the stack. Optimized code uses OSR values directly from | 1192 // frame is still on the stack. Optimized code uses OSR values directly from |
1193 // the unoptimized frame. Thus, all that needs to be done is to allocate the | 1193 // the unoptimized frame. Thus, all that needs to be done is to allocate the |
1194 // remaining stack slots. | 1194 // remaining stack slots. |
1195 if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); | 1195 if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); |
1196 osr_pc_offset_ = __ pc_offset(); | 1196 osr_pc_offset_ = __ pc_offset(); |
1197 DCHECK(stack_slots >= frame()->GetOsrStackSlotCount()); | 1197 DCHECK(stack_slots >= frame()->GetOsrStackSlotCount()); |
1198 stack_slots -= frame()->GetOsrStackSlotCount(); | 1198 stack_slots -= frame()->GetOsrStackSlotCount(); |
1199 } | 1199 } |
1200 | 1200 |
1201 if (stack_slots > 0) { | 1201 if (stack_slots > 0) { |
1202 __ subq(rsp, Immediate(stack_slots * kPointerSize)); | 1202 __ subq(rsp, Immediate(stack_slots * kPointerSize)); |
1203 } | 1203 } |
1204 } | 1204 } |
1205 | 1205 |
1206 | 1206 |
1207 void CodeGenerator::AssembleReturn() { | 1207 void CodeGenerator::AssembleReturn() { |
1208 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 1208 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
| 1209 int stack_slots = frame()->GetSpillSlotCount(); |
1209 if (descriptor->kind() == CallDescriptor::kCallAddress) { | 1210 if (descriptor->kind() == CallDescriptor::kCallAddress) { |
1210 if (frame()->GetRegisterSaveAreaSize() > 0) { | 1211 if (frame()->GetRegisterSaveAreaSize() > 0) { |
1211 // Remove this frame's spill slots first. | 1212 // Remove this frame's spill slots first. |
1212 int stack_slots = frame()->GetSpillSlotCount(); | |
1213 if (stack_slots > 0) { | 1213 if (stack_slots > 0) { |
1214 __ addq(rsp, Immediate(stack_slots * kPointerSize)); | 1214 __ addq(rsp, Immediate(stack_slots * kPointerSize)); |
1215 } | 1215 } |
1216 const RegList saves = descriptor->CalleeSavedRegisters(); | 1216 const RegList saves = descriptor->CalleeSavedRegisters(); |
1217 // Restore registers. | 1217 // Restore registers. |
1218 if (saves != 0) { | 1218 if (saves != 0) { |
1219 for (int i = 0; i < Register::kNumRegisters; i++) { | 1219 for (int i = 0; i < Register::kNumRegisters; i++) { |
1220 if (!((1 << i) & saves)) continue; | 1220 if (!((1 << i) & saves)) continue; |
1221 __ popq(Register::from_code(i)); | 1221 __ popq(Register::from_code(i)); |
1222 } | 1222 } |
1223 } | 1223 } |
1224 __ popq(rbp); // Pop caller's frame pointer. | 1224 __ popq(rbp); // Pop caller's frame pointer. |
1225 __ ret(0); | 1225 __ ret(0); |
1226 } else { | 1226 } else { |
1227 // No saved registers. | 1227 // No saved registers. |
1228 __ movq(rsp, rbp); // Move stack pointer back to frame pointer. | 1228 __ movq(rsp, rbp); // Move stack pointer back to frame pointer. |
1229 __ popq(rbp); // Pop caller's frame pointer. | 1229 __ popq(rbp); // Pop caller's frame pointer. |
1230 __ ret(0); | 1230 __ ret(0); |
1231 } | 1231 } |
1232 } else { | 1232 } else if (descriptor->IsJSFunctionCall() || stack_slots > 0) { |
1233 __ movq(rsp, rbp); // Move stack pointer back to frame pointer. | 1233 __ movq(rsp, rbp); // Move stack pointer back to frame pointer. |
1234 __ popq(rbp); // Pop caller's frame pointer. | 1234 __ popq(rbp); // Pop caller's frame pointer. |
1235 int pop_count = descriptor->IsJSFunctionCall() | 1235 int pop_count = descriptor->IsJSFunctionCall() |
1236 ? static_cast<int>(descriptor->JSParameterCount()) | 1236 ? static_cast<int>(descriptor->JSParameterCount()) |
1237 : 0; | 1237 : 0; |
1238 __ ret(pop_count * kPointerSize); | 1238 __ ret(pop_count * kPointerSize); |
| 1239 } else { |
| 1240 __ ret(0); |
1239 } | 1241 } |
1240 } | 1242 } |
1241 | 1243 |
1242 | 1244 |
1243 void CodeGenerator::AssembleMove(InstructionOperand* source, | 1245 void CodeGenerator::AssembleMove(InstructionOperand* source, |
1244 InstructionOperand* destination) { | 1246 InstructionOperand* destination) { |
1245 X64OperandConverter g(this, NULL); | 1247 X64OperandConverter g(this, NULL); |
1246 // Dispatch on the source and destination operand kinds. Not all | 1248 // Dispatch on the source and destination operand kinds. Not all |
1247 // combinations are possible. | 1249 // combinations are possible. |
1248 if (source->IsRegister()) { | 1250 if (source->IsRegister()) { |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1418 } | 1420 } |
1419 } | 1421 } |
1420 MarkLazyDeoptSite(); | 1422 MarkLazyDeoptSite(); |
1421 } | 1423 } |
1422 | 1424 |
1423 #undef __ | 1425 #undef __ |
1424 | 1426 |
1425 } // namespace internal | 1427 } // namespace internal |
1426 } // namespace compiler | 1428 } // namespace compiler |
1427 } // namespace v8 | 1429 } // namespace v8 |
OLD | NEW |