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

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

Issue 1205023002: [turbofan] Add basic support for calling to (a subset of) C functions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix argument slots. Created 5 years, 6 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/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 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 666
667 FrameStateDescriptor* frame_state_descriptor = nullptr; 667 FrameStateDescriptor* frame_state_descriptor = nullptr;
668 if (descriptor->NeedsFrameState()) { 668 if (descriptor->NeedsFrameState()) {
669 frame_state_descriptor = GetFrameStateDescriptor( 669 frame_state_descriptor = GetFrameStateDescriptor(
670 node->InputAt(static_cast<int>(descriptor->InputCount()))); 670 node->InputAt(static_cast<int>(descriptor->InputCount())));
671 } 671 }
672 672
673 CallBuffer buffer(zone(), descriptor, frame_state_descriptor); 673 CallBuffer buffer(zone(), descriptor, frame_state_descriptor);
674 674
675 // Compute InstructionOperands for inputs and outputs. 675 // Compute InstructionOperands for inputs and outputs.
676 InitializeCallBuffer(node, &buffer, true, false); 676 InitializeCallBuffer(node, &buffer, true, true);
677 677
678 const int32_t push_count = static_cast<int32_t>(buffer.pushed_nodes.size()); 678 // Prepare for C function call.
679 if (push_count > 0) { 679 if (descriptor->IsCFunctionCall()) {
680 Emit(kMips64StackClaim, g.NoOutput(), 680 Emit(kArchPrepareCallCFunction |
681 g.TempImmediate(push_count << kPointerSizeLog2)); 681 MiscField::encode(static_cast<int>(descriptor->CParameterCount())),
682 } 682 0, nullptr, 0, nullptr);
683 int32_t slot = push_count - 1; 683
684 for (Node* node : base::Reversed(buffer.pushed_nodes)) { 684 // Poke any stack arguments.
685 Emit(kMips64StoreToStackSlot, g.NoOutput(), g.UseRegister(node), 685 int slot = kCArgSlotCount;
686 g.TempImmediate(slot << kPointerSizeLog2)); 686 for (Node* node : buffer.pushed_nodes) {
687 slot--; 687 Emit(kMips64StoreToStackSlot, g.NoOutput(), g.UseRegister(node),
688 g.TempImmediate(slot << kPointerSizeLog2));
689 ++slot;
690 }
691 } else {
692 const int32_t push_count = static_cast<int32_t>(buffer.pushed_nodes.size());
693 if (push_count > 0) {
694 Emit(kMips64StackClaim, g.NoOutput(),
695 g.TempImmediate(push_count << kPointerSizeLog2));
696 }
697 int32_t slot = push_count - 1;
698 for (Node* node : base::Reversed(buffer.pushed_nodes)) {
699 Emit(kMips64StoreToStackSlot, g.NoOutput(), g.UseRegister(node),
700 g.TempImmediate(slot << kPointerSizeLog2));
701 slot--;
702 }
688 } 703 }
689 704
690 // Pass label of exception handler block. 705 // Pass label of exception handler block.
691 CallDescriptor::Flags flags = descriptor->flags(); 706 CallDescriptor::Flags flags = descriptor->flags();
692 if (handler) { 707 if (handler) {
693 DCHECK_EQ(IrOpcode::kIfException, handler->front()->opcode()); 708 DCHECK_EQ(IrOpcode::kIfException, handler->front()->opcode());
694 IfExceptionHint hint = OpParameter<IfExceptionHint>(handler->front()); 709 IfExceptionHint hint = OpParameter<IfExceptionHint>(handler->front());
695 if (hint == IfExceptionHint::kLocallyCaught) { 710 if (hint == IfExceptionHint::kLocallyCaught) {
696 flags |= CallDescriptor::kHasLocalCatchHandler; 711 flags |= CallDescriptor::kHasLocalCatchHandler;
697 } 712 }
698 flags |= CallDescriptor::kHasExceptionHandler; 713 flags |= CallDescriptor::kHasExceptionHandler;
699 buffer.instruction_args.push_back(g.Label(handler)); 714 buffer.instruction_args.push_back(g.Label(handler));
700 } 715 }
701 716
702 // Select the appropriate opcode based on the call type. 717 // Select the appropriate opcode based on the call type.
703 InstructionCode opcode; 718 InstructionCode opcode;
704 switch (descriptor->kind()) { 719 switch (descriptor->kind()) {
705 case CallDescriptor::kCallCodeObject: { 720 case CallDescriptor::kCallAddress:
706 opcode = kArchCallCodeObject; 721 opcode =
722 kArchCallCFunction |
723 MiscField::encode(static_cast<int>(descriptor->CParameterCount()));
707 break; 724 break;
708 } 725 case CallDescriptor::kCallCodeObject:
726 opcode = kArchCallCodeObject | MiscField::encode(flags);
727 break;
709 case CallDescriptor::kCallJSFunction: 728 case CallDescriptor::kCallJSFunction:
710 opcode = kArchCallJSFunction; 729 opcode = kArchCallJSFunction | MiscField::encode(flags);
711 break; 730 break;
712 default: 731 default:
713 UNREACHABLE(); 732 UNREACHABLE();
714 return; 733 return;
715 } 734 }
716 opcode |= MiscField::encode(flags); 735 opcode |= MiscField::encode(flags);
717 736
718 // Emit the call instruction. 737 // Emit the call instruction.
719 size_t const output_count = buffer.outputs.size(); 738 size_t const output_count = buffer.outputs.size();
720 auto* outputs = output_count ? &buffer.outputs.front() : nullptr; 739 auto* outputs = output_count ? &buffer.outputs.front() : nullptr;
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
1296 MachineOperatorBuilder::kFloat32Min | 1315 MachineOperatorBuilder::kFloat32Min |
1297 MachineOperatorBuilder::kFloat64Max | 1316 MachineOperatorBuilder::kFloat64Max |
1298 MachineOperatorBuilder::kFloat64Min; 1317 MachineOperatorBuilder::kFloat64Min;
1299 } 1318 }
1300 return flags; 1319 return flags;
1301 } 1320 }
1302 1321
1303 } // namespace compiler 1322 } // namespace compiler
1304 } // namespace internal 1323 } // namespace internal
1305 } // namespace v8 1324 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698