9
9
*/
10
10
package org .truffleruby .language .objects .shared ;
11
11
12
+ import com .oracle .truffle .api .CompilerAsserts ;
13
+ import com .oracle .truffle .api .dsl .GenerateCached ;
14
+ import com .oracle .truffle .api .dsl .GenerateInline ;
12
15
import com .oracle .truffle .api .nodes .Node ;
13
16
import com .oracle .truffle .api .profiles .InlinedConditionProfile ;
14
17
import org .truffleruby .collections .BoundaryIterable ;
31
34
/** Share the plain Java fields which may contain objets for subclasses of RubyDynamicObject.
32
35
* {@link RubyDynamicObject#metaClass} is handled by {@link ShareObjectNode}. */
33
36
@ ImportStatic ({ ShapeCachingGuards .class , ArrayGuards .class })
37
+ @ GenerateCached (false )
38
+ @ GenerateInline
34
39
public abstract class ShareInternalFieldsNode extends RubyBaseNode {
35
40
36
41
protected static final int CACHE_LIMIT = 8 ;
37
42
38
- protected final int depth ;
39
-
40
- public ShareInternalFieldsNode (int depth ) {
41
- this .depth = depth ;
43
+ public final void execute (Node node , RubyDynamicObject object , int depth ) {
44
+ CompilerAsserts .partialEvaluationConstant (depth );
45
+ executeInternal (node , object , depth );
42
46
}
43
47
44
- public abstract void executeShare ( RubyDynamicObject object );
48
+ protected abstract void executeInternal ( Node node , RubyDynamicObject object , int depth );
45
49
46
50
@ Specialization (limit = "CACHE_LIMIT" )
47
- protected void shareArray (RubyArray array ,
51
+ protected static void shareArray (RubyArray array , int depth ,
48
52
@ Bind ("array.getStore()" ) Object store ,
49
53
@ CachedLibrary ("store" ) ArrayStoreLibrary stores ) {
50
54
array .setStore (stores .makeShared (store , array .size ));
51
55
}
52
56
53
57
@ Specialization
54
- protected void shareCachedQueue (RubyQueue object ,
58
+ protected static void shareCachedQueue (Node node , RubyQueue object , int depth ,
55
59
@ Cached InlinedConditionProfile profileEmpty ,
56
- @ Cached WriteBarrierNode writeBarrierNode ,
57
- @ Bind ("this" ) Node node ) {
60
+ @ Cached WriteBarrierNode writeBarrierNode ) {
58
61
final UnsizedQueue queue = object .queue ;
59
- if (!profileEmpty .profile (this , queue .isEmpty ())) {
62
+ if (!profileEmpty .profile (node , queue .isEmpty ())) {
60
63
for (Object e : BoundaryIterable .wrap (queue .getContents ())) {
61
64
writeBarrierNode .execute (node , e , depth );
62
65
}
63
66
}
64
67
}
65
68
66
69
@ Specialization
67
- protected void shareCachedBasicObject (RubyBasicObject object ) {
70
+ protected static void shareCachedBasicObject (RubyBasicObject object , int depth ) {
68
71
/* No extra Java fields for RubyBasicObject */
69
72
}
70
73
@@ -73,7 +76,7 @@ protected void shareCachedBasicObject(RubyBasicObject object) {
73
76
"shareArray" ,
74
77
"shareCachedQueue" ,
75
78
"shareCachedBasicObject" })
76
- protected void shareUncached (RubyDynamicObject object ) {
79
+ protected static void shareUncached (RubyDynamicObject object , int depth ) {
77
80
SharedObjects .shareInternalFields (object );
78
81
}
79
82
0 commit comments