amd64: fixes memory.fill bug (#1055)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io> Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
This commit is contained in:
@@ -3799,6 +3799,8 @@ func (c *amd64Compiler) compileFillLoopImpl(destinationOffset, value, fillSize *
|
|||||||
emptyEightGroupsJump := c.assembler.CompileJump(amd64.JEQ)
|
emptyEightGroupsJump := c.assembler.CompileJump(amd64.JEQ)
|
||||||
|
|
||||||
if replicateByte {
|
if replicateByte {
|
||||||
|
// Truncate value.register to a single byte
|
||||||
|
c.assembler.CompileConstToRegister(amd64.ANDQ, 0xff, value.register)
|
||||||
// Replicate single byte onto full 8-byte register.
|
// Replicate single byte onto full 8-byte register.
|
||||||
c.assembler.CompileConstToRegister(amd64.MOVQ, 0x0101010101010101, tmp)
|
c.assembler.CompileConstToRegister(amd64.MOVQ, 0x0101010101010101, tmp)
|
||||||
c.assembler.CompileRegisterToRegister(amd64.IMULQ, tmp, value.register)
|
c.assembler.CompileRegisterToRegister(amd64.IMULQ, tmp, value.register)
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/tetratelabs/wazero"
|
"github.com/tetratelabs/wazero"
|
||||||
|
"github.com/tetratelabs/wazero/api"
|
||||||
"github.com/tetratelabs/wazero/internal/platform"
|
"github.com/tetratelabs/wazero/internal/platform"
|
||||||
"github.com/tetratelabs/wazero/internal/testing/require"
|
"github.com/tetratelabs/wazero/internal/testing/require"
|
||||||
"github.com/tetratelabs/wazero/internal/wasm"
|
"github.com/tetratelabs/wazero/internal/wasm"
|
||||||
@@ -383,3 +384,22 @@ func Test888(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test1054(t *testing.T) {
|
||||||
|
if !platform.CompilerSupported() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
modules := make([]api.Module, 0, 2)
|
||||||
|
run(t, func(t *testing.T, r wazero.Runtime) {
|
||||||
|
mod, err := r.InstantiateModuleFromBinary(ctx, getWasmBinary(t, 1054))
|
||||||
|
require.NoError(t, err)
|
||||||
|
modules = append(modules, mod)
|
||||||
|
})
|
||||||
|
|
||||||
|
// Checks if the memory state is the same between engines.
|
||||||
|
require.Equal(t,
|
||||||
|
modules[0].Memory().(*wasm.MemoryInstance).Buffer,
|
||||||
|
modules[1].Memory().(*wasm.MemoryInstance).Buffer,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
BIN
internal/integration_test/fuzzcases/testdata/1054.wasm
vendored
Normal file
BIN
internal/integration_test/fuzzcases/testdata/1054.wasm
vendored
Normal file
Binary file not shown.
11
internal/integration_test/fuzzcases/testdata/1054.wat
vendored
Normal file
11
internal/integration_test/fuzzcases/testdata/1054.wat
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
(module
|
||||||
|
(type (;0;) (func))
|
||||||
|
(func (;0;) (type 0)
|
||||||
|
i32.const 1000
|
||||||
|
i32.const 1000
|
||||||
|
i32.const 1000
|
||||||
|
memory.fill
|
||||||
|
)
|
||||||
|
(memory (;0;) 1 2)
|
||||||
|
(start 0)
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user