Skip to content

Commit 714c877

Browse files
committed
LocalVariableGetNode is DSL inlinable node
1 parent 973b604 commit 714c877

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

src/main/java/org/truffleruby/core/binding/BindingNodes.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -278,35 +278,37 @@ protected Object localVariableGet(RubyBinding binding, Object nameObject,
278278
@Cached NameToJavaStringNode nameToJavaStringNode,
279279
@Cached LocalVariableGetNode localVariableGetNode) {
280280
final var name = nameToJavaStringNode.execute(this, nameObject);
281-
return localVariableGetNode.execute(binding, name);
281+
return localVariableGetNode.execute(this, binding, name);
282282
}
283283
}
284284

285285
@GenerateUncached
286286
@ImportStatic(BindingNodes.class)
287+
@GenerateInline
288+
@GenerateCached(false)
287289
public abstract static class LocalVariableGetNode extends RubyBaseNode {
288290

289-
public abstract Object execute(RubyBinding binding, String name);
291+
public abstract Object execute(Node node, RubyBinding binding, String name);
290292

291293
@Specialization(guards = "!isHiddenVariable(name)")
292-
protected Object localVariableGet(RubyBinding binding, String name,
294+
protected static Object localVariableGet(Node node, RubyBinding binding, String name,
293295
@Cached FindAndReadDeclarationVariableNode readNode) {
294296
MaterializedFrame frame = binding.getFrame();
295297
Object result = readNode.execute(frame, name, null);
296298
if (result == null) {
297299
throw new RaiseException(
298-
getContext(),
299-
coreExceptions().nameErrorLocalVariableNotDefined(name, binding, this));
300+
getContext(node),
301+
coreExceptions(node).nameErrorLocalVariableNotDefined(name, binding, node));
300302
}
301303
return result;
302304
}
303305

304306
@TruffleBoundary
305307
@Specialization(guards = "isHiddenVariable(name)")
306-
protected Object localVariableGetLastLine(RubyBinding binding, String name) {
308+
protected static Object localVariableGetLastLine(Node node, RubyBinding binding, String name) {
307309
throw new RaiseException(
308-
getContext(),
309-
coreExceptions().nameError("Bad local variable name", binding, name, this));
310+
getContext(node),
311+
coreExceptions(node).nameError("Bad local variable name", binding, name, node));
310312
}
311313
}
312314

src/main/java/org/truffleruby/debug/BindingLocalVariablesObject.java

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

1212
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
13+
import com.oracle.truffle.api.dsl.Bind;
1314
import com.oracle.truffle.api.library.CachedLibrary;
15+
import com.oracle.truffle.api.nodes.Node;
1416
import org.truffleruby.core.binding.BindingNodes;
1517
import org.truffleruby.core.binding.RubyBinding;
1618
import org.truffleruby.core.string.StringUtils;
@@ -55,10 +57,11 @@ protected Object getMembers(boolean includeInternal) {
5557

5658
@ExportMessage
5759
protected Object readMember(String member,
58-
@Cached @Exclusive BindingNodes.LocalVariableGetNode localVariableGetNode)
60+
@Cached @Exclusive BindingNodes.LocalVariableGetNode localVariableGetNode,
61+
@Bind("$node") Node node)
5962
throws UnknownIdentifierException {
6063
try {
61-
return localVariableGetNode.execute(binding, member);
64+
return localVariableGetNode.execute(node, binding, member);
6265
} catch (RaiseException e) {
6366
throw UnknownIdentifierException.create(member);
6467
}

src/main/java/org/truffleruby/debug/RubyScope.java

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

1212
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
1313
import com.oracle.truffle.api.TruffleLanguage;
14+
import com.oracle.truffle.api.dsl.Bind;
1415
import com.oracle.truffle.api.dsl.Cached;
1516
import com.oracle.truffle.api.dsl.Cached.Exclusive;
1617
import com.oracle.truffle.api.dsl.Specialization;
@@ -22,6 +23,7 @@
2223
import com.oracle.truffle.api.library.CachedLibrary;
2324
import com.oracle.truffle.api.library.ExportLibrary;
2425
import com.oracle.truffle.api.library.ExportMessage;
26+
import com.oracle.truffle.api.nodes.Node;
2527
import com.oracle.truffle.api.nodes.RootNode;
2628
import com.oracle.truffle.api.source.SourceSection;
2729
import org.truffleruby.RubyContext;
@@ -125,10 +127,11 @@ protected static Object readSelf(RubyScope scope, String member) {
125127

126128
@Specialization(guards = "!RECEIVER_MEMBER.equals(member)")
127129
protected static Object read(RubyScope scope, String member,
128-
@Cached @Exclusive BindingNodes.LocalVariableGetNode localVariableGetNode)
130+
@Cached @Exclusive BindingNodes.LocalVariableGetNode localVariableGetNode,
131+
@Bind("this") Node node)
129132
throws UnknownIdentifierException {
130133
try {
131-
return localVariableGetNode.execute(scope.binding, member);
134+
return localVariableGetNode.execute(node, scope.binding, member);
132135
} catch (RaiseException e) {
133136
throw UnknownIdentifierException.create(member);
134137
}

0 commit comments

Comments
 (0)