Skip to content

Commit 8ae8936

Browse files
committed
Add comment about restrictions
1 parent 33d13f7 commit 8ae8936

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PThreadState.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,16 @@ public static PDict getOrCreateThreadStateDict(PythonContext context, PythonThre
136136
return threadStateDict;
137137
}
138138

139+
/**
140+
* This method runs on a critical bootstrap path when creating the native thread state. It may
141+
* execute while the C API state is still INITIALIZING and before the current thread has
142+
* installed its native 'tstate_current' TLS slot. So, this code must stay very restricted: only
143+
* use bootstrap-safe allocation and raw struct writes here.
144+
*
145+
* In particular, do not introduce conversions such as PythonToNative(NewRef)Node or any other
146+
* code paths that may poll the native reference queue, materialize additional native wrappers,
147+
* or otherwise assume that the native thread state is already fully initialized.
148+
*/
139149
@TruffleBoundary
140150
private static long allocateCLayout() {
141151
long ptr = CStructAccess.AllocateNode.allocUncachedPointer(CStructs.PyThreadState.size());

0 commit comments

Comments
 (0)