Chromium Code Reviews| Index: src/compiler/x64/code-generator-x64.cc |
| diff --git a/src/compiler/x64/code-generator-x64.cc b/src/compiler/x64/code-generator-x64.cc |
| index 0f7f95de00fd6b78cedb7fa4c1be1c03b4c7b89d..00b538395447786938564f1f07b3eaf5a04d659a 100644 |
| --- a/src/compiler/x64/code-generator-x64.cc |
| +++ b/src/compiler/x64/code-generator-x64.cc |
| @@ -527,6 +527,23 @@ class OutOfLineTruncateDoubleToI final : public OutOfLineCode { |
| } while (false) |
| +void CodeGenerator::FixFrameForTailCall() { |
|
Benedikt Meurer
2015/04/29 04:06:05
Hm, FixFrameForTailCall is not an appropriate name
Sven Panne
2015/04/29 10:24:18
Done.
|
| + CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
| + int stack_slots = frame()->GetSpillSlotCount(); |
| + if (descriptor->IsJSFunctionCall() || stack_slots > 0) { |
| + __ movq(rsp, rbp); |
| + __ popq(rbp); |
| + int32_t bytes_to_pop = |
| + descriptor->IsJSFunctionCall() |
| + ? static_cast<int32_t>(descriptor->JSParameterCount() * |
| + kPointerSize) |
| + : 0; |
| + __ popq(Operand(rsp, bytes_to_pop)); |
|
Benedikt Meurer
2015/04/29 04:06:05
Had to close my eyes to review these lines of code
Sven Panne
2015/04/29 10:24:18
... and I had to close my eyes to write them. :-D
|
| + __ addq(rsp, Immediate(bytes_to_pop)); |
| + } |
| +} |
| + |
| + |
| // Assembles an instruction after register allocation, producing machine code. |
| void CodeGenerator::AssembleArchInstruction(Instruction* instr) { |
| X64OperandConverter i(this, instr); |
| @@ -545,6 +562,18 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) { |
| RecordCallPosition(instr); |
| break; |
| } |
| + case kArchTailCallCodeObject: { |
| + FixFrameForTailCall(); |
| + if (HasImmediateInput(instr, 0)) { |
| + Handle<Code> code = Handle<Code>::cast(i.InputHeapObject(0)); |
| + __ jmp(code, RelocInfo::CODE_TARGET); |
| + } else { |
| + Register reg = i.InputRegister(0); |
| + int entry = Code::kHeaderSize - kHeapObjectTag; |
| + __ jmp(Operand(reg, entry)); |
| + } |
| + break; |
| + } |
| case kArchCallJSFunction: { |
| EnsureSpaceForLazyDeopt(); |
| Register func = i.InputRegister(0); |
| @@ -557,6 +586,17 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) { |
| RecordCallPosition(instr); |
| break; |
| } |
| + case kArchTailCallJSFunction: { |
| + Register func = i.InputRegister(0); |
| + if (FLAG_debug_code) { |
| + // Check the function's context matches the context argument. |
| + __ cmpp(rsi, FieldOperand(func, JSFunction::kContextOffset)); |
| + __ Assert(equal, kWrongFunctionContext); |
| + } |
| + FixFrameForTailCall(); |
| + __ jmp(FieldOperand(func, JSFunction::kCodeEntryOffset)); |
| + break; |
| + } |
| case kArchJmp: |
| AssembleArchJump(i.InputRpo(0)); |
| break; |