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

Side by Side Diff: src/compiler/mips/instruction-selector-mips.cc

Issue 1414223004: [turbofan] Move platform-independent bits of VisitTailCall to instruction-selector.cc (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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/base/adapters.h" 5 #include "src/base/adapters.h"
6 #include "src/base/bits.h" 6 #include "src/base/bits.h"
7 #include "src/compiler/instruction-selector-impl.h" 7 #include "src/compiler/instruction-selector-impl.h"
8 #include "src/compiler/node-matchers.h" 8 #include "src/compiler/node-matchers.h"
9 #include "src/compiler/node-properties.h" 9 #include "src/compiler/node-properties.h"
10 10
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 for (size_t n = 0; n < arguments->size(); ++n) { 556 for (size_t n = 0; n < arguments->size(); ++n) {
557 if (Node* input = (*arguments)[n]) { 557 if (Node* input = (*arguments)[n]) {
558 Emit(kMipsStoreToStackSlot, g.NoOutput(), g.UseRegister(input), 558 Emit(kMipsStoreToStackSlot, g.NoOutput(), g.UseRegister(input),
559 g.TempImmediate(n << kPointerSizeLog2)); 559 g.TempImmediate(n << kPointerSizeLog2));
560 } 560 }
561 } 561 }
562 } 562 }
563 } 563 }
564 564
565 565
566 void InstructionSelector::VisitTailCall(Node* node) { 566 bool InstructionSelector::IsTailCallAddressImmediate() { return false; }
567 MipsOperandGenerator g(this);
568 const CallDescriptor* descriptor = OpParameter<const CallDescriptor*>(node);
569 DCHECK_NE(0, descriptor->flags() & CallDescriptor::kSupportsTailCalls);
570 DCHECK_EQ(0, descriptor->flags() & CallDescriptor::kPatchableCallSite);
571 DCHECK_EQ(0, descriptor->flags() & CallDescriptor::kNeedsNopAfterCall);
572
573 // TODO(turbofan): Relax restriction for stack parameters.
574 if (linkage()->GetIncomingDescriptor()->CanTailCall(node)) {
575 CallBuffer buffer(zone(), descriptor, nullptr);
576
577 // Compute InstructionOperands for inputs and outputs.
578 InitializeCallBuffer(node, &buffer, true, false);
579
580 // Select the appropriate opcode based on the call type.
581 InstructionCode opcode;
582 switch (descriptor->kind()) {
583 case CallDescriptor::kCallCodeObject:
584 opcode = kArchTailCallCodeObject;
585 break;
586 case CallDescriptor::kCallJSFunction:
587 opcode = kArchTailCallJSFunction;
588 break;
589 default:
590 UNREACHABLE();
591 return;
592 }
593 opcode |= MiscField::encode(descriptor->flags());
594
595 // Emit the tailcall instruction.
596 Emit(opcode, 0, nullptr, buffer.instruction_args.size(),
597 &buffer.instruction_args.front());
598 } else {
599 FrameStateDescriptor* frame_state_descriptor =
600 descriptor->NeedsFrameState()
601 ? GetFrameStateDescriptor(
602 node->InputAt(static_cast<int>(descriptor->InputCount())))
603 : nullptr;
604
605 CallBuffer buffer(zone(), descriptor, frame_state_descriptor);
606
607 // Compute InstructionOperands for inputs and outputs.
608 InitializeCallBuffer(node, &buffer, true, false);
609 // Possibly align stack here for functions.
610 int push_count = static_cast<int>(descriptor->StackParameterCount());
611 if (push_count > 0) {
612 Emit(kMipsStackClaim, g.NoOutput(),
613 g.TempImmediate(push_count << kPointerSizeLog2));
614 }
615 int slot = static_cast<int>(buffer.pushed_nodes.size()) - 1;
616 for (Node* input : base::Reversed(buffer.pushed_nodes)) {
617 Emit(kMipsStoreToStackSlot, g.NoOutput(), g.UseRegister(input),
618 g.TempImmediate(slot << kPointerSizeLog2));
619 slot--;
620 }
621
622 // Select the appropriate opcode based on the call type.
623 InstructionCode opcode;
624 switch (descriptor->kind()) {
625 case CallDescriptor::kCallCodeObject: {
626 opcode = kArchCallCodeObject;
627 break;
628 }
629 case CallDescriptor::kCallJSFunction:
630 opcode = kArchCallJSFunction;
631 break;
632 default:
633 UNREACHABLE();
634 return;
635 }
636 opcode |= MiscField::encode(descriptor->flags());
637
638 // Emit the call instruction.
639 size_t const output_count = buffer.outputs.size();
640 auto* outputs = output_count ? &buffer.outputs.front() : nullptr;
641 Emit(opcode, output_count, outputs, buffer.instruction_args.size(),
642 &buffer.instruction_args.front())->MarkAsCall();
643 Emit(kArchRet, 0, nullptr, output_count, outputs);
644 }
645 }
646 567
647 568
648 void InstructionSelector::VisitCheckedLoad(Node* node) { 569 void InstructionSelector::VisitCheckedLoad(Node* node) {
649 MachineType rep = RepresentationOf(OpParameter<MachineType>(node)); 570 MachineType rep = RepresentationOf(OpParameter<MachineType>(node));
650 MachineType typ = TypeOf(OpParameter<MachineType>(node)); 571 MachineType typ = TypeOf(OpParameter<MachineType>(node));
651 MipsOperandGenerator g(this); 572 MipsOperandGenerator g(this);
652 Node* const buffer = node->InputAt(0); 573 Node* const buffer = node->InputAt(0);
653 Node* const offset = node->InputAt(1); 574 Node* const offset = node->InputAt(1);
654 Node* const length = node->InputAt(2); 575 Node* const length = node->InputAt(2);
655 ArchOpcode opcode; 576 ArchOpcode opcode;
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
1112 IsFp64Mode()) { 1033 IsFp64Mode()) {
1113 flags |= MachineOperatorBuilder::kFloat64RoundDown | 1034 flags |= MachineOperatorBuilder::kFloat64RoundDown |
1114 MachineOperatorBuilder::kFloat64RoundTruncate; 1035 MachineOperatorBuilder::kFloat64RoundTruncate;
1115 } 1036 }
1116 return flags; 1037 return flags;
1117 } 1038 }
1118 1039
1119 } // namespace compiler 1040 } // namespace compiler
1120 } // namespace internal 1041 } // namespace internal
1121 } // namespace v8 1042 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/instruction-selector.cc ('k') | src/compiler/mips64/instruction-selector-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698