Adds function names to host functions and improves logging listener (#697)
This improves the experimental logging listener to show parameter name
and values like so:
```
--> ._start.command_export()
--> .__wasm_call_ctors()
--> .__wasilibc_initialize_environ()
==> wasi_snapshot_preview1.environ_sizes_get(result.environc=1048572,result.environBufSize=1048568)
<== ESUCCESS
<-- ()
==> wasi_snapshot_preview1.fd_prestat_get(fd=3,result.prestat=1048568)
<== ESUCCESS
--> .dlmalloc(2)
--> .sbrk(0)
<-- (1114112)
<-- (1060080)
--snip--
```
The convention `==>` implies it was a host function call
(def.IsHostFunction). This also improves the lifecycle by creating
listeners during compile. Finally, this backfills param names for
assemblyscript and wasi.
Signed-off-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
@@ -91,13 +91,7 @@ func TestModuleInstance_Memory(t *testing.T) {
|
||||
|
||||
func TestStore_Instantiate(t *testing.T) {
|
||||
s, ns := newStore()
|
||||
m, err := NewHostModule(
|
||||
"",
|
||||
map[string]interface{}{"fn": func(api.Module) {}},
|
||||
map[string]*Memory{},
|
||||
map[string]*Global{},
|
||||
Features20191205,
|
||||
)
|
||||
m, err := NewHostModule("", map[string]interface{}{"fn": func(api.Module) {}}, nil, map[string]*Memory{}, map[string]*Global{}, Features20191205)
|
||||
require.NoError(t, err)
|
||||
|
||||
sysCtx := sys.DefaultContext(nil)
|
||||
@@ -175,13 +169,7 @@ func TestStore_CloseWithExitCode(t *testing.T) {
|
||||
func TestStore_hammer(t *testing.T) {
|
||||
const importedModuleName = "imported"
|
||||
|
||||
m, err := NewHostModule(
|
||||
importedModuleName,
|
||||
map[string]interface{}{"fn": func(api.Module) {}},
|
||||
map[string]*Memory{},
|
||||
map[string]*Global{},
|
||||
Features20191205,
|
||||
)
|
||||
m, err := NewHostModule(importedModuleName, map[string]interface{}{"fn": func(api.Module) {}}, nil, map[string]*Memory{}, map[string]*Global{}, Features20191205)
|
||||
require.NoError(t, err)
|
||||
|
||||
s, ns := newStore()
|
||||
@@ -235,13 +223,7 @@ func TestStore_Instantiate_Errors(t *testing.T) {
|
||||
const importedModuleName = "imported"
|
||||
const importingModuleName = "test"
|
||||
|
||||
m, err := NewHostModule(
|
||||
importedModuleName,
|
||||
map[string]interface{}{"fn": func(api.Module) {}},
|
||||
map[string]*Memory{},
|
||||
map[string]*Global{},
|
||||
Features20191205,
|
||||
)
|
||||
m, err := NewHostModule(importedModuleName, map[string]interface{}{"fn": func(api.Module) {}}, nil, map[string]*Memory{}, map[string]*Global{}, Features20191205)
|
||||
require.NoError(t, err)
|
||||
|
||||
t.Run("Fails if module name already in use", func(t *testing.T) {
|
||||
@@ -332,13 +314,7 @@ func TestStore_Instantiate_Errors(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCallContext_ExportedFunction(t *testing.T) {
|
||||
host, err := NewHostModule(
|
||||
"host",
|
||||
map[string]interface{}{"host_fn": func(api.Module) {}},
|
||||
map[string]*Memory{},
|
||||
map[string]*Global{},
|
||||
Features20191205,
|
||||
)
|
||||
host, err := NewHostModule("host", map[string]interface{}{"host_fn": func(api.Module) {}}, nil, map[string]*Memory{}, map[string]*Global{}, Features20191205)
|
||||
require.NoError(t, err)
|
||||
|
||||
s, ns := newStore()
|
||||
|
||||
Reference in New Issue
Block a user