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

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

Issue 1702423002: [turbofan] Further fixing ES6 tail call elimination in Turbofan. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@tco-turbo
Patch Set: Rebasing Created 4 years, 9 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
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/ast/scopes.h" 5 #include "src/ast/scopes.h"
6 #include "src/compiler/code-generator.h" 6 #include "src/compiler/code-generator.h"
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/compiler/osr.h" 10 #include "src/compiler/osr.h"
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 __ Subu(sp, sp, Operand(-sp_slot_delta * kPointerSize)); 482 __ Subu(sp, sp, Operand(-sp_slot_delta * kPointerSize));
483 frame_access_state()->IncreaseSPDelta(-sp_slot_delta); 483 frame_access_state()->IncreaseSPDelta(-sp_slot_delta);
484 } 484 }
485 if (frame()->needs_frame()) { 485 if (frame()->needs_frame()) {
486 __ lw(ra, MemOperand(fp, StandardFrameConstants::kCallerPCOffset)); 486 __ lw(ra, MemOperand(fp, StandardFrameConstants::kCallerPCOffset));
487 __ lw(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); 487 __ lw(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
488 } 488 }
489 frame_access_state()->SetFrameAccessToSP(); 489 frame_access_state()->SetFrameAccessToSP();
490 } 490 }
491 491
492 void CodeGenerator::AssemblePopArgumentsAdaptorFrame(Register args_reg,
493 Register scratch1,
494 Register scratch2,
495 Register scratch3) {
496 DCHECK(!AreAliased(args_reg, scratch1, scratch2, scratch3));
497 Label done;
498
499 // Check if current frame is an arguments adaptor frame.
500 __ lw(scratch1, MemOperand(fp, StandardFrameConstants::kContextOffset));
501 __ Branch(&done, ne, scratch1,
502 Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
503
504 // Load arguments count from current arguments adaptor frame (note, it
505 // does not include receiver).
506 Register caller_args_count_reg = scratch1;
507 __ lw(caller_args_count_reg,
508 MemOperand(fp, ArgumentsAdaptorFrameConstants::kLengthOffset));
509 __ SmiUntag(caller_args_count_reg);
510
511 ParameterCount callee_args_count(args_reg);
512 __ PrepareForTailCall(callee_args_count, caller_args_count_reg, scratch2,
513 scratch3);
514 __ bind(&done);
515 }
492 516
493 // Assembles an instruction after register allocation, producing machine code. 517 // Assembles an instruction after register allocation, producing machine code.
494 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { 518 void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
495 MipsOperandConverter i(this, instr); 519 MipsOperandConverter i(this, instr);
496 InstructionCode opcode = instr->opcode(); 520 InstructionCode opcode = instr->opcode();
497 521
498 switch (ArchOpcodeField::decode(opcode)) { 522 switch (ArchOpcodeField::decode(opcode)) {
499 case kArchCallCodeObject: { 523 case kArchCallCodeObject: {
500 EnsureSpaceForLazyDeopt(); 524 EnsureSpaceForLazyDeopt();
501 if (instr->InputAt(0)->IsImmediate()) { 525 if (instr->InputAt(0)->IsImmediate()) {
502 __ Call(Handle<Code>::cast(i.InputHeapObject(0)), 526 __ Call(Handle<Code>::cast(i.InputHeapObject(0)),
503 RelocInfo::CODE_TARGET); 527 RelocInfo::CODE_TARGET);
504 } else { 528 } else {
505 __ addiu(at, i.InputRegister(0), Code::kHeaderSize - kHeapObjectTag); 529 __ addiu(at, i.InputRegister(0), Code::kHeaderSize - kHeapObjectTag);
506 __ Call(at); 530 __ Call(at);
507 } 531 }
508 RecordCallPosition(instr); 532 RecordCallPosition(instr);
509 frame_access_state()->ClearSPDelta(); 533 frame_access_state()->ClearSPDelta();
510 break; 534 break;
511 } 535 }
536 case kArchTailCallCodeObjectFromJSFunction: {
537 int stack_param_delta = i.InputInt32(instr->InputCount() - 1);
538 AssembleDeconstructActivationRecord(stack_param_delta);
539 AssemblePopArgumentsAdaptorFrame(kJavaScriptCallArgCountRegister,
540 i.TempRegister(0), i.TempRegister(1),
541 i.TempRegister(2));
542 if (instr->InputAt(0)->IsImmediate()) {
543 __ Jump(Handle<Code>::cast(i.InputHeapObject(0)),
544 RelocInfo::CODE_TARGET);
545 } else {
546 __ addiu(at, i.InputRegister(0), Code::kHeaderSize - kHeapObjectTag);
547 __ Jump(at);
548 }
549 frame_access_state()->ClearSPDelta();
550 break;
551 }
512 case kArchTailCallCodeObject: { 552 case kArchTailCallCodeObject: {
513 int stack_param_delta = i.InputInt32(instr->InputCount() - 1); 553 int stack_param_delta = i.InputInt32(instr->InputCount() - 1);
514 AssembleDeconstructActivationRecord(stack_param_delta); 554 AssembleDeconstructActivationRecord(stack_param_delta);
515 if (instr->InputAt(0)->IsImmediate()) { 555 if (instr->InputAt(0)->IsImmediate()) {
516 __ Jump(Handle<Code>::cast(i.InputHeapObject(0)), 556 __ Jump(Handle<Code>::cast(i.InputHeapObject(0)),
517 RelocInfo::CODE_TARGET); 557 RelocInfo::CODE_TARGET);
518 } else { 558 } else {
519 __ addiu(at, i.InputRegister(0), Code::kHeaderSize - kHeapObjectTag); 559 __ addiu(at, i.InputRegister(0), Code::kHeaderSize - kHeapObjectTag);
520 __ Jump(at); 560 __ Jump(at);
521 } 561 }
522 frame_access_state()->ClearSPDelta(); 562 frame_access_state()->ClearSPDelta();
523 break; 563 break;
524 } 564 }
525 case kArchCallJSFunction: { 565 case kArchCallJSFunction: {
526 EnsureSpaceForLazyDeopt(); 566 EnsureSpaceForLazyDeopt();
527 Register func = i.InputRegister(0); 567 Register func = i.InputRegister(0);
528 if (FLAG_debug_code) { 568 if (FLAG_debug_code) {
529 // Check the function's context matches the context argument. 569 // Check the function's context matches the context argument.
530 __ lw(kScratchReg, FieldMemOperand(func, JSFunction::kContextOffset)); 570 __ lw(kScratchReg, FieldMemOperand(func, JSFunction::kContextOffset));
531 __ Assert(eq, kWrongFunctionContext, cp, Operand(kScratchReg)); 571 __ Assert(eq, kWrongFunctionContext, cp, Operand(kScratchReg));
532 } 572 }
533 573
534 __ lw(at, FieldMemOperand(func, JSFunction::kCodeEntryOffset)); 574 __ lw(at, FieldMemOperand(func, JSFunction::kCodeEntryOffset));
535 __ Call(at); 575 __ Call(at);
536 RecordCallPosition(instr); 576 RecordCallPosition(instr);
537 frame_access_state()->ClearSPDelta(); 577 frame_access_state()->ClearSPDelta();
538 break; 578 break;
539 } 579 }
580 case kArchTailCallJSFunctionFromJSFunction: {
581 Register func = i.InputRegister(0);
582 if (FLAG_debug_code) {
583 // Check the function's context matches the context argument.
584 __ lw(kScratchReg, FieldMemOperand(func, JSFunction::kContextOffset));
585 __ Assert(eq, kWrongFunctionContext, cp, Operand(kScratchReg));
586 }
587
588 int stack_param_delta = i.InputInt32(instr->InputCount() - 1);
589 AssembleDeconstructActivationRecord(stack_param_delta);
590 AssemblePopArgumentsAdaptorFrame(kJavaScriptCallArgCountRegister,
591 i.TempRegister(0), i.TempRegister(1),
592 i.TempRegister(2));
593 __ lw(at, FieldMemOperand(func, JSFunction::kCodeEntryOffset));
594 __ Jump(at);
595 frame_access_state()->ClearSPDelta();
596 break;
597 }
540 case kArchTailCallJSFunction: { 598 case kArchTailCallJSFunction: {
541 Register func = i.InputRegister(0); 599 Register func = i.InputRegister(0);
542 if (FLAG_debug_code) { 600 if (FLAG_debug_code) {
543 // Check the function's context matches the context argument. 601 // Check the function's context matches the context argument.
544 __ lw(kScratchReg, FieldMemOperand(func, JSFunction::kContextOffset)); 602 __ lw(kScratchReg, FieldMemOperand(func, JSFunction::kContextOffset));
545 __ Assert(eq, kWrongFunctionContext, cp, Operand(kScratchReg)); 603 __ Assert(eq, kWrongFunctionContext, cp, Operand(kScratchReg));
546 } 604 }
547 605
548 int stack_param_delta = i.InputInt32(instr->InputCount() - 1); 606 int stack_param_delta = i.InputInt32(instr->InputCount() - 1);
549 AssembleDeconstructActivationRecord(stack_param_delta); 607 AssembleDeconstructActivationRecord(stack_param_delta);
(...skipping 1274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1824 padding_size -= v8::internal::Assembler::kInstrSize; 1882 padding_size -= v8::internal::Assembler::kInstrSize;
1825 } 1883 }
1826 } 1884 }
1827 } 1885 }
1828 1886
1829 #undef __ 1887 #undef __
1830 1888
1831 } // namespace compiler 1889 } // namespace compiler
1832 } // namespace internal 1890 } // namespace internal
1833 } // namespace v8 1891 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698