--- a/hotspot/src/share/vm/classfile/symbolTable.cpp Sat Jul 22 15:54:27 2017 -0400
+++ b/hotspot/src/share/vm/classfile/symbolTable.cpp Wed Aug 02 18:06:38 2017 -0700
@@ -32,6 +32,7 @@
#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"
@@ -57,9 +58,9 @@
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");
@@ -95,6 +96,18 @@
}
}
+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;
@@ -568,10 +581,10 @@
}
}
-void SymbolTable::serialize(SerializeClosure* soc) {
+void SymbolTable::write_to_archive() {
#if INCLUDE_CDS
- _shared_table.reset();
- if (soc->writing()) {
+ _shared_table.reset();
+
int num_buckets = the_table()->number_of_entries() /
SharedSymbolTableBucketSize;
CompactSymbolTableWriter writer(num_buckets,
@@ -587,19 +600,22 @@
}
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();
}