46
46
import java .util .concurrent .Semaphore ;
47
47
48
48
import com .oracle .graal .python .PythonLanguage ;
49
- import com .oracle .graal .python .PythonLanguage .SharedMultiprocessingData ;
50
49
import com .oracle .graal .python .builtins .Builtin ;
51
50
import com .oracle .graal .python .builtins .CoreFunctions ;
52
51
import com .oracle .graal .python .builtins .Python3Core ;
78
77
import com .oracle .graal .python .nodes .util .CastToJavaStringNode ;
79
78
import com .oracle .graal .python .runtime .GilNode ;
80
79
import com .oracle .graal .python .runtime .PythonContext ;
80
+ import com .oracle .graal .python .runtime .PythonContext .SharedContextData ;
81
81
import com .oracle .graal .python .runtime .sequence .PSequence ;
82
82
import com .oracle .graal .python .runtime .sequence .storage .SequenceStorage ;
83
83
import com .oracle .graal .python .util .ArrayBuilder ;
@@ -268,17 +268,17 @@ private static long convertTid(long tid) {
268
268
abstract static class PipeNode extends PythonBuiltinNode {
269
269
270
270
@ Specialization
271
- PTuple pipe (@ Cached GilNode gil ,
272
- @ Cached ("getLanguage().getSharedMultiprocessingData()" ) SharedMultiprocessingData sharedData ) {
271
+ PTuple pipe (@ Cached GilNode gil ) {
273
272
int [] pipe ;
274
273
PythonContext ctx = getContext ();
274
+ SharedContextData sharedData = ctx .getSharedContextData ();
275
275
gil .release (true );
276
276
try {
277
277
pipe = sharedData .pipe ();
278
278
ctx .getChildContextFDs ().add (pipe [0 ]);
279
279
ctx .getChildContextFDs ().add (pipe [1 ]);
280
- getLanguage () .addFdToKeep (pipe [0 ]);
281
- getLanguage () .addFdToKeep (pipe [1 ]);
280
+ sharedData .addFdToKeep (pipe [0 ]);
281
+ sharedData .addFdToKeep (pipe [1 ]);
282
282
} finally {
283
283
gil .acquire ();
284
284
}
@@ -291,9 +291,9 @@ PTuple pipe(@Cached GilNode gil,
291
291
public abstract static class WriteNode extends PythonBinaryBuiltinNode {
292
292
@ Specialization (limit = "1" )
293
293
Object doWrite (int fd , PBytes data ,
294
- @ Cached ("getLanguage().getSharedMultiprocessingData()" ) SharedMultiprocessingData sharedData ,
295
294
@ CachedLibrary ("data" ) PythonBufferAccessLibrary bufferLib ,
296
295
@ Cached GilNode gil ) {
296
+ SharedContextData sharedData = getContext ().getSharedContextData ();
297
297
gil .release (true );
298
298
try {
299
299
byte [] bytes = bufferLib .getCopiedByteArray (data );
@@ -312,10 +312,9 @@ Object doWrite(int fd, PBytes data,
312
312
313
313
@ Specialization (limit = "1" )
314
314
Object doWrite (long fd , PBytes data ,
315
- @ Cached ("getLanguage().getSharedMultiprocessingData()" ) SharedMultiprocessingData sharedData ,
316
315
@ CachedLibrary ("data" ) PythonBufferAccessLibrary bufferLib ,
317
316
@ Cached GilNode gil ) {
318
- return doWrite ((int ) fd , data , sharedData , bufferLib , gil );
317
+ return doWrite ((int ) fd , data , bufferLib , gil );
319
318
}
320
319
}
321
320
@@ -324,8 +323,8 @@ Object doWrite(long fd, PBytes data,
324
323
public abstract static class ReadNode extends PythonBinaryBuiltinNode {
325
324
@ Specialization
326
325
Object doRead (int fd , @ SuppressWarnings ("unused" ) Object length ,
327
- @ Cached ("getLanguage().getSharedMultiprocessingData()" ) SharedMultiprocessingData sharedData ,
328
326
@ Cached GilNode gil ) {
327
+ SharedContextData sharedData = getContext ().getSharedContextData ();
329
328
gil .release (true );
330
329
try {
331
330
Object data = sharedData .takeSharedContextData (this , fd , () -> {
@@ -342,22 +341,20 @@ Object doRead(int fd, @SuppressWarnings("unused") Object length,
342
341
343
342
@ Specialization
344
343
Object doRead (long fd , Object length ,
345
- @ Cached ("getLanguage().getSharedMultiprocessingData()" ) SharedMultiprocessingData sharedData ,
346
344
@ Cached GilNode gil ) {
347
- return doRead ((int ) fd , length , sharedData , gil );
345
+ return doRead ((int ) fd , length , gil );
348
346
}
349
347
}
350
348
351
349
@ Builtin (name = "_close" , minNumOfPositionalArgs = 1 , parameterNames = {"fd" })
352
350
@ GenerateNodeFactory
353
351
public abstract static class CloseNode extends PythonUnaryBuiltinNode {
354
352
@ Specialization
355
- PNone close (@ SuppressWarnings ("unused" ) int fd ,
356
- @ Cached ("getLanguage().getSharedMultiprocessingData()" ) SharedMultiprocessingData sharedData ) {
353
+ PNone close (@ SuppressWarnings ("unused" ) int fd ) {
357
354
assert fd < 0 ;
358
- PythonLanguage lang = getLanguage ();
359
- if (lang .isFdToKeep (fd )) {
360
- if (lang .removeFdToKeep (fd )) {
355
+ SharedContextData sharedData = getContext (). getSharedContextData ();
356
+ if (sharedData .isFdToKeep (fd )) {
357
+ if (sharedData .removeFdToKeep (fd )) {
361
358
sharedData .closeFd (fd );
362
359
}
363
360
} else {
@@ -367,9 +364,8 @@ PNone close(@SuppressWarnings("unused") int fd,
367
364
}
368
365
369
366
@ Specialization
370
- PNone close (@ SuppressWarnings ("unused" ) long fd ,
371
- @ Cached ("getLanguage().getSharedMultiprocessingData()" ) SharedMultiprocessingData sharedData ) {
372
- return close ((int ) fd , sharedData );
367
+ PNone close (@ SuppressWarnings ("unused" ) long fd ) {
368
+ return close ((int ) fd );
373
369
}
374
370
}
375
371
@@ -378,13 +374,13 @@ PNone close(@SuppressWarnings("unused") long fd,
378
374
abstract static class SelectNode extends PythonBuiltinNode {
379
375
@ Specialization
380
376
Object doGeneric (VirtualFrame frame , Object rlist ,
381
- @ Cached ("getLanguage().getSharedMultiprocessingData()" ) SharedMultiprocessingData sharedData ,
382
377
@ Cached PyObjectSizeNode sizeNode ,
383
378
@ Cached ("createGetItem()" ) LookupAndCallBinaryNode callGetItemNode ,
384
379
@ Cached ListNodes .FastConstructListNode constructListNode ,
385
380
@ Cached CastToJavaIntLossyNode castToJava ,
386
381
@ Cached GilNode gil ) {
387
382
ArrayBuilder <Integer > notEmpty = new ArrayBuilder <>();
383
+ SharedContextData sharedData = getContext ().getSharedContextData ();
388
384
gil .release (true );
389
385
try {
390
386
PSequence pSequence = constructListNode .execute (frame , rlist );
0 commit comments