1721 // Copy cpool bytes.
1722 // Returns:
1723 // 0, in case of OutOfMemoryError
1724 // -1, in case of internal error
1725 // > 0, count of the raw cpool bytes that have been copied
1726 int ConstantPool::copy_cpool_bytes(int cpool_size,
1727 SymbolHashMap* tbl,
1728 unsigned char *bytes) {
1729 u2 idx1, idx2;
1730 jint size = 0;
1731 jint cnt = length();
1732 unsigned char *start_bytes = bytes;
1733
1734 for (jint idx = 1; idx < cnt; idx++) {
1735 u1 tag = tag_at(idx).value();
1736 jint ent_size = cpool_entry_size(idx);
1737
1738 assert(size + ent_size <= cpool_size, "Size mismatch");
1739
1740 *bytes = tag;
1741 DBG(printf("#%03hd tag=%03hd, ", idx, tag));
1742 switch(tag) {
1743 case JVM_CONSTANT_Invalid: {
1744 DBG(printf("JVM_CONSTANT_Invalid"));
1745 break;
1746 }
1747 case JVM_CONSTANT_Unicode: {
1748 assert(false, "Wrong constant pool tag: JVM_CONSTANT_Unicode");
1749 DBG(printf("JVM_CONSTANT_Unicode"));
1750 break;
1751 }
1752 case JVM_CONSTANT_Utf8: {
1753 Symbol* sym = symbol_at(idx);
1754 char* str = sym->as_utf8();
1755 // Warning! It's crashing on x86 with len = sym->utf8_length()
1756 int len = (int) strlen(str);
1757 Bytes::put_Java_u2((address) (bytes+1), (u2) len);
1758 for (int i = 0; i < len; i++) {
1759 bytes[3+i] = (u1) str[i];
1760 }
1761 DBG(printf("JVM_CONSTANT_Utf8: %s ", str));
|
1721 // Copy cpool bytes.
1722 // Returns:
1723 // 0, in case of OutOfMemoryError
1724 // -1, in case of internal error
1725 // > 0, count of the raw cpool bytes that have been copied
1726 int ConstantPool::copy_cpool_bytes(int cpool_size,
1727 SymbolHashMap* tbl,
1728 unsigned char *bytes) {
1729 u2 idx1, idx2;
1730 jint size = 0;
1731 jint cnt = length();
1732 unsigned char *start_bytes = bytes;
1733
1734 for (jint idx = 1; idx < cnt; idx++) {
1735 u1 tag = tag_at(idx).value();
1736 jint ent_size = cpool_entry_size(idx);
1737
1738 assert(size + ent_size <= cpool_size, "Size mismatch");
1739
1740 *bytes = tag;
1741 DBG(printf("#%03hd tag=%03hd, ", (short)idx, (short)tag));
1742 switch(tag) {
1743 case JVM_CONSTANT_Invalid: {
1744 DBG(printf("JVM_CONSTANT_Invalid"));
1745 break;
1746 }
1747 case JVM_CONSTANT_Unicode: {
1748 assert(false, "Wrong constant pool tag: JVM_CONSTANT_Unicode");
1749 DBG(printf("JVM_CONSTANT_Unicode"));
1750 break;
1751 }
1752 case JVM_CONSTANT_Utf8: {
1753 Symbol* sym = symbol_at(idx);
1754 char* str = sym->as_utf8();
1755 // Warning! It's crashing on x86 with len = sym->utf8_length()
1756 int len = (int) strlen(str);
1757 Bytes::put_Java_u2((address) (bytes+1), (u2) len);
1758 for (int i = 0; i < len; i++) {
1759 bytes[3+i] = (u1) str[i];
1760 }
1761 DBG(printf("JVM_CONSTANT_Utf8: %s ", str));
|