compiler: save conditional values at data.drop (#724)

Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
This commit is contained in:
Takeshi Yoneda
2022-07-27 17:18:42 +09:00
committed by GitHub
parent a064f68532
commit d1336806d6
5 changed files with 32 additions and 0 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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])
})
}

Binary file not shown.

View 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")
)