Skip to content

Commit 659c98a

Browse files
committed
GetSpecialVariableStorageNode is converted to DSl inlinable node
1 parent b73178d commit 659c98a

9 files changed

+30
-19
lines changed

src/main/java/org/truffleruby/core/kernel/TruffleKernelNodes.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212
import java.io.IOException;
1313

1414
import com.oracle.truffle.api.RootCallTarget;
15+
import com.oracle.truffle.api.dsl.GenerateInline;
1516
import com.oracle.truffle.api.dsl.GenerateUncached;
1617
import com.oracle.truffle.api.dsl.NeverDefault;
1718
import com.oracle.truffle.api.frame.Frame;
19+
import com.oracle.truffle.api.nodes.Node;
1820
import com.oracle.truffle.api.profiles.InlinedConditionProfile;
1921
import com.oracle.truffle.api.source.Source;
2022
import com.oracle.truffle.api.strings.TruffleString;
@@ -215,21 +217,26 @@ public static int declarationDepth(Frame topFrame) {
215217

216218
@ImportStatic(TruffleKernelNodes.class)
217219
@GenerateUncached
220+
@GenerateInline(inlineByDefault = true)
218221
public abstract static class GetSpecialVariableStorage extends RubyBaseNode {
219222

220223
@NeverDefault
221224
public static GetSpecialVariableStorage create() {
222225
return GetSpecialVariableStorageNodeGen.create();
223226
}
224227

225-
public static GetSpecialVariableStorage getUncached() {
226-
return GetSpecialVariableStorageNodeGen.getUncached();
228+
public final SpecialVariableStorage executeCached(Frame frame) {
229+
return execute(frame, this);
227230
}
228231

229-
public abstract SpecialVariableStorage execute(Frame frame);
232+
public static SpecialVariableStorage executeUncached(Frame frame) {
233+
return GetSpecialVariableStorageNodeGen.getUncached().execute(frame, null);
234+
}
235+
236+
public abstract SpecialVariableStorage execute(Frame frame, Node node);
230237

231238
@Specialization(guards = "frame.getFrameDescriptor() == descriptor", limit = "1")
232-
protected SpecialVariableStorage getFromKnownFrameDescriptor(Frame frame,
239+
protected static SpecialVariableStorage getFromKnownFrameDescriptor(Frame frame,
233240
@Cached("frame.getFrameDescriptor()") FrameDescriptor descriptor,
234241
@Cached("declarationDepth(frame)") int declarationFrameDepth) {
235242
Frame storageFrame = RubyArguments.getDeclarationFrame(frame, declarationFrameDepth);
@@ -247,7 +254,7 @@ protected SpecialVariableStorage getFromKnownFrameDescriptor(Frame frame,
247254
}
248255

249256
@Specialization(replaces = "getFromKnownFrameDescriptor")
250-
protected SpecialVariableStorage slowPath(Frame frame) {
257+
protected static SpecialVariableStorage slowPath(Frame frame) {
251258
return getSlow(frame.materialize());
252259
}
253260

src/main/java/org/truffleruby/core/thread/TruffleThreadNodes.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
package org.truffleruby.core.thread;
1111

1212
import com.oracle.truffle.api.frame.MaterializedFrame;
13+
import com.oracle.truffle.api.nodes.Node;
1314
import org.truffleruby.annotations.CoreMethod;
1415
import org.truffleruby.builtins.CoreMethodArrayArgumentsNode;
1516
import org.truffleruby.annotations.CoreModule;
@@ -35,20 +36,21 @@ public abstract static class FindRubyCallerSpecialStorage extends CoreMethodArra
3536

3637
@TruffleBoundary
3738
@Specialization(limit = "storageStrategyLimit()")
38-
protected Object findRubyCaller(RubyArray modules,
39+
protected static Object findRubyCaller(RubyArray modules,
3940
@Bind("modules.getStore()") Object store,
4041
@CachedLibrary("store") ArrayStoreLibrary stores,
41-
@Cached GetSpecialVariableStorage storageNode) {
42+
@Cached GetSpecialVariableStorage storageNode,
43+
@Bind("this") Node node) {
4244
final int modulesSize = modules.size;
4345
Object[] moduleArray = stores.boxedCopyOfRange(store, 0, modulesSize);
44-
MaterializedFrame frame = getContext()
46+
MaterializedFrame frame = getContext(node)
4547
.getCallStack()
4648
.iterateFrameNotInModules(moduleArray, f -> f.getFrame(FrameAccess.MATERIALIZE).materialize());
4749
if (frame == null) {
4850
return nil;
4951
} else {
50-
Object variables = storageNode.execute(frame.materialize());
51-
getLanguage().getCurrentFiber().extensionCallStack.setSpecialVariables(variables);
52+
Object variables = storageNode.execute(frame.materialize(), node);
53+
getLanguage(node).getCurrentFiber().extensionCallStack.setSpecialVariables(variables);
5254
return variables;
5355
}
5456
}

src/main/java/org/truffleruby/language/arguments/ReadCallerVariablesNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@ protected SpecialVariableStorage getCallerSpecialVariables() {
5353
this));
5454
}
5555

56-
return GetSpecialVariableStorage.getUncached().execute(callerFrame);
56+
return GetSpecialVariableStorage.executeUncached(callerFrame);
5757
}
5858
}

src/main/java/org/truffleruby/language/dispatch/DispatchNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ protected Object dispatch(
303303
RubyArguments.setMethod(rubyArgs, method);
304304

305305
if (!specialVariableAssumption.isValid()) {
306-
RubyArguments.setCallerSpecialVariables(rubyArgs, readingNode.execute(frame));
306+
RubyArguments.setCallerSpecialVariables(rubyArgs, readingNode.execute(frame, this));
307307
}
308308
assert RubyArguments.assertFrameArguments(rubyArgs);
309309

src/main/java/org/truffleruby/language/globals/IsDefinedGlobalVariableNode.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import com.oracle.truffle.api.dsl.Bind;
1313
import com.oracle.truffle.api.dsl.Cached.Exclusive;
14+
import com.oracle.truffle.api.nodes.Node;
1415
import org.truffleruby.core.kernel.TruffleKernelNodes.GetSpecialVariableStorage;
1516
import org.truffleruby.core.string.FrozenStrings;
1617
import org.truffleruby.language.RubyBaseNode;
@@ -55,12 +56,13 @@ protected Object hooks(VirtualFrame frame,
5556
}
5657

5758
@Specialization(guards = { "storage.hasHooks()", "arity == 1" })
58-
protected Object hooksWithBinding(VirtualFrame frame,
59+
protected static Object hooksWithBinding(VirtualFrame frame,
5960
@Bind("getStorage(frame)") GlobalVariableStorage storage,
6061
@Cached("isDefinedArity(storage)") int arity,
6162
@Cached @Exclusive CallBlockNode yieldNode,
62-
@Cached GetSpecialVariableStorage readStorage) {
63-
return yieldNode.yield(storage.getIsDefined(), readStorage.execute(frame));
63+
@Cached GetSpecialVariableStorage readStorage,
64+
@Bind("this") Node node) {
65+
return yieldNode.yield(storage.getIsDefined(), readStorage.execute(frame, node));
6466
}
6567

6668
protected int isDefinedArity(GlobalVariableStorage storage) {

src/main/java/org/truffleruby/language/globals/ReadGlobalVariableNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ protected Object readHooksWithStorage(VirtualFrame frame,
5555
@Bind("getterArity(storage)") int arity,
5656
@Cached @Exclusive CallBlockNode yieldNode,
5757
@Cached GetSpecialVariableStorage storageNode) {
58-
return yieldNode.yield(storage.getGetter(), storageNode.execute(frame));
58+
return yieldNode.yield(storage.getGetter(), storageNode.execute(frame, this));
5959
}
6060

6161
protected int getterArity(GlobalVariableStorage storage) {

src/main/java/org/truffleruby/language/globals/WriteGlobalVariableNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ protected Object writeHooksWithStorage(VirtualFrame frame, Object value,
6969
yieldNode.yield(
7070
storage.getSetter(),
7171
value,
72-
storageNode.execute(frame));
72+
storageNode.execute(frame, this));
7373
return value;
7474
}
7575

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public RubyProc execute(VirtualFrame frame) {
7474
sharedMethodInfo,
7575
callTargets,
7676
frame.materialize(),
77-
readSpecialVariableStorageNode.execute(frame),
77+
readSpecialVariableStorageNode.executeCached(frame),
7878
RubyArguments.getMethod(frame),
7979
frameOnStackMarker,
8080
executeWithoutVisibility(RubyArguments.getDeclarationContext(frame)));

src/main/java/org/truffleruby/language/supercall/CallSuperMethodNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public Object execute(
6161

6262
SpecialVariableStorage callerSpecialVariables = null;
6363
if (!getSpecialVariableStorageAssumption(frame).isValid()) {
64-
callerSpecialVariables = getReadingNode().execute(frame);
64+
callerSpecialVariables = getReadingNode().executeCached(frame);
6565
}
6666

6767
final Object[] rubyArgs = RubyArguments.pack(

0 commit comments

Comments
 (0)