Skip to content

Commit 1600cec

Browse files
committed
Convert CheckClassVariableNameNode to DSL inlinable node
1 parent e550e5a commit 1600cec

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ boolean isClassVariableDefinedString(RubyModule module, Object nameObject,
825825
@Cached CheckClassVariableNameNode checkClassVariableNameNode,
826826
@Cached LookupClassVariableNode lookupClassVariableNode) {
827827
final var name = nameToJavaStringNode.execute(this, nameObject);
828-
checkClassVariableNameNode.execute(module, name);
828+
checkClassVariableNameNode.execute(this, module, name);
829829
return lookupClassVariableNode.execute(module, name) != null;
830830
}
831831

@@ -841,7 +841,7 @@ Object getClassVariable(RubyModule module, Object nameObject,
841841
@Cached LookupClassVariableNode lookupClassVariableNode,
842842
@Cached InlinedConditionProfile undefinedProfile) {
843843
final var name = nameToJavaStringNode.execute(this, nameObject);
844-
checkClassVariableNameNode.execute(module, name);
844+
checkClassVariableNameNode.execute(this, module, name);
845845
final Object value = lookupClassVariableNode.execute(module, name);
846846

847847
if (undefinedProfile.profile(this, value == null)) {
@@ -864,7 +864,7 @@ Object setClassVariable(RubyModule module, Object nameObject, Object value,
864864
@Cached CheckClassVariableNameNode checkClassVariableNameNode,
865865
@Cached SetClassVariableNode setClassVariableNode) {
866866
final var name = nameToJavaStringNode.execute(this, nameObject);
867-
checkClassVariableNameNode.execute(module, name);
867+
checkClassVariableNameNode.execute(this, module, name);
868868
setClassVariableNode.execute(module, name, value);
869869
return value;
870870
}
@@ -2003,7 +2003,7 @@ Object removeClassVariableString(RubyModule module, Object nameObject,
20032003
@Cached NameToJavaStringNode nameToJavaStringNode,
20042004
@Cached CheckClassVariableNameNode checkClassVariableNameNode) {
20052005
final var name = nameToJavaStringNode.execute(this, nameObject);
2006-
checkClassVariableNameNode.execute(module, name);
2006+
checkClassVariableNameNode.execute(this, module, name);
20072007
return ModuleOperations.removeClassVariable(module.fields, getContext(), this, name);
20082008
}
20092009

src/main/java/org/truffleruby/language/objects/classvariables/CheckClassVariableNameNode.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,39 @@
1010
package org.truffleruby.language.objects.classvariables;
1111

1212
import com.oracle.truffle.api.dsl.Cached;
13+
import com.oracle.truffle.api.dsl.GenerateCached;
14+
import com.oracle.truffle.api.dsl.GenerateInline;
1315
import com.oracle.truffle.api.dsl.ImportStatic;
1416
import com.oracle.truffle.api.dsl.Specialization;
17+
import com.oracle.truffle.api.nodes.Node;
1518
import com.oracle.truffle.api.profiles.InlinedBranchProfile;
1619
import org.truffleruby.language.RubyBaseNode;
1720
import org.truffleruby.language.RubyDynamicObject;
1821
import org.truffleruby.language.control.RaiseException;
1922
import org.truffleruby.parser.Identifiers;
2023

2124
@ImportStatic(Identifiers.class)
25+
@GenerateInline
26+
@GenerateCached(false)
2227
public abstract class CheckClassVariableNameNode extends RubyBaseNode {
2328

24-
public abstract void execute(RubyDynamicObject object, String name);
29+
public abstract void execute(Node node, RubyDynamicObject object, String name);
2530

2631
@Specialization(guards = { "name == cachedName", "isValidClassVariableName(cachedName)" },
2732
limit = "getDefaultCacheLimit()")
28-
void cached(RubyDynamicObject object, String name,
33+
static void cached(RubyDynamicObject object, String name,
2934
@Cached("name") String cachedName) {
3035
}
3136

3237
@Specialization(replaces = "cached")
33-
void uncached(RubyDynamicObject object, String name,
38+
static void uncached(Node node, RubyDynamicObject object, String name,
3439
@Cached InlinedBranchProfile errorProfile) {
3540
if (!Identifiers.isValidClassVariableName(name)) {
36-
errorProfile.enter(this);
37-
throw new RaiseException(getContext(), coreExceptions().nameErrorInstanceNameNotAllowable(
41+
errorProfile.enter(node);
42+
throw new RaiseException(getContext(node), coreExceptions(node).nameErrorInstanceNameNotAllowable(
3843
name,
3944
object,
40-
this));
45+
node));
4146
}
4247
}
4348

0 commit comments

Comments
 (0)