Commit b209d2de authored by Milad Farazmand's avatar Milad Farazmand Committed by Commit Bot

PPC: [wasm-c-api] Add tests and fixes

Port f72c844a

Original Commit Message:

    Port f5ab7d38

    Port 65f3861e

    Original Commit Message:

        In a new test suite: "wasm-api-tests", using a new binary "wasm_api_tests",
        powered by gtest/gmock (like unittests).
        Also fix a bunch of issues that these tests uncovered, mostly to ensure
        that the stack is walkable.

R=miladfar@ca.ibm.com, joransiu@ca.ibm.com, jyan@ca.ibm.com, michael_dawson@ca.ibm.com
BUG=
LOG=N

Change-Id: I565fba1a2437eb49be0c5247740f3fcac7b071db
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1775723Reviewed-by: 's avatarJoran Siu <joransiu@ca.ibm.com>
Commit-Queue: Milad Farazmand <miladfar@ca.ibm.com>
Cr-Commit-Position: refs/heads/master@{#63460}
parent 32939550
......@@ -1024,13 +1024,14 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
Label start_call;
bool isWasmCapiFunction =
linkage()->GetIncomingDescriptor()->IsWasmCapiFunction();
constexpr int offset = 12;
constexpr int offset = 9 * kInstrSize;
if (isWasmCapiFunction) {
__ mflr(kScratchReg);
__ mflr(r0);
__ bind(&start_call);
__ LoadPC(r0);
__ addi(r0, r0, Operand(offset));
__ StoreP(r0, MemOperand(fp, WasmExitFrameConstants::kCallingPCOffset));
__ LoadPC(kScratchReg);
__ addi(kScratchReg, kScratchReg, Operand(offset));
__ StoreP(kScratchReg,
MemOperand(fp, WasmExitFrameConstants::kCallingPCOffset));
__ mtlr(r0);
}
if (instr->InputAt(0)->IsImmediate()) {
......@@ -1040,11 +1041,11 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
Register func = i.InputRegister(0);
__ CallCFunction(func, num_parameters);
}
// TODO(miladfar): In the above block, r0 must be populated with the
// strictly-correct PC, which is the return address at this spot. The
// offset is set to 12 right now, which is counted from where we are
// binding to the label and ends at this spot. If failed, replace it it
// with the correct offset suggested. More info on f5ab7d3.
// 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) right now, 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.
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