Skip to content

Commit d12fd46

Browse files
committed
No need to track the enclosing method's block in RubyProc
1 parent ba5d299 commit d12fd46

File tree

10 files changed

+9
-22
lines changed

10 files changed

+9
-22
lines changed

src/main/java/org/truffleruby/core/basicobject/BasicObjectNodes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ protected Object instanceExec(VirtualFrame frame, Object receiver, Object[] argu
448448
block.declarationContext.getRefinements());
449449
var descriptor = RubyArguments.getDescriptor(frame);
450450
return callBlockNode.executeCallBlock(
451-
declarationContext, block, receiver, block.block, descriptor, arguments, null);
451+
declarationContext, block, receiver, nil, descriptor, arguments, null);
452452
}
453453

454454
@Specialization

src/main/java/org/truffleruby/core/method/MethodNodes.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,6 @@ private RubyProc createProc(RootCallTarget callTarget, InternalMethod method, Ob
320320
declarationFrame,
321321
variables,
322322
method,
323-
nil,
324323
null,
325324
method.getDeclarationContext());
326325
}

src/main/java/org/truffleruby/core/module/ModuleNodes.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ public Object classExec(ArgumentsDescriptor descriptor, RubyModule self, Object[
810810
new FixedDefaultDefinee(self),
811811
block.declarationContext.getRefinements());
812812

813-
return callBlockNode.executeCallBlock(declarationContext, block, self, block.block, descriptor, args, null);
813+
return callBlockNode.executeCallBlock(declarationContext, block, self, nil, descriptor, args, null);
814814
}
815815
}
816816

@@ -2289,7 +2289,7 @@ protected RubyModule refine(RubyModule namespace, RubyModule moduleToRefine, Rub
22892289
declarationContext,
22902290
block,
22912291
refinement,
2292-
block.block,
2292+
nil,
22932293
EmptyArgumentsDescriptor.INSTANCE,
22942294
EMPTY_ARGUMENTS,
22952295
null);

src/main/java/org/truffleruby/core/proc/ProcNodes.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ protected RubyProc procSpecial(VirtualFrame frame, RubyClass procClass, Object[]
125125
block.declarationFrame,
126126
block.declarationVariables,
127127
block.method,
128-
block.block,
129128
block.frameOnStackMarker,
130129
block.declarationContext);
131130

@@ -164,7 +163,6 @@ protected RubyProc dup(RubyProc proc) {
164163
proc.declarationFrame,
165164
proc.declarationVariables,
166165
proc.method,
167-
proc.block,
168166
proc.frameOnStackMarker,
169167
proc.declarationContext);
170168

src/main/java/org/truffleruby/core/proc/ProcOperations.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
import com.oracle.truffle.api.RootCallTarget;
2626
import com.oracle.truffle.api.frame.MaterializedFrame;
2727

