if Experiment.RegabiG && !Experiment.RegabiWrappers {
panic("GOEXPERIMENT regabig requires regabiwrappers")
}
- if Experiment.RegabiArgs && !(Experiment.RegabiWrappers && Experiment.RegabiReflect && Experiment.RegabiDefer) {
- panic("GOEXPERIMENT regabiargs requires regabiwrappers,regabireflect,regabidefer")
+ if Experiment.RegabiArgs && !(Experiment.RegabiWrappers && Experiment.RegabiG && Experiment.RegabiReflect && Experiment.RegabiDefer) {
+ panic("GOEXPERIMENT regabiargs requires regabiwrappers,regabig,regabireflect,regabidefer")
}
// Set GOEXPERIMENT to the parsed and canonicalized set of experiments.
// RegabiArgs enables register arguments/results in all
// compiled Go functions.
//
- // Requires wrappers, reflect, defer.
+ // Requires wrappers (to do ABI translation), g (because
+ // runtime assembly that's been ported to ABIInternal uses the
+ // G register), reflect (so reflection calls use registers),
+ // and defer (because the runtime doesn't support passing
+ // register arguments to defer/go).
RegabiArgs bool
}
// Switch to m->g0's stack, call fn(g).
// Fn must never return. It should gogo(&g->sched)
// to keep running g.
+#ifdef GOEXPERIMENT_REGABI_ARGS
+TEXT runtime·mcall<ABIInternal>(SB), NOSPLIT, $0-8
+ MOVQ AX, DX // DX = fn
+
+ // save state in g->sched
+ MOVQ 0(SP), BX // caller's PC
+ MOVQ BX, (g_sched+gobuf_pc)(R14)
+ LEAQ fn+0(FP), BX // caller's SP
+ MOVQ BX, (g_sched+gobuf_sp)(R14)
+ MOVQ BP, (g_sched+gobuf_bp)(R14)
+
+ // switch to m->g0 & its stack, call fn
+ MOVQ g_m(R14), BX
+ MOVQ m_g0(BX), SI // SI = g.m.g0
+ CMPQ SI, R14 // if g == m->g0 call badmcall
+ JNE goodm
+ JMP runtime·badmcall(SB)
+goodm:
+ MOVQ R14, AX // AX (and arg 0) = g
+ MOVQ SI, R14 // g = g.m.g0
+ get_tls(CX) // Set G in TLS
+ MOVQ R14, g(CX)
+ MOVQ (g_sched+gobuf_sp)(R14), SP // sp = g0.sched.sp
+ MOVQ 0(DX), R12
+ CALL R12 // fn(g)
+ JMP runtime·badmcall2(SB)
+ RET
+#else
TEXT runtime·mcall(SB), NOSPLIT, $0-8
MOVQ fn+0(FP), DI
MOVQ $runtime·badmcall2(SB), AX
JMP AX
RET
+#endif
// systemstack_switch is a dummy routine that systemstack leaves at the bottom
// of the G stack. We need to distinguish the routine that
return errno
}
-// Call from C back to Go.
+// Call from C back to Go. fn must point to an ABIInternal Go entry-point.
//go:nosplit
func cgocallbackg(fn, frame unsafe.Pointer, ctxt uintptr) {
gp := getg()
}
}
-// netbsdMStart is the function call that starts executing a newly
+// mstart is the entry-point for new Ms.
+// It is written in assembly, uses ABI0, is marked TOPFRAME, and calls netbsdMstart0.
+func netbsdMstart()
+
+// netbsdMStart0 is the function call that starts executing a newly
// created thread. On NetBSD, a new thread inherits the signal stack
// of the creating thread. That confuses minit, so we remove that
// signal stack here before calling the regular mstart. It's a bit
// it's a simple change that keeps NetBSD working like other OS's.
// At this point all signals are blocked, so there is no race.
//go:nosplit
-func netbsdMstart() {
+func netbsdMstart0() {
st := stackt{ss_flags: _SS_DISABLE}
sigaltstack(&st, nil)
- mstart()
+ mstart0()
}
func osinit() {
}
// mstart is the entry-point for new Ms.
-// It is written in assembly, marked TOPFRAME, and calls mstart0.
+// It is written in assembly, uses ABI0, is marked TOPFRAME, and calls mstart0.
func mstart()
// mstart0 is the Go entry-point for new Ms.
CALL runtime·stackcheck(SB)
nog2:
- // Call fn
+ // Call fn. This is the PC of an ABI0 function.
CALL R12
// It shouldn't return. If it does, exit that thread.
MOVL $0x1234, 0x1005
RET
+TEXT ·netbsdMstart(SB),NOSPLIT|TOPFRAME,$0
+ CALL ·netbsdMstart0(SB)
+ RET // not reached
+
TEXT runtime·sigaltstack(SB),NOSPLIT,$-8
MOVL $SYS___sigaltstack14, AX
MOVL new+0(FP), BX
MOVQ R9, g(CX)
CALL runtime·stackcheck(SB)
- // Call fn
+ // Call fn. This is an ABI0 PC.
CALL R12
// It shouldn't return. If it does, exit.
SYSCALL
JMP -3(PC) // keep exiting
+TEXT ·netbsdMstart(SB),NOSPLIT|TOPFRAME,$0
+ CALL ·netbsdMstart0(SB)
+ RET // not reached
+
TEXT runtime·osyield(SB),NOSPLIT,$0
MOVL $SYS_sched_yield, AX
SYSCALL
MOVW R8, (R8)
RET
+TEXT ·netbsdMstart(SB),NOSPLIT|TOPFRAME,$0
+ BL ·netbsdMstart0(SB)
+ RET // not reached
+
TEXT runtime·usleep(SB),NOSPLIT,$16
MOVW usec+0(FP), R0
CALL runtime·usplitR0(SB)
MOVD $0, R0 // crash (not reached)
MOVD R0, (R8)
+TEXT ·netbsdMstart(SB),NOSPLIT|TOPFRAME,$0
+ CALL ·netbsdMstart0(SB)
+ RET // not reached
+
TEXT runtime·osyield(SB),NOSPLIT,$0
SVC $SYS_sched_yield
RET
// Call cgocallback, which will call callbackWrap(frame).
MOVQ $0, 16(SP) // context
MOVQ AX, 8(SP) // frame (address of callbackArgs)
- LEAQ ·callbackWrap(SB), BX
+ LEAQ ·callbackWrap<ABIInternal>(SB), BX // cgocallback takes an ABIInternal entry-point
MOVQ BX, 0(SP) // PC of function value to call (callbackWrap)
CALL ·cgocallback(SB)
// Get callback result.