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/ia32/assembler-ia32.h" | 10 #include "src/ia32/assembler-ia32.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 | 39 |
40 Operand ToOperand(InstructionOperand* op, int extra = 0) { | 40 Operand ToOperand(InstructionOperand* op, int extra = 0) { |
41 if (op->IsRegister()) { | 41 if (op->IsRegister()) { |
42 DCHECK(extra == 0); | 42 DCHECK(extra == 0); |
43 return Operand(ToRegister(op)); | 43 return Operand(ToRegister(op)); |
44 } else if (op->IsDoubleRegister()) { | 44 } else if (op->IsDoubleRegister()) { |
45 DCHECK(extra == 0); | 45 DCHECK(extra == 0); |
46 return Operand(ToDoubleRegister(op)); | 46 return Operand(ToDoubleRegister(op)); |
47 } | 47 } |
48 DCHECK(op->IsStackSlot() || op->IsDoubleStackSlot()); | 48 DCHECK(op->IsStackSlot() || op->IsDoubleStackSlot()); |
49 FrameOffset offset = | 49 // The linkage computes where all spill slots are located. |
50 linkage()->GetFrameOffset(AllocatedOperand::cast(op)->index(), frame()); | 50 FrameOffset offset = linkage()->GetFrameOffset( |
51 return Operand(offset.from_stack_pointer() ? esp : ebp, | 51 AllocatedOperand::cast(op)->index(), frame(), extra); |
52 offset.offset() + extra); | 52 return Operand(offset.from_stack_pointer() ? esp : ebp, offset.offset()); |
53 } | 53 } |
54 | 54 |
55 Operand HighOperand(InstructionOperand* op) { | 55 Operand HighOperand(InstructionOperand* op) { |
56 DCHECK(op->IsDoubleStackSlot()); | 56 DCHECK(op->IsDoubleStackSlot()); |
57 return ToOperand(op, kPointerSize); | 57 return ToOperand(op, kPointerSize); |
58 } | 58 } |
59 | 59 |
60 Immediate ToImmediate(InstructionOperand* operand) { | 60 Immediate ToImmediate(InstructionOperand* operand) { |
61 Constant constant = ToConstant(operand); | 61 Constant constant = ToConstant(operand); |
62 switch (constant.type()) { | 62 switch (constant.type()) { |
(...skipping 1255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1318 __ add(esp, Immediate(stack_slots * kPointerSize)); | 1318 __ add(esp, Immediate(stack_slots * kPointerSize)); |
1319 } | 1319 } |
1320 // Restore registers. | 1320 // Restore registers. |
1321 if (saves != 0) { | 1321 if (saves != 0) { |
1322 for (int i = 0; i < Register::kNumRegisters; i++) { | 1322 for (int i = 0; i < Register::kNumRegisters; i++) { |
1323 if (!((1 << i) & saves)) continue; | 1323 if (!((1 << i) & saves)) continue; |
1324 __ pop(Register::from_code(i)); | 1324 __ pop(Register::from_code(i)); |
1325 } | 1325 } |
1326 } | 1326 } |
1327 __ pop(ebp); // Pop caller's frame pointer. | 1327 __ pop(ebp); // Pop caller's frame pointer. |
| 1328 __ ret(0); |
1328 } else { | 1329 } else { |
1329 // No saved registers. | 1330 // No saved registers. |
1330 __ mov(esp, ebp); // Move stack pointer back to frame pointer. | 1331 __ mov(esp, ebp); // Move stack pointer back to frame pointer. |
1331 __ pop(ebp); // Pop caller's frame pointer. | 1332 __ pop(ebp); // Pop caller's frame pointer. |
| 1333 __ ret(0); |
1332 } | 1334 } |
1333 } else if (descriptor->IsJSFunctionCall() || needs_frame_) { | 1335 } else if (descriptor->IsJSFunctionCall() || needs_frame_) { |
1334 // Canonicalize JSFunction return sites for now. | 1336 // Canonicalize JSFunction return sites for now. |
1335 if (return_label_.is_bound()) { | 1337 if (return_label_.is_bound()) { |
1336 __ jmp(&return_label_); | 1338 __ jmp(&return_label_); |
1337 return; | |
1338 } else { | 1339 } else { |
1339 __ bind(&return_label_); | 1340 __ bind(&return_label_); |
1340 __ mov(esp, ebp); // Move stack pointer back to frame pointer. | 1341 __ mov(esp, ebp); // Move stack pointer back to frame pointer. |
1341 __ pop(ebp); // Pop caller's frame pointer. | 1342 __ pop(ebp); // Pop caller's frame pointer. |
| 1343 int pop_count = static_cast<int>(descriptor->StackParameterCount()); |
| 1344 if (pop_count == 0) { |
| 1345 __ ret(0); |
| 1346 } else { |
| 1347 __ Ret(pop_count * kPointerSize, ebx); |
| 1348 } |
1342 } | 1349 } |
| 1350 } else { |
| 1351 __ ret(0); |
1343 } | 1352 } |
1344 size_t pop_size = descriptor->StackParameterCount() * kPointerSize; | |
1345 // Might need ecx for scratch if pop_size is too big. | |
1346 DCHECK_EQ(0, descriptor->CalleeSavedRegisters() & ecx.bit()); | |
1347 __ Ret(static_cast<int>(pop_size), ecx); | |
1348 } | 1353 } |
1349 | 1354 |
1350 | 1355 |
1351 void CodeGenerator::AssembleMove(InstructionOperand* source, | 1356 void CodeGenerator::AssembleMove(InstructionOperand* source, |
1352 InstructionOperand* destination) { | 1357 InstructionOperand* destination) { |
1353 IA32OperandConverter g(this, NULL); | 1358 IA32OperandConverter g(this, NULL); |
1354 // Dispatch on the source and destination operand kinds. Not all | 1359 // Dispatch on the source and destination operand kinds. Not all |
1355 // combinations are possible. | 1360 // combinations are possible. |
1356 if (source->IsRegister()) { | 1361 if (source->IsRegister()) { |
1357 DCHECK(destination->IsRegister() || destination->IsStackSlot()); | 1362 DCHECK(destination->IsRegister() || destination->IsStackSlot()); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1533 __ Nop(padding_size); | 1538 __ Nop(padding_size); |
1534 } | 1539 } |
1535 } | 1540 } |
1536 } | 1541 } |
1537 | 1542 |
1538 #undef __ | 1543 #undef __ |
1539 | 1544 |
1540 } // namespace compiler | 1545 } // namespace compiler |
1541 } // namespace internal | 1546 } // namespace internal |
1542 } // namespace v8 | 1547 } // namespace v8 |
OLD | NEW |