Use same CompiledCode for import replacement (#478)

This commit allows CompiledCode to be re-used regardless of
the existence of import replacement configs for instantiation.

In order to achieve this, we introduce ModuleID, which is sha256
checksum calculated on source bytes, as a key for module compilation
cache. Previously, we used*wasm.Module as keys for caches which
differ before/after import replacement.

Signed-off-by: Takeshi Yoneda takeshi@tetrate.io
This commit is contained in:
Takeshi Yoneda
2022-04-18 20:07:28 +09:00
committed by GitHub
parent d2905d480c
commit 0ca7ee1340
13 changed files with 78 additions and 99 deletions

View File

@@ -346,8 +346,11 @@ func TestNewModuleBuilder_Build(t *testing.T) {
b := tc.input(NewRuntime()).(*moduleBuilder)
m, err := b.Build()
require.NoError(t, err)
requireHostModuleEquals(t, tc.expected, m.module)
require.Equal(t, b.r.store.Engine, m.compiledEngine)
// Built module must be instantiable by Engine.
_, err = b.r.InstantiateModule(m)
require.NoError(t, err)