|
68 | 68 | @TypeSystemReference(PythonTypes.class)
|
69 | 69 | @ImportStatic({PGuards.class})
|
70 | 70 | public abstract class GetClassNode extends PNodeWithContext {
|
| 71 | + private final ValueProfile classProfile = ValueProfile.createClassProfile(); |
| 72 | + |
71 | 73 | public static GetClassNode create() {
|
72 | 74 | return GetClassNodeGen.create();
|
73 | 75 | }
|
74 | 76 |
|
75 |
| - public abstract PythonClass execute(Object object); |
| 77 | + public abstract PythonClass execute(boolean object); |
| 78 | + |
| 79 | + public abstract PythonClass execute(int object); |
| 80 | + |
| 81 | + public abstract PythonClass execute(long object); |
| 82 | + |
| 83 | + public abstract PythonClass execute(double object); |
| 84 | + |
| 85 | + public final PythonClass execute(Object object) { |
| 86 | + return executeGetClass(classProfile.profile(object)); |
| 87 | + } |
| 88 | + |
| 89 | + public abstract PythonClass executeGetClass(Object object); |
76 | 90 |
|
77 | 91 | @Specialization(assumptions = "singleContextAssumption()")
|
78 | 92 | protected PythonClass getIt(@SuppressWarnings("unused") GetSetDescriptor object,
|
@@ -191,23 +205,7 @@ protected PythonClass getIt(PythonNativeObject object,
|
191 | 205 | return getNativeClassNode.execute(object);
|
192 | 206 | }
|
193 | 207 |
|
194 |
| - @SuppressWarnings("unchecked") |
195 |
| - protected Class<? extends PythonObject> asPythonObjectSubclass(Class<? extends Object> clazz) { |
196 |
| - Class<? extends PythonObject> retval = null; |
197 |
| - if (PythonObject.class.isAssignableFrom(clazz)) { |
198 |
| - retval = (Class<? extends PythonObject>) clazz; |
199 |
| - } |
200 |
| - return retval; |
201 |
| - } |
202 |
| - |
203 |
| - @Specialization(guards = {"object.getClass() == cachedClass"}, limit = "5") |
204 |
| - protected PythonClass getPythonClassCached(Object object, |
205 |
| - @Cached("asPythonObjectSubclass(object.getClass())") Class<? extends PythonObject> cachedClass, |
206 |
| - @Cached("createIdentityProfile()") ValueProfile profile) { |
207 |
| - return profile.profile(cachedClass.cast(object).getPythonClass()); |
208 |
| - } |
209 |
| - |
210 |
| - @Specialization(replaces = "getPythonClassCached") |
| 208 | + @Specialization |
211 | 209 | protected PythonClass getPythonClassGeneric(PythonObject object,
|
212 | 210 | @Cached("createIdentityProfile()") ValueProfile profile) {
|
213 | 211 | return profile.profile(object.getPythonClass());
|
|
0 commit comments