50
50
51
51
import java .math .BigInteger ;
52
52
import java .util .Arrays ;
53
+ import java .util .concurrent .locks .Lock ;
53
54
54
55
import com .oracle .graal .python .PythonLanguage ;
55
56
import com .oracle .graal .python .builtins .PythonBuiltinClassType ;
@@ -659,9 +660,15 @@ private <A, T extends Node> T insertChildNode(Node[] nodes, int nodeIndex, Class
659
660
@ SuppressWarnings ("unchecked" )
660
661
private <A , T extends Node > T doInsertChildNode (Node [] nodes , int nodeIndex , NodeFunction <A , T > nodeSupplier , A argument ) {
661
662
CompilerDirectives .transferToInterpreterAndInvalidate ();
662
- T newNode = nodeSupplier .apply (argument );
663
- nodes [nodeIndex ] = insert (newNode );
664
- return newNode ;
663
+ Lock lock = getLock ();
664
+ lock .lock ();
665
+ try {
666
+ T newNode = nodeSupplier .apply (argument );
667
+ nodes [nodeIndex ] = insert (newNode );
668
+ return newNode ;
669
+ } finally {
670
+ lock .unlock ();
671
+ }
665
672
}
666
673
667
674
@ SuppressWarnings ("unchecked" )
@@ -688,9 +695,15 @@ private <T extends Node, U> T insertChildNodeInt(Node[] nodes, int nodeIndex, Cl
688
695
@ SuppressWarnings ("unchecked" )
689
696
private <T extends Node > T doInsertChildNodeInt (Node [] nodes , int nodeIndex , IntNodeFunction <T > nodeSupplier , int argument ) {
690
697
CompilerDirectives .transferToInterpreterAndInvalidate ();
691
- T newNode = nodeSupplier .apply (argument );
692
- nodes [nodeIndex ] = insert (newNode );
693
- return newNode ;
698
+ Lock lock = getLock ();
699
+ lock .lock ();
700
+ try {
701
+ T newNode = nodeSupplier .apply (argument );
702
+ nodes [nodeIndex ] = insert (newNode );
703
+ return newNode ;
704
+ } finally {
705
+ lock .unlock ();
706
+ }
694
707
}
695
708
696
709
@ SuppressWarnings ("unchecked" )
@@ -705,9 +718,15 @@ private <T extends Node, U extends T> U insertChildNode(Node[] nodes, int nodeIn
705
718
@ SuppressWarnings ("unchecked" )
706
719
private <T extends Node > T doInsertChildNode (Node [] nodes , int nodeIndex , NodeSupplier <T > nodeSupplier ) {
707
720
CompilerDirectives .transferToInterpreterAndInvalidate ();
708
- T newNode = nodeSupplier .get ();
709
- nodes [nodeIndex ] = insert (newNode );
710
- return newNode ;
721
+ Lock lock = getLock ();
722
+ lock .lock ();
723
+ try {
724
+ T newNode = nodeSupplier .get ();
725
+ nodes [nodeIndex ] = insert (newNode );
726
+ return newNode ;
727
+ } finally {
728
+ lock .unlock ();
729
+ }
711
730
}
712
731
713
732
@ SuppressWarnings ("unchecked" )
0 commit comments