@@ -673,9 +673,11 @@ protected Object delete(RubyArray array, Object value, Object maybeBlock,
673
673
@ Bind ("array.getStore()" ) Object store ,
674
674
@ CachedLibrary ("store" ) ArrayStoreLibrary stores ,
675
675
@ Cached @ Shared IntValueProfile arraySizeProfile ,
676
- @ Cached @ Shared LoopConditionProfile loopProfile ) {
676
+ @ Cached @ Shared LoopConditionProfile loopProfile ,
677
+ @ Cached @ Shared CallBlockNode yieldNode ) {
677
678
678
- return delete (array , value , maybeBlock , true , store , store , stores , stores , arraySizeProfile , loopProfile );
679
+ return delete (array , value , maybeBlock , true , store , store , stores , stores , arraySizeProfile , loopProfile ,
680
+ yieldNode );
679
681
}
680
682
681
683
@ Specialization (
@@ -686,11 +688,12 @@ protected Object delete(RubyArray array, Object value, Object maybeBlock,
686
688
@ CachedLibrary ("store" ) ArrayStoreLibrary stores ,
687
689
@ CachedLibrary (limit = "1" ) ArrayStoreLibrary newStores ,
688
690
@ Cached @ Shared IntValueProfile arraySizeProfile ,
689
- @ Cached @ Shared LoopConditionProfile loopProfile ) {
691
+ @ Cached @ Shared LoopConditionProfile loopProfile ,
692
+ @ Cached @ Shared CallBlockNode yieldNode ) {
690
693
691
694
final Object newStore = stores .allocator (store ).allocate (arraySizeProfile .profile (array .size ));
692
695
return delete (array , value , maybeBlock , false , store , newStore , stores , newStores , arraySizeProfile ,
693
- loopProfile );
696
+ loopProfile , yieldNode );
694
697
}
695
698
696
699
private Object delete (RubyArray array , Object value , Object maybeBlock ,
@@ -700,7 +703,8 @@ private Object delete(RubyArray array, Object value, Object maybeBlock,
700
703
ArrayStoreLibrary oldStores ,
701
704
ArrayStoreLibrary newStores ,
702
705
IntValueProfile arraySizeProfile ,
703
- LoopConditionProfile loopProfile ) {
706
+ LoopConditionProfile loopProfile ,
707
+ CallBlockNode yieldNode ) {
704
708
705
709
assert !sameStores || (oldStore == newStore && oldStores == newStores );
706
710
@@ -739,7 +743,7 @@ private Object delete(RubyArray array, Object value, Object maybeBlock,
739
743
if (maybeBlock == nil ) {
740
744
return nil ;
741
745
} else {
742
- return callBlock ((RubyProc ) maybeBlock , value );
746
+ return callBlock (yieldNode , (RubyProc ) maybeBlock , value );
743
747
}
744
748
}
745
749
}
@@ -830,9 +834,9 @@ protected Object each(RubyArray array, RubyProc block,
830
834
}
831
835
832
836
@ Override
833
- public void accept (RubyArray array , Object state , Object element , int index ) {
837
+ public void accept (CallBlockNode yieldNode , RubyArray array , Object state , Object element , int index ) {
834
838
RubyProc block = (RubyProc ) state ;
835
- callBlock (block , element );
839
+ callBlock (yieldNode , block , element );
836
840
}
837
841
838
842
}
@@ -842,16 +846,14 @@ public void accept(RubyArray array, Object state, Object element, int index) {
842
846
public abstract static class EachWithIndexNode extends PrimitiveArrayArgumentsNode
843
847
implements ArrayElementConsumerNode {
844
848
845
- @ Child private CallBlockNode yieldNode = CallBlockNode .create ();
846
-
847
849
@ Specialization
848
850
protected Object eachOther (RubyArray array , RubyProc block ,
849
851
@ Cached ArrayEachIteratorNode iteratorNode ) {
850
852
return iteratorNode .execute (array , block , 0 , this );
851
853
}
852
854
853
855
@ Override
854
- public void accept (RubyArray array , Object state , Object element , int index ) {
856
+ public void accept (CallBlockNode yieldNode , RubyArray array , Object state , Object element , int index ) {
855
857
RubyProc block = (RubyProc ) state ;
856
858
yieldNode .yield (block , element , index );
857
859
}
@@ -1235,13 +1237,14 @@ protected Object initializeBlock(RubyArray array, int size, Object unusedFilling
1235
1237
@ CachedLibrary (limit = "2" ) @ Exclusive ArrayStoreLibrary stores ,
1236
1238
@ Cached @ Shared IsSharedNode isSharedNode ,
1237
1239
@ Cached @ Shared ConditionProfile sharedProfile ,
1238
- @ Cached @ Exclusive LoopConditionProfile loopProfile ) {
1240
+ @ Cached @ Exclusive LoopConditionProfile loopProfile ,
1241
+ @ Cached CallBlockNode yieldNode ) {
1239
1242
BuilderState state = arrayBuilder .start (size );
1240
1243
1241
1244
int n = 0 ;
1242
1245
try {
1243
1246
for (; loopProfile .inject (n < size ); n ++) {
1244
- final Object value = callBlock (block , n );
1247
+ final Object value = callBlock (yieldNode , block , n );
1245
1248
arrayBuilder .appendValue (state , n , value );
1246
1249
}
1247
1250
} finally {
@@ -1347,7 +1350,6 @@ private static class State {
1347
1350
}
1348
1351
1349
1352
@ Child private DispatchNode dispatch = DispatchNode .create (PUBLIC );
1350
- @ Child private CallBlockNode yieldNode = CallBlockNode .create ();
1351
1353
1352
1354
// Uses block and no Symbol
1353
1355
@@ -1390,10 +1392,9 @@ private Object injectBlockHelper(RubyArray array,
1390
1392
}
1391
1393
1392
1394
@ Override
1393
- public void accept (RubyArray array , Object stateObject , Object element , int index ) {
1395
+ public void accept (CallBlockNode yieldNode , RubyArray array , Object stateObject , Object element , int index ) {
1394
1396
final State state = (State ) stateObject ;
1395
- final Object accumulator = yieldNode .yield (state .block , state .accumulator , element );
1396
- state .accumulator = accumulator ;
1397
+ state .accumulator = yieldNode .yield (state .block , state .accumulator , element );
1397
1398
}
1398
1399
1399
1400
// Uses Symbol and no block
@@ -1506,10 +1507,10 @@ protected Object map(RubyArray array, RubyProc block,
1506
1507
}
1507
1508
1508
1509
@ Override
1509
- public void accept (RubyArray array , Object stateObject , Object element , int index ) {
1510
+ public void accept (CallBlockNode yieldNode , RubyArray array , Object stateObject , Object element , int index ) {
1510
1511
final State state = (State ) stateObject ;
1511
1512
1512
- Object value = callBlock (state .block , element );
1513
+ Object value = callBlock (yieldNode , state .block , element );
1513
1514
arrayBuilder .appendValue (state .builderState , index , value );
1514
1515
}
1515
1516
@@ -1528,9 +1529,9 @@ protected Object map(RubyArray array, RubyProc block,
1528
1529
}
1529
1530
1530
1531
@ Override
1531
- public void accept (RubyArray array , Object state , Object element , int index ) {
1532
+ public void accept (CallBlockNode yieldNode , RubyArray array , Object state , Object element , int index ) {
1532
1533
RubyProc block = (RubyProc ) state ;
1533
- writeNode .executeWrite (array , index , callBlock (block , element ));
1534
+ writeNode .executeWrite (array , index , callBlock (yieldNode , block , element ));
1534
1535
}
1535
1536
1536
1537
}
@@ -1793,10 +1794,10 @@ protected Object reject(RubyArray array, RubyProc block,
1793
1794
}
1794
1795
1795
1796
@ Override
1796
- public void accept (RubyArray array , Object stateObject , Object element , int index ) {
1797
+ public void accept (CallBlockNode yieldNode , RubyArray array , Object stateObject , Object element , int index ) {
1797
1798
final State state = (State ) stateObject ;
1798
1799
1799
- if (!booleanCastNode .execute (callBlock (state .block , element ))) {
1800
+ if (!booleanCastNode .execute (callBlock (yieldNode , state .block , element ))) {
1800
1801
arrayBuilder .appendValue (state .builderState , state .newArraySize , element );
1801
1802
state .newArraySize ++;
1802
1803
}
@@ -2006,10 +2007,10 @@ protected Object select(RubyArray array, RubyProc block,
2006
2007
}
2007
2008
2008
2009
@ Override
2009
- public void accept (RubyArray array , Object stateObject , Object element , int index ) {
2010
+ public void accept (CallBlockNode yieldNode , RubyArray array , Object stateObject , Object element , int index ) {
2010
2011
final State state = (State ) stateObject ;
2011
2012
2012
- if (booleanCastNode .execute (callBlock (state .block , element ))) {
2013
+ if (booleanCastNode .execute (callBlock (yieldNode , state .block , element ))) {
2013
2014
arrayBuilder .appendValue (state .builderState , state .selectedSize , element );
2014
2015
state .selectedSize ++;
2015
2016
}
0 commit comments