--- old/src/share/vm/oops/constantPool.cpp Tue Dec 16 21:48:57 2014 +++ new/src/share/vm/oops/constantPool.cpp Tue Dec 16 21:48:57 2014 @@ -44,11 +44,12 @@ PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC -ConstantPool* ConstantPool::allocate(ClassLoaderData* loader_data, int length, TRAPS) { +ConstantPool* ConstantPool::allocate(ClassLoaderData* loader_data, int length, bool patched, TRAPS) { // Tags are RW but comment below applies to tags also. Array* tags = MetadataFactory::new_writeable_array(loader_data, length, 0, CHECK_NULL); - int size = ConstantPool::size(length); + // Reserve optional slot for pseudo_string_map if patched + int size = ConstantPool::size(length) + (patched ? sizeof(intptr_t*) : 0); // CDS considerations: // Allocate read-write but may be able to move to read-only at dumping time @@ -56,10 +57,10 @@ // the resolved_references array, which is recreated at startup time. // But that could be moved to InstanceKlass (although a pain to access from // assembly code). Maybe it could be moved to the cpCache which is RW. - return new (loader_data, size, false, MetaspaceObj::ConstantPoolType, THREAD) ConstantPool(tags); + return new (loader_data, size, false, MetaspaceObj::ConstantPoolType, THREAD) ConstantPool(tags, patched); } -ConstantPool::ConstantPool(Array* tags) { +ConstantPool::ConstantPool(Array* tags, bool patched) { set_length(tags->length()); set_tags(NULL); set_cache(NULL); @@ -78,6 +79,11 @@ tags->at_put(index, JVM_CONSTANT_Invalid); } set_tags(tags); + if (patched) { + set_flags(_patched); + GrowableArray** addr = pseudo_string_map_addr(); + *addr = NULL; // Initialize the optional filed, a pseudo-string map is allocated lazily + } } void ConstantPool::deallocate_contents(ClassLoaderData* loader_data) { @@ -1597,7 +1603,7 @@ // This function fills in SymbolHashMaps, one for utf8s and one for // class names, returns size of the cpool raw bytes. jint ConstantPool::hash_entries_to(SymbolHashMap *symmap, - SymbolHashMap *classmap) { + SymbolHashMap *classmap) { jint size = 0; for (u2 idx = 1; idx < length(); idx++) { @@ -1636,8 +1642,8 @@ // -1, in case of internal error // > 0, count of the raw cpool bytes that have been copied int ConstantPool::copy_cpool_bytes(int cpool_size, - SymbolHashMap* tbl, - unsigned char *bytes) { + SymbolHashMap* tbl, + unsigned char *bytes) { u2 idx1, idx2; jint size = 0; jint cnt = length(); @@ -1709,10 +1715,15 @@ case JVM_CONSTANT_String: { *bytes = JVM_CONSTANT_String; Symbol* sym = unresolved_string_at(idx); - idx1 = tbl->symbol_to_value(sym); - assert(idx1 != 0, "Have not found a hashtable entry"); + if (is_pseudo_string_at(idx)) { + idx1 = get_pseudo_string_utf8_index(idx); + assert(idx1 != 0, "Have not found a pseudo-string placeholder entry"); + } else { + idx1 = tbl->symbol_to_value(sym); + assert(idx1 != 0, "Have not found a hashtable entry"); + } Bytes::put_Java_u2((address) (bytes+1), idx1); - DBG(printf("JVM_CONSTANT_String: idx=#%03hd, %s", idx1, sym->as_utf8())); + DBG(printf("JVM_CONSTANT_String: idx=#%03hd, %s", idx1, sym == NULL ? "NULL" : sym->as_utf8())); break; } case JVM_CONSTANT_Fieldref: