Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(269)

Side by Side Diff: src/compiler/x64/code-generator-x64.cc

Issue 1284893002: Reland: [turbofan] Various fixes to allow unboxed doubles as arguments in registers and on the stac… (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/register-allocator-verifier.cc ('k') | src/compiler/x87/code-generator-x87.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 30 matching lines...) Expand all
41 Constant constant = ToConstant(operand); 41 Constant constant = ToConstant(operand);
42 if (constant.type() == Constant::kFloat64) { 42 if (constant.type() == Constant::kFloat64) {
43 DCHECK_EQ(0, bit_cast<int64_t>(constant.ToFloat64())); 43 DCHECK_EQ(0, bit_cast<int64_t>(constant.ToFloat64()));
44 return Immediate(0); 44 return Immediate(0);
45 } 45 }
46 return Immediate(constant.ToInt32()); 46 return Immediate(constant.ToInt32());
47 } 47 }
48 48
49 Operand ToOperand(InstructionOperand* op, int extra = 0) { 49 Operand ToOperand(InstructionOperand* op, int extra = 0) {
50 DCHECK(op->IsStackSlot() || op->IsDoubleStackSlot()); 50 DCHECK(op->IsStackSlot() || op->IsDoubleStackSlot());
51 // The linkage computes where all spill slots are located. 51 FrameOffset offset =
52 FrameOffset offset = linkage()->GetFrameOffset( 52 linkage()->GetFrameOffset(AllocatedOperand::cast(op)->index(), frame());
53 AllocatedOperand::cast(op)->index(), frame(), extra); 53 return Operand(offset.from_stack_pointer() ? rsp : rbp,
54 return Operand(offset.from_stack_pointer() ? rsp : rbp, offset.offset()); 54 offset.offset() + extra);
55 } 55 }
56 56
57 static size_t NextOffset(size_t* offset) { 57 static size_t NextOffset(size_t* offset) {
58 size_t i = *offset; 58 size_t i = *offset;
59 (*offset)++; 59 (*offset)++;
60 return i; 60 return i;
61 } 61 }
62 62
63 static ScaleFactor ScaleFor(AddressingMode one, AddressingMode mode) { 63 static ScaleFactor ScaleFor(AddressingMode one, AddressingMode mode) {
64 STATIC_ASSERT(0 == static_cast<int>(times_1)); 64 STATIC_ASSERT(0 == static_cast<int>(times_1));
(...skipping 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(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
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
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
OLDNEW
« no previous file with comments | « src/compiler/register-allocator-verifier.cc ('k') | src/compiler/x87/code-generator-x87.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698