mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
update go-ffmpreg to v0.2.5 (pulls in latest tetratelabs/wazero) (#3203)
This commit is contained in:
3
vendor/github.com/tetratelabs/wazero/internal/wasm/binary/value.go
generated
vendored
3
vendor/github.com/tetratelabs/wazero/internal/wasm/binary/value.go
generated
vendored
@ -54,7 +54,6 @@ func decodeUTF8(r *bytes.Reader, contextFormat string, contextArgs ...interface{
|
||||
return "", 0, fmt.Errorf("%s is not valid UTF-8", fmt.Sprintf(contextFormat, contextArgs...))
|
||||
}
|
||||
|
||||
// TODO: use unsafe.String after flooring Go 1.20.
|
||||
ret := *(*string)(unsafe.Pointer(&buf))
|
||||
ret := unsafe.String(&buf[0], int(size))
|
||||
return ret, size + uint32(sizeOfSize), nil
|
||||
}
|
||||
|
9
vendor/github.com/tetratelabs/wazero/internal/wasm/func_validation.go
generated
vendored
9
vendor/github.com/tetratelabs/wazero/internal/wasm/func_validation.go
generated
vendored
@ -451,14 +451,14 @@ func (m *Module) validateFunctionWithMaxStackValues(
|
||||
return fmt.Errorf("read immediate: %w", err)
|
||||
}
|
||||
|
||||
list := make([]uint32, nl)
|
||||
sts.ls = sts.ls[:0]
|
||||
for i := uint32(0); i < nl; i++ {
|
||||
l, n, err := leb128.DecodeUint32(br)
|
||||
if err != nil {
|
||||
return fmt.Errorf("read immediate: %w", err)
|
||||
}
|
||||
num += n
|
||||
list[i] = l
|
||||
sts.ls = append(sts.ls, l)
|
||||
}
|
||||
ln, n, err := leb128.DecodeUint32(br)
|
||||
if err != nil {
|
||||
@ -511,7 +511,7 @@ func (m *Module) validateFunctionWithMaxStackValues(
|
||||
}
|
||||
}
|
||||
|
||||
for _, l := range list {
|
||||
for _, l := range sts.ls {
|
||||
if int(l) >= len(controlBlockStack.stack) {
|
||||
return fmt.Errorf("invalid l param given for %s", OpcodeBrTableName)
|
||||
}
|
||||
@ -2003,6 +2003,8 @@ var vecSplatValueTypes = [...]ValueType{
|
||||
type stacks struct {
|
||||
vs valueTypeStack
|
||||
cs controlBlockStack
|
||||
// ls is the label slice that is reused for each br_table instruction.
|
||||
ls []uint32
|
||||
}
|
||||
|
||||
func (sts *stacks) reset(functionType *FunctionType) {
|
||||
@ -2012,6 +2014,7 @@ func (sts *stacks) reset(functionType *FunctionType) {
|
||||
sts.vs.maximumStackPointer = 0
|
||||
sts.cs.stack = sts.cs.stack[:0]
|
||||
sts.cs.stack = append(sts.cs.stack, controlBlock{blockType: functionType})
|
||||
sts.ls = sts.ls[:0]
|
||||
}
|
||||
|
||||
type controlBlockStack struct {
|
||||
|
10
vendor/github.com/tetratelabs/wazero/internal/wasm/memory.go
generated
vendored
10
vendor/github.com/tetratelabs/wazero/internal/wasm/memory.go
generated
vendored
@ -52,7 +52,8 @@ type MemoryInstance struct {
|
||||
definition api.MemoryDefinition
|
||||
|
||||
// Mux is used in interpreter mode to prevent overlapping calls to atomic instructions,
|
||||
// introduced with WebAssembly threads proposal.
|
||||
// introduced with WebAssembly threads proposal, and in compiler mode to make memory modifications
|
||||
// within Grow non-racy for the Go race detector.
|
||||
Mux sync.Mutex
|
||||
|
||||
// waiters implements atomic wait and notify. It is implemented similarly to golang.org/x/sync/semaphore,
|
||||
@ -227,6 +228,11 @@ func MemoryPagesToBytesNum(pages uint32) (bytesNum uint64) {
|
||||
|
||||
// Grow implements the same method as documented on api.Memory.
|
||||
func (m *MemoryInstance) Grow(delta uint32) (result uint32, ok bool) {
|
||||
if m.Shared {
|
||||
m.Mux.Lock()
|
||||
defer m.Mux.Unlock()
|
||||
}
|
||||
|
||||
currentPages := m.Pages()
|
||||
if delta == 0 {
|
||||
return currentPages, true
|
||||
@ -299,6 +305,7 @@ func PagesToUnitOfBytes(pages uint32) string {
|
||||
|
||||
// Uses atomic write to update the length of a slice.
|
||||
func atomicStoreLengthAndCap(slice *[]byte, length uintptr, cap uintptr) {
|
||||
//nolint:staticcheck
|
||||
slicePtr := (*reflect.SliceHeader)(unsafe.Pointer(slice))
|
||||
capPtr := (*uintptr)(unsafe.Pointer(&slicePtr.Cap))
|
||||
atomic.StoreUintptr(capPtr, cap)
|
||||
@ -308,6 +315,7 @@ func atomicStoreLengthAndCap(slice *[]byte, length uintptr, cap uintptr) {
|
||||
|
||||
// Uses atomic write to update the length of a slice.
|
||||
func atomicStoreLength(slice *[]byte, length uintptr) {
|
||||
//nolint:staticcheck
|
||||
slicePtr := (*reflect.SliceHeader)(unsafe.Pointer(slice))
|
||||
lenPtr := (*uintptr)(unsafe.Pointer(&slicePtr.Len))
|
||||
atomic.StoreUintptr(lenPtr, length)
|
||||
|
31
vendor/github.com/tetratelabs/wazero/internal/wasm/store.go
generated
vendored
31
vendor/github.com/tetratelabs/wazero/internal/wasm/store.go
generated
vendored
@ -3,6 +3,7 @@ package wasm
|
||||
import (
|
||||
"context"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
@ -352,7 +353,7 @@ func (s *Store) instantiate(
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err = m.resolveImports(module); err != nil {
|
||||
if err = m.resolveImports(ctx, module); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -410,12 +411,22 @@ func (s *Store) instantiate(
|
||||
return
|
||||
}
|
||||
|
||||
func (m *ModuleInstance) resolveImports(module *Module) (err error) {
|
||||
func (m *ModuleInstance) resolveImports(ctx context.Context, module *Module) (err error) {
|
||||
// Check if ctx contains an ImportResolver.
|
||||
resolveImport, _ := ctx.Value(expctxkeys.ImportResolverKey{}).(experimental.ImportResolver)
|
||||
|
||||
for moduleName, imports := range module.ImportPerModule {
|
||||
var importedModule *ModuleInstance
|
||||
importedModule, err = m.s.module(moduleName)
|
||||
if err != nil {
|
||||
return err
|
||||
if resolveImport != nil {
|
||||
if v := resolveImport(moduleName); v != nil {
|
||||
importedModule = v.(*ModuleInstance)
|
||||
}
|
||||
}
|
||||
if importedModule == nil {
|
||||
importedModule, err = m.s.module(moduleName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
for _, i := range imports {
|
||||
@ -649,20 +660,20 @@ func (s *Store) GetFunctionTypeID(t *FunctionType) (FunctionTypeID, error) {
|
||||
}
|
||||
|
||||
// CloseWithExitCode implements the same method as documented on wazero.Runtime.
|
||||
func (s *Store) CloseWithExitCode(ctx context.Context, exitCode uint32) (err error) {
|
||||
func (s *Store) CloseWithExitCode(ctx context.Context, exitCode uint32) error {
|
||||
s.mux.Lock()
|
||||
defer s.mux.Unlock()
|
||||
// Close modules in reverse initialization order.
|
||||
var errs []error
|
||||
for m := s.moduleList; m != nil; m = m.next {
|
||||
// If closing this module errs, proceed anyway to close the others.
|
||||
if e := m.closeWithExitCode(ctx, exitCode); e != nil && err == nil {
|
||||
// TODO: use multiple errors handling in Go 1.20.
|
||||
err = e // first error
|
||||
if err := m.closeWithExitCode(ctx, exitCode); err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
}
|
||||
s.moduleList = nil
|
||||
s.nameToModule = nil
|
||||
s.nameToModuleCap = 0
|
||||
s.typeIDs = nil
|
||||
return
|
||||
return errors.Join(errs...)
|
||||
}
|
||||
|
4
vendor/github.com/tetratelabs/wazero/internal/wasm/store_module_list.go
generated
vendored
4
vendor/github.com/tetratelabs/wazero/internal/wasm/store_module_list.go
generated
vendored
@ -3,8 +3,6 @@ package wasm
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/tetratelabs/wazero/api"
|
||||
)
|
||||
|
||||
// deleteModule makes the moduleName available for instantiation again.
|
||||
@ -88,7 +86,7 @@ func (s *Store) registerModule(m *ModuleInstance) error {
|
||||
}
|
||||
|
||||
// Module implements wazero.Runtime Module
|
||||
func (s *Store) Module(moduleName string) api.Module {
|
||||
func (s *Store) Module(moduleName string) *ModuleInstance {
|
||||
m, err := s.module(moduleName)
|
||||
if err != nil {
|
||||
return nil
|
||||
|
Reference in New Issue
Block a user