Skip to content

Commit 69dd507

Browse files
committed
Fix invalid conversion of load of TLBC when compiled in C++
1 parent 38264a0 commit 69dd507

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Include/internal/pycore_code.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -609,12 +609,18 @@ PyAPI_DATA(const struct _PyCode8) _Py_InitCleanup;
609609

610610
#ifdef Py_GIL_DISABLED
611611

612+
static inline _PyCodeArray *
613+
_PyCode_GetTLBCArray(PyCodeObject *co)
614+
{
615+
return _Py_CAST(_PyCodeArray*, _Py_atomic_load_ptr_acquire(&co->co_tlbc));
616+
}
617+
612618
// Return a pointer to the thread-local bytecode for the current thread, if it
613619
// exists.
614620
static inline _Py_CODEUNIT *
615621
_PyCode_GetTLBCFast(PyThreadState *tstate, PyCodeObject *co)
616622
{
617-
_PyCodeArray *code = _Py_atomic_load_ptr_acquire(&co->co_tlbc);
623+
_PyCodeArray *code = _PyCode_GetTLBCArray(co);
618624
int32_t idx = ((_PyThreadStateImpl*) tstate)->tlbc_index;
619625
if (idx < code->size && code->entries[idx] != NULL) {
620626
return (_Py_CODEUNIT *) code->entries[idx];

Include/internal/pycore_frame.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ _PyFrame_GetBytecode(_PyInterpreterFrame *f)
9393
{
9494
#ifdef Py_GIL_DISABLED
9595
PyCodeObject *co = _PyFrame_GetCode(f);
96-
_PyCodeArray *tlbc = _Py_atomic_load_ptr_acquire(&co->co_tlbc);
96+
_PyCodeArray *tlbc = _PyCode_GetTLBCArray(co);
9797
assert(f->tlbc_index >= 0 && f->tlbc_index < tlbc->size);
9898
return (_Py_CODEUNIT *)tlbc->entries[f->tlbc_index];
9999
#else

0 commit comments

Comments
 (0)