Skip to content

Commit a1466ae

Browse files
committed
Convert ToWrapperNode to DSL inlinable
1 parent b48bd14 commit a1466ae

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

src/main/java/org/truffleruby/cext/CExtNodes.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,7 +1796,7 @@ public abstract static class AddToMarkList extends CoreMethodArrayArgumentsNode
17961796
protected Object addToMarkList(Object markedObject,
17971797
@Cached InlinedBranchProfile noExceptionProfile,
17981798
@Cached UnwrapNode.ToWrapperNode toWrapperNode) {
1799-
ValueWrapper wrappedValue = toWrapperNode.execute(markedObject);
1799+
ValueWrapper wrappedValue = toWrapperNode.execute(this, markedObject);
18001800
if (wrappedValue != null) {
18011801
noExceptionProfile.enter(this);
18021802
getContext().getMarkingService()
@@ -1818,7 +1818,7 @@ protected Object addToMarkList(Object guardedObject,
18181818
@Cached MarkingServiceNodes.KeepAliveNode keepAliveNode,
18191819
@Cached InlinedBranchProfile noExceptionProfile,
18201820
@Cached UnwrapNode.ToWrapperNode toWrapperNode) {
1821-
ValueWrapper wrappedValue = toWrapperNode.execute(guardedObject);
1821+
ValueWrapper wrappedValue = toWrapperNode.execute(this, guardedObject);
18221822
if (wrappedValue != null) {
18231823
noExceptionProfile.enter(this);
18241824
keepAliveNode.execute(wrappedValue);

src/main/java/org/truffleruby/cext/UnwrapNode.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,35 +154,38 @@ protected static ValueWrapper unWrapUnexpectedHandle(long handle) {
154154
}
155155
}
156156

157+
@GenerateInline
158+
@GenerateCached(false)
157159
@ImportStatic(ValueWrapperManager.class)
158160
public abstract static class ToWrapperNode extends RubyBaseNode {
159161

160-
public abstract ValueWrapper execute(Object value);
162+
public abstract ValueWrapper execute(Node node, Object value);
161163

162164
@Specialization
163-
protected ValueWrapper wrappedValueWrapper(ValueWrapper value) {
165+
protected static ValueWrapper wrappedValueWrapper(ValueWrapper value) {
164166
return value;
165167
}
166168

167169
@Specialization
168-
protected ValueWrapper longToWrapper(long value,
170+
protected static ValueWrapper longToWrapper(Node node, long value,
169171
@Cached @Shared NativeToWrapperNode nativeToWrapperNode) {
170-
return nativeToWrapperNode.execute(this, value);
172+
return nativeToWrapperNode.execute(node, value);
171173
}
172174

173175
@Fallback
174-
protected ValueWrapper genericToWrapper(Object value,
176+
protected static ValueWrapper genericToWrapper(Node node, Object value,
175177
@CachedLibrary(limit = "getCacheLimit()") InteropLibrary values,
176178
@Cached @Shared NativeToWrapperNode nativeToWrapperNode,
177179
@Cached InlinedBranchProfile unsupportedProfile) {
178180
long handle;
179181
try {
180182
handle = values.asPointer(value);
181183
} catch (UnsupportedMessageException e) {
182-
unsupportedProfile.enter(this);
183-
throw new RaiseException(getContext(), coreExceptions().argumentError(e.getMessage(), this, e));
184+
unsupportedProfile.enter(node);
185+
throw new RaiseException(getContext(node),
186+
coreExceptions(node).argumentError(e.getMessage(), getNode(node), e));
184187
}
185-
return nativeToWrapperNode.execute(this, handle);
188+
return nativeToWrapperNode.execute(node, handle);
186189
}
187190

188191
protected int getCacheLimit() {

0 commit comments

Comments
 (0)