Skip to content

Commit 70062d2

Browse files
committed
[GR-45042] Address truffle-inlining warnings 1
PullRequest: truffleruby/3804
2 parents d3be383 + 28f1a0f commit 70062d2

File tree

10 files changed

+43
-31
lines changed

10 files changed

+43
-31
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Memory Footprint:
2626

2727
* Replaced `RubyLibrary` with `FreezeNode` and `IsFrozenNode` (@horakivo).
2828
* Address many truffle-sharing warnings (@horakivo).
29+
* Address many truffle-inlining warnings (@horakivo).
2930

3031

3132
# 23.0.0

src/main/java/org/truffleruby/core/inlined/InlinedAtNode.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
*/
1010
package org.truffleruby.core.inlined;
1111

12+
import com.oracle.truffle.api.dsl.Bind;
13+
import com.oracle.truffle.api.nodes.Node;
14+
import com.oracle.truffle.api.profiles.InlinedConditionProfile;
1215
import org.truffleruby.RubyLanguage;
1316
import org.truffleruby.core.array.ArrayIndexNodes;
1417
import org.truffleruby.core.array.RubyArray;
@@ -19,7 +22,6 @@
1922
import com.oracle.truffle.api.dsl.Cached;
2023
import com.oracle.truffle.api.dsl.Specialization;
2124
import com.oracle.truffle.api.frame.VirtualFrame;
22-
import com.oracle.truffle.api.profiles.ConditionProfile;
2325

2426
public abstract class InlinedAtNode extends BinaryInlinedOperationNode {
2527

@@ -33,11 +35,12 @@ public InlinedAtNode(RubyLanguage language, RubyCallNodeParameters callNodeParam
3335
guards = "lookupNode.lookupProtected(frame, array, METHOD) == coreMethods().ARRAY_AT",
3436
assumptions = "assumptions",
3537
limit = "1")
36-
protected Object arrayAt(VirtualFrame frame, RubyArray array, int index,
38+
protected static Object arrayAt(VirtualFrame frame, RubyArray array, int index,
3739
@Cached LookupMethodOnSelfNode lookupNode,
3840
@Cached ArrayIndexNodes.ReadNormalizedNode readNormalizedNode,
39-
@Cached ConditionProfile denormalized) {
40-
if (denormalized.profile(index < 0)) {
41+
@Cached InlinedConditionProfile denormalized,
42+
@Bind("this") Node node) {
43+
if (denormalized.profile(node, index < 0)) {
4144
index += array.size;
4245
}
4346
return readNormalizedNode.executeRead(array, index);

src/main/java/org/truffleruby/core/inlined/InlinedIndexGetNode.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
*/
1010
package org.truffleruby.core.inlined;
1111

12-
import com.oracle.truffle.api.profiles.ConditionProfile;
12+
import com.oracle.truffle.api.dsl.Bind;
13+
import com.oracle.truffle.api.nodes.Node;
14+
import com.oracle.truffle.api.profiles.InlinedConditionProfile;
1315
import org.truffleruby.RubyLanguage;
1416
import org.truffleruby.core.array.ArrayIndexNodes;
1517
import org.truffleruby.core.array.RubyArray;
@@ -33,11 +35,12 @@ public InlinedIndexGetNode(RubyLanguage language, RubyCallNodeParameters callNod
3335
guards = "lookupNode.lookupProtected(frame, array, METHOD) == coreMethods().ARRAY_INDEX_GET",
3436
assumptions = "assumptions",
3537
limit = "1")
36-
protected Object arrayRead(VirtualFrame frame, RubyArray array, int index,
38+
protected static Object arrayRead(VirtualFrame frame, RubyArray array, int index,
3739
@Cached LookupMethodOnSelfNode lookupNode,
3840
@Cached ArrayIndexNodes.ReadNormalizedNode readNormalizedNode,
39-
@Cached ConditionProfile denormalized) {
40-
if (denormalized.profile(index < 0)) {
41+
@Cached InlinedConditionProfile denormalized,
42+
@Bind("this") Node node) {
43+
if (denormalized.profile(node, index < 0)) {
4144
index += array.size;
4245
}
4346
return readNormalizedNode.executeRead(array, index);

src/main/java/org/truffleruby/core/inlined/InlinedIndexSetNode.java

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

1212
import com.oracle.truffle.api.dsl.Bind;
13+
import com.oracle.truffle.api.nodes.Node;
14+
import com.oracle.truffle.api.profiles.InlinedConditionProfile;
1315
import org.truffleruby.RubyLanguage;
1416
import org.truffleruby.core.array.ArrayWriteNormalizedNode;
1517
import org.truffleruby.core.array.AssignableNode;
@@ -22,7 +24,6 @@
2224
import com.oracle.truffle.api.dsl.Cached;
2325
import com.oracle.truffle.api.dsl.Specialization;
2426
import com.oracle.truffle.api.frame.VirtualFrame;
25-
import com.oracle.truffle.api.profiles.ConditionProfile;
2627

2728
public abstract class InlinedIndexSetNode extends TernaryInlinedOperationNode implements AssignableNode {
2829

@@ -40,10 +41,11 @@ public InlinedIndexSetNode(RubyLanguage language, RubyCallNodeParameters callNod
4041
"normalizedIndex >= 0" },
4142
assumptions = "assumptions",
4243
limit = "1")
43-
protected Object arrayWrite(VirtualFrame frame, RubyArray array, int index, Object value,
44+
protected static Object arrayWrite(VirtualFrame frame, RubyArray array, int index, Object value,
4445
@Cached LookupMethodOnSelfNode lookupNode,
45-
@Cached ConditionProfile denormalized,
46-
@Bind("normalize(array, index, denormalized)") int normalizedIndex,
46+
@Cached InlinedConditionProfile denormalized,
47+
@Bind("this") Node node,
48+
@Bind("normalize(node, array, index, denormalized)") int normalizedIndex,
4749
@Cached ArrayWriteNormalizedNode writeNode) {
4850
return writeNode.executeWrite(array, normalizedIndex, value);
4951
}
@@ -53,8 +55,8 @@ protected Object fallback(VirtualFrame frame, Object a, Object b, Object c) {
5355
return rewriteAndCall(frame, a, b, c);
5456
}
5557

56-
protected int normalize(RubyArray array, int index, ConditionProfile denormalized) {
57-
if (denormalized.profile(index < 0)) {
58+
protected int normalize(Node node, RubyArray array, int index, InlinedConditionProfile denormalized) {
59+
if (denormalized.profile(node, index < 0)) {
5860
index += array.size;
5961
}
6062
return index;

src/main/java/org/truffleruby/core/inlined/package-info.java

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

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@
99
*/
1010
package org.truffleruby.debug;
1111

12+
import com.oracle.truffle.api.dsl.Bind;
1213
import com.oracle.truffle.api.dsl.Cached;
1314
import com.oracle.truffle.api.interop.InteropLibrary;
1415
import com.oracle.truffle.api.interop.InvalidArrayIndexException;
1516
import com.oracle.truffle.api.interop.TruffleObject;
1617
import com.oracle.truffle.api.library.ExportLibrary;
1718
import com.oracle.truffle.api.library.ExportMessage;
18-
import com.oracle.truffle.api.profiles.BranchProfile;
19+
import com.oracle.truffle.api.nodes.Node;
20+
import com.oracle.truffle.api.profiles.InlinedBranchProfile;
1921

2022
@ExportLibrary(InteropLibrary.class)
2123
public class SingleElementArray implements TruffleObject {
@@ -38,11 +40,12 @@ protected long getArraySize() {
3840

3941
@ExportMessage
4042
protected Object readArrayElement(long index,
41-
@Cached BranchProfile errorProfile) throws InvalidArrayIndexException {
43+
@Cached InlinedBranchProfile errorProfile,
44+
@Bind("$node") Node node) throws InvalidArrayIndexException {
4245
if (isArrayElementReadable(index)) {
4346
return element;
4447
} else {
45-
errorProfile.enter();
48+
errorProfile.enter(node);
4649
throw InvalidArrayIndexException.create(index);
4750
}
4851
}

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@
99
*/
1010
package org.truffleruby.debug;
1111

12+
import com.oracle.truffle.api.dsl.Bind;
1213
import com.oracle.truffle.api.dsl.Cached;
1314
import com.oracle.truffle.api.interop.InteropLibrary;
1415
import com.oracle.truffle.api.interop.TruffleObject;
1516
import com.oracle.truffle.api.interop.UnknownIdentifierException;
1617
import com.oracle.truffle.api.library.ExportLibrary;
1718
import com.oracle.truffle.api.library.ExportMessage;
18-
import com.oracle.truffle.api.profiles.BranchProfile;
19+
import com.oracle.truffle.api.nodes.Node;
20+
import com.oracle.truffle.api.profiles.InlinedBranchProfile;
1921

2022
@ExportLibrary(InteropLibrary.class)
2123
public class SingleMemberDescriptor implements TruffleObject {
@@ -45,11 +47,12 @@ protected boolean isMemberReadable(String member) {
4547

4648
@ExportMessage
4749
protected Object readMember(String member,
48-
@Cached BranchProfile errorProfile) throws UnknownIdentifierException {
50+
@Cached InlinedBranchProfile errorProfile,
51+
@Bind("$node") Node node) throws UnknownIdentifierException {
4952
if (isMemberReadable(member)) {
5053
return value;
5154
} else {
52-
errorProfile.enter();
55+
errorProfile.enter(node);
5356
throw UnknownIdentifierException.create(member);
5457
}
5558
}

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@
99
*/
1010
package org.truffleruby.debug;
1111

12+
import com.oracle.truffle.api.dsl.Bind;
1213
import com.oracle.truffle.api.dsl.Cached;
1314
import com.oracle.truffle.api.interop.InteropLibrary;
1415
import com.oracle.truffle.api.interop.InvalidArrayIndexException;
1516
import com.oracle.truffle.api.interop.TruffleObject;
1617
import com.oracle.truffle.api.library.ExportLibrary;
1718
import com.oracle.truffle.api.library.ExportMessage;
18-
import com.oracle.truffle.api.profiles.BranchProfile;
19+
import com.oracle.truffle.api.nodes.Node;
20+
import com.oracle.truffle.api.profiles.InlinedBranchProfile;
1921

2022
@ExportLibrary(InteropLibrary.class)
2123
public class VariableNamesObject implements TruffleObject {
@@ -38,11 +40,12 @@ protected long getArraySize() {
3840

3941
@ExportMessage
4042
protected Object readArrayElement(long index,
41-
@Cached BranchProfile errorProfile) throws InvalidArrayIndexException {
43+
@Cached InlinedBranchProfile errorProfile,
44+
@Bind("$node") Node node) throws InvalidArrayIndexException {
4245
if (isArrayElementReadable(index)) {
4346
return names[(int) index];
4447
} else {
45-
errorProfile.enter();
48+
errorProfile.enter(node);
4649
throw InvalidArrayIndexException.create(index);
4750
}
4851
}

src/main/java/org/truffleruby/debug/package-info.java

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

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

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

1212
import com.oracle.truffle.api.CompilerAsserts;
13+
import com.oracle.truffle.api.dsl.GenerateInline;
1314
import com.oracle.truffle.api.dsl.Idempotent;
1415
import com.oracle.truffle.api.dsl.ImportStatic;
1516
import com.oracle.truffle.api.dsl.TypeSystemReference;
@@ -41,6 +42,7 @@
4142
import java.math.BigInteger;
4243

4344
/** Base of all Ruby nodes */
45+
@GenerateInline(value = false, inherit = true)
4446
@TypeSystemReference(RubyTypes.class)
4547
@ImportStatic(RubyGuards.class)
4648
public abstract class RubyBaseNode extends Node {

0 commit comments

Comments
 (0)