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

Side by Side Diff: src/compiler/mips64/code-generator-mips64.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: Addressing comments 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 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 __ Dsubu(sp, sp, Operand(-sp_slot_delta * kPointerSize)); 494 __ Dsubu(sp, sp, Operand(-sp_slot_delta * kPointerSize));
495 frame_access_state()->IncreaseSPDelta(-sp_slot_delta); 495 frame_access_state()->IncreaseSPDelta(-sp_slot_delta);
496 } 496 }
497 if (frame()->needs_frame()) { 497 if (frame()->needs_frame()) {
498 __ ld(ra, MemOperand(fp, StandardFrameConstants::kCallerPCOffset)); 498 __ ld(ra, MemOperand(fp, StandardFrameConstants::kCallerPCOffset));
499 __ ld(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); 499 __ ld(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
500 } 500 }
501 frame_access_state()->SetFrameAccessToSP(); 501 frame_access_state()->SetFrameAccessToSP();
502 } 502 }
503 503
504 void CodeGenerator::AssemblePopArgumentsAdaptorFrame(Register args_reg,
505 Register scratch1,
506 Register scratch2,
507 Register scratch3) {
508 DCHECK(!AreAliased(args_reg, scratch1, scratch2, scratch3));
509 Label done;
510
511 // Check if current frame is an arguments adaptor frame.
512 __ ld(scratch3, MemOperand(fp, StandardFrameConstants::kContextOffset));
513 __ Branch(&done, ne, scratch3,
514 Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
515
516 // Load arguments count from current arguments adaptor frame (note, it
517 // does not include receiver).
518 Register caller_args_count_reg = scratch1;
519 __ ld(caller_args_count_reg,
520 MemOperand(fp, ArgumentsAdaptorFrameConstants::kLengthOffset));
521 __ SmiUntag(caller_args_count_reg);
522
523 ParameterCount callee_args_count(args_reg);
524 __ PrepareForTailCall(callee_args_count, caller_args_count_reg, scratch2,
525 scratch3);
526 __ bind(&done);
527 }
504 528
505 // Assembles an instruction after register allocation, producing machine code. 529 // Assembles an instruction after register allocation, producing machine code.
506 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { 530 void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
507 MipsOperandConverter i(this, instr); 531 MipsOperandConverter i(this, instr);
508 InstructionCode opcode = instr->opcode(); 532 InstructionCode opcode = instr->opcode();
509 533 ArchOpcode arch_opcode = ArchOpcodeField::decode(opcode);
510 switch (ArchOpcodeField::decode(opcode)) { 534 switch (arch_opcode) {
511 case kArchCallCodeObject: { 535 case kArchCallCodeObject: {
512 EnsureSpaceForLazyDeopt(); 536 EnsureSpaceForLazyDeopt();
513 if (instr->InputAt(0)->IsImmediate()) { 537 if (instr->InputAt(0)->IsImmediate()) {
514 __ Call(Handle<Code>::cast(i.InputHeapObject(0)), 538 __ Call(Handle<Code>::cast(i.InputHeapObject(0)),
515 RelocInfo::CODE_TARGET); 539 RelocInfo::CODE_TARGET);
516 } else { 540 } else {
517 __ daddiu(at, i.InputRegister(0), Code::kHeaderSize - kHeapObjectTag); 541 __ daddiu(at, i.InputRegister(0), Code::kHeaderSize - kHeapObjectTag);
518 __ Call(at); 542 __ Call(at);
519 } 543 }
520 RecordCallPosition(instr); 544 RecordCallPosition(instr);
521 frame_access_state()->ClearSPDelta(); 545 frame_access_state()->ClearSPDelta();
522 break; 546 break;
523 } 547 }
548 case kArchTailCallCodeObjectFromJSFunction:
524 case kArchTailCallCodeObject: { 549 case kArchTailCallCodeObject: {
525 int stack_param_delta = i.InputInt32(instr->InputCount() - 1); 550 int stack_param_delta = i.InputInt32(instr->InputCount() - 1);
526 AssembleDeconstructActivationRecord(stack_param_delta); 551 AssembleDeconstructActivationRecord(stack_param_delta);
552 if (arch_opcode == kArchTailCallCodeObjectFromJSFunction) {
553 AssemblePopArgumentsAdaptorFrame(kJavaScriptCallArgCountRegister,
554 i.TempRegister(0), i.TempRegister(1),
555 i.TempRegister(2));
556 }
527 if (instr->InputAt(0)->IsImmediate()) { 557 if (instr->InputAt(0)->IsImmediate()) {
528 __ Jump(Handle<Code>::cast(i.InputHeapObject(0)), 558 __ Jump(Handle<Code>::cast(i.InputHeapObject(0)),
529 RelocInfo::CODE_TARGET); 559 RelocInfo::CODE_TARGET);
530 } else { 560 } else {
531 __ daddiu(at, i.InputRegister(0), Code::kHeaderSize - kHeapObjectTag); 561 __ daddiu(at, i.InputRegister(0), Code::kHeaderSize - kHeapObjectTag);
532 __ Jump(at); 562 __ Jump(at);
533 } 563 }
534 frame_access_state()->ClearSPDelta(); 564 frame_access_state()->ClearSPDelta();
535 break; 565 break;
536 } 566 }
537 case kArchCallJSFunction: { 567 case kArchCallJSFunction: {
538 EnsureSpaceForLazyDeopt(); 568 EnsureSpaceForLazyDeopt();
539 Register func = i.InputRegister(0); 569 Register func = i.InputRegister(0);
540 if (FLAG_debug_code) { 570 if (FLAG_debug_code) {
541 // Check the function's context matches the context argument. 571 // Check the function's context matches the context argument.
542 __ ld(kScratchReg, FieldMemOperand(func, JSFunction::kContextOffset)); 572 __ ld(kScratchReg, FieldMemOperand(func, JSFunction::kContextOffset));
543 __ Assert(eq, kWrongFunctionContext, cp, Operand(kScratchReg)); 573 __ Assert(eq, kWrongFunctionContext, cp, Operand(kScratchReg));
544 } 574 }
545 __ ld(at, FieldMemOperand(func, JSFunction::kCodeEntryOffset)); 575 __ ld(at, FieldMemOperand(func, JSFunction::kCodeEntryOffset));
546 __ Call(at); 576 __ Call(at);
547 RecordCallPosition(instr); 577 RecordCallPosition(instr);
548 frame_access_state()->ClearSPDelta(); 578 frame_access_state()->ClearSPDelta();
549 break; 579 break;
550 } 580 }
581 case kArchTailCallJSFunctionFromJSFunction:
551 case kArchTailCallJSFunction: { 582 case kArchTailCallJSFunction: {
552 Register func = i.InputRegister(0); 583 Register func = i.InputRegister(0);
553 if (FLAG_debug_code) { 584 if (FLAG_debug_code) {
554 // Check the function's context matches the context argument. 585 // Check the function's context matches the context argument.
555 __ ld(kScratchReg, FieldMemOperand(func, JSFunction::kContextOffset)); 586 __ ld(kScratchReg, FieldMemOperand(func, JSFunction::kContextOffset));
556 __ Assert(eq, kWrongFunctionContext, cp, Operand(kScratchReg)); 587 __ Assert(eq, kWrongFunctionContext, cp, Operand(kScratchReg));
557 } 588 }
558 int stack_param_delta = i.InputInt32(instr->InputCount() - 1); 589 int stack_param_delta = i.InputInt32(instr->InputCount() - 1);
559 AssembleDeconstructActivationRecord(stack_param_delta); 590 AssembleDeconstructActivationRecord(stack_param_delta);
591 if (arch_opcode == kArchTailCallJSFunctionFromJSFunction) {
592 AssemblePopArgumentsAdaptorFrame(kJavaScriptCallArgCountRegister,
593 i.TempRegister(0), i.TempRegister(1),
594 i.TempRegister(2));
595 }
560 __ ld(at, FieldMemOperand(func, JSFunction::kCodeEntryOffset)); 596 __ ld(at, FieldMemOperand(func, JSFunction::kCodeEntryOffset));
561 __ Jump(at); 597 __ Jump(at);
562 frame_access_state()->ClearSPDelta(); 598 frame_access_state()->ClearSPDelta();
563 break; 599 break;
564 } 600 }
565 case kArchPrepareCallCFunction: { 601 case kArchPrepareCallCFunction: {
566 int const num_parameters = MiscField::decode(instr->opcode()); 602 int const num_parameters = MiscField::decode(instr->opcode());
567 __ PrepareCallCFunction(num_parameters, kScratchReg); 603 __ PrepareCallCFunction(num_parameters, kScratchReg);
568 // Frame alignment requires using FP-relative frame addressing. 604 // Frame alignment requires using FP-relative frame addressing.
569 frame_access_state()->SetFrameAccessToFP(); 605 frame_access_state()->SetFrameAccessToFP();
(...skipping 1558 matching lines...) Expand 10 before | Expand all | Expand 10 after
2128 padding_size -= v8::internal::Assembler::kInstrSize; 2164 padding_size -= v8::internal::Assembler::kInstrSize;
2129 } 2165 }
2130 } 2166 }
2131 } 2167 }
2132 2168
2133 #undef __ 2169 #undef __
2134 2170
2135 } // namespace compiler 2171 } // namespace compiler
2136 } // namespace internal 2172 } // namespace internal
2137 } // namespace v8 2173 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/mips/instruction-selector-mips.cc ('k') | src/compiler/mips64/instruction-selector-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698