Commit 6950e9f8 authored by Milad Fa's avatar Milad Fa Committed by V8 LUCI CQ

PPC [wasm-c-api]: Fix offset under kArchCallCFunction

After https://crrev.com/c/2905605, input type might
also be a register in which case different number of instructions
get emitted. The number also changes if constant pool is
disabled.

Port: 54d84cf3

Change-Id: I9a7adb02de55caebaad552c1e15440c97b4384b0
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2914055
Commit-Queue: Milad Fa <mfarazma@redhat.com>
Reviewed-by: 's avatarJunliang Yan <junyan@redhat.com>
Cr-Commit-Position: refs/heads/master@{#74754}
parent 1bfa5139
......@@ -1020,8 +1020,23 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
Label start_call;
bool isWasmCapiFunction =
linkage()->GetIncomingDescriptor()->IsWasmCapiFunction();
int offset = (FLAG_enable_embedded_constant_pool ? 20 : 23) * kInstrSize;
int offset = 20 * kInstrSize;
if (instr->InputAt(0)->IsImmediate() &&
!FLAG_enable_embedded_constant_pool) {
// If loading an immediate without constant pool then 4 instructions get
// emitted instead of a single load (which makes it 3 extra).
offset = 23 * kInstrSize;
}
if (!instr->InputAt(0)->IsImmediate() && !ABI_CALL_VIA_IP) {
// On Linux and Sim, there will be an extra
// instruction to pass the input using the `ip` register. This
// instruction gets emitted under `CallCFunction` or
// `CallCFunctionHelper` depending on the type of the input (immediate
// or register). This extra move is only emitted on AIX if the input is
// an immediate and not a register.
offset -= kInstrSize;
}
#if ABI_USES_FUNCTION_DESCRIPTORS
// AIX/PPC64BE Linux uses a function descriptor
int kNumParametersMask = kHasFunctionDescriptorBitMask - 1;
......@@ -1054,10 +1069,9 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
}
// TODO(miladfar): In the above block, kScratchReg must be populated with
// the strictly-correct PC, which is the return address at this spot. The
// offset is set to 36 (9 * kInstrSize) on pLinux and 44 on AIX, which is
// counted from where we are binding to the label and ends at this spot.
// If failed, replace it with the correct offset suggested. More info on
// f5ab7d3.
// offset is counted from where we are binding to the label and ends at
// this spot. If failed, replace it with the correct offset suggested.
// More info on f5ab7d3.
#if V8_ENABLE_WEBASSEMBLY
if (isWasmCapiFunction) {
CHECK_EQ(offset, __ SizeOfCodeGeneratedSince(&start_call));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment