47
47
import com .oracle .graal .python .builtins .PythonBuiltinClassType ;
48
48
import com .oracle .graal .python .builtins .modules .WarningsModuleBuiltins ;
49
49
import com .oracle .graal .python .builtins .objects .PNone ;
50
+ import com .oracle .graal .python .builtins .objects .PythonAbstractObject ;
50
51
import com .oracle .graal .python .builtins .objects .cext .PythonAbstractNativeObject ;
51
52
import com .oracle .graal .python .builtins .objects .ints .PInt ;
52
53
import com .oracle .graal .python .builtins .objects .object .PythonObjectLibrary ;
@@ -95,7 +96,7 @@ static long doLong(long object) {
95
96
}
96
97
97
98
@ Specialization (rewriteOn = UnexpectedResultException .class )
98
- int doCallIndexInt (VirtualFrame frame , Object object ,
99
+ int doCallIndexInt (VirtualFrame frame , PythonAbstractObject object ,
99
100
@ Shared ("callIndex" ) @ Cached CallIndexNode callIndex ,
100
101
@ Shared ("lib" ) @ CachedLibrary (limit = "3" ) PythonObjectLibrary lib ,
101
102
@ Shared ("isSubtype" ) @ Cached IsSubtypeNode isSubtype ) throws UnexpectedResultException {
@@ -117,14 +118,15 @@ int doCallIndexInt(VirtualFrame frame, Object object,
117
118
}
118
119
}
119
120
121
+ // TODO: Accept "Object" again once GR-30482 is fixed
120
122
@ Specialization (replaces = "doCallIndexInt" )
121
- static Object doCallIndex (VirtualFrame frame , Object object ,
123
+ static Object doCallIndex (VirtualFrame frame , PythonAbstractObject object ,
122
124
@ Shared ("callIndex" ) @ Cached CallIndexNode callIndex ,
123
125
@ Shared ("lib" ) @ CachedLibrary (limit = "3" ) PythonObjectLibrary lib ,
124
126
@ Shared ("isSubtype" ) @ Cached IsSubtypeNode isSubtype ,
125
- @ Cached IsBuiltinClassProfile isInt ,
126
- @ Cached PRaiseNode raiseNode ,
127
- @ Cached WarningsModuleBuiltins .WarnNode warnNode ) {
127
+ @ Shared ( "isInt" ) @ Cached IsBuiltinClassProfile isInt ,
128
+ @ Shared ( "raiseNode" ) @ Cached PRaiseNode raiseNode ,
129
+ @ Shared ( "warnNode" ) @ Cached WarningsModuleBuiltins .WarnNode warnNode ) {
128
130
if (isSubtype .execute (lib .getLazyPythonClass (object ), PythonBuiltinClassType .PInt )) {
129
131
return object ;
130
132
}
@@ -133,6 +135,20 @@ static Object doCallIndex(VirtualFrame frame, Object object,
133
135
return result ;
134
136
}
135
137
138
+ // TODO: Remove again once GR-30482 is fixed
139
+ @ Specialization (guards = "!isAnyPythonObject(object)" )
140
+ static Object doCallIndexForeign (VirtualFrame frame , Object object ,
141
+ @ Shared ("callIndex" ) @ Cached CallIndexNode callIndex ,
142
+ @ Shared ("lib" ) @ CachedLibrary (limit = "3" ) PythonObjectLibrary lib ,
143
+ @ Shared ("isSubtype" ) @ Cached IsSubtypeNode isSubtype ,
144
+ @ Shared ("isInt" ) @ Cached IsBuiltinClassProfile isInt ,
145
+ @ Shared ("raiseNode" ) @ Cached PRaiseNode raiseNode ,
146
+ @ Shared ("warnNode" ) @ Cached WarningsModuleBuiltins .WarnNode warnNode ) {
147
+ Object result = callIndex .execute (frame , object );
148
+ checkResult (frame , object , result , lib , isSubtype , isInt , raiseNode , warnNode );
149
+ return result ;
150
+ }
151
+
136
152
private static void checkResult (VirtualFrame frame , Object originalObject , Object result , PythonObjectLibrary lib , IsSubtypeNode isSubtype , IsBuiltinClassProfile isInt , PRaiseNode raiseNode ,
137
153
WarningsModuleBuiltins .WarnNode warnNode ) {
138
154
if (!isInt .profileObject (result , PythonBuiltinClassType .PInt )) {
0 commit comments