Make CompileModule actually compile (#469)

This commit makes it possible for functions to be compiled before instantiation.
Notably, this adds CompileModule method on Engine interface where we pass
wasm.Module (which is the decoded module) to engines, and engines compile
all the module functions and caches them keyed on *wasm.Module.

In order to achieve that, this stops the compiled native code from embedding typeID
which is assigned for all the function types in a store.

Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
This commit is contained in:
Takeshi Yoneda
2022-04-18 18:14:58 +09:00
committed by GitHub
parent d34e7ee3be
commit d2905d480c
36 changed files with 1172 additions and 1287 deletions

View File

@@ -343,9 +343,14 @@ func TestNewModuleBuilder_Build(t *testing.T) {
tc := tt
t.Run(tc.name, func(t *testing.T) {
m, e := tc.input(NewRuntime()).Build()
require.NoError(t, e)
b := tc.input(NewRuntime()).(*moduleBuilder)
m, err := b.Build()
require.NoError(t, err)
requireHostModuleEquals(t, tc.expected, m.module)
// Built module must be instantiable by Engine.
_, err = b.r.InstantiateModule(m)
require.NoError(t, err)
})
}
}