File tree 1 file changed +12
-6
lines changed 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -1306,18 +1306,13 @@ func setThreadCPUProfiler(hz int32) {
1306
1306
atomic .Store ((* uint32 )(unsafe .Pointer (& getg ().m .profilehz )), uint32 (hz ))
1307
1307
}
1308
1308
1309
- const preemptMSupported = GOARCH != "arm64"
1309
+ const preemptMSupported = true
1310
1310
1311
1311
// suspendLock protects simultaneous SuspendThread operations from
1312
1312
// suspending each other.
1313
1313
var suspendLock mutex
1314
1314
1315
1315
func preemptM (mp * m ) {
1316
- if ! preemptMSupported {
1317
- // TODO: Implement call injection
1318
- return
1319
- }
1320
-
1321
1316
if mp == getg ().m {
1322
1317
throw ("self-preempt" )
1323
1318
}
@@ -1412,6 +1407,17 @@ func preemptM(mp *m) {
1412
1407
* (* uint32 )(unsafe .Pointer (sp )) = uint32 (c .lr ())
1413
1408
c .set_lr (newpc - 1 )
1414
1409
c .set_ip (targetPC )
1410
+
1411
+ case "arm64" :
1412
+ // Push LR. The injected call is responsible
1413
+ // for restoring LR. gentraceback is aware of
1414
+ // this extra slot. See sigctxt.pushCall in
1415
+ // signal_arm64.go.
1416
+ sp := c .sp () - 16 // SP needs 16-byte alignment
1417
+ c .set_sp (sp )
1418
+ * (* uint64 )(unsafe .Pointer (sp )) = uint64 (c .lr ())
1419
+ c .set_lr (newpc )
1420
+ c .set_ip (targetPC )
1415
1421
}
1416
1422
stdcall2 (_SetThreadContext , thread , uintptr (unsafe .Pointer (c )))
1417
1423
}
You can’t perform that action at this time.
0 commit comments