Skip to content

Commit b24e393

Browse files
committed
[Truffle] Remove abstract non-DSL execute methods in cast and coerce nodes.
* They are generated by the DSL anyway and likely remnants when they were not yet DSL nodes. * execute() is the same when generated, with just an extra try/catch. * Keep the execute with evaluated values above specializations for consistency.
1 parent 06c53b9 commit b24e393

File tree

7 files changed

+9
-34
lines changed

7 files changed

+9
-34
lines changed

truffle/src/main/java/org/jruby/truffle/nodes/cast/BooleanCastNode.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ public BooleanCastNode(BooleanCastNode copy) {
3232
super(copy.getContext(), copy.getSourceSection());
3333
}
3434

35+
public abstract boolean executeBoolean(VirtualFrame frame, Object value);
36+
3537
@Specialization
3638
public boolean doNil(RubyNilClass nil) {
3739
return false;
@@ -62,14 +64,4 @@ public boolean doBasicObject(RubyBasicObject object) {
6264
return true;
6365
}
6466

65-
@Override
66-
public abstract boolean executeBoolean(VirtualFrame frame);
67-
68-
public abstract boolean executeBoolean(VirtualFrame frame, Object value);
69-
70-
@Override
71-
public final Object execute(VirtualFrame frame) {
72-
return executeBoolean(frame);
73-
}
74-
7567
}

truffle/src/main/java/org/jruby/truffle/nodes/cast/CmpIntNode.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ public CmpIntNode(CmpIntNode prev) {
5858
ltNode = prev.ltNode;
5959
}
6060

61+
public abstract int executeCmpInt(VirtualFrame frame, Object value, Object receiver, Object other);
62+
6163
@Specialization
6264
public int cmpInt(int value, Object receiver, Object other) {
6365
if (value > 0) {
@@ -126,5 +128,4 @@ public int cmpObject(VirtualFrame frame, Object value, Object receiver, Object o
126128
return 0;
127129
}
128130

129-
public abstract int executeIntegerFixnum(VirtualFrame frame, Object value, Object receiver, Object other);
130131
}

truffle/src/main/java/org/jruby/truffle/nodes/cast/ToSNode.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,4 @@ public RubyString toSFallback(VirtualFrame frame, Object object) {
7474
}
7575
}
7676

77-
@Override
78-
public final Object execute(VirtualFrame frame) {
79-
return executeRubyString(frame);
80-
}
81-
8277
}

truffle/src/main/java/org/jruby/truffle/nodes/coerce/SymbolOrToStrNode.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,4 @@ public String coerceObject(VirtualFrame frame, Object object) {
7676
}
7777
}
7878

79-
@Override
80-
public abstract String executeString(VirtualFrame frame);
81-
82-
@Override
83-
public final Object execute(VirtualFrame frame) {
84-
return executeString(frame);
85-
}
8679
}

truffle/src/main/java/org/jruby/truffle/nodes/coerce/ToIntNode.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ public ToIntNode(ToIntNode prev) {
4040
super(prev);
4141
}
4242

43+
public abstract int executeInt(VirtualFrame frame, Object object);
44+
4345
@Specialization
4446
public int coerceInt(int value) {
4547
return value;
@@ -104,5 +106,4 @@ private Object coerceObject(VirtualFrame frame, Object object) {
104106
}
105107
}
106108

107-
public abstract int executeInt(VirtualFrame frame, Object object);
108109
}

truffle/src/main/java/org/jruby/truffle/nodes/coerce/ToStrNode.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ public ToStrNode(ToStrNode prev) {
3737
toStrNode = prev.toStrNode;
3838
}
3939

40+
public abstract RubyString executeRubyString(VirtualFrame frame, Object object);
41+
4042
@Specialization
4143
public RubyString coerceRubyString(RubyString string) {
4244
return string;
@@ -71,13 +73,4 @@ public RubyString coerceObject(VirtualFrame frame, Object object) {
7173
}
7274
}
7375

74-
@Override
75-
public abstract RubyString executeRubyString(VirtualFrame frame);
76-
77-
public abstract RubyString executeRubyString(VirtualFrame frame, Object object);
78-
79-
@Override
80-
public final Object execute(VirtualFrame frame) {
81-
return executeRubyString(frame);
82-
}
8376
}

truffle/src/main/java/org/jruby/truffle/nodes/core/StringNodes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ public Object compare(VirtualFrame frame, RubyString a, Object b) {
301301
cmpIntNode = insert(CmpIntNodeFactory.create(getContext(), getSourceSection(), null, null, null));
302302
}
303303

304-
return -(cmpIntNode.executeIntegerFixnum(frame, cmpResult, a, b));
304+
return -(cmpIntNode.executeCmpInt(frame, cmpResult, a, b));
305305
}
306306

307307
return nil();

0 commit comments

Comments
 (0)