diff options
| author | 2025-11-10 07:29:48 +0100 | |
|---|---|---|
| committer | 2025-11-17 14:14:33 +0100 | |
| commit | 6a3b09a507aca0498845d9118a21a82bb5054301 (patch) | |
| tree | 5297960ecfe66f723179eb5a1a6f8d59504c3433 /vendor/github.com/tetratelabs/wazero/internal/wasm/func_validation.go | |
| parent | [performance] add optional S3 object info caching (#4546) (diff) | |
| download | gotosocial-6a3b09a507aca0498845d9118a21a82bb5054301.tar.xz | |
[chore] update dependencies (#4547)
- codeberg.org/gruf/go-ffmpreg: v0.6.12 -> v0.6.14
- github.com/ncruces/go-sqlite3: v0.30.0 -> v0.30.1
- github.com/wazero/wazero: v1.9.0 -> v1.10.0
Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4547
Co-authored-by: kim <grufwub@gmail.com>
Co-committed-by: kim <grufwub@gmail.com>
Diffstat (limited to 'vendor/github.com/tetratelabs/wazero/internal/wasm/func_validation.go')
| -rw-r--r-- | vendor/github.com/tetratelabs/wazero/internal/wasm/func_validation.go | 59 |
1 files changed, 48 insertions, 11 deletions
diff --git a/vendor/github.com/tetratelabs/wazero/internal/wasm/func_validation.go b/vendor/github.com/tetratelabs/wazero/internal/wasm/func_validation.go index 604489228..96d061a7b 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/wasm/func_validation.go +++ b/vendor/github.com/tetratelabs/wazero/internal/wasm/func_validation.go @@ -4,6 +4,7 @@ import ( "bytes" "errors" "fmt" + "slices" "strconv" "strings" @@ -480,11 +481,9 @@ func (m *Module) validateFunctionWithMaxStackValues( // function type might result in invalid value types if the block is the outermost label // which equals the function's type. if lnLabel.op != OpcodeLoop { // Loop operation doesn't require results since the continuation is the beginning of the loop. - defaultLabelType = make([]ValueType, len(lnLabel.blockType.Results)) - copy(defaultLabelType, lnLabel.blockType.Results) + defaultLabelType = slices.Clone(lnLabel.blockType.Results) } else { - defaultLabelType = make([]ValueType, len(lnLabel.blockType.Params)) - copy(defaultLabelType, lnLabel.blockType.Params) + defaultLabelType = slices.Clone(lnLabel.blockType.Params) } if enabledFeatures.IsEnabled(api.CoreFeatureReferenceTypes) { @@ -534,7 +533,7 @@ func (m *Module) validateFunctionWithMaxStackValues( // br_table instruction is stack-polymorphic. valueTypeStack.unreachable() - } else if op == OpcodeCall { + } else if op == OpcodeCall || op == OpcodeTailCallReturnCall { pc++ index, num, err := leb128.LoadUint32(body[pc:]) if err != nil { @@ -544,16 +543,35 @@ func (m *Module) validateFunctionWithMaxStackValues( if int(index) >= len(functions) { return fmt.Errorf("invalid function index") } + + var opcodeName string + if op == OpcodeCall { + opcodeName = OpcodeCallName + } else { + opcodeName = OpcodeTailCallReturnCallName + } + funcType := &m.TypeSection[functions[index]] for i := 0; i < len(funcType.Params); i++ { if err := valueTypeStack.popAndVerifyType(funcType.Params[len(funcType.Params)-1-i]); err != nil { - return fmt.Errorf("type mismatch on %s operation param type: %v", OpcodeCallName, err) + return fmt.Errorf("type mismatch on %s operation param type: %v", opcodeName, err) } } for _, exp := range funcType.Results { valueTypeStack.push(exp) } - } else if op == OpcodeCallIndirect { + if op == OpcodeTailCallReturnCall { + if err := enabledFeatures.RequireEnabled(experimental.CoreFeaturesTailCall); err != nil { + return fmt.Errorf("%s invalid as %v", OpcodeTailCallReturnCallName, err) + } + // Same formatting as OpcodeEnd on the outer-most block + if err := valueTypeStack.requireStackValues(false, "", functionType.Results, false); err != nil { + return err + } + // behaves as a jump. + valueTypeStack.unreachable() + } + } else if op == OpcodeCallIndirect || op == OpcodeTailCallReturnCallIndirect { pc++ typeIndex, num, err := leb128.LoadUint32(body[pc:]) if err != nil { @@ -561,8 +579,15 @@ func (m *Module) validateFunctionWithMaxStackValues( } pc += num + var opcodeName string + if op == OpcodeCallIndirect { + opcodeName = OpcodeCallIndirectName + } else { + opcodeName = OpcodeTailCallReturnCallIndirectName + } + if int(typeIndex) >= len(m.TypeSection) { - return fmt.Errorf("invalid type index at %s: %d", OpcodeCallIndirectName, typeIndex) + return fmt.Errorf("invalid type index at %s: %d", opcodeName, typeIndex) } tableIndex, num, err := leb128.LoadUint32(body[pc:]) @@ -582,21 +607,33 @@ func (m *Module) validateFunctionWithMaxStackValues( table := tables[tableIndex] if table.Type != RefTypeFuncref { - return fmt.Errorf("table is not funcref type but was %s for %s", RefTypeName(table.Type), OpcodeCallIndirectName) + return fmt.Errorf("table is not funcref type but was %s for %s", RefTypeName(table.Type), opcodeName) } if err = valueTypeStack.popAndVerifyType(ValueTypeI32); err != nil { - return fmt.Errorf("cannot pop the offset in table for %s", OpcodeCallIndirectName) + return fmt.Errorf("cannot pop the offset in table for %s", opcodeName) } funcType := &m.TypeSection[typeIndex] for i := 0; i < len(funcType.Params); i++ { if err = valueTypeStack.popAndVerifyType(funcType.Params[len(funcType.Params)-1-i]); err != nil { - return fmt.Errorf("type mismatch on %s operation input type", OpcodeCallIndirectName) + return fmt.Errorf("type mismatch on %s operation input type", opcodeName) } } for _, exp := range funcType.Results { valueTypeStack.push(exp) } + + if op == OpcodeTailCallReturnCallIndirect { + if err := enabledFeatures.RequireEnabled(experimental.CoreFeaturesTailCall); err != nil { + return fmt.Errorf("%s invalid as %v", OpcodeTailCallReturnCallIndirectName, err) + } + // Same formatting as OpcodeEnd on the outer-most block + if err := valueTypeStack.requireStackValues(false, "", functionType.Results, false); err != nil { + return err + } + // behaves as a jump. + valueTypeStack.unreachable() + } } else if OpcodeI32Eqz <= op && op <= OpcodeI64Extend32S { switch op { case OpcodeI32Eqz: |
