4747import com .oracle .svm .core .meta .SubstrateObjectConstant ;
4848import com .oracle .svm .core .monitor .MonitorSupport ;
4949
50+ import jdk .graal .compiler .nodes .FrameState ;
5051import jdk .vm .ci .code .InstalledCode ;
5152import jdk .vm .ci .meta .JavaConstant ;
5253
@@ -267,9 +268,9 @@ static class RelockObjectData {
267268 }
268269
269270 protected static DeoptimizedFrame factory (int targetContentSize , long sourceEncodedFrameSize , SubstrateInstalledCode sourceInstalledCode , VirtualFrame topFrame ,
270- RelockObjectData [] relockedObjects , CodePointer sourcePC ) {
271+ RelockObjectData [] relockedObjects , CodePointer sourcePC , boolean rethrowException ) {
271272 final TargetContent targetContentBuffer = new TargetContent (targetContentSize , ConfigurationValues .getTarget ().arch .getByteOrder ());
272- return new DeoptimizedFrame (sourceEncodedFrameSize , sourceInstalledCode , topFrame , targetContentBuffer , relockedObjects , sourcePC );
273+ return new DeoptimizedFrame (sourceEncodedFrameSize , sourceInstalledCode , topFrame , targetContentBuffer , relockedObjects , sourcePC , rethrowException );
273274 }
274275
275276 private final long sourceEncodedFrameSize ;
@@ -280,9 +281,16 @@ protected static DeoptimizedFrame factory(int targetContentSize, long sourceEnco
280281 private final PinnedObject pin ;
281282 private final CodePointer sourcePC ;
282283 private final char [] completedMessage ;
284+ /**
285+ * This flag indicates this DeoptimizedFrame corresponds to a state where
286+ * {@link FrameState#rethrowException()} is set. Within the execution, this marks a spot where
287+ * we have an exception and are now starting to walk the exceptions handlers to see if execution
288+ * should continue in a matching handler or unwind.
289+ */
290+ private final boolean rethrowException ;
283291
284292 private DeoptimizedFrame (long sourceEncodedFrameSize , SubstrateInstalledCode sourceInstalledCode , VirtualFrame topFrame , Deoptimizer .TargetContent targetContent ,
285- RelockObjectData [] relockedObjects , CodePointer sourcePC ) {
293+ RelockObjectData [] relockedObjects , CodePointer sourcePC , boolean rethrowException ) {
286294 this .sourceEncodedFrameSize = sourceEncodedFrameSize ;
287295 this .topFrame = topFrame ;
288296 this .targetContent = targetContent ;
@@ -293,6 +301,7 @@ private DeoptimizedFrame(long sourceEncodedFrameSize, SubstrateInstalledCode sou
293301 StringBuilderLog sbl = new StringBuilderLog ();
294302 sbl .string ("deoptStub: completed for DeoptimizedFrame at " ).hex (pin .addressOfObject ()).newline ();
295303 this .completedMessage = sbl .getResult ().toCharArray ();
304+ this .rethrowException = rethrowException ;
296305 }
297306
298307 /**
@@ -393,6 +402,13 @@ protected void buildContent(Pointer newSp) {
393402 * the deoptimization target.
394403 */
395404 public void takeException () {
405+ if (rethrowException ) {
406+ /*
407+ * This frame already corresponds to the start of an execution handler walk. Nothing
408+ * needs to be done.
409+ */
410+ return ;
411+ }
396412 ReturnAddress firstAddressEntry = topFrame .returnAddress ;
397413 CodePointer ip = WordFactory .pointer (firstAddressEntry .returnAddress );
398414 CodeInfo info = CodeInfoTable .getImageCodeInfo (ip );
0 commit comments