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

Unified Diff: src/compiler/ppc/instruction-selector-ppc.cc

Issue 1206343002: PPC: [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: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/ppc/instruction-codes-ppc.h ('k') | src/compiler/ppc/linkage-ppc.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/ppc/instruction-selector-ppc.cc
diff --git a/src/compiler/ppc/instruction-selector-ppc.cc b/src/compiler/ppc/instruction-selector-ppc.cc
index 0f45647865df3ae57cdeb762c66f5a2f66797ccc..300e27fe6f07aca3be7d0981566000132a3e55d7 100644
--- a/src/compiler/ppc/instruction-selector-ppc.cc
+++ b/src/compiler/ppc/instruction-selector-ppc.cc
@@ -1442,12 +1442,35 @@ void InstructionSelector::VisitCall(Node* node, BasicBlock* handler) {
// TODO(turbofan): on PPC it's probably better to use the code object in a
// register if there are multiple uses of it. Improve constant pool and the
// heuristics in the register allocator for where to emit constants.
- InitializeCallBuffer(node, &buffer, true, false);
-
- // Push any stack arguments.
- // TODO(mbrandy): reverse order and use push only for first
- for (Node* node : base::Reversed(buffer.pushed_nodes)) {
- Emit(kPPC_Push, g.NoOutput(), g.UseRegister(node));
+ InitializeCallBuffer(node, &buffer, true, true);
+
+ // Prepare for C function call.
+ if (descriptor->IsCFunctionCall()) {
+ Emit(kArchPrepareCallCFunction |
+ MiscField::encode(static_cast<int>(descriptor->CParameterCount())),
+ 0, nullptr, 0, nullptr);
+
+ // Poke any stack arguments.
+ int slot = kStackFrameExtraParamSlot;
+ for (Node* node : buffer.pushed_nodes) {
+ Emit(kPPC_StoreToStackSlot, g.NoOutput(), g.UseRegister(node),
+ g.TempImmediate(slot));
+ ++slot;
+ }
+ } else {
+ // Push any stack arguments.
+ int num_slots = buffer.pushed_nodes.size();
+ int slot = 0;
+ for (Node* node : buffer.pushed_nodes) {
+ if (slot == 0) {
+ Emit(kPPC_PushFrame, g.NoOutput(), g.UseRegister(node),
+ g.TempImmediate(num_slots));
+ } else {
+ Emit(kPPC_StoreToStackSlot, g.NoOutput(), g.UseRegister(node),
+ g.TempImmediate(slot));
+ }
+ ++slot;
+ }
}
// Pass label of exception handler block.
@@ -1465,18 +1488,21 @@ void InstructionSelector::VisitCall(Node* node, BasicBlock* handler) {
// Select the appropriate opcode based on the call type.
InstructionCode opcode;
switch (descriptor->kind()) {
- case CallDescriptor::kCallCodeObject: {
- opcode = kArchCallCodeObject;
+ case CallDescriptor::kCallAddress:
+ opcode =
+ kArchCallCFunction |
+ MiscField::encode(static_cast<int>(descriptor->CParameterCount()));
+ break;
+ case CallDescriptor::kCallCodeObject:
+ opcode = kArchCallCodeObject | MiscField::encode(flags);
break;
- }
case CallDescriptor::kCallJSFunction:
- opcode = kArchCallJSFunction;
+ opcode = kArchCallJSFunction | MiscField::encode(flags);
break;
default:
UNREACHABLE();
return;
}
- opcode |= MiscField::encode(flags);
// Emit the call instruction.
size_t const output_count = buffer.outputs.size();
« no previous file with comments | « src/compiler/ppc/instruction-codes-ppc.h ('k') | src/compiler/ppc/linkage-ppc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698