< prev index next >
src/share/vm/classfile/symbolTable.cpp
Print this page
@@ -30,10 +30,11 @@
#include "classfile/systemDictionary.hpp"
#include "gc/shared/collectedHeap.inline.hpp"
#include "gc/shared/gcLocker.inline.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/filemap.hpp"
+#include "memory/metaspaceClosure.hpp"
#include "memory/resourceArea.hpp"
#include "oops/oop.inline.hpp"
#include "runtime/atomic.hpp"
#include "runtime/mutexLocker.hpp"
#include "utilities/hashtable.inline.hpp"
@@ -54,13 +55,13 @@
assert (len <= Symbol::max_length(), "should be checked by caller");
Symbol* sym;
if (DumpSharedSpaces) {
- // Allocate all symbols to CLD shared metaspace
- sym = new (len, ClassLoaderData::the_null_class_loader_data(), THREAD) Symbol(name, len, PERM_REFCOUNT);
- } else if (c_heap) {
+ c_heap = false;
+ }
+ if (c_heap) {
// refcount starts as 1
sym = new (len, THREAD) Symbol(name, len, 1);
assert(sym != NULL, "new should call vm_exit_out_of_memory if C_HEAP is exhausted");
} else {
// Allocate to global arena
@@ -78,12 +79,14 @@
}
}
// Call function for all symbols in the symbol table.
void SymbolTable::symbols_do(SymbolClosure *cl) {
+ if (!DumpSharedSpaces) {
// all symbols from shared table
_shared_table.symbols_do(cl);
+ }
// all symbols from the dynamic table
const int n = the_table()->table_size();
for (int i = 0; i < n; i++) {
for (HashtableEntry<Symbol*, mtSymbol>* p = the_table()->bucket(i);
@@ -92,10 +95,22 @@
cl->do_symbol(p->literal_addr());
}
}
}
+void SymbolTable::metaspace_pointers_do(MetaspaceClosure* it) {
+ assert(DumpSharedSpaces, "called only during dump time");
+ const int n = the_table()->table_size();
+ for (int i = 0; i < n; i++) {
+ for (HashtableEntry<Symbol*, mtSymbol>* p = the_table()->bucket(i);
+ p != NULL;
+ p = p->next()) {
+ it->push(p->literal_addr());
+ }
+ }
+}
+
int SymbolTable::_symbols_removed = 0;
int SymbolTable::_symbols_counted = 0;
volatile int SymbolTable::_parallel_claimed_idx = 0;
void SymbolTable::buckets_unlink(int start_idx, int end_idx, BucketUnlinkContext* context) {
@@ -565,14 +580,14 @@
}
}
}
}
-void SymbolTable::serialize(SerializeClosure* soc) {
+void SymbolTable::write_to_archive() {
#if INCLUDE_CDS
_shared_table.reset();
- if (soc->writing()) {
+
int num_buckets = the_table()->number_of_entries() /
SharedSymbolTableBucketSize;
CompactSymbolTableWriter writer(num_buckets,
&MetaspaceShared::stats()->symbol);
for (int i = 0; i < the_table()->table_size(); ++i) {
@@ -584,23 +599,26 @@
writer.add(fixed_hash, s);
}
}
writer.dump(&_shared_table);
- }
- _shared_table.set_type(CompactHashtable<Symbol*, char>::_symbol_table);
- _shared_table.serialize(soc);
-
- if (soc->writing()) {
// Verify table is correct
Symbol* sym = vmSymbols::java_lang_Object();
const char* name = (const char*)sym->bytes();
int len = sym->utf8_length();
unsigned int hash = hash_symbol(name, len);
assert(sym == _shared_table.lookup(name, hash, len), "sanity");
+#endif
+}
+void SymbolTable::serialize(SerializeClosure* soc) {
+#if INCLUDE_CDS
+ _shared_table.set_type(CompactHashtable<Symbol*, char>::_symbol_table);
+ _shared_table.serialize(soc);
+
+ if (soc->writing()) {
// Sanity. Make sure we don't use the shared table at dump time
_shared_table.reset();
}
#endif
}
< prev index next >