File tree Expand file tree Collapse file tree 3 files changed +13
-1
lines changed Expand file tree Collapse file tree 3 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ typedef struct _PyThreadStateImpl {
78
78
#endif
79
79
80
80
#ifdef _Py_TIER2
81
- struct _PyUOpInstruction buffer [ UOP_MAX_TRACE_LENGTH ] ;
81
+ struct _PyUOpInstruction * buffer ;
82
82
#endif
83
83
84
84
} _PyThreadStateImpl ;
Original file line number Diff line number Diff line change @@ -1281,6 +1281,13 @@ uop_optimize(
1281
1281
_PyBloomFilter dependencies ;
1282
1282
_Py_BloomFilter_Init (& dependencies );
1283
1283
_PyThreadStateImpl * tstate = (_PyThreadStateImpl * )_PyThreadState_GET ();
1284
+ if (tstate -> buffer == NULL ) {
1285
+ tstate -> buffer = (_PyUOpInstruction * )PyMem_RawMalloc (UOP_MAX_TRACE_LENGTH * sizeof (_PyUOpInstruction ));
1286
+ if (tstate -> buffer == NULL ) {
1287
+ PyErr_NoMemory ();
1288
+ return -1 ;
1289
+ }
1290
+ }
1284
1291
_PyUOpInstruction * buffer = tstate -> buffer ;
1285
1292
OPT_STAT_INC (attempts );
1286
1293
char * env_var = Py_GETENV ("PYTHON_UOPS_OPTIMIZE" );
Original file line number Diff line number Diff line change @@ -1704,6 +1704,11 @@ finalize_modules(PyThreadState *tstate)
1704
1704
interp -> jit = false;
1705
1705
#ifdef _Py_TIER2
1706
1706
_Py_Executors_InvalidateAll (interp , 0 );
1707
+ _PyThreadStateImpl * _tstate = (_PyThreadStateImpl * )tstate ;
1708
+ if (_tstate -> buffer != NULL ) {
1709
+ PyMem_RawFree (_tstate -> buffer );
1710
+ _tstate -> buffer = NULL ;
1711
+ }
1707
1712
#endif
1708
1713
1709
1714
// Stop watching __builtin__ modifications
You can’t perform that action at this time.
0 commit comments