oop StringTable::intern(Handle string_or_null, jchar* name, int len, TRAPS){ unsignedint hashValue = hash_string(name, len); int index = the_table()->hash_to_index(hashValue); oop found_string = the_table()->lookup(index, name, len, hashValue);
// Found if (found_string != NULL) { ensure_string_alive(found_string); return found_string; }
// ... 此处代码省略
Handle string; // try to reuse the string if possible if (!string_or_null.is_null()) { string = string_or_null; } else { string = java_lang_String::create_from_unicode(name, len, CHECK_NULL); }
// ... 此处代码省略
// Grab the StringTable_lock before getting the_table() because it could // change at safepoint. oop added_or_found; { MutexLocker ml(StringTable_lock, THREAD); // Otherwise, add to symbol to table added_or_found = the_table()->basic_add(index, string, name, len, hashValue, CHECK_NULL); }
jint status = Universe::initialize_heap(); if (status != JNI_OK) { return status; }
Metaspace::global_initialize();
// Create memory for metadata. Must be after initializing heap for // DumpSharedSpaces. ClassLoaderData::init_null_class_loader_data();
// ... 忽略部分代码
if (UseSharedSpaces) { // Read the data structures supporting the shared spaces (shared // system dictionary, symbol table, etc.). After that, access to // the file (other than the mapped regions) is no longer needed, and // the file is closed. Closing the file does not affect the // currently mapped regions. MetaspaceShared::initialize_shared_spaces(); StringTable::create_table(); } else { SymbolTable::create_table(); StringTable::create_table(); ClassLoader::create_package_info_table();
if (DumpSharedSpaces) { MetaspaceShared::prepare_for_dumping(); } }