@@ -630,16 +630,6 @@ nosave:
630
630
TEXT ·cgocallback(SB),NOSPLIT,$12 -12
631
631
NO_LOCAL_POINTERS
632
632
633
- // Skip cgocallbackg, just dropm when fn is nil, and frame is the saved g.
634
- // It is used to dropm while thread is exiting.
635
- MOVW fn+0 (FP), R1
636
- CMP $0 , R1
637
- B.NE loadg
638
- // Restore the g from frame.
639
- MOVW frame+4 (FP), g
640
- B dropm
641
-
642
- loadg:
643
633
// Load m and g from thread-local storage.
644
634
#ifdef GOOS_openbsd
645
635
BL runtime·load_g(SB)
@@ -649,8 +639,7 @@ loadg:
649
639
BL.NE runtime·load_g(SB)
650
640
#endif
651
641
652
- // If g is nil, Go did not create the current thread,
653
- // or if this thread never called into Go on pthread platforms.
642
+ // If g is nil, Go did not create the current thread.
654
643
// Call needm to obtain one for temporary use.
655
644
// In this case, we're running on the thread stack, so there's
656
645
// lots of space, but the linker doesn't know. Hide the call from
@@ -664,7 +653,7 @@ loadg:
664
653
665
654
needm:
666
655
MOVW g, savedm-4 (SP) // g is zero, so is m.
667
- MOVW $runtime·needAndBindM (SB), R0
656
+ MOVW $runtime·needm (SB), R0
668
657
BL (R0)
669
658
670
659
// Set m->g0->sched.sp = SP, so that if a panic happens
@@ -735,31 +724,14 @@ havem:
735
724
MOVW savedsp-12 (SP), R4 // must match frame size
736
725
MOVW R4, (g_sched+gobuf_sp)(g)
737
726
738
- // If the m on entry was nil, we called needm above to borrow an m,
739
- // 1. for the duration of the call on non-pthread platforms,
740
- // 2. or the duration of the C thread alive on pthread platforms.
741
- // If the m on entry wasn't nil,
742
- // 1. the thread might be a Go thread,
743
- // 2. or it's wasn't the first call from a C thread on pthread platforms,
744
- // since the we skip dropm to resue the m in the first call.
727
+ // If the m on entry was nil, we called needm above to borrow an m
728
+ // for the duration of the call. Since the call is over, return it with dropm.
745
729
MOVW savedm-4 (SP), R6
746
730
CMP $0 , R6
747
- B.NE done
748
-
749
- // Skip dropm to reuse it in the next call, when a pthread key has been created.
750
- MOVW _cgo_pthread_key_created(SB), R6
751
- // It means cgo is disabled when _cgo_pthread_key_created is a nil pointer, need dropm.
752
- CMP $0 , R6
753
- B.EQ dropm
754
- MOVW (R6), R6
755
- CMP $0 , R6
756
- B.NE done
757
-
758
- dropm:
731
+ B.NE 3 (PC)
759
732
MOVW $runtime·dropm(SB), R0
760
733
BL (R0)
761
734
762
- done:
763
735
// Done!
764
736
RET
765
737
0 commit comments