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