//go:build scheduler.tasks && wasm package task import "unsafe" var systemStack uintptr // calleeSavedRegs on WASM is empty — WASM manages its own value stack. // Task switching is done via the asyncify transform or cooperative yields. type calleeSavedRegs struct{} // archInit stores the function and args for the task. On WASM, there are no // hardware registers to initialize — the runtime uses cooperative scheduling. func (s *state) archInit(r *calleeSavedRegs, fn uintptr, args unsafe.Pointer) { s.sp = uintptr(unsafe.Pointer(r)) } func (s *state) resume() { swapTask(s.sp, &systemStack) } func (s *state) pause() { newStack := systemStack systemStack = 0 swapTask(newStack, &s.sp) } func SystemStack() uintptr { return systemStack }