28+
import static org.truffleruby.language.RubyBaseNode.nil;
29+
2830
public abstract class ProcOperations {
2931

3032
private static Object[] packArguments(RubyProc proc, ArgumentsDescriptor descriptor, Object... args) {
@@ -34,7 +36,7 @@ private static Object[] packArguments(RubyProc proc, ArgumentsDescriptor descrip
3436
proc.method,
3537
proc.frameOnStackMarker,
3638
getSelf(proc),
37-
proc.block,
39+
nil,
3840
descriptor,
3941
args);
4042
}
@@ -61,7 +63,6 @@ public static RubyProc createRubyProc(
6163
MaterializedFrame declarationFrame,
6264
SpecialVariableStorage variables,
6365
InternalMethod method,
64-
Object block,
6566
FrameOnStackMarker frameOnStackMarker,
6667
DeclarationContext declarationContext) {
6768

@@ -89,7 +90,6 @@ public static RubyProc createRubyProc(
8990
declarationFrame,
9091
variables,
9192
method,
92-
block,
9393
frameOnStackMarker,
9494
declarationContext);
9595

@@ -107,7 +107,6 @@ public static RubyProc convertBlock(RubyContext context, RubyLanguage language,
107107
block.declarationFrame,
108108
block.declarationVariables,
109109
block.method,
110-
block.block,
111110
type == ProcType.PROC ? block.frameOnStackMarker : null,
112111
block.declarationContext);
113112
}

src/main/java/org/truffleruby/core/proc/RubyProc.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
import java.util.Set;
1313

1414
import org.truffleruby.core.klass.RubyClass;
15-
import org.truffleruby.core.string.StringUtils;
1615
import org.truffleruby.interop.ForeignToRubyArgumentsNode;
17-
import org.truffleruby.language.Nil;
1816
import org.truffleruby.language.RubyDynamicObject;
1917
import org.truffleruby.language.RubyRootNode;
2018
import org.truffleruby.language.control.FrameOnStackMarker;
@@ -54,7 +52,6 @@ public class RubyProc extends RubyDynamicObject implements ObjectGraphNode {
5452
/** Can differ from {@link SharedMethodInfo#getRawArgumentDescriptors()} */
5553
public final ArgumentDescriptor[] argumentDescriptors;
5654
public final SpecialVariableStorage declarationVariables;
57-
public final Object block;
5855

5956
public RubyProc(
6057
RubyClass rubyClass,
@@ -67,11 +64,9 @@ public RubyProc(
6764
MaterializedFrame declarationFrame,
6865
SpecialVariableStorage declarationVariables,
6966
InternalMethod method,
70-
Object block,
7167
FrameOnStackMarker frameOnStackMarker,
7268
DeclarationContext declarationContext) {
7369
super(rubyClass, shape);
74-
assert block instanceof Nil || block instanceof RubyProc : StringUtils.toString(block);
7570
this.type = type;
7671
this.arity = arity;
7772
this.argumentDescriptors = argumentDescriptors;
@@ -80,7 +75,6 @@ public RubyProc(
8075
this.declarationFrame = declarationFrame;
8176
this.declarationVariables = declarationVariables;
8277
this.method = method;
83-
this.block = block;
8478
this.frameOnStackMarker = frameOnStackMarker;
8579
this.declarationContext = declarationContext;
8680
}
@@ -98,7 +92,6 @@ public RubyProc withArity(Arity newArity, ArgumentDescriptor[] newArgumentDescri
9892
declarationFrame,
9993
declarationVariables,
10094
method,
101-
block,
10295
frameOnStackMarker,
10396
declarationContext);
10497
}
@@ -107,7 +100,6 @@ public RubyProc withArity(Arity newArity, ArgumentDescriptor[] newArgumentDescri
107100
public void getAdjacentObjects(Set<Object> reachable) {
108101
ObjectGraph.getObjectsInFrame(declarationFrame, reachable);
109102
ObjectGraph.addProperty(reachable, method);
110-
ObjectGraph.addProperty(reachable, block);
111103
}
112104

113105
public boolean isLambda() {

src/main/java/org/truffleruby/core/symbol/SymbolNodes.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ public static RubyProc createProc(RubyContext context, RubyLanguage language,
214214
declarationFrame,
215215
variables,
216216
method,
217-
nil,
218217
null,
219218
declarationContext);
220219
}

src/main/java/org/truffleruby/extra/TruffleGraalNodes.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ protected RubyProc copyCapturedLocals(RubyProc proc) {
132132
newDeclarationFrame,
133133
variables,
134134
proc.method,
135-
proc.block,
136135
proc.frameOnStackMarker,
137136
proc.declarationContext);
138137

src/main/java/org/truffleruby/language/methods/BlockDefinitionNode.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ public RubyProc execute(VirtualFrame frame) {
7575
frame.materialize(),
7676
readSpecialVariableStorageNode.execute(frame),
7777
RubyArguments.getMethod(frame),
78-
RubyArguments.getBlock(frame),
7978
frameOnStackMarker,
8079
executeWithoutVisibility(RubyArguments.getDeclarationContext(frame)));
8180
}

src/main/java/org/truffleruby/language/methods/InternalMethod.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
3030
import com.oracle.truffle.api.RootCallTarget;
3131

32+
import static org.truffleruby.language.RubyBaseNode.nil;
33+
3234
/** A Ruby method: either a method in a module, a literal module/class body or some meta-information for eval'd code.
3335
* Blocks capture the method in which they are defined. */
3436
public class InternalMethod implements ObjectGraphNode {
@@ -79,7 +81,7 @@ public static InternalMethod fromProc(
7981
proc,
8082
callTarget,
8183
null,
82-
proc.block);
84+
nil);
8385
}
8486

8587
public InternalMethod(

0 commit comments

Comments
 (0)