s390x: [liftoff] implement CallC and CallNativeWasmCode
Change-Id: Id7b756cb216d034108c08374c89bffc7a0c3aaa8 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2736514 Reviewed-by: Milad Fa <mfarazma@redhat.com> Commit-Queue: Junliang Yan <junyan@redhat.com> Cr-Commit-Position: refs/heads/master@{#73196}
This commit is contained in:
parent
36a7cba2d6
commit
024d2c0604
@ -2742,11 +2742,91 @@ void LiftoffAssembler::CallC(const ValueKindSig* sig,
|
||||
const LiftoffRegister* rets,
|
||||
ValueKind out_argument_kind, int stack_bytes,
|
||||
ExternalReference ext_ref) {
|
||||
bailout(kUnsupportedArchitecture, "CallC");
|
||||
int total_size = RoundUp(stack_bytes, 8);
|
||||
|
||||
int size = total_size;
|
||||
constexpr int kStackPageSize = 4 * KB;
|
||||
|
||||
// Reserve space in the stack.
|
||||
while (size > kStackPageSize) {
|
||||
lay(sp, MemOperand(sp, -kStackPageSize));
|
||||
StoreU64(r0, MemOperand(sp));
|
||||
size -= kStackPageSize;
|
||||
}
|
||||
|
||||
lay(sp, MemOperand(sp, -size));
|
||||
|
||||
int arg_bytes = 0;
|
||||
for (ValueKind param_kind : sig->parameters()) {
|
||||
switch (param_kind) {
|
||||
case kI32:
|
||||
StoreU32(args->gp(), MemOperand(sp, arg_bytes));
|
||||
break;
|
||||
case kI64:
|
||||
StoreU64(args->gp(), MemOperand(sp, arg_bytes));
|
||||
break;
|
||||
case kF32:
|
||||
StoreF32(args->fp(), MemOperand(sp, arg_bytes));
|
||||
break;
|
||||
case kF64:
|
||||
StoreF64(args->fp(), MemOperand(sp, arg_bytes));
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
args++;
|
||||
arg_bytes += element_size_bytes(param_kind);
|
||||
}
|
||||
|
||||
DCHECK_LE(arg_bytes, stack_bytes);
|
||||
|
||||
// Pass a pointer to the buffer with the arguments to the C function.
|
||||
mov(r2, sp);
|
||||
|
||||
// Now call the C function.
|
||||
constexpr int kNumCCallArgs = 1;
|
||||
PrepareCallCFunction(kNumCCallArgs, no_reg);
|
||||
CallCFunction(ext_ref, kNumCCallArgs);
|
||||
|
||||
// Move return value to the right register.
|
||||
const LiftoffRegister* result_reg = rets;
|
||||
if (sig->return_count() > 0) {
|
||||
DCHECK_EQ(1, sig->return_count());
|
||||
constexpr Register kReturnReg = r2;
|
||||
if (kReturnReg != rets->gp()) {
|
||||
Move(*rets, LiftoffRegister(kReturnReg), sig->GetReturn(0));
|
||||
}
|
||||
result_reg++;
|
||||
}
|
||||
|
||||
// Load potential output value from the buffer on the stack.
|
||||
if (out_argument_kind != kStmt) {
|
||||
switch (out_argument_kind) {
|
||||
case kI32:
|
||||
LoadS32(result_reg->gp(), MemOperand(sp));
|
||||
break;
|
||||
case kI64:
|
||||
case kOptRef:
|
||||
case kRef:
|
||||
case kRtt:
|
||||
case kRttWithDepth:
|
||||
LoadU64(result_reg->gp(), MemOperand(sp));
|
||||
break;
|
||||
case kF32:
|
||||
LoadF32(result_reg->fp(), MemOperand(sp));
|
||||
break;
|
||||
case kF64:
|
||||
LoadF64(result_reg->fp(), MemOperand(sp));
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
lay(sp, MemOperand(sp, total_size));
|
||||
}
|
||||
|
||||
void LiftoffAssembler::CallNativeWasmCode(Address addr) {
|
||||
bailout(kUnsupportedArchitecture, "CallNativeWasmCode");
|
||||
Call(addr, RelocInfo::WASM_CALL);
|
||||
}
|
||||
|
||||
void LiftoffAssembler::TailCallNativeWasmCode(Address addr) {
|
||||
|
Loading…
Reference in New Issue
Block a user