diff --git a/internal/build/build.go b/internal/build/build.go index 7302df55..cb1dcd3e 100644 --- a/internal/build/build.go +++ b/internal/build/build.go @@ -691,7 +691,7 @@ func buildLdflags(goos, goarch, targetTriple string) []string { "-lwasi-emulated-signal", "-fwasm-exceptions", "-mllvm", "-wasm-enable-sjlj", - "-mllvm", "-wasm-enable-eh", + // "-mllvm", "-wasm-enable-eh", // unreachable error if enabled // "-mllvm", "-wasm-disable-explicit-locals", // WASM module load failed: type mismatch: expect data but stack was empty if enabled ) if IsWasiThreadsEnabled() { diff --git a/runtime/abi/type.go b/runtime/abi/type.go index 069d1b2a..750a68fd 100644 --- a/runtime/abi/type.go +++ b/runtime/abi/type.go @@ -342,14 +342,28 @@ func (t *UncommonType) Methods() []Method { if t.Mcount == 0 { return nil } - return (*[1 << 16]Method)(addChecked(unsafe.Pointer(t), uintptr(t.Moff), "t.mcount > 0"))[:t.Mcount:t.Mcount] + methodsPtr := addChecked(unsafe.Pointer(t), uintptr(t.Moff), "t.mcount > 0") + methods := make([]Method, t.Mcount) + for i := 0; i < int(t.Mcount); i++ { + elemPtr := addChecked(methodsPtr, uintptr(i)*unsafe.Sizeof(Method{}), "accessing method element") + elem := (*Method)(elemPtr) + methods[i] = *elem + } + return methods } func (t *UncommonType) ExportedMethods() []Method { if t.Xcount == 0 { return nil } - return (*[1 << 16]Method)(addChecked(unsafe.Pointer(t), uintptr(t.Moff), "t.xcount > 0"))[:t.Xcount:t.Xcount] + mthdsPtr := addChecked(unsafe.Pointer(t), uintptr(t.Moff), "t.xcount > 0") + mthds := make([]Method, t.Xcount) + for i := 0; i < int(t.Xcount); i++ { + elemPtr := addChecked(mthdsPtr, uintptr(i)*unsafe.Sizeof(Method{}), "accessing method element") + elem := (*Method)(elemPtr) + mthds[i] = *elem + } + return mthds } // Imethod represents a method on an interface type