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

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

Issue 1108563002: Detect simple tail calls (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixed index type Created 5 years, 7 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
« no previous file with comments | « src/compiler/node-properties.cc ('k') | src/compiler/ppc/instruction-selector-ppc.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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/ppc/macro-assembler-ppc.h" 10 #include "src/ppc/macro-assembler-ppc.h"
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 __ add(index, object, index); \ 574 __ add(index, object, index); \
575 __ StoreP(value, MemOperand(index)); \ 575 __ StoreP(value, MemOperand(index)); \
576 SaveFPRegsMode mode = \ 576 SaveFPRegsMode mode = \
577 frame()->DidAllocateDoubleRegisters() ? kSaveFPRegs : kDontSaveFPRegs; \ 577 frame()->DidAllocateDoubleRegisters() ? kSaveFPRegs : kDontSaveFPRegs; \
578 LinkRegisterStatus lr_status = kLRHasNotBeenSaved; \ 578 LinkRegisterStatus lr_status = kLRHasNotBeenSaved; \
579 __ RecordWrite(object, index, value, lr_status, mode); \ 579 __ RecordWrite(object, index, value, lr_status, mode); \
580 DCHECK_EQ(LeaveRC, i.OutputRCBit()); \ 580 DCHECK_EQ(LeaveRC, i.OutputRCBit()); \
581 } while (0) 581 } while (0)
582 582
583 583
584 void CodeGenerator::AssembleDeconstructActivationRecord() {
585 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
586 int stack_slots = frame()->GetSpillSlotCount();
587 if (descriptor->IsJSFunctionCall() || stack_slots > 0) {
588 int pop_count = descriptor->IsJSFunctionCall()
589 ? static_cast<int>(descriptor->JSParameterCount())
590 : 0;
591 __ LeaveFrame(StackFrame::MANUAL, pop_count * kPointerSize);
592 }
593 }
594
595
584 // Assembles an instruction after register allocation, producing machine code. 596 // Assembles an instruction after register allocation, producing machine code.
585 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { 597 void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
586 PPCOperandConverter i(this, instr); 598 PPCOperandConverter i(this, instr);
587 ArchOpcode opcode = ArchOpcodeField::decode(instr->opcode()); 599 ArchOpcode opcode = ArchOpcodeField::decode(instr->opcode());
588 600
589 switch (opcode) { 601 switch (opcode) {
590 case kArchCallCodeObject: { 602 case kArchCallCodeObject: {
591 EnsureSpaceForLazyDeopt(); 603 EnsureSpaceForLazyDeopt();
592 if (HasRegisterInput(instr, 0)) { 604 if (HasRegisterInput(instr, 0)) {
593 __ addi(ip, i.InputRegister(0), 605 __ addi(ip, i.InputRegister(0),
594 Operand(Code::kHeaderSize - kHeapObjectTag)); 606 Operand(Code::kHeaderSize - kHeapObjectTag));
595 __ Call(ip); 607 __ Call(ip);
596 } else { 608 } else {
597 __ Call(Handle<Code>::cast(i.InputHeapObject(0)), 609 __ Call(Handle<Code>::cast(i.InputHeapObject(0)),
598 RelocInfo::CODE_TARGET); 610 RelocInfo::CODE_TARGET);
599 } 611 }
600 RecordCallPosition(instr); 612 RecordCallPosition(instr);
601 DCHECK_EQ(LeaveRC, i.OutputRCBit()); 613 DCHECK_EQ(LeaveRC, i.OutputRCBit());
602 break; 614 break;
603 } 615 }
616 case kArchTailCallCodeObject: {
617 AssembleDeconstructActivationRecord();
618 if (HasRegisterInput(instr, 0)) {
619 __ addi(ip, i.InputRegister(0),
620 Operand(Code::kHeaderSize - kHeapObjectTag));
621 __ Jump(ip);
622 } else {
623 __ Jump(Handle<Code>::cast(i.InputHeapObject(0)),
624 RelocInfo::CODE_TARGET);
625 }
626 DCHECK_EQ(LeaveRC, i.OutputRCBit());
627 break;
628 }
604 case kArchCallJSFunction: { 629 case kArchCallJSFunction: {
605 EnsureSpaceForLazyDeopt(); 630 EnsureSpaceForLazyDeopt();
606 Register func = i.InputRegister(0); 631 Register func = i.InputRegister(0);
607 if (FLAG_debug_code) { 632 if (FLAG_debug_code) {
608 // Check the function's context matches the context argument. 633 // Check the function's context matches the context argument.
609 __ LoadP(kScratchReg, 634 __ LoadP(kScratchReg,
610 FieldMemOperand(func, JSFunction::kContextOffset)); 635 FieldMemOperand(func, JSFunction::kContextOffset));
611 __ cmp(cp, kScratchReg); 636 __ cmp(cp, kScratchReg);
612 __ Assert(eq, kWrongFunctionContext); 637 __ Assert(eq, kWrongFunctionContext);
613 } 638 }
614 __ LoadP(ip, FieldMemOperand(func, JSFunction::kCodeEntryOffset)); 639 __ LoadP(ip, FieldMemOperand(func, JSFunction::kCodeEntryOffset));
615 __ Call(ip); 640 __ Call(ip);
616 RecordCallPosition(instr); 641 RecordCallPosition(instr);
617 DCHECK_EQ(LeaveRC, i.OutputRCBit()); 642 DCHECK_EQ(LeaveRC, i.OutputRCBit());
618 break; 643 break;
619 } 644 }
645 case kArchTailCallJSFunction: {
646 Register func = i.InputRegister(0);
647 if (FLAG_debug_code) {
648 // Check the function's context matches the context argument.
649 __ LoadP(kScratchReg,
650 FieldMemOperand(func, JSFunction::kContextOffset));
651 __ cmp(cp, kScratchReg);
652 __ Assert(eq, kWrongFunctionContext);
653 }
654 AssembleDeconstructActivationRecord();
655 __ LoadP(ip, FieldMemOperand(func, JSFunction::kCodeEntryOffset));
656 __ Jump(ip);
657 DCHECK_EQ(LeaveRC, i.OutputRCBit());
658 break;
659 }
620 case kArchJmp: 660 case kArchJmp:
621 AssembleArchJump(i.InputRpo(0)); 661 AssembleArchJump(i.InputRpo(0));
622 DCHECK_EQ(LeaveRC, i.OutputRCBit()); 662 DCHECK_EQ(LeaveRC, i.OutputRCBit());
623 break; 663 break;
624 case kArchLookupSwitch: 664 case kArchLookupSwitch:
625 AssembleArchLookupSwitch(instr); 665 AssembleArchLookupSwitch(instr);
626 DCHECK_EQ(LeaveRC, i.OutputRCBit()); 666 DCHECK_EQ(LeaveRC, i.OutputRCBit());
627 break; 667 break;
628 case kArchTableSwitch: 668 case kArchTableSwitch:
629 AssembleArchTableSwitch(instr); 669 AssembleArchTableSwitch(instr);
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 case kCheckedStoreFloat32: 1118 case kCheckedStoreFloat32:
1079 ASSEMBLE_CHECKED_STORE_FLOAT32(); 1119 ASSEMBLE_CHECKED_STORE_FLOAT32();
1080 break; 1120 break;
1081 case kCheckedStoreFloat64: 1121 case kCheckedStoreFloat64:
1082 ASSEMBLE_CHECKED_STORE_DOUBLE(); 1122 ASSEMBLE_CHECKED_STORE_DOUBLE();
1083 break; 1123 break;
1084 default: 1124 default:
1085 UNREACHABLE(); 1125 UNREACHABLE();
1086 break; 1126 break;
1087 } 1127 }
1088 } 1128 } // NOLINT(readability/fn_size)
1089 1129
1090 1130
1091 // Assembles branches after an instruction. 1131 // Assembles branches after an instruction.
1092 void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) { 1132 void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) {
1093 PPCOperandConverter i(this, instr); 1133 PPCOperandConverter i(this, instr);
1094 Label* tlabel = branch->true_label; 1134 Label* tlabel = branch->true_label;
1095 Label* flabel = branch->false_label; 1135 Label* flabel = branch->false_label;
1096 ArchOpcode op = instr->arch_opcode(); 1136 ArchOpcode op = instr->arch_opcode();
1097 FlagsCondition condition = branch->condition; 1137 FlagsCondition condition = branch->condition;
1098 CRegister cr = cr0; 1138 CRegister cr = cr0;
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1501 } 1541 }
1502 } 1542 }
1503 MarkLazyDeoptSite(); 1543 MarkLazyDeoptSite();
1504 } 1544 }
1505 1545
1506 #undef __ 1546 #undef __
1507 1547
1508 } // namespace compiler 1548 } // namespace compiler
1509 } // namespace internal 1549 } // namespace internal
1510 } // namespace v8 1550 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/node-properties.cc ('k') | src/compiler/ppc/instruction-selector-ppc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698