13
13
import static org .truffleruby .cext .ValueWrapperManager .UNSET_HANDLE ;
14
14
15
15
import com .oracle .truffle .api .dsl .Bind ;
16
+ import com .oracle .truffle .api .dsl .ImportStatic ;
16
17
import com .oracle .truffle .api .dsl .NeverDefault ;
17
18
import com .oracle .truffle .api .nodes .Node ;
18
19
import com .oracle .truffle .api .profiles .InlinedBranchProfile ;
27
28
import org .truffleruby .language .control .RaiseException ;
28
29
29
30
import com .oracle .truffle .api .dsl .Cached ;
30
- import com .oracle .truffle .api .dsl .Cached .Exclusive ;
31
31
import com .oracle .truffle .api .dsl .Cached .Shared ;
32
32
import com .oracle .truffle .api .dsl .GenerateUncached ;
33
33
import com .oracle .truffle .api .dsl .Specialization ;
34
34
import com .oracle .truffle .api .library .CachedLibrary ;
35
35
import com .oracle .truffle .api .object .DynamicObjectLibrary ;
36
+ import org .truffleruby .language .objects .ObjectIDOperations ;
36
37
37
38
import java .lang .invoke .VarHandle ;
38
39
40
+ @ ImportStatic (ObjectIDOperations .class )
39
41
@ GenerateUncached
40
42
public abstract class WrapNode extends RubyBaseNode {
41
43
@@ -46,21 +48,20 @@ public static WrapNode create() {
46
48
47
49
public abstract ValueWrapper execute (Object value );
48
50
49
- @ Specialization
50
- ValueWrapper wrapLong (long value ,
51
- @ Cached @ Exclusive InlinedBranchProfile smallFixnumProfile ) {
52
- if (value >= ValueWrapperManager .MIN_FIXNUM_VALUE && value <= ValueWrapperManager .MAX_FIXNUM_VALUE ) {
53
- smallFixnumProfile .enter (this );
54
- long val = (value << 1 ) | LONG_TAG ;
55
- return new ValueWrapper (null , val , null );
56
- } else {
57
- return getContext ().getValueWrapperManager ().longWrapper (value );
58
- }
51
+ @ Specialization (guards = "isSmallFixnum(value)" )
52
+ ValueWrapper wrapFixnum (long value ) {
53
+ long val = (value << 1 ) | LONG_TAG ;
54
+ return new ValueWrapper (null , val , null );
55
+ }
56
+
57
+ @ Specialization (guards = "!isSmallFixnum(value)" )
58
+ ValueWrapper wrapNonFixnum (long value ) {
59
+ return new ValueWrapper (value , UNSET_HANDLE , null );
59
60
}
60
61
61
62
@ Specialization
62
63
ValueWrapper wrapDouble (double value ) {
63
- return getContext (). getValueWrapperManager (). doubleWrapper ( value );
64
+ return new ValueWrapper ( value , UNSET_HANDLE , null );
64
65
}
65
66
66
67
@ Specialization
0 commit comments