diff options
author | 2024-11-26 16:25:48 +0000 | |
---|---|---|
committer | 2024-11-26 16:25:48 +0000 | |
commit | 61f8f1e0e3236993f5522215f1900d35e49680c0 (patch) | |
tree | b8bec737013b8213996a40ab913a810833ac5e4e /vendor/github.com/tetratelabs/wazero/internal/engine | |
parent | [bugfix] Allow unsetting filter expiration dates (#3560) (diff) | |
download | gotosocial-61f8f1e0e3236993f5522215f1900d35e49680c0.tar.xz |
pull in ncruces/go-sqlite3 v0.20.3 with tetratelabs/wazero v1.8.2 (#3574)
Diffstat (limited to 'vendor/github.com/tetratelabs/wazero/internal/engine')
4 files changed, 14 insertions, 7 deletions
diff --git a/vendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/machine.go b/vendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/machine.go index aeeb6b645..7c27c92af 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/machine.go +++ b/vendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/machine.go @@ -2196,7 +2196,7 @@ func (m *machine) Encode(ctx context.Context) (err error) { } // ResolveRelocations implements backend.Machine. -func (m *machine) ResolveRelocations(refToBinaryOffset []int, binary []byte, relocations []backend.RelocationInfo, _ []int) { +func (m *machine) ResolveRelocations(refToBinaryOffset []int, _ int, binary []byte, relocations []backend.RelocationInfo, _ []int) { for _, r := range relocations { offset := r.Offset calleeFnOffset := refToBinaryOffset[r.FuncRef] diff --git a/vendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/machine_relocation.go b/vendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/machine_relocation.go index 83902d927..932fe842b 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/machine_relocation.go +++ b/vendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/machine_relocation.go @@ -21,7 +21,7 @@ const ( // trampolineIslandInterval is the range of the trampoline island. // Half of the range is used for the trampoline island, and the other half is used for the function. - trampolineIslandInterval = maxUnconditionalBranchOffset / 2 + trampolineIslandInterval = (maxUnconditionalBranchOffset - 1) / 2 // maxNumFunctions explicitly specifies the maximum number of functions that can be allowed in a single executable. maxNumFunctions = trampolineIslandInterval >> 6 @@ -42,12 +42,13 @@ func (m *machine) CallTrampolineIslandInfo(numFunctions int) (interval, size int // ResolveRelocations implements backend.Machine ResolveRelocations. func (m *machine) ResolveRelocations( refToBinaryOffset []int, + importedFns int, executable []byte, relocations []backend.RelocationInfo, callTrampolineIslandOffsets []int, ) { for _, islandOffset := range callTrampolineIslandOffsets { - encodeCallTrampolineIsland(refToBinaryOffset, islandOffset, executable) + encodeCallTrampolineIsland(refToBinaryOffset, importedFns, islandOffset, executable) } for _, r := range relocations { @@ -71,11 +72,15 @@ func (m *machine) ResolveRelocations( // encodeCallTrampolineIsland encodes a trampoline island for the given functions. // Each island consists of a trampoline instruction sequence for each function. // Each trampoline instruction sequence consists of 4 instructions + 32-bit immediate. -func encodeCallTrampolineIsland(refToBinaryOffset []int, islandOffset int, executable []byte) { - for i := 0; i < len(refToBinaryOffset); i++ { +func encodeCallTrampolineIsland(refToBinaryOffset []int, importedFns int, islandOffset int, executable []byte) { + // We skip the imported functions: they don't need trampolines + // and are not accounted for. + binaryOffsets := refToBinaryOffset[importedFns:] + + for i := 0; i < len(binaryOffsets); i++ { trampolineOffset := islandOffset + trampolineCallSize*i - fnOffset := refToBinaryOffset[i] + fnOffset := binaryOffsets[i] diff := fnOffset - (trampolineOffset + 16) if diff > math.MaxInt32 || diff < math.MinInt32 { // This case even amd64 can't handle. 4GB is too big. diff --git a/vendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/machine.go b/vendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/machine.go index 9044a9e4b..3a29e7cd6 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/machine.go +++ b/vendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/machine.go @@ -77,11 +77,13 @@ type ( // ResolveRelocations resolves the relocations after emitting machine code. // * refToBinaryOffset: the map from the function reference (ssa.FuncRef) to the executable offset. + // * importedFns: the max index of the imported functions at the beginning of refToBinaryOffset // * executable: the binary to resolve the relocations. // * relocations: the relocations to resolve. // * callTrampolineIslandOffsets: the offsets of the trampoline islands in the executable. ResolveRelocations( refToBinaryOffset []int, + importedFns int, executable []byte, relocations []RelocationInfo, callTrampolineIslandOffsets []int, diff --git a/vendor/github.com/tetratelabs/wazero/internal/engine/wazevo/engine.go b/vendor/github.com/tetratelabs/wazero/internal/engine/wazevo/engine.go index f02b905fc..a6df3e7e7 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/engine/wazevo/engine.go +++ b/vendor/github.com/tetratelabs/wazero/internal/engine/wazevo/engine.go @@ -314,7 +314,7 @@ func (e *engine) compileModule(ctx context.Context, module *wasm.Module, listene // Resolve relocations for local function calls. if len(rels) > 0 { - machine.ResolveRelocations(refToBinaryOffset, executable, rels, callTrampolineIslandOffsets) + machine.ResolveRelocations(refToBinaryOffset, importedFns, executable, rels, callTrampolineIslandOffsets) } if runtime.GOARCH == "arm64" { |