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 {
7878#endif
7979
8080#ifdef _Py_TIER2
81- struct _PyUOpInstruction buffer [ UOP_MAX_TRACE_LENGTH ] ;
81+ struct _PyUOpInstruction * buffer ;
8282#endif
8383
8484} _PyThreadStateImpl ;
Original file line number Diff line number Diff line change @@ -1281,6 +1281,13 @@ uop_optimize(
12811281 _PyBloomFilter dependencies ;
12821282 _Py_BloomFilter_Init (& dependencies );
12831283 _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+ }
12841291 _PyUOpInstruction * buffer = tstate -> buffer ;
12851292 OPT_STAT_INC (attempts );
12861293 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)
17041704 interp -> jit = false;
17051705#ifdef _Py_TIER2
17061706 _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+ }
17071712#endif
17081713
17091714 // Stop watching __builtin__ modifications
You can’t perform that action at this time.
0 commit comments