Skip to content

Commit b48bd14

Browse files
committed
Convert NativeToWrapperNode to DSL inlinable
1 parent 693ae31 commit b48bd14

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

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

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,43 +109,45 @@ private static void raiseError(long handle) {
109109
}
110110

111111
@GenerateUncached
112+
@GenerateInline
113+
@GenerateCached(false)
112114
@ImportStatic(ValueWrapperManager.class)
113115
public abstract static class NativeToWrapperNode extends RubyBaseNode {
114116

115-
public abstract ValueWrapper execute(long handle);
117+
public abstract ValueWrapper execute(Node node, long handle);
116118

117119
@Specialization(guards = "handle == FALSE_HANDLE")
118-
protected ValueWrapper unwrapFalse(long handle) {
120+
protected static ValueWrapper unwrapFalse(long handle) {
119121
return new ValueWrapper(false, FALSE_HANDLE, null);
120122
}
121123

122124
@Specialization(guards = "handle == TRUE_HANDLE")
123-
protected ValueWrapper unwrapTrue(long handle) {
125+
protected static ValueWrapper unwrapTrue(long handle) {
124126
return new ValueWrapper(true, TRUE_HANDLE, null);
125127
}
126128

127129
@Specialization(guards = "handle == UNDEF_HANDLE")
128-
protected ValueWrapper unwrapUndef(long handle) {
130+
protected static ValueWrapper unwrapUndef(long handle) {
129131
return new ValueWrapper(NotProvided.INSTANCE, UNDEF_HANDLE, null);
130132
}
131133

132134
@Specialization(guards = "handle == NIL_HANDLE")
133-
protected ValueWrapper unwrapNil(long handle) {
135+
protected static ValueWrapper unwrapNil(long handle) {
134136
return nil.getValueWrapper();
135137
}
136138

137139
@Specialization(guards = "isTaggedLong(handle)")
138-
protected ValueWrapper unwrapTaggedLong(long handle) {
140+
protected static ValueWrapper unwrapTaggedLong(long handle) {
139141
return new ValueWrapper(null, handle, null);
140142
}
141143

142144
@Specialization(guards = "isTaggedObject(handle)")
143-
protected ValueWrapper unwrapTaggedObject(long handle) {
144-
return getContext().getValueWrapperManager().getWrapperFromHandleMap(handle, getLanguage());
145+
protected static ValueWrapper unwrapTaggedObject(Node node, long handle) {
146+
return getContext(node).getValueWrapperManager().getWrapperFromHandleMap(handle, getLanguage(node));
145147
}
146148

147149
@Fallback
148-
protected ValueWrapper unWrapUnexpectedHandle(long handle) {
150+
protected static ValueWrapper unWrapUnexpectedHandle(long handle) {
149151
// Avoid throwing a specialization exception when given an uninitialized or corrupt
150152
// handle.
151153
return null;
@@ -165,7 +167,7 @@ protected ValueWrapper wrappedValueWrapper(ValueWrapper value) {
165167
@Specialization
166168
protected ValueWrapper longToWrapper(long value,
167169
@Cached @Shared NativeToWrapperNode nativeToWrapperNode) {
168-
return nativeToWrapperNode.execute(value);
170+
return nativeToWrapperNode.execute(this, value);
169171
}
170172

171173
@Fallback
@@ -180,7 +182,7 @@ protected ValueWrapper genericToWrapper(Object value,
180182
unsupportedProfile.enter(this);
181183
throw new RaiseException(getContext(), coreExceptions().argumentError(e.getMessage(), this, e));
182184
}
183-
return nativeToWrapperNode.execute(handle);
185+
return nativeToWrapperNode.execute(this, handle);
184186
}
185187

186188
protected int getCacheLimit() {

0 commit comments

Comments
 (0)