@@ -473,8 +473,8 @@ public Thread getOwner() {
473
473
474
474
public static final class ChildContextData {
475
475
private int exitCode = 0 ;
476
- private TruffleContext ctx ;
477
- private PythonContext parentCtx ;
476
+ @ CompilationFinal private TruffleContext ctx ;
477
+ @ CompilationFinal private PythonContext parentCtx ;
478
478
479
479
private final AtomicBoolean exiting = new AtomicBoolean (false );
480
480
private final CountDownLatch running = new CountDownLatch (1 );
@@ -487,10 +487,20 @@ public int getExitCode() {
487
487
return this .exitCode ;
488
488
}
489
489
490
- public TruffleContext getCtx () {
490
+ private void setTruffleContext (TruffleContext ctx ) {
491
+ assert this .ctx == null ;
492
+ this .ctx = ctx ;
493
+ }
494
+
495
+ public TruffleContext getTruffleContext () {
491
496
return ctx ;
492
497
}
493
498
499
+ private void setParentContext (PythonContext parentCtx ) {
500
+ assert this .parentCtx == null ;
501
+ this .parentCtx = parentCtx ;
502
+ }
503
+
494
504
public void awaitRunning () throws InterruptedException {
495
505
running .await ();
496
506
}
@@ -537,9 +547,9 @@ public ChildContextData getChildContextData() {
537
547
public long spawnTruffleContext (int fd , int sentinel , int [] fdsToKeep ) {
538
548
ChildContextData data = new ChildContextData ();
539
549
if (!isChildContext ()) {
540
- data .parentCtx = this ;
550
+ data .setParentContext ( this ) ;
541
551
} else {
542
- data .parentCtx = childContextData .parentCtx ;
552
+ data .setParentContext ( childContextData .parentCtx ) ;
543
553
}
544
554
545
555
Builder builder = data .parentCtx .env .newContextBuilder ().config (PythonContext .CHILD_CONTEXT_DATA , data );
@@ -597,7 +607,7 @@ public void run() {
597
607
try {
598
608
LOGGER .fine ("starting spawned child context" );
599
609
TruffleContext ctx = builder .build ();
600
- data .ctx = ctx ;
610
+ data .setTruffleContext ( ctx ) ;
601
611
Object parent = ctx .enter (null );
602
612
try {
603
613
Source source = Source .newBuilder (PythonLanguage .ID ,
0 commit comments