@@ -441,8 +441,8 @@ public Object invokeMember(String member, Object[] arguments,
441
441
@ Exclusive @ Cached LookupInheritedAttributeNode .Dynamic lookupGetattributeNode ,
442
442
@ Exclusive @ Cached CallNode callGetattributeNode ,
443
443
@ Exclusive @ Cached PExecuteNode executeNode ,
444
- @ Cached ("createBinaryProfile()" ) ConditionProfile profileGetattribute ,
445
- @ Cached ("createBinaryProfile()" ) ConditionProfile profileMember ) throws UnknownIdentifierException , UnsupportedMessageException {
444
+ @ Exclusive @ Cached ("createBinaryProfile()" ) ConditionProfile profileGetattribute ,
445
+ @ Exclusive @ Cached ("createBinaryProfile()" ) ConditionProfile profileMember ) throws UnknownIdentifierException , UnsupportedMessageException {
446
446
Object attrGetattribute = lookupGetattributeNode .execute (this , __GETATTRIBUTE__ );
447
447
if (profileGetattribute .profile (attrGetattribute != PNone .NO_VALUE )) {
448
448
Object memberObj = callGetattributeNode .execute (null , attrGetattribute , this , member );
@@ -678,19 +678,7 @@ public final boolean isContextManager(@Exclusive @Cached HasInheritedAttributeNo
678
678
@ Exclusive @ Cached ("createBinaryProfile()" ) ConditionProfile profile ) {
679
679
return profile .profile (hasEnterNode .execute (this , __ENTER__ ) && hasExitNode .execute (this , __EXIT__ ));
680
680
}
681
-
682
- @ ExportMessage
683
- public boolean isSequence (@ Shared ("thisObject" ) @ Cached GetLazyClassNode getClassNode ,
684
- @ CachedLibrary (limit = "1" ) PythonTypeLibrary pythonTypeLibrary ) {
685
- return pythonTypeLibrary .isSequenceType (getClassNode .execute (this ));
686
- }
687
-
688
- @ ExportMessage
689
- public boolean isMapping (@ Shared ("thisObject" ) @ Cached GetLazyClassNode getClassNode ,
690
- @ CachedLibrary (limit = "1" ) PythonTypeLibrary pythonTypeLibrary ) {
691
- return pythonTypeLibrary .isMappingType (getClassNode .execute (this ));
692
- }
693
-
681
+
694
682
private static final String DATETIME_MODULE_NAME = "datetime" ;
695
683
private static final String TIME_MODULE_NAME = "time" ;
696
684
private static final String DATE_TYPE = "date" ;
@@ -701,17 +689,19 @@ public boolean isMapping(@Shared("thisObject") @Cached GetLazyClassNode getClass
701
689
@ ExportMessage
702
690
public boolean isDate (@ Shared ("getClassNode" ) @ Cached GetLazyClassNode getClassNode ,
703
691
@ Shared ("readTypeNode" ) @ Cached ReadAttributeFromObjectNode readTypeNode ,
704
- @ Shared ("isSubtypeNode" ) @ Cached IsSubtypeNode .IsSubtypeWithoutFrameNode isSubtypeNode ) {
692
+ @ Shared ("isSubtypeNode" ) @ Cached IsSubtypeNode .IsSubtypeWithoutFrameNode isSubtypeNode ,
693
+ @ Shared ("dateTimeModuleProfile" ) @ Cached ("createBinaryProfile()" ) ConditionProfile dateTimeModuleLoaded ,
694
+ @ Shared ("timeModuleProfile" ) @ Cached ("createBinaryProfile()" ) ConditionProfile timeModuleLoaded ) {
705
695
LazyPythonClass objType = getClassNode .execute (this );
706
696
PDict importedModules = PythonLanguage .getContext ().getImportedModules ();
707
697
Object module = importedModules .getItem (DATETIME_MODULE_NAME );
708
- if (module != null ) {
698
+ if (dateTimeModuleLoaded . profile ( module != null ) ) {
709
699
if (isSubtypeNode .executeWithGlobalState (objType , readTypeNode .execute (module , DATETIME_TYPE )) || isSubtypeNode .executeWithGlobalState (objType , readTypeNode .execute (module , DATE_TYPE ))) {
710
700
return true ;
711
701
}
712
702
}
713
703
module = importedModules .getItem (TIME_MODULE_NAME );
714
- if (module != null ) {
704
+ if (timeModuleLoaded . profile ( module != null ) ) {
715
705
if (isSubtypeNode .executeWithGlobalState (objType , readTypeNode .execute (module , STRUCT_TIME_TYPE ))) {
716
706
return true ;
717
707
}
@@ -725,8 +715,8 @@ public LocalDate asDate(@Shared("getClassNode") @Cached GetLazyClassNode getClas
725
715
@ Shared ("isSubtypeNode" ) @ Cached IsSubtypeNode .IsSubtypeWithoutFrameNode isSubtypeNode ,
726
716
@ Shared ("castToIntNode" ) @ Cached CastToJavaIntNode castToIntNode ,
727
717
@ CachedLibrary ("this" ) InteropLibrary lib ,
728
- @ Cached ("createBinaryProfile()" ) ConditionProfile dateTimeModuleLoaded ,
729
- @ Cached ("createBinaryProfile()" ) ConditionProfile timeModuleLoaded ) throws UnsupportedMessageException {
718
+ @ Shared ( "dateTimeModuleProfile" ) @ Cached ("createBinaryProfile()" ) ConditionProfile dateTimeModuleLoaded ,
719
+ @ Shared ( "timeModuleProfile" ) @ Cached ("createBinaryProfile()" ) ConditionProfile timeModuleLoaded ) throws UnsupportedMessageException {
730
720
LazyPythonClass objType = getClassNode .execute (this );
731
721
PDict importedModules = PythonLanguage .getContext ().getImportedModules ();
732
722
Object module = importedModules .getItem (DATETIME_MODULE_NAME );
@@ -762,8 +752,8 @@ public LocalDate asDate(@Shared("getClassNode") @Cached GetLazyClassNode getClas
762
752
public boolean isTime (@ Shared ("getClassNode" ) @ Cached GetLazyClassNode getClassNode ,
763
753
@ Shared ("readTypeNode" ) @ Cached ReadAttributeFromObjectNode readTypeNode ,
764
754
@ Shared ("isSubtypeNode" ) @ Cached IsSubtypeNode .IsSubtypeWithoutFrameNode isSubtype ,
765
- @ Cached ("createBinaryProfile()" ) ConditionProfile dateTimeModuleLoaded ,
766
- @ Cached ("createBinaryProfile()" ) ConditionProfile timeModuleLoaded ) {
755
+ @ Shared ( "dateTimeModuleProfile" ) @ Cached ("createBinaryProfile()" ) ConditionProfile dateTimeModuleLoaded ,
756
+ @ Shared ( "timeModuleProfile" ) @ Cached ("createBinaryProfile()" ) ConditionProfile timeModuleLoaded ) {
767
757
LazyPythonClass objType = getClassNode .execute (this );
768
758
PDict importedModules = PythonLanguage .getContext ().getImportedModules ();
769
759
Object module = importedModules .getItem (DATETIME_MODULE_NAME );
@@ -787,8 +777,8 @@ public LocalTime asTime(@Shared("getClassNode") @Cached GetLazyClassNode getClas
787
777
@ Shared ("isSubtypeNode" ) @ Cached IsSubtypeNode .IsSubtypeWithoutFrameNode isSubtypeNode ,
788
778
@ Shared ("castToIntNode" ) @ Cached CastToJavaIntNode castToIntNode ,
789
779
@ CachedLibrary ("this" ) InteropLibrary lib ,
790
- @ Cached ("createBinaryProfile()" ) ConditionProfile dateTimeModuleLoaded ,
791
- @ Cached ("createBinaryProfile()" ) ConditionProfile timeModuleLoaded ) throws UnsupportedMessageException {
780
+ @ Shared ( "dateTimeModuleProfile" ) @ Cached ("createBinaryProfile()" ) ConditionProfile dateTimeModuleLoaded ,
781
+ @ Shared ( "timeModuleProfile" ) @ Cached ("createBinaryProfile()" ) ConditionProfile timeModuleLoaded ) throws UnsupportedMessageException {
792
782
LazyPythonClass objType = getClassNode .execute (this );
793
783
PDict importedModules = PythonLanguage .getContext ().getImportedModules ();
794
784
Object module = importedModules .getItem (DATETIME_MODULE_NAME );
@@ -826,8 +816,8 @@ public boolean isTimeZone(@Shared("getClassNode") @Cached GetLazyClassNode getCl
826
816
@ Shared ("readTypeNode" ) @ Cached ReadAttributeFromObjectNode readTypeNode ,
827
817
@ Shared ("isSubtypeNode" ) @ Cached IsSubtypeNode .IsSubtypeWithoutFrameNode isSubtype ,
828
818
@ CachedLibrary (limit = "2" ) InteropLibrary lib ,
829
- @ Cached ("createBinaryProfile()" ) ConditionProfile dateTimeModuleLoaded ,
830
- @ Cached ("createBinaryProfile()" ) ConditionProfile timeModuleLoaded ) {
819
+ @ Shared ( "dateTimeModuleProfile" ) @ Cached ("createBinaryProfile()" ) ConditionProfile dateTimeModuleLoaded ,
820
+ @ Shared ( "timeModuleProfile" ) @ Cached ("createBinaryProfile()" ) ConditionProfile timeModuleLoaded ) {
831
821
LazyPythonClass objType = getClassNode .execute (this );
832
822
PDict importedModules = PythonLanguage .getContext ().getImportedModules ();
833
823
Object module = importedModules .getItem (DATETIME_MODULE_NAME );
@@ -880,8 +870,8 @@ public ZoneId asTimeZone(@Shared("getClassNode") @Cached GetLazyClassNode getCla
880
870
@ Shared ("isSubtypeNode" ) @ Cached IsSubtypeNode .IsSubtypeWithoutFrameNode isSubtypeNode ,
881
871
@ Shared ("castToIntNode" ) @ Cached CastToJavaIntNode castToIntNode ,
882
872
@ CachedLibrary (limit = "3" ) InteropLibrary lib ,
883
- @ Cached ("createBinaryProfile()" ) ConditionProfile dateTimeModuleLoaded ,
884
- @ Cached ("createBinaryProfile()" ) ConditionProfile timeModuleLoaded ) throws UnsupportedMessageException {
873
+ @ Shared ( "dateTimeModuleProfile" ) @ Cached ("createBinaryProfile()" ) ConditionProfile dateTimeModuleLoaded ,
874
+ @ Shared ( "timeModuleProfile" ) @ Cached ("createBinaryProfile()" ) ConditionProfile timeModuleLoaded ) throws UnsupportedMessageException {
885
875
if (!lib .isTimeZone (this )) {
886
876
throw UnsupportedMessageException .create ();
887
877
}
@@ -1476,4 +1466,4 @@ public static PInteropDeleteAttributeNode getUncached() {
1476
1466
private static boolean objectHasAttribute (Object object , Object field ) {
1477
1467
return ((PythonObject ) object ).getAttributeNames ().contains (field );
1478
1468
}
1479
- }
1469
+ }
0 commit comments