Files
tinygo/src/runtime/arch_amd64.go
T
Jake Bailey 29b4c6723f runtime: make divide-by-zero and nil dereference panics recoverable
Modify the Unix signal handler to redirect execution to a Go sigpanic
function instead of printing an error and re-raising the signal.
The C signal handler modifies the ucontext to make the faulting
instruction appear to have called tinygo_sigpanic, which then calls
runtimePanic with the appropriate message.

Supported on all architectures TinyGo targets on Linux and Darwin:
x86_64, i386, aarch64, ARM, and MIPS. Also registers SIGFPE, which
was previously not handled at all.
2026-06-04 19:25:47 +02:00

30 lines
611 B
Go

package runtime
const GOARCH = "amd64"
// The bitness of the CPU (e.g. 8, 32, 64).
const TargetBits = 64
const deferExtraRegs = 0
const callInstSize = 5 // "call someFunction" is 5 bytes
const (
linux_MAP_ANONYMOUS = 0x20
linux_SIGBUS = 7
linux_SIGFPE = 8
linux_SIGILL = 4
linux_SIGSEGV = 11
)
// Align a pointer.
// Note that some amd64 instructions (like movaps) expect 16-byte aligned
// memory, thus the result must be 16-byte aligned.
func align(ptr uintptr) uintptr {
return (ptr + 15) &^ 15
}
func getCurrentStackPointer() uintptr {
return uintptr(stacksave())
}