Skip to content

Commit

Permalink
Merge pull request #22 from jerbob92/feature/implement-emscripten-3.1…
Browse files Browse the repository at this point in the history
….48-additions

Add support for Emscripten 3.1.48 - 3.1.50, recompile examples and testdata
  • Loading branch information
jerbob92 authored Dec 2, 2023
2 parents 6c704ca + ec9b908 commit f3ff5ac
Show file tree
Hide file tree
Showing 22 changed files with 1,475 additions and 2,413 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/emscripten.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
emscripten: [ "3.1.44", "3.1.45", "3.1.46", "3.1.47" ]
emscripten: [ "3.1.44", "3.1.45", "3.1.46", "3.1.47", "3.1.48", "3.1.49", "3.1.50" ]
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v3
Expand Down
Binary file modified examples/classes/wasm/classes.wasm
Binary file not shown.
Binary file modified examples/enums-and-constants/wasm/enums_and_constants.wasm
Binary file not shown.
Binary file modified examples/hello-world/wasm/hello_world.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion internal/array.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ var FinalizeValueArray = api.GoModuleFunc(func(ctx context.Context, mod api.Modu
baseType: baseType{
rawType: rawTupleType,
name: reg.name,
argPackAdvance: 8,
argPackAdvance: GenericWireTypeSize,
},
reg: reg,
elementsLength: elementsLength,
Expand Down
2 changes: 1 addition & 1 deletion internal/bigint.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ var RegisterBigInt = api.GoModuleFunc(func(ctx context.Context, mod api.Module,
baseType: baseType{
rawType: rawType,
name: name,
argPackAdvance: 8,
argPackAdvance: GenericWireTypeSize,
},
size: api.DecodeI32(stack[2]),
signed: !strings.HasPrefix(name, "u"),
Expand Down
2 changes: 1 addition & 1 deletion internal/bool.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ var RegisterBool = func(hasSize bool) api.GoModuleFunc {
baseType: baseType{
rawType: rawType,
name: name,
argPackAdvance: 8,
argPackAdvance: GenericWireTypeSize,
},
size: size,
trueVal: trueVal,
Expand Down
18 changes: 14 additions & 4 deletions internal/class.go
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ var RegisterClass = api.GoModuleFunc(func(ctx context.Context, mod api.Module, s

referenceConverter := &registeredPointerType{
baseType: baseType{
argPackAdvance: 8,
argPackAdvance: GenericWireTypeSize,
name: name,
},
registeredClass: engine.registeredClasses[name],
Expand All @@ -657,7 +657,7 @@ var RegisterClass = api.GoModuleFunc(func(ctx context.Context, mod api.Module, s

pointerConverter := &registeredPointerType{
baseType: baseType{
argPackAdvance: 8,
argPackAdvance: GenericWireTypeSize,
name: name + "*",
},
registeredClass: engine.registeredClasses[name],
Expand All @@ -668,7 +668,7 @@ var RegisterClass = api.GoModuleFunc(func(ctx context.Context, mod api.Module, s

constPointerConverter := &registeredPointerType{
baseType: baseType{
argPackAdvance: 8,
argPackAdvance: GenericWireTypeSize,
name: name + " const*",
},
registeredClass: engine.registeredClasses[name],
Expand Down Expand Up @@ -805,6 +805,11 @@ var RegisterClassFunction = api.GoModuleFunc(func(ctx context.Context, mod api.M
panic(fmt.Errorf("could not read method name: %w", err))
}

methodName, err = getFunctionName(methodName)
if err != nil {
panic(fmt.Errorf("could not read method name: %w", err))
}

err = engine.whenDependentTypesAreResolved([]int32{}, []int32{rawClassType}, func(classTypes []registeredType) ([]registeredType, error) {
classType := classTypes[0].(*registeredPointerType)
humanName := classType.Name() + "." + methodName
Expand Down Expand Up @@ -937,6 +942,11 @@ var RegisterClassClassFunction = api.GoModuleFunc(func(ctx context.Context, mod
panic(fmt.Errorf("could not read method name: %w", err))
}

methodName, err = getFunctionName(methodName)
if err != nil {
panic(fmt.Errorf("could not read method name: %w", err))
}

err = engine.whenDependentTypesAreResolved([]int32{}, []int32{rawClassType}, func(classTypes []registeredType) ([]registeredType, error) {
classType := classTypes[0].(*registeredPointerType)
humanName := classType.Name() + "." + methodName
Expand Down Expand Up @@ -1356,7 +1366,7 @@ var RegisterSmartPtr = api.GoModuleFunc(func(ctx context.Context, mod api.Module

smartPointerType := &registeredPointerType{
baseType: baseType{
argPackAdvance: 8,
argPackAdvance: GenericWireTypeSize,
name: name,
},
registeredClass: pointeeType.(*registeredPointerType).registeredClass,
Expand Down
13 changes: 13 additions & 0 deletions internal/embind.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"reflect"
"strings"

"github.com/tetratelabs/wazero/api"
)
Expand Down Expand Up @@ -105,3 +106,15 @@ func CreateEngine(config IEngineConfig) IEngine {
emvalEngine: createEmvalEngine(),
}
}

const GenericWireTypeSize = 8

func getFunctionName(signature string) (string, error) {
signature = strings.TrimSpace(signature)
argsIndex := strings.Index(signature, "(")
if argsIndex != -1 {
return signature[0:argsIndex], nil
}

return signature, nil
}
Loading

0 comments on commit f3ff5ac

Please sign in to comment.