📄 verifier.c
字号:
/*0990*/ }
/*0991*/ for (i = 0; i < nargs; i++) {
/*0992*/ n += change_Arg_to_StackType(&sig, &vLocals[n]);
/*0993*/ }
/*0994*/ returnSig = sig;
/*0995*/ }
/*0996*/
/*0997*/ noControlFlow = FALSE;
/*0998*/
/*0999*/ while (ip < codeLength) {
/*1000*/ int opcode;
/*1001*/
/*1002*/ START_TEMPORARY_ROOTS
/*1003*/
/*1017*/ {
/*1018*/ /* Check that stackmaps are ordered according to offset, and
/*1019./ * every offset in stackmaps point to the beginning to an
/*1020./ * instruction.
/*1021./ */
/*1022*/ POINTERLIST stackMaps = thisMethod->u.java.stackMaps.verifierMap;
/*1023*/ if (stackMaps && stackMapIndex < stackMaps->length) {
/*1024*/ long thisOffset =
/*1025*/ stackMaps->data[stackMapIndex + stackMaps->length].cell;
/*1026*/ if (thisOffset == ip) {
/*1027*/ stackMapIndex++; /* This offset is good. */
/*1028*/ } else if (thisOffset < ip) {
/*1029*/ /* ip should have met offset. */
/*1030*/ VERIFIER_ERROR(VE_BAD_STACKMAP);
/*1031*/ } else {
/*1032*/ /* Good so far. Nothing to do */
/*1033*/ }
/*1034*/ }
/*1035*/ }
/*1036*/
/*1037*/ {
/*1038*/ /* Merge with the next instruction. Note how noControlFlow
/*1039./ * is used here.
/*1040./ */
/*1041*/ int flags = (noControlFlow ? 0 : SM_CHECK) | SM_MERGE;
/*1047*/ if (!matchStackMap(thisMethod, ip, ip, flags)) {
/*1048*/ VERIFIER_ERROR(VE_SEQ_BAD_TYPE);
/*1049*/ }
/*1050*/ noControlFlow = FALSE;
/*1051*/ }
/*1052*/
/*1053*/ {
/*1054*/ /* Look for possible jump target in exception handlers. */
/*1055*/ HANDLERTABLE handlers = thisMethod->u.java.handlers;
/*1056*/ if (handlers) {
/*1057*/ int i;
/*1058*/ for (i = 0; i < handlers->length; i++) {
/*1059*/ if (ip >= handlers->handlers[i].startPC &&
/*1060*/ ip < handlers->handlers[i].endPC) {
/*1061*/ unsigned short exceptionClassKey;
/*1062*/ unsigned short vSP_bak;
/*1063*/ unsigned short vStack0_bak;
/*1064*/ index = handlers->handlers[i].exception;
/*1065*/ if (index) {
/*1066*/ exceptionClassKey =
/*1067*/ GET_CLASS_CONSTANT_KEY(constPool, index);
/*1068*/ } else {
/*1069*/ exceptionClassKey = throwableClassKey;
/*1070*/ }
/*1071*/ /* Reset stack to only contain the exception object. */
/*1072*/ vSP_bak = vSP;
/*1073*/ vStack0_bak = vStack[0];
/*1074*/ vSP = 0;
/*1075*/ PUSH_STACK(exceptionClassKey);
/*1076*/
/*1083*/ CHECK_TARGET(ip, handlers->handlers[i].handlerPC);
/*1084*/ /* Recover old stack. */
/*1085*/ vStack[0] = vStack0_bak;
/*1086*/ vSP = vSP_bak;
/*1087*/ }
/*1088*/ }
/*1089*/ }
/*1090*/ }
/*1091*/
/*1092*/ opcode = code[ip];
/*1096*/ switch (opcode) {
/*1097*/ case IF_ICMPEQ :
/*1098*/ case IF_ICMPNE :
/*1099*/ case IF_ICMPLT :
/*1100*/ case IF_ICMPGE :
/*1101*/ case IF_ICMPGT :
/*1102*/ case IF_ICMPLE :
/*1103*/ POP_STACK(ITEM_Integer);
/*1104*/ /* fall through */
/*1105*/ case IFEQ :
/*1106*/ case IFNE :
/*1107*/ case IFLT :
/*1108*/ case IFGE :
/*1109*/ case IFGT :
/*1110*/ case IFLE :
/*1111*/ POP_STACK(ITEM_Integer);
/*1112*/ CHECK_JUMP_TARGET(ip, ip + getShort(code + ip + 1));
/*1113*/ ip += 3;
/*1114*/ break;
/*1115*/
/*1116*/ case IF_ACMPEQ :
/*1117*/ case IF_ACMPNE :
/*1118*/ POP_STACK(ITEM_Reference);
/*1119*/ /* fall through */
/*1120*/ case IFNULL :
/*1121*/ case IFNONNULL :
/*1122*/ POP_STACK(ITEM_Reference);
/*1123*/ CHECK_JUMP_TARGET(ip, ip + getShort(code + ip + 1));
/*1124*/ ip += 3;
/*1125*/ break;
/*1126*/
/*1127*/ case GOTO:
/*1128*/ CHECK_JUMP_TARGET(ip, ip + getShort(code + ip + 1));
/*1129*/ ip += 3;
/*1130*/ noControlFlow = TRUE;
/*1131*/ break;
/*1132*/
/*1133*/ case GOTO_W:
/*1134*/ CHECK_JUMP_TARGET(ip, ip + getCell(code + ip + 1));
/*1135*/ ip += 5;
/*1136*/ noControlFlow = TRUE;
/*1137*/ break;
/*1138*/
/*1139*/ case TABLESWITCH:
/*1140*/ case LOOKUPSWITCH:
/*1141*/ {
/*1142*/ long *lpc = (long *)(((long)(code + ip + 1) + 3) & ~3);
/*1143*/ long *lptr;
/*1144*/ int keys;
/*1145*/ int k, delta;
/*1146*/ POP_STACK(ITEM_Integer);
/*1147*/ if (opcode == TABLESWITCH) {
/*1148*/ keys = getCell(&lpc[2]) - getCell(&lpc[1]) + 1;
/*1149*/ delta = 1;
/*1150*/ } else {
/*1151*/ keys = getCell(&lpc[1]);
/*1152*/ delta = 2;
/*1153*/ /* Make sure that the tableswitch items are sorted */
/*1154*/ for (k = keys - 1, lptr = &lpc[2]; --k >= 0; lptr += 2) {
/*1155*/ long this_key = getCell(&lptr[0]);
/*1156*/ long next_key = getCell(&lptr[2]);
/*1157*/ if (this_key >= next_key) {
/*1158*/ VERIFIER_ERROR(VE_BAD_LOOKUPSWITCH);
/*1159*/ }
/*1160*/ }
/*1161*/ }
/*1162*/ CHECK_JUMP_TARGET(ip, ip + getCell(&lpc[0]));
/*1163*/ for (k = keys, lptr = &lpc[3]; --k >= 0; lptr += delta) {
/*1164*/ CHECK_JUMP_TARGET(ip, ip + getCell(&lptr[0]));
/*1165*/ }
/*1166*/ ip = (unsigned char*)(lptr - delta + 1) - code;
/*1167*/ noControlFlow = TRUE;
/*1168*/ break;
/*1169*/ }
/*1170*/
/*1171*/ case NOP :
/*1172*/ ip++;
/*1173*/ break;
/*1174*/ case ACONST_NULL :
/*1175*/ PUSH_STACK(ITEM_Null);
/*1176*/ ip++;
/*1177*/ break;
/*1178*/ case ICONST_M1 :
/*1179*/ case ICONST_0 :
/*1180*/ case ICONST_1 :
/*1181*/ case ICONST_2 :
/*1182*/ case ICONST_3 :
/*1183*/ case ICONST_4 :
/*1184*/ case ICONST_5 :
/*1185*/ PUSH_STACK(ITEM_Integer);
/*1186*/ ip++;
/*1187*/ break;
/*1188*/ case LCONST_0 :
/*1189*/ case LCONST_1 :
/*1190*/ PUSH_STACK(ITEM_Long);
/*1191*/ PUSH_STACK(ITEM_Long_2);
/*1192*/ ip++;
/*1193*/ break;
/*1194*/#if IMPLEMENTS_FLOAT
/*1195*/ case FCONST_0 :
/*1196*/ case FCONST_1 :
/*1197*/ case FCONST_2 :
/*1198*/ PUSH_STACK(ITEM_Float);
/*1199*/ ip++;
/*1200*/ break;
/*1201*/ case DCONST_0 :
/*1202*/ case DCONST_1 :
/*1203*/ PUSH_STACK(ITEM_Double);
/*1204*/ PUSH_STACK(ITEM_Double_2);
/*1205*/ ip++;
/*1206*/ break;
/*1207*/#endif /* IMPLEMENTS_FLOAT */
/*1208*/ case SIPUSH :
/*1209*/ ip++;
/*1210*/ /* fall through */
/*1211*/ case BIPUSH :
/*1212*/ PUSH_STACK(ITEM_Integer);
/*1213*/ ip += 2;
/*1214*/ break;
/*1215*/ case LDC :
/*1216*/ index = code[ip + 1];
/*1217*/ ip += 2;
/*1218*/ goto label_ldc;
/*1219*/ case LDC_W :
/*1220*/ /* fall through */
/*1221*/ case LDC2_W :
/*1222*/ index = getUShort(code + ip + 1);
/*1223*/ ip += 3;
/*1224*/ label_ldc:
/*1225*/ CHECK_VALID_CP_INDEX(constPool, index);
/*1226*/ tag = CONSTANTPOOL_MASKED_TAG(constPool, index);
/*1227*/ if (opcode == LDC || opcode == LDC_W) {
/*1228*/ if (tag == CONSTANT_String) {
/*1229*/ PUSH_STACK(stringClassKey);
/*1230*/ break;
/*1231*/ } else if (tag == CONSTANT_Integer) {
/*1232*/ PUSH_STACK(ITEM_Integer);
/*1233*/ break;
/*1234*/#if IMPLEMENTS_FLOAT
/*1235*/ } else if (tag == CONSTANT_Float) {
/*1236*/ PUSH_STACK(ITEM_Float);
/*1237*/ break;
/*1238*/#endif
/*1239*/ }
/*1240*/#if IMPLEMENTS_FLOAT
/*1241*/ } else if (tag == CONSTANT_Double) {
/*1242*/ PUSH_STACK(ITEM_Double);
/*1243*/ PUSH_STACK(ITEM_Double_2);
/*1244*/ break;
/*1245*/#endif
/*1246*/ } else if (tag == CONSTANT_Long) {
/*1247*/ PUSH_STACK(ITEM_Long);
/*1248*/ PUSH_STACK(ITEM_Long_2);
/*1249*/ break;
/*1250*/ }
/*1251*/ VERIFIER_ERROR(VE_BAD_LDC);
/*1252*/ case ILOAD :
/*1253*/ index = code[ip + 1];
/*1254*/ ip += 2;
/*1255*/ goto label_iload;
/*1256*/ case ILOAD_0 :
/*1257*/ case ILOAD_1 :
/*1258*/ case ILOAD_2 :
/*1259*/ case ILOAD_3 :
/*1260*/ index = opcode - ILOAD_0;
/*1261*/ ip++;
/*1262*/ label_iload:
/*1263*/ GET_LOCAL(index, ITEM_Integer);
/*1264*/ PUSH_STACK(ITEM_Integer);
/*1265*/ break;
/*1266*/ case LLOAD :
/*1267*/ index = code[ip + 1];
/*1268*/ ip += 2;
/*1269*/ goto label_lload;
/*1270*/ case LLOAD_0 :
/*1271*/ case LLOAD_1 :
/*1272*/ case LLOAD_2 :
/*1273*/ case LLOAD_3 :
/*1274*/ index = opcode - LLOAD_0;
/*1275*/ ip++;
/*1276*/ label_lload:
/*1277*/ GET_LOCAL(index, ITEM_Long);
/*1278*/ GET_LOCAL(index + 1, ITEM_Long_2);
/*1279*/ PUSH_STACK(ITEM_Long);
/*1280*/ PUSH_STACK(ITEM_Long_2);
/*1281*/ break;
/*1282*/#if IMPLEMENTS_FLOAT
/*1283*/ case FLOAD :
/*1284*/ index = code[ip + 1];
/*1285*/ ip += 2;
/*1286*/ goto label_fload;
/*1287*/ case FLOAD_0 :
/*1288*/ case FLOAD_1 :
/*1289*/ case FLOAD_2 :
/*1290*/ case FLOAD_3 :
/*1291*/ index = opcode - FLOAD_0;
/*1292*/ ip++;
/*1293*/ label_fload:
/*1294*/ GET_LOCAL(index, ITEM_Float);
/*1295*/ PUSH_STACK(ITEM_Float);
/*1296*/ break;
/*1297*/ case DLOAD :
/*1298*/ index = code[ip + 1];
/*1299*/ ip += 2;
/*1300*/ goto label_dload;
/*1301*/ case DLOAD_0 :
/*1302*/ case DLOAD_1 :
/*1303*/ case DLOAD_2 :
/*1304*/ case DLOAD_3 :
/*1305*/ index = opcode - DLOAD_0;
/*1306*/ ip++;
/*1307*/ label_dload:
/*1308*/ GET_LOCAL(index, ITEM_Double);
/*1309*/ GET_LOCAL(index + 1, ITEM_Double_2);
/*1310*/ PUSH_STACK(ITEM_Double);
/*1311*/ PUSH_STACK(ITEM_Double_2);
/*1312*/ break;
/*1313*/#endif /* IMPLEMENTS_FLOAT */
/*1314*/ case ALOAD :
/*1315*/ index = code[ip + 1];
/*1316*/ ip += 2;
/*1317*/ goto label_aload;
/*1318*/ case ALOAD_0 :
/*1319*/ case ALOAD_1 :
/*1320*/ case ALOAD_2 :
/*1321*/ case ALOAD_3 :
/*1322*/ index = opcode - ALOAD_0;
/*1323*/ ip++;
/*1324*/ label_aload:
/*1325*/ GET_LOCAL(index, ITEM_Reference);
/*1326*/ PUSH_STACK(lastLocalGet);
/*1327*/ break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -