Index: src/compiler/arm/instruction-selector-arm.cc |
diff --git a/src/compiler/arm/instruction-selector-arm.cc b/src/compiler/arm/instruction-selector-arm.cc |
index 6fb0c5b5d5f61d8ef88418f8c86b191030f0613f..9deae6bef1ffd5c72eb43608084effd0d8c7a396 100644 |
--- a/src/compiler/arm/instruction-selector-arm.cc |
+++ b/src/compiler/arm/instruction-selector-arm.cc |
@@ -1096,11 +1096,26 @@ void InstructionSelector::VisitCall(Node* node, BasicBlock* handler) { |
// TODO(turbofan): on ARM 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. |
- for (Node* node : base::Reversed(buffer.pushed_nodes)) { |
- Emit(kArmPush, 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 = 0; |
+ for (Node* node : buffer.pushed_nodes) { |
+ Emit(kArmPoke | MiscField::encode(slot), g.NoOutput(), |
+ g.UseRegister(node)); |
+ ++slot; |
+ } |
+ } else { |
+ // Push any stack arguments. |
+ for (Node* node : base::Reversed(buffer.pushed_nodes)) { |
+ Emit(kArmPush, g.NoOutput(), g.UseRegister(node)); |
+ } |
} |
// Pass label of exception handler block. |
@@ -1118,18 +1133,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(); |