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:
@@ -181,13 +181,7 @@ func TestNewHostModule(t *testing.T) {
|
||||
tc := tt
|
||||
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
m, e := NewHostModule(
|
||||
tc.moduleName,
|
||||
tc.nameToGoFunc,
|
||||
tc.nameToMemory,
|
||||
tc.nameToGlobal,
|
||||
Features20191205|FeatureMultiValue,
|
||||
)
|
||||
m, e := NewHostModule(tc.moduleName, tc.nameToGoFunc, nil, tc.nameToMemory, tc.nameToGlobal, Features20191205|FeatureMultiValue)
|
||||
require.NoError(t, e)
|
||||
requireHostModuleEquals(t, tc.expected, m)
|
||||
})
|
||||
@@ -227,19 +221,19 @@ func TestNewHostModule_Errors(t *testing.T) {
|
||||
{
|
||||
name: "not a function",
|
||||
nameToGoFunc: map[string]interface{}{"fn": t},
|
||||
expectedErr: "func[fn] kind != func: ptr",
|
||||
expectedErr: "func[.fn] kind != func: ptr",
|
||||
},
|
||||
{
|
||||
name: "function has multiple results",
|
||||
nameToGoFunc: map[string]interface{}{"fn": func() (uint32, uint32) { return 0, 0 }},
|
||||
nameToMemory: map[string]*Memory{"mem": {Min: 1, Max: 1}},
|
||||
expectedErr: "func[fn] multiple result types invalid as feature \"multi-value\" is disabled",
|
||||
expectedErr: "func[.fn] multiple result types invalid as feature \"multi-value\" is disabled",
|
||||
},
|
||||
{
|
||||
name: "func collides on memory name",
|
||||
nameToGoFunc: map[string]interface{}{"fn": ArgsSizesGet},
|
||||
nameToMemory: map[string]*Memory{"fn": {Min: 1, Max: 1}},
|
||||
expectedErr: "func[fn] exports the same name as a memory",
|
||||
expectedErr: "func[.fn] exports the same name as a memory",
|
||||
},
|
||||
{
|
||||
name: "multiple memories",
|
||||
@@ -255,7 +249,7 @@ func TestNewHostModule_Errors(t *testing.T) {
|
||||
name: "func collides on global name",
|
||||
nameToGoFunc: map[string]interface{}{"fn": ArgsSizesGet},
|
||||
nameToGlobal: map[string]*Global{"fn": {}},
|
||||
expectedErr: "func[fn] exports the same name as a global",
|
||||
expectedErr: "func[.fn] exports the same name as a global",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -263,7 +257,7 @@ func TestNewHostModule_Errors(t *testing.T) {
|
||||
tc := tt
|
||||
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
_, e := NewHostModule(tc.moduleName, tc.nameToGoFunc, tc.nameToMemory, tc.nameToGlobal, Features20191205)
|
||||
_, e := NewHostModule(tc.moduleName, tc.nameToGoFunc, nil, tc.nameToMemory, tc.nameToGlobal, Features20191205)
|
||||
require.EqualError(t, e, tc.expectedErr)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user