Sign in Join
Wiki copytemporary

WebAssembly/Reference types

The WebAssembly reference types extension adds support for two opaque types - externref and funcref. They are managed by the host and cannot be stored in linear memory. They can be used as function parameters (they can only be passed by value), local variables, function results, and as WebAssembly globals.

Free Pascal support

Partial support for reference types was merged into the main FPC branch on Jun 26 2023.

externref

There is a new type in the System unit, called WasmExternRef. It represents the externref WebAssembly type.

funcref

Procedural types can now be declared as WasmFuncRef. For example:

pascal
type
  TMyWasmFuncRef = function(a: longint; b: int64): longint; WasmFuncRef;

These types represent the funcref WebAssembly type.

Restrictions

The WebAssembly reference types don't have an in-memory representation. Therefore, the following is not allowed:

Allowed operations

The WebAssembly reference types can be used in the following ways:

Future features (Not yet implemented)

The following seem to be possible to implement in the future, but is not yet implemented:

An additional WebAssembly proposal might allow equality comparison between reference types (currently, only comparison to nil is allowed).

See also


From the Free Pascal wiki, page "WebAssembly/Reference types", as it stood on 2023-06-26 after a change by Nickysn, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 2, last changed by WikiArchive .

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.