compiler: save conditional values at data.drop (#724)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
This commit is contained in:
@@ -3580,6 +3580,10 @@ func (c *amd64Compiler) compileInitImpl(isTable bool, index, tableIndex uint32)
|
||||
|
||||
// compileDataDrop implements compiler.compileDataDrop for the amd64 architecture.
|
||||
func (c *amd64Compiler) compileDataDrop(o *wazeroir.OperationDataDrop) error {
|
||||
if err := c.maybeCompileMoveTopConditionalToGeneralPurposeRegister(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tmp, err := c.allocateRegister(registerTypeGeneralPurpose)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -3221,6 +3221,10 @@ func (c *arm64Compiler) compileInitImpl(isTable bool, index, tableIndex uint32)
|
||||
|
||||
// compileDataDrop implements compiler.compileDataDrop for the arm64 architecture.
|
||||
func (c *arm64Compiler) compileDataDrop(o *wazeroir.OperationDataDrop) error {
|
||||
if err := c.maybeCompileMoveTopConditionalToGeneralPurposeRegister(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tmp, err := c.allocateRegister(registerTypeGeneralPurpose)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -235,3 +235,17 @@ func Test721(t *testing.T) {
|
||||
require.Equal(t, uint64(1), ret[0])
|
||||
})
|
||||
}
|
||||
|
||||
func Test722(t *testing.T) {
|
||||
run(t, func(t *testing.T, r wazero.Runtime) {
|
||||
mod, err := r.InstantiateModuleFromBinary(ctx, getWasmBinary(t, 722))
|
||||
require.NoError(t, err)
|
||||
|
||||
f := mod.ExportedFunction("conditional before data.drop")
|
||||
require.NotNil(t, f)
|
||||
ret, err := f.Call(ctx)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, uint64(1), ret[0])
|
||||
})
|
||||
}
|
||||
|
||||
BIN
internal/integration_test/fuzzcases/testdata/722.wasm
vendored
Normal file
BIN
internal/integration_test/fuzzcases/testdata/722.wasm
vendored
Normal file
Binary file not shown.
10
internal/integration_test/fuzzcases/testdata/722.wat
vendored
Normal file
10
internal/integration_test/fuzzcases/testdata/722.wat
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
(module
|
||||
(func (export "conditional before data.drop") (result i32)
|
||||
ref.null func
|
||||
ref.is_null
|
||||
;; At this point, i32 value is placed on the conditional register.
|
||||
;; data.drop must handle it correctly and save it to a general purpose one.
|
||||
data.drop 0
|
||||
)
|
||||
(data "\ff")
|
||||
)
|
||||
Reference in New Issue
Block a user