| Index: src/compiler/x87/code-generator-x87.cc
|
| diff --git a/src/compiler/x87/code-generator-x87.cc b/src/compiler/x87/code-generator-x87.cc
|
| index 98b6c88e1305dad90d065a22805663f2ecdcb6c9..82a2d14c51d281320dd16db048051e988c0b9fd1 100644
|
| --- a/src/compiler/x87/code-generator-x87.cc
|
| +++ b/src/compiler/x87/code-generator-x87.cc
|
| @@ -362,12 +362,50 @@ void CodeGenerator::AssemblePrepareTailCall(int stack_param_delta) {
|
| frame_access_state()->SetFrameAccessToSP();
|
| }
|
|
|
| +void CodeGenerator::AssemblePopArgumentsAdaptorFrame(Register args_reg,
|
| + Register, Register,
|
| + Register) {
|
| + // There are not enough temp registers left on ia32 for a call instruction
|
| + // so we pick some scratch registers and save/restore them manually here.
|
| + int scratch_count = 3;
|
| + Register scratch1 = ebx;
|
| + Register scratch2 = ecx;
|
| + Register scratch3 = edx;
|
| + DCHECK(!AreAliased(args_reg, scratch1, scratch2, scratch3));
|
| + Label done;
|
| +
|
| + // Check if current frame is an arguments adaptor frame.
|
| + __ cmp(Operand(ebp, StandardFrameConstants::kContextOffset),
|
| + Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
|
| + __ j(not_equal, &done, Label::kNear);
|
| +
|
| + __ push(scratch1);
|
| + __ push(scratch2);
|
| + __ push(scratch3);
|
| +
|
| + // Load arguments count from current arguments adaptor frame (note, it
|
| + // does not include receiver).
|
| + Register caller_args_count_reg = scratch1;
|
| + __ mov(caller_args_count_reg,
|
| + Operand(ebp, ArgumentsAdaptorFrameConstants::kLengthOffset));
|
| + __ SmiUntag(caller_args_count_reg);
|
| +
|
| + ParameterCount callee_args_count(args_reg);
|
| + __ PrepareForTailCall(callee_args_count, caller_args_count_reg, scratch2,
|
| + scratch3, ReturnAddressState::kOnStack, scratch_count);
|
| + __ pop(scratch3);
|
| + __ pop(scratch2);
|
| + __ pop(scratch1);
|
| +
|
| + __ bind(&done);
|
| +}
|
|
|
| // Assembles an instruction after register allocation, producing machine code.
|
| void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
|
| X87OperandConverter i(this, instr);
|
| -
|
| - switch (ArchOpcodeField::decode(instr->opcode())) {
|
| + InstructionCode opcode = instr->opcode();
|
| + ArchOpcode arch_opcode = ArchOpcodeField::decode(opcode);
|
| + switch (arch_opcode) {
|
| case kArchCallCodeObject: {
|
| if (FLAG_debug_code && FLAG_enable_slow_asserts) {
|
| __ VerifyX87StackDepth(1);
|
| @@ -399,6 +437,7 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
|
| frame_access_state()->ClearSPDelta();
|
| break;
|
| }
|
| + case kArchTailCallCodeObjectFromJSFunction:
|
| case kArchTailCallCodeObject: {
|
| if (FLAG_debug_code && FLAG_enable_slow_asserts) {
|
| __ VerifyX87StackDepth(1);
|
| @@ -406,6 +445,10 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
|
| __ fstp(0);
|
| int stack_param_delta = i.InputInt32(instr->InputCount() - 1);
|
| AssembleDeconstructActivationRecord(stack_param_delta);
|
| + if (arch_opcode == kArchTailCallCodeObjectFromJSFunction) {
|
| + AssemblePopArgumentsAdaptorFrame(kJavaScriptCallArgCountRegister,
|
| + no_reg, no_reg, no_reg);
|
| + }
|
| if (HasImmediateInput(instr, 0)) {
|
| Handle<Code> code = Handle<Code>::cast(i.InputHeapObject(0));
|
| __ jmp(code, RelocInfo::CODE_TARGET);
|
| @@ -447,6 +490,7 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
|
| frame_access_state()->ClearSPDelta();
|
| break;
|
| }
|
| + case kArchTailCallJSFunctionFromJSFunction:
|
| case kArchTailCallJSFunction: {
|
| Register func = i.InputRegister(0);
|
| if (FLAG_debug_code) {
|
| @@ -460,6 +504,10 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
|
| __ fstp(0);
|
| int stack_param_delta = i.InputInt32(instr->InputCount() - 1);
|
| AssembleDeconstructActivationRecord(stack_param_delta);
|
| + if (arch_opcode == kArchTailCallJSFunctionFromJSFunction) {
|
| + AssemblePopArgumentsAdaptorFrame(kJavaScriptCallArgCountRegister,
|
| + no_reg, no_reg, no_reg);
|
| + }
|
| __ jmp(FieldOperand(func, JSFunction::kCodeEntryOffset));
|
| frame_access_state()->ClearSPDelta();
|
| break;
|
|
|