1372 const char* ConstantPool::printable_name_at(int which) {
1373
1374 constantTag tag = tag_at(which);
1375
1376 if (tag.is_string()) {
1377 return string_at_noresolve(which);
1378 } else if (tag.is_klass() || tag.is_unresolved_klass()) {
1379 return klass_name_at(which)->as_C_string();
1380 } else if (tag.is_symbol()) {
1381 return symbol_at(which)->as_C_string();
1382 }
1383 return "";
1384 }
1385
1386 #endif // PRODUCT
1387
1388
1389 // JVMTI GetConstantPool support
1390
1391 // For temporary use until code is stable.
1392 #define DBG(code)
1393
1394 static const char* WARN_MSG = "Must not be such entry!";
1395
1396 static void print_cpool_bytes(jint cnt, u1 *bytes) {
1397 jint size = 0;
1398 u2 idx1, idx2;
1399
1400 for (jint idx = 1; idx < cnt; idx++) {
1401 jint ent_size = 0;
1402 u1 tag = *bytes++;
1403 size++; // count tag
1404
1405 printf("const #%03d, tag: %02d ", idx, tag);
1406 switch(tag) {
1407 case JVM_CONSTANT_Invalid: {
1408 printf("Invalid");
1409 break;
1410 }
1411 case JVM_CONSTANT_Unicode: {
1412 printf("Unicode %s", WARN_MSG);
1498 printf("UnresolvedClass: %s", WARN_MSG);
1499 break;
1500 }
1501 case JVM_CONSTANT_UnresolvedClassInError: {
1502 printf("UnresolvedClassInErr: %s", WARN_MSG);
1503 break;
1504 }
1505 case JVM_CONSTANT_StringIndex: {
1506 printf("StringIndex: %s", WARN_MSG);
1507 break;
1508 }
1509 }
1510 printf(";\n");
1511 bytes += ent_size;
1512 size += ent_size;
1513 }
1514 printf("Cpool size: %d\n", size);
1515 fflush(0);
1516 return;
1517 } /* end print_cpool_bytes */
1518
1519
1520 // Returns size of constant pool entry.
1521 jint ConstantPool::cpool_entry_size(jint idx) {
1522 switch(tag_at(idx).value()) {
1523 case JVM_CONSTANT_Invalid:
1524 case JVM_CONSTANT_Unicode:
1525 return 1;
1526
1527 case JVM_CONSTANT_Utf8:
1528 return 3 + symbol_at(idx)->utf8_length();
1529
1530 case JVM_CONSTANT_Class:
1531 case JVM_CONSTANT_String:
1532 case JVM_CONSTANT_ClassIndex:
1533 case JVM_CONSTANT_UnresolvedClass:
1534 case JVM_CONSTANT_UnresolvedClassInError:
1535 case JVM_CONSTANT_StringIndex:
1536 case JVM_CONSTANT_MethodType:
1537 return 3;
|
1372 const char* ConstantPool::printable_name_at(int which) {
1373
1374 constantTag tag = tag_at(which);
1375
1376 if (tag.is_string()) {
1377 return string_at_noresolve(which);
1378 } else if (tag.is_klass() || tag.is_unresolved_klass()) {
1379 return klass_name_at(which)->as_C_string();
1380 } else if (tag.is_symbol()) {
1381 return symbol_at(which)->as_C_string();
1382 }
1383 return "";
1384 }
1385
1386 #endif // PRODUCT
1387
1388
1389 // JVMTI GetConstantPool support
1390
1391 // For temporary use until code is stable.
1392 #if DEBUG_CPOOL
1393 #define DBG(code) code
1394
1395 static const char* WARN_MSG = "Must not be such entry!";
1396
1397 static void print_cpool_bytes(jint cnt, u1 *bytes) {
1398 jint size = 0;
1399 u2 idx1, idx2;
1400
1401 for (jint idx = 1; idx < cnt; idx++) {
1402 jint ent_size = 0;
1403 u1 tag = *bytes++;
1404 size++; // count tag
1405
1406 printf("const #%03d, tag: %02d ", idx, tag);
1407 switch(tag) {
1408 case JVM_CONSTANT_Invalid: {
1409 printf("Invalid");
1410 break;
1411 }
1412 case JVM_CONSTANT_Unicode: {
1413 printf("Unicode %s", WARN_MSG);
1499 printf("UnresolvedClass: %s", WARN_MSG);
1500 break;
1501 }
1502 case JVM_CONSTANT_UnresolvedClassInError: {
1503 printf("UnresolvedClassInErr: %s", WARN_MSG);
1504 break;
1505 }
1506 case JVM_CONSTANT_StringIndex: {
1507 printf("StringIndex: %s", WARN_MSG);
1508 break;
1509 }
1510 }
1511 printf(";\n");
1512 bytes += ent_size;
1513 size += ent_size;
1514 }
1515 printf("Cpool size: %d\n", size);
1516 fflush(0);
1517 return;
1518 } /* end print_cpool_bytes */
1519
1520 #else
1521
1522 #define DBG(code)
1523
1524 #endif
1525
1526
1527 // Returns size of constant pool entry.
1528 jint ConstantPool::cpool_entry_size(jint idx) {
1529 switch(tag_at(idx).value()) {
1530 case JVM_CONSTANT_Invalid:
1531 case JVM_CONSTANT_Unicode:
1532 return 1;
1533
1534 case JVM_CONSTANT_Utf8:
1535 return 3 + symbol_at(idx)->utf8_length();
1536
1537 case JVM_CONSTANT_Class:
1538 case JVM_CONSTANT_String:
1539 case JVM_CONSTANT_ClassIndex:
1540 case JVM_CONSTANT_UnresolvedClass:
1541 case JVM_CONSTANT_UnresolvedClassInError:
1542 case JVM_CONSTANT_StringIndex:
1543 case JVM_CONSTANT_MethodType:
1544 return 3;
|