Skip to content

Commit b221f25

Browse files
committed
Share libraries in PythonBuiltinClassType
1 parent 49d9056 commit b221f25

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/PythonBuiltinClassType.java

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import com.oracle.truffle.api.CompilerDirectives;
4242
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
4343
import com.oracle.truffle.api.dsl.Cached;
44+
import com.oracle.truffle.api.dsl.Cached.Shared;
4445
import com.oracle.truffle.api.dsl.CachedContext;
4546
import com.oracle.truffle.api.dsl.Fallback;
4647
import com.oracle.truffle.api.dsl.Specialization;
@@ -416,134 +417,134 @@ public boolean hasMembers() {
416417

417418
@ExportMessage
418419
public Object getMembers(boolean includeInternal,
419-
@CachedLibrary(limit = "1") InteropLibrary lib,
420+
@Shared("interop") @CachedLibrary(limit = "1") InteropLibrary lib,
420421
@CachedContext(PythonLanguage.class) PythonContext context) throws UnsupportedMessageException {
421422
return lib.getMembers(context.getCore().lookupType(this), includeInternal);
422423
}
423424

424425
@ExportMessage
425426
public boolean isMemberReadable(String key,
426-
@CachedLibrary(limit = "1") InteropLibrary lib,
427+
@Shared("interop") @CachedLibrary(limit = "1") InteropLibrary lib,
427428
@CachedContext(PythonLanguage.class) PythonContext context) {
428429
return lib.isMemberReadable(context.getCore().lookupType(this), key);
429430
}
430431

431432
@ExportMessage
432433
public Object readMember(String key,
433-
@CachedLibrary(limit = "1") InteropLibrary lib,
434+
@Shared("interop") @CachedLibrary(limit = "1") InteropLibrary lib,
434435
@CachedContext(PythonLanguage.class) PythonContext context) throws UnsupportedMessageException, UnknownIdentifierException {
435436
return lib.readMember(context.getCore().lookupType(this), key);
436437
}
437438

438439
@ExportMessage
439440
public boolean isMemberModifiable(String key,
440-
@CachedLibrary(limit = "1") InteropLibrary lib,
441+
@Shared("interop") @CachedLibrary(limit = "1") InteropLibrary lib,
441442
@CachedContext(PythonLanguage.class) PythonContext context) {
442443
return lib.isMemberModifiable(context.getCore().lookupType(this), key);
443444
}
444445

445446
@ExportMessage
446447
public boolean isMemberInsertable(String key,
447-
@CachedLibrary(limit = "1") InteropLibrary lib,
448+
@Shared("interop") @CachedLibrary(limit = "1") InteropLibrary lib,
448449
@CachedContext(PythonLanguage.class) PythonContext context) {
449450
return lib.isMemberInsertable(context.getCore().lookupType(this), key);
450451
}
451452

452453
@ExportMessage
453454
public void writeMember(String key, Object value,
454-
@CachedLibrary(limit = "1") InteropLibrary lib,
455+
@Shared("interop") @CachedLibrary(limit = "1") InteropLibrary lib,
455456
@CachedContext(PythonLanguage.class) PythonContext context) throws UnsupportedMessageException, UnknownIdentifierException, UnsupportedTypeException {
456457
lib.writeMember(context.getCore().lookupType(this), key, value);
457458
}
458459

459460
@ExportMessage
460461
public boolean isMemberRemovable(String key,
461-
@CachedLibrary(limit = "1") InteropLibrary lib,
462+
@Shared("interop") @CachedLibrary(limit = "1") InteropLibrary lib,
462463
@CachedContext(PythonLanguage.class) PythonContext context) {
463464
return lib.isMemberRemovable(context.getCore().lookupType(this), key);
464465
}
465466

466467
@ExportMessage
467468
public void removeMember(String key,
468-
@CachedLibrary(limit = "1") InteropLibrary lib,
469+
@Shared("interop") @CachedLibrary(limit = "1") InteropLibrary lib,
469470
@CachedContext(PythonLanguage.class) PythonContext context) throws UnsupportedMessageException, UnknownIdentifierException {
470471
lib.removeMember(context.getCore().lookupType(this), key);
471472
}
472473

473474
@ExportMessage
474475
public boolean isMemberInvocable(String key,
475-
@CachedLibrary(limit = "1") InteropLibrary lib,
476+
@Shared("interop") @CachedLibrary(limit = "1") InteropLibrary lib,
476477
@CachedContext(PythonLanguage.class) PythonContext context) {
477478
return lib.isMemberInvocable(context.getCore().lookupType(this), key);
478479
}
479480

480481
@ExportMessage
481482
public Object invokeMember(String key, Object[] arguments,
482-
@CachedLibrary(limit = "1") InteropLibrary lib,
483+
@Shared("interop") @CachedLibrary(limit = "1") InteropLibrary lib,
483484
@CachedContext(PythonLanguage.class) PythonContext context) throws UnsupportedMessageException, ArityException, UnknownIdentifierException, UnsupportedTypeException {
484485
return lib.invokeMember(context.getCore().lookupType(this), key, arguments);
485486
}
486487

487488
@ExportMessage
488489
public boolean isMemberInternal(String key,
489-
@CachedLibrary(limit = "1") InteropLibrary lib,
490+
@Shared("interop") @CachedLibrary(limit = "1") InteropLibrary lib,
490491
@CachedContext(PythonLanguage.class) PythonContext context) {
491492
return lib.isMemberInternal(context.getCore().lookupType(this), key);
492493
}
493494

494495
@ExportMessage
495496
public boolean hasMemberReadSideEffects(String key,
496-
@CachedLibrary(limit = "1") InteropLibrary lib,
497+
@Shared("interop") @CachedLibrary(limit = "1") InteropLibrary lib,
497498
@CachedContext(PythonLanguage.class) PythonContext context) {
498499
return lib.hasMemberReadSideEffects(context.getCore().lookupType(this), key);
499500
}
500501

501502
@ExportMessage
502503
public boolean hasMemberWriteSideEffects(String key,
503-
@CachedLibrary(limit = "1") InteropLibrary lib,
504+
@Shared("interop") @CachedLibrary(limit = "1") InteropLibrary lib,
504505
@CachedContext(PythonLanguage.class) PythonContext context) {
505506
return lib.hasMemberWriteSideEffects(context.getCore().lookupType(this), key);
506507
}
507508

508509
@ExportMessage
509510
static boolean isSequenceType(PythonBuiltinClassType type,
510511
@CachedContext(PythonLanguage.class) PythonContext context,
511-
@CachedLibrary(limit = "1") PythonObjectLibrary lib) {
512+
@Shared("pol") @CachedLibrary(limit = "1") PythonObjectLibrary lib) {
512513
return lib.isSequenceType(context.getCore().lookupType(type));
513514
}
514515

515516
@ExportMessage
516517
static boolean isMappingType(PythonBuiltinClassType type,
517518
@CachedContext(PythonLanguage.class) PythonContext context,
518-
@CachedLibrary(limit = "1") PythonObjectLibrary lib) {
519+
@Shared("pol") @CachedLibrary(limit = "1") PythonObjectLibrary lib) {
519520
return lib.isMappingType(context.getCore().lookupType(type));
520521
}
521522

522523
@ExportMessage
523524
static long hashWithState(PythonBuiltinClassType type, ThreadState state,
524525
@CachedContext(PythonLanguage.class) PythonContext context,
525-
@CachedLibrary(limit = "1") PythonObjectLibrary lib) {
526+
@Shared("pol") @CachedLibrary(limit = "1") PythonObjectLibrary lib) {
526527
return lib.hashWithState(context.getCore().lookupType(type), state);
527528
}
528529

529530
@ExportMessage
530531
@SuppressWarnings("unused")
531532
static double asJavaDoubleWithState(PythonBuiltinClassType type, ThreadState state,
532-
@Cached PRaiseNode raiseNode) {
533+
@Shared("raise") @Cached PRaiseNode raiseNode) {
533534
throw raiseNode.raise(TypeError, ErrorMessages.MUST_BE_REAL_NUMBER, type);
534535
}
535536

536537
@ExportMessage
537538
@SuppressWarnings("unused")
538539
static Object asPIntWithState(PythonBuiltinClassType type, ThreadState state,
539-
@Cached PRaiseNode raiseNode) {
540+
@Shared("raise") @Cached PRaiseNode raiseNode) {
540541
throw raiseNode.raise(TypeError, ErrorMessages.OBJ_CANNOT_BE_INTERPRETED_AS_INTEGER, type);
541542
}
542543

543544
@ExportMessage
544545
@SuppressWarnings("unused")
545546
static long asJavaLongWithState(PythonBuiltinClassType type, ThreadState state,
546-
@Cached PRaiseNode raiseNode) {
547+
@Shared("raise") @Cached PRaiseNode raiseNode) {
547548
throw raiseNode.raise(TypeError, ErrorMessages.MUST_BE_NUMERIC, type);
548549
}
549550

0 commit comments

Comments
 (0)