Skip to content

Commit b4c6663

Browse files
author
Nicolas Laurent
committed
eliminate DispatchAction
1 parent 4c3a5e4 commit b4c6663

File tree

7 files changed

+13
-38
lines changed

7 files changed

+13
-38
lines changed

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

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

1212
import static org.truffleruby.language.dispatch.DispatchConfiguration.PRIVATE;
1313
import static org.truffleruby.language.dispatch.DispatchConfiguration.PUBLIC;
14-
import static org.truffleruby.language.dispatch.DispatchConfiguration.PUBLIC_DOES_RESPOND;
1514

1615
import java.io.File;
1716
import java.io.PrintStream;
@@ -1555,7 +1554,7 @@ public abstract static class RespondToNode extends CoreMethodNode {
15551554
private final ConditionProfile respondToMissingProfile = ConditionProfile.create();
15561555

15571556
public RespondToNode() {
1558-
dispatch = DispatchRespondToNode.create(PUBLIC_DOES_RESPOND);
1557+
dispatch = DispatchRespondToNode.create(PUBLIC);
15591558
dispatchIgnoreVisibility = DispatchRespondToNode.create();
15601559
dispatchRespondToMissing = DispatchRespondToNode.create();
15611560
}

src/main/java/org/truffleruby/language/ImmutableRubyObject.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public Object invokeMember(String name, Object[] arguments,
156156
@ExportMessage
157157
public boolean isMemberInternal(String name,
158158
@Cached @Shared("definedNode") DispatchRespondToNode definedNode,
159-
@Exclusive @Cached(parameters = "PUBLIC_DOES_RESPOND") DispatchRespondToNode definedPublicNode) {
159+
@Exclusive @Cached(parameters = "PUBLIC") DispatchRespondToNode definedPublicNode) {
160160
// defined but not publicly
161161
return definedNode.doesRespondTo(null, name, this) &&
162162
!definedPublicNode.doesRespondTo(null, name, this);

src/main/java/org/truffleruby/language/RubyDynamicObject.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ public boolean isMemberInvocable(String name,
629629
public boolean isMemberInternal(String name,
630630
@CachedLibrary("this") DynamicObjectLibrary objectLibrary,
631631
@Cached @Shared("definedNode") DispatchRespondToNode definedNode,
632-
@Exclusive @Cached(parameters = "PUBLIC_DOES_RESPOND") DispatchRespondToNode definedPublicNode,
632+
@Exclusive @Cached(parameters = "PUBLIC") DispatchRespondToNode definedPublicNode,
633633
@Exclusive @Cached(parameters = "PRIVATE_RETURN_MISSING") DispatchNode dispatchNode,
634634
@Cached @Shared("nameToRubyNode") ForeignToRubyNode nameToRubyNode,
635635
@Exclusive @Cached BooleanCastNode booleanCastNode,
@@ -685,7 +685,7 @@ public boolean hasMemberWriteSideEffects(String name,
685685
// region Instantiable
686686
@ExportMessage
687687
public boolean isInstantiable(
688-
@Exclusive @Cached(parameters = "PUBLIC_DOES_RESPOND") DispatchRespondToNode doesRespond) {
688+
@Exclusive @Cached(parameters = "PUBLIC") DispatchRespondToNode doesRespond) {
689689
return doesRespond.doesRespondTo(null, "new", this);
690690
}
691691

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

Lines changed: 0 additions & 15 deletions
This file was deleted.

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

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,22 @@
1111

1212

1313
public enum DispatchConfiguration {
14-
PUBLIC(false, true, MissingBehavior.CALL_METHOD_MISSING, DispatchAction.CALL_METHOD),
15-
PRIVATE(true, false, MissingBehavior.CALL_METHOD_MISSING, DispatchAction.CALL_METHOD),
16-
PROTECTED(false, false, MissingBehavior.CALL_METHOD_MISSING, DispatchAction.CALL_METHOD),
17-
PUBLIC_RETURN_MISSING(false, true, MissingBehavior.RETURN_MISSING, DispatchAction.CALL_METHOD),
18-
PRIVATE_RETURN_MISSING(true, false, MissingBehavior.RETURN_MISSING, DispatchAction.CALL_METHOD),
19-
PUBLIC_DOES_RESPOND(false, true, MissingBehavior.RETURN_MISSING, DispatchAction.RESPOND_TO_METHOD),
20-
PRIVATE_DOES_RESPOND(true, false, MissingBehavior.RETURN_MISSING, DispatchAction.RESPOND_TO_METHOD);
14+
PUBLIC(false, true, MissingBehavior.CALL_METHOD_MISSING),
15+
PRIVATE(true, false, MissingBehavior.CALL_METHOD_MISSING),
16+
PROTECTED(false, false, MissingBehavior.CALL_METHOD_MISSING),
17+
PUBLIC_RETURN_MISSING(false, true, MissingBehavior.RETURN_MISSING),
18+
PRIVATE_RETURN_MISSING(true, false, MissingBehavior.RETURN_MISSING);
2119

2220
public final boolean ignoreVisibility;
2321
public final boolean onlyLookupPublic;
2422
public final MissingBehavior missingBehavior;
25-
public final DispatchAction dispatchAction;
2623

2724
DispatchConfiguration(
2825
boolean ignoreVisibility,
2926
boolean onlyLookupPublic,
30-
MissingBehavior missingBehavior,
31-
DispatchAction dispatchAction) {
27+
MissingBehavior missingBehavior) {
3228
this.ignoreVisibility = ignoreVisibility;
3329
this.onlyLookupPublic = onlyLookupPublic;
3430
this.missingBehavior = missingBehavior;
35-
this.dispatchAction = dispatchAction;
3631
}
3732
}

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,9 @@ public Object dispatch(VirtualFrame frame, Object receiver, String methodName, R
123123

124124
public Object execute(VirtualFrame frame, Object receiver, String methodName, RubyProc block, Object[] arguments) {
125125

126-
assert config.dispatchAction == DispatchAction.CALL_METHOD;
127-
128126
final RubyClass metaclass = metaclassNode.execute(receiver);
129127

130128
if (isForeignCall.profile(metaclass == getContext().getCoreLibrary().truffleInteropForeignClass)) {
131-
assert config.dispatchAction == DispatchAction.CALL_METHOD;
132129
return callForeign(receiver, methodName, block, arguments);
133130
}
134131

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,22 @@
2323
public class DispatchRespondToNode extends RubyBaseNode {
2424

2525
// NOTE(norswap): cf. comment above static fields in DispatchNode to see why we need this field
26-
public static final DispatchConfiguration PUBLIC_DOES_RESPOND = DispatchConfiguration.PUBLIC_DOES_RESPOND;
26+
public static final DispatchConfiguration PUBLIC = DispatchConfiguration.PUBLIC;
2727

2828
public static DispatchRespondToNode create(DispatchConfiguration config) {
2929
return new DispatchRespondToNode(config);
3030
}
3131

3232
public static DispatchRespondToNode create() {
33-
return new DispatchRespondToNode(DispatchConfiguration.PRIVATE_DOES_RESPOND);
33+
return new DispatchRespondToNode(DispatchConfiguration.PRIVATE);
3434
}
3535

3636
public static DispatchRespondToNode getUncached(DispatchConfiguration config) {
3737
return Uncached.UNCACHED_NODES[config.ordinal()];
3838
}
3939

4040
public static DispatchRespondToNode getUncached() {
41-
return getUncached(DispatchConfiguration.PRIVATE_DOES_RESPOND);
41+
return getUncached(DispatchConfiguration.PRIVATE);
4242
}
4343

4444
public final DispatchConfiguration config;
@@ -63,7 +63,6 @@ public boolean doesRespondTo(VirtualFrame frame, String methodName, Object recei
6363
}
6464

6565
public Object execute(VirtualFrame frame, Object receiver, String methodName, RubyProc block, Object[] arguments) {
66-
assert config.dispatchAction == DispatchAction.RESPOND_TO_METHOD;
6766
final RubyClass metaclass = metaclassNode.execute(receiver);
6867
final InternalMethod method = methodLookup.execute(frame, metaclass, methodName, config);
6968
return method != null && method.isDefined() && method.isImplemented();

0 commit comments

Comments
 (0)