@@ -450,6 +450,21 @@ static Object doPythonClassUncached(@SuppressWarnings("unused") CExtContext cext
450
450
return PythonClassNativeWrapper .wrap (object , getNameNode .execute (object ));
451
451
}
452
452
453
+ @ Specialization (guards = "object == cachedObject" , limit = "3" , assumptions = "singleContextAssumption()" )
454
+ static Object doPythonType (@ SuppressWarnings ("unused" ) CExtContext cextContext , @ SuppressWarnings ("unused" ) PythonBuiltinClassType object ,
455
+ @ SuppressWarnings ("unused" ) @ Cached ("object" ) PythonBuiltinClassType cachedObject ,
456
+ @ SuppressWarnings ("unused" ) @ CachedContext (PythonLanguage .class ) PythonContext ctx ,
457
+ @ Cached ("wrapNativeClass(ctx, object)" ) PythonClassNativeWrapper wrapper ) {
458
+ return wrapper ;
459
+ }
460
+
461
+ @ Specialization (replaces = "doPythonType" )
462
+ static Object doPythonTypeUncached (@ SuppressWarnings ("unused" ) CExtContext cextContext , PythonBuiltinClassType object ,
463
+ @ CachedContext (PythonLanguage .class ) PythonContext ctx ,
464
+ @ Cached TypeNodes .GetNameNode getNameNode ) {
465
+ return PythonClassNativeWrapper .wrap (ctx .getCore ().lookupType (object ), getNameNode .execute (object ));
466
+ }
467
+
453
468
@ Specialization (guards = {"cachedClass == object.getClass()" , "!isClass(object, lib)" , "!isNativeObject(object)" , "!isSpecialSingleton(object)" })
454
469
static Object runAbstractObjectCached (@ SuppressWarnings ("unused" ) CExtContext cextContext , PythonAbstractObject object ,
455
470
@ Cached ("createBinaryProfile()" ) ConditionProfile noWrapperProfile ,
@@ -486,10 +501,14 @@ protected static PythonClassNativeWrapper wrapNativeClass(PythonManagedClass obj
486
501
return PythonClassNativeWrapper .wrap (object , GetNameNode .doSlowPath (object ));
487
502
}
488
503
504
+ protected static PythonClassNativeWrapper wrapNativeClass (PythonContext ctx , PythonBuiltinClassType object ) {
505
+ return PythonClassNativeWrapper .wrap (ctx .getCore ().lookupType (object ), GetNameNode .doSlowPath (object ));
506
+ }
507
+
489
508
static boolean isFallback (Object object , PythonObjectLibrary lib ) {
490
509
return !(object instanceof String || object instanceof Boolean || object instanceof Integer || object instanceof Long || object instanceof Double ||
491
- object instanceof PythonNativeNull || object == DescriptorDeleteMarker .INSTANCE || object instanceof PythonAbstractObject ) &&
492
- !(lib .isForeignObject (object ) && !CApiGuards .isNativeWrapper (object ));
510
+ object instanceof PythonBuiltinClassType || object instanceof PythonNativeNull || object == DescriptorDeleteMarker .INSTANCE ||
511
+ object instanceof PythonAbstractObject ) && !(lib .isForeignObject (object ) && !CApiGuards .isNativeWrapper (object ));
493
512
}
494
513
495
514
protected static boolean isNaN (double d ) {
@@ -688,6 +707,22 @@ static Object doPythonClassUncached(@SuppressWarnings("unused") CExtContext cext
688
707
return PythonClassNativeWrapper .wrapNewRef (object , getNameNode .execute (object ));
689
708
}
690
709
710
+ @ Specialization (guards = "object == cachedObject" , limit = "3" , assumptions = "singleContextAssumption()" )
711
+ static Object doPythonType (@ SuppressWarnings ("unused" ) CExtContext cextContext , @ SuppressWarnings ("unused" ) PythonBuiltinClassType object ,
712
+ @ SuppressWarnings ("unused" ) @ Cached ("object" ) PythonBuiltinClassType cachedObject ,
713
+ @ SuppressWarnings ("unused" ) @ CachedContext (PythonLanguage .class ) PythonContext ctx ,
714
+ @ Cached ("wrapNativeClass(ctx, object)" ) PythonClassNativeWrapper wrapper ) {
715
+ wrapper .increaseRefCount ();
716
+ return wrapper ;
717
+ }
718
+
719
+ @ Specialization (replaces = "doPythonType" )
720
+ static Object doPythonTypeUncached (@ SuppressWarnings ("unused" ) CExtContext cextContext , PythonBuiltinClassType object ,
721
+ @ CachedContext (PythonLanguage .class ) PythonContext ctx ,
722
+ @ Cached TypeNodes .GetNameNode getNameNode ) {
723
+ return PythonClassNativeWrapper .wrapNewRef (ctx .getCore ().lookupType (object ), getNameNode .execute (object ));
724
+ }
725
+
691
726
@ Specialization (guards = {"cachedClass == object.getClass()" , "!isClass(object, lib)" , "!isNativeObject(object)" , "!isSpecialSingleton(object)" })
692
727
static Object runAbstractObjectCached (@ SuppressWarnings ("unused" ) CExtContext cextContext , PythonAbstractObject object ,
693
728
@ Cached ("createBinaryProfile()" ) ConditionProfile noWrapperProfile ,
@@ -722,6 +757,10 @@ protected static PythonClassNativeWrapper wrapNativeClass(PythonManagedClass obj
722
757
return PythonClassNativeWrapper .wrap (object , GetNameNode .doSlowPath (object ));
723
758
}
724
759
760
+ protected static PythonClassNativeWrapper wrapNativeClass (PythonContext ctx , PythonBuiltinClassType object ) {
761
+ return PythonClassNativeWrapper .wrap (ctx .getCore ().lookupType (object ), GetNameNode .doSlowPath (object ));
762
+ }
763
+
725
764
static boolean isFallback (Object object , PythonObjectLibrary lib ) {
726
765
return ToSulongNode .isFallback (object , lib );
727
766
}
@@ -851,6 +890,22 @@ static Object doPythonClassUncached(@SuppressWarnings("unused") CExtContext cext
851
890
return PythonClassNativeWrapper .wrapNewRef (object , getNameNode .execute (object ));
852
891
}
853
892
893
+ @ Specialization (guards = "object == cachedObject" , limit = "3" , assumptions = "singleContextAssumption()" )
894
+ static Object doPythonType (@ SuppressWarnings ("unused" ) CExtContext cextContext , @ SuppressWarnings ("unused" ) PythonBuiltinClassType object ,
895
+ @ SuppressWarnings ("unused" ) @ Cached ("object" ) PythonBuiltinClassType cachedObject ,
896
+ @ SuppressWarnings ("unused" ) @ CachedContext (PythonLanguage .class ) PythonContext ctx ,
897
+ @ Cached ("wrapNativeClass(ctx, object)" ) PythonClassNativeWrapper wrapper ) {
898
+ wrapper .increaseRefCount ();
899
+ return wrapper ;
900
+ }
901
+
902
+ @ Specialization (replaces = "doPythonType" )
903
+ static Object doPythonTypeUncached (@ SuppressWarnings ("unused" ) CExtContext cextContext , PythonBuiltinClassType object ,
904
+ @ CachedContext (PythonLanguage .class ) PythonContext ctx ,
905
+ @ Cached TypeNodes .GetNameNode getNameNode ) {
906
+ return PythonClassNativeWrapper .wrapNewRef (ctx .getCore ().lookupType (object ), getNameNode .execute (object ));
907
+ }
908
+
854
909
@ Specialization (guards = {"cachedClass == object.getClass()" , "!isClass(object, lib)" , "!isNativeObject(object)" , "!isSpecialSingleton(object)" })
855
910
static Object runAbstractObjectCached (@ SuppressWarnings ("unused" ) CExtContext cextContext , PythonAbstractObject object ,
856
911
@ Cached ("createBinaryProfile()" ) ConditionProfile noWrapperProfile ,
@@ -885,6 +940,10 @@ protected static PythonClassNativeWrapper wrapNativeClass(PythonManagedClass obj
885
940
return PythonClassNativeWrapper .wrap (object , GetNameNode .doSlowPath (object ));
886
941
}
887
942
943
+ protected static PythonClassNativeWrapper wrapNativeClass (PythonContext ctx , PythonBuiltinClassType object ) {
944
+ return PythonClassNativeWrapper .wrap (ctx .getCore ().lookupType (object ), GetNameNode .doSlowPath (object ));
945
+ }
946
+
888
947
static boolean isFallback (Object object , PythonObjectLibrary lib ) {
889
948
return ToSulongNode .isFallback (object , lib );
890
949
}
0 commit comments