wazevo: handle empty host module (#2125)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
This commit is contained in:
@@ -308,7 +308,9 @@ func TestNewHostModuleBuilder_Compile(t *testing.T) {
|
|||||||
tc := tt
|
tc := tt
|
||||||
|
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
b := tc.input(NewRuntime(testCtx)).(*hostModuleBuilder)
|
cfg := NewRuntimeConfig()
|
||||||
|
cfg.(*runtimeConfig).EnableOptimizingCompiler()
|
||||||
|
b := tc.input(NewRuntimeWithConfig(testCtx, cfg)).(*hostModuleBuilder)
|
||||||
compiled, err := b.Compile(testCtx)
|
compiled, err := b.Compile(testCtx)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
m := compiled.(*compiledModule)
|
m := compiled.(*compiledModule)
|
||||||
|
|||||||
@@ -437,6 +437,11 @@ func (e *engine) compileHostModule(ctx context.Context, module *wasm.Module, lis
|
|||||||
totalSize += len(body)
|
totalSize += len(body)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if totalSize == 0 {
|
||||||
|
// Empty module.
|
||||||
|
return cm, nil
|
||||||
|
}
|
||||||
|
|
||||||
// Allocate executable memory and then copy the generated machine code.
|
// Allocate executable memory and then copy the generated machine code.
|
||||||
executable, err := platform.MmapCodeSegment(totalSize)
|
executable, err := platform.MmapCodeSegment(totalSize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user