< prev index next >
src/hotspot/share/classfile/symbolTable.cpp
Print this page
*** 63,81 ****
// Static arena for symbols that are not deallocated
Arena* SymbolTable::_arena = NULL;
static juint murmur_seed = 0;
! static inline void _log_trace_symboltable_helper(Symbol* sym, const char* msg) {
#ifndef PRODUCT
! if (log_is_enabled(Trace, symboltable)) {
! if (sym->as_quoted_ascii() == NULL) {
! log_trace(symboltable)("%s [%s]", msg, "NULL");
! } else {
! log_trace(symboltable)("%s [%s]", msg, sym->as_quoted_ascii());
! }
! }
#endif // PRODUCT
}
// Pick hashing algorithm.
static uintx hash_symbol(const char* s, int len, bool useAlt) {
--- 63,76 ----
// Static arena for symbols that are not deallocated
Arena* SymbolTable::_arena = NULL;
static juint murmur_seed = 0;
! static inline void log_trace_symboltable_helper(Symbol* sym, const char* msg) {
#ifndef PRODUCT
! ResourceMark rm;
! log_trace(symboltable)("%s [%s]", msg, sym->as_quoted_ascii());
#endif // PRODUCT
}
// Pick hashing algorithm.
static uintx hash_symbol(const char* s, int len, bool useAlt) {
*** 117,137 ****
SymbolTableHash::BaseConfig::free_node(memory, value);
SymbolTable::item_removed();
}
};
! static size_t log2_ceil(uintx value) {
size_t ret;
for (ret = 1; ((size_t)1 << ret) < value; ++ret);
return ret;
}
! SymbolTable::SymbolTable() : _local_table(NULL), _current_size(0), _has_work(0),
! _needs_rehashing(false), _items_count(0), _uncleaned_items_count(0),
! _symbols_removed(0), _symbols_counted(0) {
! size_t start_size_log_2 = log2_ceil(SymbolTableSize);
_current_size = ((size_t)1) << start_size_log_2;
log_trace(symboltable)("Start size: " SIZE_FORMAT " (" SIZE_FORMAT ")",
_current_size, start_size_log_2);
_local_table = new SymbolTableHash(start_size_log_2, END_SIZE, REHASH_LEN);
}
--- 112,133 ----
SymbolTableHash::BaseConfig::free_node(memory, value);
SymbolTable::item_removed();
}
};
! static size_t ceil_log2(size_t value) {
size_t ret;
for (ret = 1; ((size_t)1 << ret) < value; ++ret);
return ret;
}
! SymbolTable::SymbolTable() :
! _symbols_removed(0), _symbols_counted(0), _local_table(NULL),
! _current_size(0), _has_work(0), _needs_rehashing(false),
! _items_count(0), _uncleaned_items_count(0) {
! size_t start_size_log_2 = ceil_log2(SymbolTableSize);
_current_size = ((size_t)1) << start_size_log_2;
log_trace(symboltable)("Start size: " SIZE_FORMAT " (" SIZE_FORMAT ")",
_current_size, start_size_log_2);
_local_table = new SymbolTableHash(start_size_log_2, END_SIZE, REHASH_LEN);
}
*** 139,151 ****
void SymbolTable::delete_symbol(Symbol* sym) {
if (sym->refcount() == PERM_REFCOUNT) {
MutexLocker ml(SymbolTable_lock); // Protect arena
// Deleting permanent symbol should not occur very often (insert race condition),
// so log it.
! _log_trace_symboltable_helper(sym, "Freeing permanent symbol");
if (!arena()->Afree(sym, sym->size())) {
! _log_trace_symboltable_helper(sym, "Leaked permanent symbol");
}
} else {
delete sym;
}
}
--- 135,147 ----
void SymbolTable::delete_symbol(Symbol* sym) {
if (sym->refcount() == PERM_REFCOUNT) {
MutexLocker ml(SymbolTable_lock); // Protect arena
// Deleting permanent symbol should not occur very often (insert race condition),
// so log it.
! log_trace_symboltable_helper(sym, "Freeing permanent symbol");
if (!arena()->Afree(sym, sym->size())) {
! log_trace_symboltable_helper(sym, "Leaked permanent symbol");
}
} else {
delete sym;
}
}
*** 176,188 ****
double SymbolTable::get_dead_factor() {
return (double)_uncleaned_items_count/_current_size;
}
! size_t SymbolTable::table_size(Thread* thread) {
! return ((size_t)(1)) << _local_table->get_size_log2(thread != NULL ? thread
! : Thread::current());
}
void SymbolTable::trigger_concurrent_work() {
MutexLockerEx ml(Service_lock, Mutex::_no_safepoint_check_flag);
SymbolTable::the_table()->_has_work = true;
--- 172,183 ----
double SymbolTable::get_dead_factor() {
return (double)_uncleaned_items_count/_current_size;
}
! size_t SymbolTable::table_size() {
! return ((size_t)1) << _local_table->get_size_log2(Thread::current());
}
void SymbolTable::trigger_concurrent_work() {
MutexLockerEx ml(Service_lock, Mutex::_no_safepoint_check_flag);
SymbolTable::the_table()->_has_work = true;
*** 330,340 ****
uintx _hash;
int _len;
const char* _str;
public:
SymbolTableLookup(Thread* thread, const char* key, int len, uintx hash)
! : _thread(thread), _hash(hash), _str(key), _len(len) {}
uintx get_hash() const {
return _hash;
}
bool equals(Symbol** value, bool* is_dead) {
assert(value != NULL, "expected valid value");
--- 325,335 ----
uintx _hash;
int _len;
const char* _str;
public:
SymbolTableLookup(Thread* thread, const char* key, int len, uintx hash)
! : _thread(thread), _hash(hash), _len(len), _str(key) {}
uintx get_hash() const {
return _hash;
}
bool equals(Symbol** value, bool* is_dead) {
assert(value != NULL, "expected valid value");
*** 357,367 ****
};
class SymbolTableGet : public StackObj {
Symbol* _return;
public:
! SymbolTableGet() : _return(NULL) { }
void operator()(Symbol** value) {
assert(value != NULL, "expected valid value");
assert(*value != NULL, "value should point to a symbol");
_return = *value;
}
--- 352,362 ----
};
class SymbolTableGet : public StackObj {
Symbol* _return;
public:
! SymbolTableGet() : _return(NULL) {}
void operator()(Symbol** value) {
assert(value != NULL, "expected valid value");
assert(*value != NULL, "value should point to a symbol");
_return = *value;
}
*** 526,536 ****
if (sym == NULL) {
sym = SymbolTable::the_table()->do_add_if_needed(name, len, hash, false, CHECK_NULL);
}
if (sym->refcount() != PERM_REFCOUNT) {
sym->increment_refcount();
! _log_trace_symboltable_helper(sym, "Asked for a permanent symbol, but got a regular one");
}
return sym;
}
struct SizeFunc : StackObj {
--- 521,531 ----
if (sym == NULL) {
sym = SymbolTable::the_table()->do_add_if_needed(name, len, hash, false, CHECK_NULL);
}
if (sym->refcount() != PERM_REFCOUNT) {
sym->increment_refcount();
! log_trace_symboltable_helper(sym, "Asked for a permanent symbol, but got a regular one");
}
return sym;
}
struct SizeFunc : StackObj {
*** 629,639 ****
}
void SymbolTable::write_to_archive() {
_shared_table.reset();
! int num_buckets = (SymbolTable::the_table()->_items_count / SharedSymbolTableBucketSize);
// calculation of num_buckets can result in zero buckets, we need at least one
CompactSymbolTableWriter writer(num_buckets > 1 ? num_buckets : 1,
&MetaspaceShared::stats()->symbol);
copy_shared_symbol_table(&writer);
writer.dump(&_shared_table);
--- 624,634 ----
}
void SymbolTable::write_to_archive() {
_shared_table.reset();
! int num_buckets = (int)(SymbolTable::the_table()->_items_count / SharedSymbolTableBucketSize);
// calculation of num_buckets can result in zero buckets, we need at least one
CompactSymbolTableWriter writer(num_buckets > 1 ? num_buckets : 1,
&MetaspaceShared::stats()->symbol);
copy_shared_symbol_table(&writer);
writer.dump(&_shared_table);
*** 673,683 ****
}
gt.cont(jt);
}
}
gt.done(jt);
! _current_size = table_size(jt);
log_debug(symboltable)("Grown to size:" SIZE_FORMAT, _current_size);
}
struct SymbolTableDoDelete : StackObj {
int _deleted;
--- 668,678 ----
}
gt.cont(jt);
}
}
gt.done(jt);
! _current_size = table_size();
log_debug(symboltable)("Grown to size:" SIZE_FORMAT, _current_size);
}
struct SymbolTableDoDelete : StackObj {
int _deleted;
< prev index next >