Skip to content

Commit d7cb09f

Browse files
committed
use _Py_THREAD_SANITIZER macro for performance reasons
1 parent 7cb877b commit d7cb09f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Objects/object.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2485,12 +2485,19 @@ new_reference(PyObject *op)
24852485
op->ob_refcnt = 1;
24862486
#endif
24872487
#else
2488-
_Py_atomic_store_uintptr_relaxed(&op->ob_tid, _Py_ThreadId());
24892488
op->ob_flags = 0;
24902489
op->ob_mutex = (PyMutex){ 0 };
2490+
#ifdef _Py_THREAD_SANITIZER
2491+
_Py_atomic_store_uintptr_relaxed(&op->ob_tid, _Py_ThreadId());
24912492
_Py_atomic_store_uint8_relaxed(&op->ob_gc_bits, 0);
24922493
_Py_atomic_store_uint32_relaxed(&op->ob_ref_local, 1);
24932494
_Py_atomic_store_ssize_relaxed(&op->ob_ref_shared, 0);
2495+
#else
2496+
op->ob_tid = _Py_ThreadId();
2497+
op->ob_gc_bits = 0;
2498+
op->ob_ref_local = 1;
2499+
op->ob_ref_shared = 0;
2500+
#endif
24942501
#endif
24952502
#ifdef Py_TRACE_REFS
24962503
_Py_AddToAllObjects(op);

0 commit comments

Comments
 (0)