45
45
public abstract class UnwrapNode extends RubyBaseNode {
46
46
47
47
@ GenerateUncached
48
+ @ GenerateInline
49
+ @ GenerateCached (false )
48
50
@ ImportStatic (ValueWrapperManager .class )
49
51
public abstract static class UnwrapNativeNode extends RubyBaseNode {
50
52
51
- public abstract Object execute (long handle );
53
+ public static Object executeUncached (long handle ) {
54
+ return UnwrapNodeGen .UnwrapNativeNodeGen .getUncached ().execute (null , handle );
55
+ }
56
+
57
+ public abstract Object execute (Node node , long handle );
52
58
53
59
@ Specialization (guards = "handle == FALSE_HANDLE" )
54
- protected boolean unwrapFalse (long handle ) {
60
+ protected static boolean unwrapFalse (long handle ) {
55
61
return false ;
56
62
}
57
63
58
64
@ Specialization (guards = "handle == TRUE_HANDLE" )
59
- protected boolean unwrapTrue (long handle ) {
65
+ protected static boolean unwrapTrue (long handle ) {
60
66
return true ;
61
67
}
62
68
63
69
@ Specialization (guards = "handle == UNDEF_HANDLE" )
64
- protected NotProvided unwrapUndef (long handle ) {
70
+ protected static NotProvided unwrapUndef (long handle ) {
65
71
return NotProvided .INSTANCE ;
66
72
}
67
73
68
74
@ Specialization (guards = "handle == NIL_HANDLE" )
69
- protected Object unwrapNil (long handle ) {
75
+ protected static Object unwrapNil (long handle ) {
70
76
return nil ;
71
77
}
72
78
73
79
@ Specialization (guards = "isTaggedLong(handle)" )
74
- protected long unwrapTaggedLong (long handle ) {
80
+ protected static long unwrapTaggedLong (long handle ) {
75
81
return ValueWrapperManager .untagTaggedLong (handle );
76
82
}
77
83
78
84
@ Specialization (guards = "isTaggedObject(handle)" )
79
- protected Object unwrapTaggedObject (long handle ,
85
+ protected static Object unwrapTaggedObject (Node node , long handle ,
80
86
@ Cached InlinedBranchProfile noHandleProfile ) {
81
- final ValueWrapper wrapper = getContext ()
87
+ final ValueWrapper wrapper = getContext (node )
82
88
.getValueWrapperManager ()
83
- .getWrapperFromHandleMap (handle , getLanguage ());
89
+ .getWrapperFromHandleMap (handle , getLanguage (node ));
84
90
if (wrapper == null ) {
85
- noHandleProfile .enter (this );
91
+ noHandleProfile .enter (node );
86
92
raiseError (handle );
87
93
}
88
94
return wrapper .getObject ();
89
95
}
90
96
91
97
@ Fallback
92
- protected ValueWrapper unWrapUnexpectedHandle (long handle ) {
98
+ protected static ValueWrapper unWrapUnexpectedHandle (long handle ) {
93
99
// Avoid throwing a specialization exception when given an uninitialized or corrupt
94
100
// handle.
95
101
CompilerDirectives .transferToInterpreterAndInvalidate ();
96
102
throw CompilerDirectives .shouldNotReachHere ("corrupt handle 0x" + Long .toHexString (handle ));
97
103
}
98
104
99
105
@ TruffleBoundary
100
- private void raiseError (long handle ) {
106
+ private static void raiseError (long handle ) {
101
107
throw CompilerDirectives .shouldNotReachHere ("dead handle 0x" + Long .toHexString (handle ));
102
108
}
103
109
}
@@ -254,9 +260,9 @@ protected static long unwrapValueTaggedLong(ValueWrapper value) {
254
260
}
255
261
256
262
@ Specialization
257
- protected static Object longToWrapper (long value ,
263
+ protected static Object longToWrapper (Node node , long value ,
258
264
@ Cached @ Shared UnwrapNativeNode unwrapNativeNode ) {
259
- return unwrapNativeNode .execute (value );
265
+ return unwrapNativeNode .execute (node , value );
260
266
}
261
267
262
268
@ Specialization (guards = { "!isWrapper(value)" , "!isImplicitLong(value)" })
@@ -271,7 +277,7 @@ protected static Object unwrapGeneric(Node node, Object value,
271
277
unsupportedProfile .enter (node );
272
278
throw new RaiseException (getContext (node ), coreExceptions (node ).argumentError (e .getMessage (), node , e ));
273
279
}
274
- return unwrapNativeNode .execute (handle );
280
+ return unwrapNativeNode .execute (node , handle );
275
281
}
276
282
277
283
protected int getCacheLimit () {
0 commit comments