@@ -60,13 +60,7 @@ public class ValueWrapperManager {
60
60
61
61
private volatile HandleBlockWeakReference [] blockMap = new HandleBlockWeakReference [0 ];
62
62
63
- private final RubyContext context ;
64
-
65
- public ValueWrapperManager (RubyContext context ) {
66
- this .context = context ;
67
- }
68
-
69
- public HandleBlockHolder makeThreadData () {
63
+ public HandleBlockHolder makeThreadData (RubyContext context ) {
70
64
HandleBlockHolder holder = new HandleBlockHolder ();
71
65
context .getFinalizationService ().addFinalizer (
72
66
context ,
@@ -77,10 +71,10 @@ public HandleBlockHolder makeThreadData() {
77
71
return holder ;
78
72
}
79
73
80
- public HandleBlockHolder getBlockHolder (RubyLanguage language ) {
74
+ public HandleBlockHolder getBlockHolder (RubyContext context , RubyLanguage language ) {
81
75
RubyFiber fiber = language .getCurrentThread ().getCurrentFiber ();
82
76
if (fiber .handleData == null ) {
83
- fiber .handleData = makeThreadData ();
77
+ fiber .handleData = makeThreadData (context );
84
78
}
85
79
return fiber .handleData ;
86
80
}
@@ -96,7 +90,7 @@ public ValueWrapper doubleWrapper(double value) {
96
90
}
97
91
98
92
@ TruffleBoundary
99
- public synchronized void addToBlockMap (HandleBlock block , RubyLanguage language ) {
93
+ public synchronized void addToBlockMap (HandleBlock block , RubyContext context , RubyLanguage language ) {
100
94
int blockIndex = block .getIndex ();
101
95
long blockBase = block .getBase ();
102
96
HandleBlockAllocator allocator = language .handleBlockAllocator ;
@@ -111,7 +105,7 @@ public synchronized void addToBlockMap(HandleBlock block, RubyLanguage language)
111
105
}
112
106
113
107
@ TruffleBoundary
114
- public void addToSharedBlockMap (HandleBlock block , RubyLanguage language ) {
108
+ public void addToSharedBlockMap (HandleBlock block , RubyContext context , RubyLanguage language ) {
115
109
synchronized (language ) {
116
110
int blockIndex = block .getIndex ();
117
111
long blockBase = block .getBase ();
@@ -309,7 +303,7 @@ protected long allocateHandleOnKnownThread(ValueWrapper wrapper) {
309
303
wrapper ,
310
304
getContext (),
311
305
getLanguage (),
312
- getContext ().getValueWrapperManager ().getBlockHolder (getLanguage ()),
306
+ getContext ().getValueWrapperManager ().getBlockHolder (getContext (), getLanguage ()),
313
307
false );
314
308
}
315
309
@@ -319,7 +313,7 @@ protected long allocateSharedHandleOnKnownThread(ValueWrapper wrapper) {
319
313
wrapper ,
320
314
getContext (),
321
315
getLanguage (),
322
- getContext ().getValueWrapperManager ().getBlockHolder (getLanguage ()),
316
+ getContext ().getValueWrapperManager ().getBlockHolder (getContext (), getLanguage ()),
323
317
true );
324
318
}
325
319
@@ -342,10 +336,10 @@ protected static long allocateHandle(ValueWrapper wrapper, RubyContext context,
342
336
}
343
337
if (shared ) {
344
338
block = (holder .sharedHandleBlock = new HandleBlock (context , language .handleBlockAllocator ));
345
- context .getValueWrapperManager ().addToSharedBlockMap (block , language );
339
+ context .getValueWrapperManager ().addToSharedBlockMap (block , context , language );
346
340
} else {
347
341
block = (holder .handleBlock = new HandleBlock (context , language .handleBlockAllocator ));
348
- context .getValueWrapperManager ().addToBlockMap (block , language );
342
+ context .getValueWrapperManager ().addToBlockMap (block , context , language );
349
343
}
350
344
351
345
}
0 commit comments