github.com/bananabytelabs/wazero@v0.0.0-20240105073314-54b22a776da8/internal/engine/wazevo/machine.go (about) 1 package wazevo 2 3 import ( 4 "runtime" 5 6 "github.com/bananabytelabs/wazero/internal/engine/wazevo/backend" 7 "github.com/bananabytelabs/wazero/internal/engine/wazevo/backend/isa/amd64" 8 "github.com/bananabytelabs/wazero/internal/engine/wazevo/backend/isa/arm64" 9 ) 10 11 func newMachine() backend.Machine { 12 switch runtime.GOARCH { 13 case "arm64": 14 return arm64.NewBackend() 15 case "amd64": 16 return amd64.NewBackend() 17 default: 18 panic("unsupported architecture") 19 } 20 } 21 22 func unwindStack(sp, top uintptr, returnAddresses []uintptr) []uintptr { 23 switch runtime.GOARCH { 24 case "arm64": 25 return arm64.UnwindStack(sp, top, returnAddresses) 26 case "amd64": 27 return amd64.UnwindStack(sp, top, returnAddresses) 28 default: 29 panic("unsupported architecture") 30 } 31 } 32 33 func goCallStackView(stackPointerBeforeGoCall *uint64) []uint64 { 34 switch runtime.GOARCH { 35 case "arm64": 36 return arm64.GoCallStackView(stackPointerBeforeGoCall) 37 case "amd64": 38 return amd64.GoCallStackView(stackPointerBeforeGoCall) 39 default: 40 panic("unsupported architecture") 41 } 42 }