Skip to content

Commit 928485a

Browse files
committed
Address code review
1 parent 9051791 commit 928485a

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

Include/internal/pycore_uop.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ typedef struct _PyUOpInstruction{
3737

3838
// This is the length of the trace we project initially.
3939
#define UOP_MAX_TRACE_LENGTH 1200
40+
#define UOP_BUFFER_SIZE (UOP_MAX_TRACE_LENGTH * sizeof(_PyUOpInstruction))
4041

4142
#ifdef __cplusplus
4243
}

Python/optimizer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1282,7 +1282,7 @@ uop_optimize(
12821282
_Py_BloomFilter_Init(&dependencies);
12831283
PyInterpreterState *interp = _PyInterpreterState_GET();
12841284
if (interp->jit_uop_buffer == NULL) {
1285-
interp->jit_uop_buffer = (_PyUOpInstruction *)PyMem_RawMalloc(UOP_MAX_TRACE_LENGTH*sizeof(_PyUOpInstruction));
1285+
interp->jit_uop_buffer = (_PyUOpInstruction *)_PyObject_VirtualAlloc(UOP_BUFFER_SIZE);
12861286
if (interp->jit_uop_buffer == NULL) {
12871287
return 0;
12881288
}

Python/pystate.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "pycore_runtime_init.h" // _PyRuntimeState_INIT
2424
#include "pycore_stackref.h" // Py_STACKREF_DEBUG
2525
#include "pycore_time.h" // _PyTime_Init()
26+
#include "pycore_uop.h". // UOP_BUFFER_SIZE
2627
#include "pycore_uniqueid.h" // _PyObject_FinalizePerThreadRefcounts()
2728

2829

@@ -809,7 +810,7 @@ interpreter_clear(PyInterpreterState *interp, PyThreadState *tstate)
809810
#ifdef _Py_TIER2
810811
_Py_ClearExecutorDeletionList(interp);
811812
if (interp->jit_uop_buffer != NULL) {
812-
PyMem_RawFree(interp->jit_uop_buffer);
813+
_PyObject_VirtualFree(interp->jit_uop_buffer, UOP_BUFFER_SIZE);
813814
interp->jit_uop_buffer = NULL;
814815
}
815816
#endif

0 commit comments

Comments
 (0)