Skip to content

Commit a024a93

Browse files
committed
Move astore exception table comparison before the instruction
According to JVMS 4.10.1.4 the state of a stack map frame is the incoming state of an instruction. Since astore can change local variable types perform the comparison before updating the state. Check the state for each astore so no type changes are missed. Signed-off-by: Theresa Mammarella <[email protected]>
1 parent 152bbb2 commit a024a93

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

runtime/bcverify/rtverify.c

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,6 @@ verifyBytecodes (J9BytecodeVerificationData * verifyData)
456456
I_32 offset32;
457457
UDATA argCount;
458458
UDATA checkIfInsideException = romMethod->modifiers & J9AccMethodHasExceptionInfo;
459-
UDATA tempStoreChange;
460459
J9ExceptionInfo *exceptionInfo = J9_EXCEPTION_DATA_FROM_ROM_METHOD(romMethod);
461460
J9ExceptionHandler *handler;
462461
J9UTF8 *catchName;
@@ -809,8 +808,6 @@ verifyBytecodes (J9BytecodeVerificationData * verifyData)
809808
goto _inconsistentStack;
810809
}
811810

812-
tempStoreChange = FALSE;
813-
814811
if (type != type1) {
815812
if ((type1 != BCV_GENERIC_OBJECT) || (type & BCV_TAG_BASE_TYPE_OR_TOP)) {
816813
inconsistentStack = TRUE;
@@ -823,21 +820,7 @@ verifyBytecodes (J9BytecodeVerificationData * verifyData)
823820
}
824821
}
825822

826-
/* because of pre-index local clearing - the order here matters */
827-
if (type1 & BCV_WIDE_TYPE_MASK) {
828-
tempStoreChange = (temps[index + 1] != BCV_BASE_TYPE_TOP);
829-
STORE_TEMP((index + 1), BCV_BASE_TYPE_TOP);
830-
}
831-
tempStoreChange |= (type != temps[index]);
832-
STORE_TEMP(index, type);
833-
834-
if (checkIfInsideException && tempStoreChange) {
835-
/* If we've stored a value into an arg/local, and it's of a different type than was
836-
* originally there, we need to ensure that we are still compatible with all our
837-
* exception handlers.
838-
*
839-
* For all exception handlers covering this instruction
840-
*/
823+
if (checkIfInsideException) {
841824
handler = J9EXCEPTIONINFO_HANDLERS(exceptionInfo);
842825
SAVE_STACKTOP(liveStack, stackTop);
843826

@@ -880,6 +863,16 @@ verifyBytecodes (J9BytecodeVerificationData * verifyData)
880863
liveStack->stackElements[liveStack->stackBaseIndex] = originalStackZeroEntry;
881864
stackTop = originalStackTop;
882865
}
866+
867+
/* Wait to set local variable types until after exception handler
868+
* stack map frame verification. According to spec 4.10.1.4
869+
* the incoming type state should be compared.
870+
* Because of pre-index local clearing - the order here matters.
871+
*/
872+
if (type1 & BCV_WIDE_TYPE_MASK) {
873+
STORE_TEMP((index + 1), BCV_BASE_TYPE_TOP);
874+
}
875+
STORE_TEMP(index, type);
883876
break;
884877

885878
case RTV_ARRAY_STORE:

0 commit comments

Comments
 (0)