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

@@ -256,9 +256,7 @@ func (b *moduleBuilder) Build() (*CompiledCode, error) {
return nil, err
}
ret := &CompiledCode{module: module}
ret.addCacheEntry(module, b.r.store.Engine)
return &CompiledCode{module: module}, nil
return &CompiledCode{module: module, compiledEngine: b.r.store.Engine}, nil
}
// Instantiate implements ModuleBuilder.Instantiate