-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Function references unresolved issues #6455
Copy link
Copy link
Closed
Description
PR #5288 implements the function references proposal modulo a few missing bits. The missing bits are:
- Support for function references in the embedder API.
- Failing tests:
-
type-equivalence.wast: type canonicalisation is currently broken due to#[derive(hash)]not considering that two distinct typed function reference indices may point to structurally equivalent types. -
br_table.wast: this fails due to incomplete support for the various syntactic sugar in the wasm-tools/wastcrate. See Support for Wast table initialisation syntactic sugar with typeful references wasm-tools#952. -
ref_null.wastandlocal_init.wast: fail due to lack of support in the embedder API. -
return_call_ref.wast,return_call_indirect.wast,andreturn_call.wast: fail due to lack of tail call support.
-
At the time of writing the implementation does not take advantage of the static non-null safety to elide null checks when executing call_ref:
wasmtime/crates/cranelift/src/func_environ.rs
Lines 1744 to 1762 in 36e9f7e
| fn translate_call_ref( | |
| &mut self, | |
| builder: &mut FunctionBuilder, | |
| sig_ref: ir::SigRef, | |
| callee: ir::Value, | |
| call_args: &[ir::Value], | |
| ) -> WasmResult<ir::Inst> { | |
| // Check for whether the callee is null, and trap if so. | |
| // | |
| // FIXME: the wasm type system tracks enough information to know whether | |
| // `callee` is a null reference or not. In some situations it can be | |
| // statically known here that `callee` cannot be null in which case this | |
| // null check can be elided. This requires feeding type information from | |
| // wasmparser's validator into this function, however, which is not | |
| // easily done at this time. | |
| builder.ins().trapz(callee, ir::TrapCode::NullReference); | |
| self.call_function_unchecked(builder, sig_ref, callee, call_args) | |
| } |
Reactions are currently unavailable