Chromium Code Reviews| 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 1201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1212 break; | 1212 break; |
| 1213 case kX64Inc32: | 1213 case kX64Inc32: |
| 1214 __ incl(i.OutputRegister()); | 1214 __ incl(i.OutputRegister()); |
| 1215 break; | 1215 break; |
| 1216 case kX64Push: | 1216 case kX64Push: |
| 1217 if (HasImmediateInput(instr, 0)) { | 1217 if (HasImmediateInput(instr, 0)) { |
| 1218 __ pushq(i.InputImmediate(0)); | 1218 __ pushq(i.InputImmediate(0)); |
| 1219 } else { | 1219 } else { |
| 1220 if (instr->InputAt(0)->IsRegister()) { | 1220 if (instr->InputAt(0)->IsRegister()) { |
| 1221 __ pushq(i.InputRegister(0)); | 1221 __ pushq(i.InputRegister(0)); |
| 1222 } else if (instr->InputAt(0)->IsDoubleRegister()) { | |
| 1223 // TODO(titzer): use another machine instruction? | |
| 1224 __ subq(rsp, Immediate(8)); | |
|
Jarin
2015/08/03 10:38:18
Maybe replace 8 with kDoubleSize?
| |
| 1225 __ movsd(Operand(rsp, 0), i.InputDoubleRegister(0)); | |
| 1222 } else { | 1226 } else { |
| 1223 __ pushq(i.InputOperand(0)); | 1227 __ pushq(i.InputOperand(0)); |
| 1224 } | 1228 } |
| 1225 } | 1229 } |
| 1226 break; | 1230 break; |
| 1227 case kX64Poke: { | 1231 case kX64Poke: { |
| 1228 int const slot = MiscField::decode(instr->opcode()); | 1232 int const slot = MiscField::decode(instr->opcode()); |
| 1229 if (HasImmediateInput(instr, 0)) { | 1233 if (HasImmediateInput(instr, 0)) { |
| 1230 __ movq(Operand(rsp, slot * kPointerSize), i.InputImmediate(0)); | 1234 __ movq(Operand(rsp, slot * kPointerSize), i.InputImmediate(0)); |
| 1231 } else { | 1235 } else { |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1547 __ addp(rsp, Immediate(stack_size)); | 1551 __ addp(rsp, Immediate(stack_size)); |
| 1548 } | 1552 } |
| 1549 const RegList saves = descriptor->CalleeSavedRegisters(); | 1553 const RegList saves = descriptor->CalleeSavedRegisters(); |
| 1550 if (saves != 0) { | 1554 if (saves != 0) { |
| 1551 for (int i = 0; i < Register::kNumRegisters; i++) { | 1555 for (int i = 0; i < Register::kNumRegisters; i++) { |
| 1552 if (!((1 << i) & saves)) continue; | 1556 if (!((1 << i) & saves)) continue; |
| 1553 __ popq(Register::from_code(i)); | 1557 __ popq(Register::from_code(i)); |
| 1554 } | 1558 } |
| 1555 } | 1559 } |
| 1556 __ popq(rbp); // Pop caller's frame pointer. | 1560 __ popq(rbp); // Pop caller's frame pointer. |
| 1557 __ ret(0); | |
| 1558 } else { | 1561 } else { |
| 1559 // No saved registers. | 1562 // No saved registers. |
| 1560 __ movq(rsp, rbp); // Move stack pointer back to frame pointer. | 1563 __ movq(rsp, rbp); // Move stack pointer back to frame pointer. |
| 1561 __ popq(rbp); // Pop caller's frame pointer. | 1564 __ popq(rbp); // Pop caller's frame pointer. |
| 1562 __ ret(0); | |
| 1563 } | 1565 } |
| 1564 } else if (descriptor->IsJSFunctionCall() || needs_frame_) { | 1566 } else if (descriptor->IsJSFunctionCall() || needs_frame_) { |
| 1565 // Canonicalize JSFunction return sites for now. | 1567 // Canonicalize JSFunction return sites for now. |
| 1566 if (return_label_.is_bound()) { | 1568 if (return_label_.is_bound()) { |
| 1567 __ jmp(&return_label_); | 1569 __ jmp(&return_label_); |
| 1570 return; | |
| 1568 } else { | 1571 } else { |
| 1569 __ bind(&return_label_); | 1572 __ bind(&return_label_); |
| 1570 __ movq(rsp, rbp); // Move stack pointer back to frame pointer. | 1573 __ movq(rsp, rbp); // Move stack pointer back to frame pointer. |
| 1571 __ popq(rbp); // Pop caller's frame pointer. | 1574 __ popq(rbp); // Pop caller's frame pointer. |
| 1572 int pop_count = static_cast<int>(descriptor->StackParameterCount()); | |
| 1573 if (pop_count == 0) { | |
| 1574 __ Ret(); | |
| 1575 } else { | |
| 1576 __ Ret(pop_count * kPointerSize, rbx); | |
| 1577 } | |
| 1578 } | 1575 } |
| 1579 } else { | |
| 1580 __ Ret(); | |
| 1581 } | 1576 } |
| 1577 size_t pop_size = descriptor->StackParameterCount() * kPointerSize; | |
| 1578 // Might need rcx for scratch if pop_size is too big. | |
| 1579 DCHECK_EQ(0, descriptor->CalleeSavedRegisters() & rcx.bit()); | |
| 1580 __ Ret(static_cast<int>(pop_size), rcx); | |
| 1582 } | 1581 } |
| 1583 | 1582 |
| 1584 | 1583 |
| 1585 void CodeGenerator::AssembleMove(InstructionOperand* source, | 1584 void CodeGenerator::AssembleMove(InstructionOperand* source, |
| 1586 InstructionOperand* destination) { | 1585 InstructionOperand* destination) { |
| 1587 X64OperandConverter g(this, NULL); | 1586 X64OperandConverter g(this, NULL); |
| 1588 // Dispatch on the source and destination operand kinds. Not all | 1587 // Dispatch on the source and destination operand kinds. Not all |
| 1589 // combinations are possible. | 1588 // combinations are possible. |
| 1590 if (source->IsRegister()) { | 1589 if (source->IsRegister()) { |
| 1591 DCHECK(destination->IsRegister() || destination->IsStackSlot()); | 1590 DCHECK(destination->IsRegister() || destination->IsStackSlot()); |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1769 __ Nop(padding_size); | 1768 __ Nop(padding_size); |
| 1770 } | 1769 } |
| 1771 } | 1770 } |
| 1772 } | 1771 } |
| 1773 | 1772 |
| 1774 #undef __ | 1773 #undef __ |
| 1775 | 1774 |
| 1776 } // namespace internal | 1775 } // namespace internal |
| 1777 } // namespace compiler | 1776 } // namespace compiler |
| 1778 } // namespace v8 | 1777 } // namespace v8 |
| OLD | NEW |