in plugins/experimental/wasm/lib/src/wasm.cc [106:157]
void WasmBase::registerCallbacks() {
#define _REGISTER(_fn) \
wasm_vm_->registerCallback( \
"env", #_fn, &exports::_fn, \
&ConvertFunctionWordToUint32<decltype(exports::_fn), \
exports::_fn>::convertFunctionWordToUint32)
_REGISTER(pthread_equal);
_REGISTER(emscripten_notify_memory_growth);
#undef _REGISTER
// Register the capability with the VM if it has been allowed, otherwise register a stub.
#define _REGISTER(module_name, name_prefix, export_prefix, _fn) \
if (capabilityAllowed(name_prefix #_fn)) { \
wasm_vm_->registerCallback( \
module_name, name_prefix #_fn, &exports::export_prefix##_fn, \
&ConvertFunctionWordToUint32<decltype(exports::export_prefix##_fn), \
exports::export_prefix##_fn>::convertFunctionWordToUint32); \
} else { \
typedef decltype(exports::export_prefix##_fn) export_type; \
constexpr export_type *stub = &exports::_fn##Stub<export_type>::stub; \
wasm_vm_->registerCallback( \
module_name, name_prefix #_fn, stub, \
&ConvertFunctionWordToUint32<export_type, stub>::convertFunctionWordToUint32); \
}
#define _REGISTER_WASI_UNSTABLE(_fn) _REGISTER("wasi_unstable", , wasi_unstable_, _fn)
#define _REGISTER_WASI_SNAPSHOT(_fn) _REGISTER("wasi_snapshot_preview1", , wasi_unstable_, _fn)
FOR_ALL_WASI_FUNCTIONS(_REGISTER_WASI_UNSTABLE);
FOR_ALL_WASI_FUNCTIONS(_REGISTER_WASI_SNAPSHOT);
#undef _REGISTER_WASI_UNSTABLE
#undef _REGISTER_WASI_SNAPSHOT
#define _REGISTER_PROXY(_fn) _REGISTER("env", "proxy_", , _fn)
FOR_ALL_HOST_FUNCTIONS(_REGISTER_PROXY);
if (abiVersion() == AbiVersion::ProxyWasm_0_1_0) {
_REGISTER_PROXY(get_configuration);
_REGISTER_PROXY(continue_request);
_REGISTER_PROXY(continue_response);
_REGISTER_PROXY(clear_route_cache);
} else if (abiVersion() == AbiVersion::ProxyWasm_0_2_0) {
_REGISTER_PROXY(continue_stream);
_REGISTER_PROXY(close_stream);
} else if (abiVersion() == AbiVersion::ProxyWasm_0_2_1) {
_REGISTER_PROXY(continue_stream);
_REGISTER_PROXY(close_stream);
_REGISTER_PROXY(get_log_level);
}
#undef _REGISTER_PROXY
#undef _REGISTER
}