OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/ppc/macro-assembler-ppc.h" | 10 #include "src/ppc/macro-assembler-ppc.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 UNREACHABLE(); | 92 UNREACHABLE(); |
93 return MemOperand(r0); | 93 return MemOperand(r0); |
94 } | 94 } |
95 | 95 |
96 MemOperand MemoryOperand(AddressingMode* mode, size_t first_index = 0) { | 96 MemOperand MemoryOperand(AddressingMode* mode, size_t first_index = 0) { |
97 return MemoryOperand(mode, &first_index); | 97 return MemoryOperand(mode, &first_index); |
98 } | 98 } |
99 | 99 |
100 MemOperand ToMemOperand(InstructionOperand* op) const { | 100 MemOperand ToMemOperand(InstructionOperand* op) const { |
101 DCHECK(op != NULL); | 101 DCHECK(op != NULL); |
| 102 DCHECK(!op->IsRegister()); |
| 103 DCHECK(!op->IsDoubleRegister()); |
102 DCHECK(op->IsStackSlot() || op->IsDoubleStackSlot()); | 104 DCHECK(op->IsStackSlot() || op->IsDoubleStackSlot()); |
103 FrameOffset offset = | 105 // The linkage computes where all spill slots are located. |
104 linkage()->GetFrameOffset(AllocatedOperand::cast(op)->index(), frame()); | 106 FrameOffset offset = linkage()->GetFrameOffset( |
| 107 AllocatedOperand::cast(op)->index(), frame(), 0); |
105 return MemOperand(offset.from_stack_pointer() ? sp : fp, offset.offset()); | 108 return MemOperand(offset.from_stack_pointer() ? sp : fp, offset.offset()); |
106 } | 109 } |
107 }; | 110 }; |
108 | 111 |
109 | 112 |
110 static inline bool HasRegisterInput(Instruction* instr, size_t index) { | 113 static inline bool HasRegisterInput(Instruction* instr, size_t index) { |
111 return instr->InputAt(index)->IsRegister(); | 114 return instr->InputAt(index)->IsRegister(); |
112 } | 115 } |
113 | 116 |
114 | 117 |
(...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1350 | 1353 |
1351 if (stack_slots > 0) { | 1354 if (stack_slots > 0) { |
1352 __ Add(sp, sp, -stack_slots * kPointerSize, r0); | 1355 __ Add(sp, sp, -stack_slots * kPointerSize, r0); |
1353 } | 1356 } |
1354 } | 1357 } |
1355 | 1358 |
1356 | 1359 |
1357 void CodeGenerator::AssembleReturn() { | 1360 void CodeGenerator::AssembleReturn() { |
1358 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 1361 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
1359 int stack_slots = frame()->GetSpillSlotCount(); | 1362 int stack_slots = frame()->GetSpillSlotCount(); |
1360 int pop_count = static_cast<int>(descriptor->StackParameterCount()); | |
1361 if (descriptor->kind() == CallDescriptor::kCallAddress) { | 1363 if (descriptor->kind() == CallDescriptor::kCallAddress) { |
1362 if (frame()->GetRegisterSaveAreaSize() > 0) { | 1364 if (frame()->GetRegisterSaveAreaSize() > 0) { |
1363 // Remove this frame's spill slots first. | 1365 // Remove this frame's spill slots first. |
1364 if (stack_slots > 0) { | 1366 if (stack_slots > 0) { |
1365 __ Add(sp, sp, stack_slots * kPointerSize, r0); | 1367 __ Add(sp, sp, stack_slots * kPointerSize, r0); |
1366 } | 1368 } |
1367 // Restore double registers. | 1369 // Restore double registers. |
1368 const RegList double_saves = descriptor->CalleeSavedFPRegisters(); | 1370 const RegList double_saves = descriptor->CalleeSavedFPRegisters(); |
1369 __ MultiPopDoubles(double_saves); | 1371 __ MultiPopDoubles(double_saves); |
1370 | 1372 |
1371 // Restore registers. | 1373 // Restore registers. |
1372 RegList frame_saves = 0; | 1374 RegList frame_saves = 0; |
1373 if (FLAG_enable_embedded_constant_pool) { | 1375 if (FLAG_enable_embedded_constant_pool) { |
1374 frame_saves |= kConstantPoolRegister.bit(); | 1376 frame_saves |= kConstantPoolRegister.bit(); |
1375 } | 1377 } |
1376 const RegList saves = descriptor->CalleeSavedRegisters() & ~frame_saves; | 1378 const RegList saves = descriptor->CalleeSavedRegisters() & ~frame_saves; |
1377 __ MultiPop(saves); | 1379 __ MultiPop(saves); |
1378 } | 1380 } |
| 1381 __ LeaveFrame(StackFrame::MANUAL); |
| 1382 __ Ret(); |
1379 } else if (descriptor->IsJSFunctionCall() || needs_frame_) { | 1383 } else if (descriptor->IsJSFunctionCall() || needs_frame_) { |
1380 // Canonicalize JSFunction return sites for now. | 1384 // Canonicalize JSFunction return sites for now. |
1381 if (return_label_.is_bound()) { | 1385 if (return_label_.is_bound()) { |
1382 __ b(&return_label_); | 1386 __ b(&return_label_); |
1383 return; | |
1384 } else { | 1387 } else { |
1385 __ bind(&return_label_); | 1388 __ bind(&return_label_); |
| 1389 int pop_count = static_cast<int>(descriptor->StackParameterCount()); |
| 1390 __ LeaveFrame(StackFrame::MANUAL, pop_count * kPointerSize); |
| 1391 __ Ret(); |
1386 } | 1392 } |
| 1393 } else { |
| 1394 __ Ret(); |
1387 } | 1395 } |
1388 __ LeaveFrame(StackFrame::MANUAL, pop_count * kPointerSize); | |
1389 __ Ret(); | |
1390 } | 1396 } |
1391 | 1397 |
1392 | 1398 |
1393 void CodeGenerator::AssembleMove(InstructionOperand* source, | 1399 void CodeGenerator::AssembleMove(InstructionOperand* source, |
1394 InstructionOperand* destination) { | 1400 InstructionOperand* destination) { |
1395 PPCOperandConverter g(this, NULL); | 1401 PPCOperandConverter g(this, NULL); |
1396 // Dispatch on the source and destination operand kinds. Not all | 1402 // Dispatch on the source and destination operand kinds. Not all |
1397 // combinations are possible. | 1403 // combinations are possible. |
1398 if (source->IsRegister()) { | 1404 if (source->IsRegister()) { |
1399 DCHECK(destination->IsRegister() || destination->IsStackSlot()); | 1405 DCHECK(destination->IsRegister() || destination->IsStackSlot()); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1588 } | 1594 } |
1589 } | 1595 } |
1590 } | 1596 } |
1591 } | 1597 } |
1592 | 1598 |
1593 #undef __ | 1599 #undef __ |
1594 | 1600 |
1595 } // namespace compiler | 1601 } // namespace compiler |
1596 } // namespace internal | 1602 } // namespace internal |
1597 } // namespace v8 | 1603 } // namespace v8 |
OLD | NEW |