Skip to content

Commit dac6b64

Browse files
committed
Fix invalid context property caching.
1 parent 604746c commit dac6b64

File tree

1 file changed

+6
-10
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/statement

1 file changed

+6
-10
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/statement/ExceptNode.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,9 @@ boolean isPythonException(VirtualFrame frame, LazyPythonClass type,
180180
return isSubtype.execute(frame, type, PythonBuiltinClassType.PBaseException);
181181
}
182182

183-
@Specialization(guards = {"emulateJython", "context.getEnv().isHostObject(type)"}, limit = "1")
183+
@Specialization(guards = {"emulateJython(context)", "context.getEnv().isHostObject(type)"})
184184
boolean isJavaException(@SuppressWarnings("unused") VirtualFrame frame, Object type,
185-
@CachedContext(PythonLanguage.class) PythonContext context,
186-
@SuppressWarnings("unused") @Cached("emulateJython(context)") boolean emulateJython) {
185+
@CachedContext(PythonLanguage.class) PythonContext context) {
187186
Object hostType = context.getEnv().asHostObject(type);
188187
return hostType instanceof Class && Throwable.class.isAssignableFrom((Class<?>) hostType);
189188
}
@@ -228,31 +227,28 @@ boolean matchPythonSingle(VirtualFrame frame, PException e, Object clause,
228227
return isSubtype.execute(frame, plib.getLazyPythonClass(e.getExceptionObject()), clause);
229228
}
230229

231-
@Specialization(guards = {"emulateJython", "context.getEnv().isHostException(e)", "context.getEnv().isHostObject(clause)"}, limit = "1")
230+
@Specialization(guards = {"emulateJython(context)", "context.getEnv().isHostException(e)", "context.getEnv().isHostObject(clause)"})
232231
boolean matchJava(VirtualFrame frame, Throwable e, Object clause,
233232
@Cached ValidExceptionNode isValidException,
234-
@CachedContext(PythonLanguage.class) PythonContext context,
235-
@SuppressWarnings("unused") @Cached("emulateJython(context)") boolean emulateJython) {
233+
@CachedContext(PythonLanguage.class) PythonContext context) {
236234
raiseIfNoException(frame, clause, isValidException);
237235
// cast must succeed due to ValidExceptionNode above
238236
Class<?> javaClause = (Class<?>) context.getEnv().asHostObject(clause);
239237
Throwable hostException = context.getEnv().asHostException(e);
240238
return javaClause.isInstance(hostException);
241239
}
242240

243-
@Specialization(guards = {"emulateJython", "context.getEnv().isHostObject(clause)"}, limit = "1")
241+
@Specialization(guards = {"emulateJython(context)", "context.getEnv().isHostObject(clause)"})
244242
boolean doNotMatchPython(VirtualFrame frame, @SuppressWarnings("unused") PException e, Object clause,
245243
@SuppressWarnings("unused") @CachedContext(PythonLanguage.class) PythonContext context,
246-
@SuppressWarnings("unused") @Cached("emulateJython(context)") boolean emulateJython,
247244
@Cached ValidExceptionNode isValidException) {
248245
raiseIfNoException(frame, clause, isValidException);
249246
return false;
250247
}
251248

252-
@Specialization(guards = {"emulateJython", "context.getEnv().isHostException(e)"}, limit = "1")
249+
@Specialization(guards = {"emulateJython(context)", "context.getEnv().isHostException(e)"})
253250
boolean doNotMatchJava(VirtualFrame frame, @SuppressWarnings("unused") Throwable e, LazyPythonClass clause,
254251
@SuppressWarnings("unused") @CachedContext(PythonLanguage.class) PythonContext context,
255-
@SuppressWarnings("unused") @Cached("emulateJython(context)") boolean emulateJython,
256252
@Cached ValidExceptionNode isValidException) {
257253
raiseIfNoException(frame, clause, isValidException);
258254
return false;

0 commit comments

Comments
 (0)