39
39
#endif
40
40
41
41
#ifdef Py_GIL_DISABLED
42
-
42
+ // MODIFY_BYTECODE modifies thread local bytecode of all threads,
43
+ // so it must be called with the world stopped.
43
44
#define MODIFY_BYTECODE (code , func , ...) \
44
45
do { \
45
46
ASSERT_WORLD_STOPPED(); \
@@ -671,6 +672,7 @@ de_instrument(PyCodeObject *code, _Py_CODEUNIT *bytecode, _PyCoMonitoringData *m
671
672
{
672
673
assert (event != PY_MONITORING_EVENT_INSTRUCTION );
673
674
assert (event != PY_MONITORING_EVENT_LINE );
675
+ ASSERT_WORLD_STOPPED ();
674
676
675
677
_Py_CODEUNIT * instr = & bytecode [i ];
676
678
uint8_t * opcode_ptr = & instr -> op .code ;
@@ -700,6 +702,7 @@ static void
700
702
de_instrument_line (PyCodeObject * code , _Py_CODEUNIT * bytecode , _PyCoMonitoringData * monitoring ,
701
703
int i )
702
704
{
705
+ ASSERT_WORLD_STOPPED ();
703
706
_Py_CODEUNIT * instr = & bytecode [i ];
704
707
int opcode = instr -> op .code ;
705
708
if (opcode != INSTRUMENTED_LINE ) {
@@ -724,6 +727,7 @@ static void
724
727
de_instrument_per_instruction (PyCodeObject * code , _Py_CODEUNIT * bytecode ,
725
728
_PyCoMonitoringData * monitoring , int i )
726
729
{
730
+ ASSERT_WORLD_STOPPED ();
727
731
_Py_CODEUNIT * instr = & bytecode [i ];
728
732
uint8_t * opcode_ptr = & instr -> op .code ;
729
733
int opcode = * opcode_ptr ;
@@ -749,6 +753,7 @@ de_instrument_per_instruction(PyCodeObject *code, _Py_CODEUNIT *bytecode,
749
753
static void
750
754
instrument (PyCodeObject * code , _Py_CODEUNIT * bytecode , _PyCoMonitoringData * monitoring , int i )
751
755
{
756
+ ASSERT_WORLD_STOPPED ();
752
757
_Py_CODEUNIT * instr = & bytecode [i ];
753
758
uint8_t * opcode_ptr = & instr -> op .code ;
754
759
int opcode = * opcode_ptr ;
@@ -778,6 +783,7 @@ instrument(PyCodeObject *code, _Py_CODEUNIT *bytecode, _PyCoMonitoringData *moni
778
783
static void
779
784
instrument_line (PyCodeObject * code , _Py_CODEUNIT * bytecode , _PyCoMonitoringData * monitoring , int i )
780
785
{
786
+ ASSERT_WORLD_STOPPED ();
781
787
uint8_t * opcode_ptr = & bytecode [i ].op .code ;
782
788
int opcode = * opcode_ptr ;
783
789
if (opcode == INSTRUMENTED_LINE ) {
@@ -792,6 +798,7 @@ static void
792
798
instrument_per_instruction (PyCodeObject * code , _Py_CODEUNIT * bytecode ,
793
799
_PyCoMonitoringData * monitoring , int i )
794
800
{
801
+ ASSERT_WORLD_STOPPED ();
795
802
_Py_CODEUNIT * instr = & bytecode [i ];
796
803
uint8_t * opcode_ptr = & instr -> op .code ;
797
804
int opcode = * opcode_ptr ;
0 commit comments