Add extra layer of indirection for funcref, update tables

This is still a WIP, cranelift is passing spectests but singlepass has 3
failures and LLVM is not implemented correctly
This commit is contained in:
Mark McCaskey
2021-02-03 07:47:25 -08:00
parent 917fba558e
commit ecf891e0ac
22 changed files with 687 additions and 104 deletions

View File

@ -2202,18 +2202,23 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
// We assume the table has the `anyfunc` element type.
let casted_table_base = self.builder.build_pointer_cast(
table_base,
self.intrinsics.anyfunc_ty.ptr_type(AddressSpace::Generic),
self.intrinsics.funcref_ty.ptr_type(AddressSpace::Generic),
"casted_table_base",
);
let anyfunc_struct_ptr = unsafe {
let funcref_ptr = unsafe {
self.builder.build_in_bounds_gep(
casted_table_base,
&[func_index],
"anyfunc_struct_ptr",
"funcref_ptr",
)
};
let anyfunc_struct_ptr = self
.builder
.build_load(funcref_ptr, "anyfunc_struct_ptr")
.into_pointer_value();
// Load things from the anyfunc data structure.
let (func_ptr, found_dynamic_sigindex, ctx_ptr) = (
self.builder