mirror of
https://github.com/mii443/wasmer.git
synced 2025-08-24 09:19:25 +00:00
Added Wait / Notify opcode to LLVM compiler (for #3157)
This commit is contained in:
@ -11231,6 +11231,59 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
|
||||
.unwrap();
|
||||
self.state.push1(size);
|
||||
}
|
||||
Operator::MemoryAtomicWait32 { memarg } => {
|
||||
let memory_index = MemoryIndex::from_u32(memarg.memory);
|
||||
let (dst, val, timeout) = self.state.pop3()?;
|
||||
let wait32_fn_ptr = self.ctx.memory_wait32(memory_index, self.intrinsics);
|
||||
let callable_func = inkwell::values::CallableValue::try_from(wait32_fn_ptr).unwrap();
|
||||
let ret = self.builder.build_call(
|
||||
callable_func,
|
||||
&[
|
||||
vmctx.as_basic_value_enum().into(),
|
||||
self.intrinsics.i32_ty.const_int(memarg.memory as u64, false).into(),
|
||||
dst.into(),
|
||||
val.into(),
|
||||
timeout.into(),
|
||||
],
|
||||
"",
|
||||
);
|
||||
self.state.push1(ret.try_as_basic_value().left().unwrap());
|
||||
}
|
||||
Operator::MemoryAtomicWait64 { memarg } => {
|
||||
let memory_index = MemoryIndex::from_u32(memarg.memory);
|
||||
let (dst, val, timeout) = self.state.pop3()?;
|
||||
let wait64_fn_ptr = self.ctx.memory_wait64(memory_index, self.intrinsics);
|
||||
let callable_func = inkwell::values::CallableValue::try_from(wait64_fn_ptr).unwrap();
|
||||
let ret = self.builder.build_call(
|
||||
callable_func,
|
||||
&[
|
||||
vmctx.as_basic_value_enum().into(),
|
||||
self.intrinsics.i32_ty.const_int(memarg.memory as u64, false).into(),
|
||||
dst.into(),
|
||||
val.into(),
|
||||
timeout.into(),
|
||||
],
|
||||
"",
|
||||
);
|
||||
self.state.push1(ret.try_as_basic_value().left().unwrap());
|
||||
}
|
||||
Operator::MemoryAtomicNotify { memarg } => {
|
||||
let memory_index = MemoryIndex::from_u32(memarg.memory);
|
||||
let (dst, count) = self.state.pop2()?;
|
||||
let notify_fn_ptr = self.ctx.memory_notify(memory_index, self.intrinsics);
|
||||
let callable_func = inkwell::values::CallableValue::try_from(notify_fn_ptr).unwrap();
|
||||
let cnt = self.builder.build_call(
|
||||
callable_func,
|
||||
&[
|
||||
vmctx.as_basic_value_enum().into(),
|
||||
self.intrinsics.i32_ty.const_int(memarg.memory as u64, false).into(),
|
||||
dst.into(),
|
||||
count.into(),
|
||||
],
|
||||
"",
|
||||
);
|
||||
self.state.push1(cnt.try_as_basic_value().left().unwrap());
|
||||
}
|
||||
_ => {
|
||||
return Err(CompileError::Codegen(format!(
|
||||
"Operator {:?} unimplemented",
|
||||
|
Reference in New Issue
Block a user