< prev index next >

src/hotspot/share/classfile/symbolTable.cpp

Print this page




 203 }
 204 
 205 double SymbolTable::get_load_factor() {
 206   return (double)_items_count/_current_size;
 207 }
 208 
 209 size_t SymbolTable::table_size() {
 210   return ((size_t)1) << _local_table->get_size_log2(Thread::current());
 211 }
 212 
 213 void SymbolTable::trigger_cleanup() {
 214   MutexLocker ml(Service_lock, Mutex::_no_safepoint_check_flag);
 215   _has_work = true;
 216   Service_lock->notify_all();
 217 }
 218 
 219 Symbol* SymbolTable::allocate_symbol(const char* name, int len, bool c_heap) {
 220   assert (len <= Symbol::max_length(), "should be checked by caller");
 221 
 222   Symbol* sym;
 223   if (DumpSharedSpaces || DynamicDumpSharedSpaces) {
 224     c_heap = false;
 225   }
 226   if (c_heap) {
 227     // refcount starts as 1
 228     sym = new (len) Symbol((const u1*)name, len, 1);
 229     assert(sym != NULL, "new should call vm_exit_out_of_memory if C_HEAP is exhausted");
 230   } else {
 231     // Allocate to global arena
 232     MutexLocker ml(SymbolArena_lock, Mutex::_no_safepoint_check_flag); // Protect arena
 233     sym = new (len, arena()) Symbol((const u1*)name, len, PERM_REFCOUNT);
 234   }
 235   return sym;
 236 }
 237 
 238 class SymbolsDo : StackObj {
 239   SymbolClosure *_cl;
 240 public:
 241   SymbolsDo(SymbolClosure *cl) : _cl(cl) {}
 242   bool operator()(Symbol** value) {
 243     assert(value != NULL, "expected valid value");


 266   // all symbols from the dynamic table
 267   SymbolsDo sd(cl);
 268   if (!_local_table->try_scan(Thread::current(), sd)) {
 269     log_info(symboltable)("symbols_do unavailable at this moment");
 270   }
 271 }
 272 
 273 class MetaspacePointersDo : StackObj {
 274   MetaspaceClosure *_it;
 275 public:
 276   MetaspacePointersDo(MetaspaceClosure *it) : _it(it) {}
 277   bool operator()(Symbol** value) {
 278     assert(value != NULL, "expected valid value");
 279     assert(*value != NULL, "value should point to a symbol");
 280     _it->push(value);
 281     return true;
 282   };
 283 };
 284 
 285 void SymbolTable::metaspace_pointers_do(MetaspaceClosure* it) {
 286   assert(DumpSharedSpaces || DynamicDumpSharedSpaces, "called only during dump time");
 287   MetaspacePointersDo mpd(it);
 288   _local_table->do_safepoint_scan(mpd);
 289 }
 290 
 291 Symbol* SymbolTable::lookup_dynamic(const char* name,
 292                                     int len, unsigned int hash) {
 293   Symbol* sym = do_lookup(name, len, hash);
 294   assert((sym == NULL) || sym->refcount() != 0, "refcount must not be zero");
 295   return sym;
 296 }
 297 
 298 #if INCLUDE_CDS
 299 Symbol* SymbolTable::lookup_shared(const char* name,
 300                                    int len, unsigned int hash) {
 301   Symbol* sym = NULL;
 302   if (!_shared_table.empty()) {
 303     if (_alt_hash) {
 304       // hash_code parameter may use alternate hashing algorithm but the shared table
 305       // always uses the same original hash code.
 306       hash = hash_shared_symbol(name, len);




 203 }
 204 
 205 double SymbolTable::get_load_factor() {
 206   return (double)_items_count/_current_size;
 207 }
 208 
 209 size_t SymbolTable::table_size() {
 210   return ((size_t)1) << _local_table->get_size_log2(Thread::current());
 211 }
 212 
 213 void SymbolTable::trigger_cleanup() {
 214   MutexLocker ml(Service_lock, Mutex::_no_safepoint_check_flag);
 215   _has_work = true;
 216   Service_lock->notify_all();
 217 }
 218 
 219 Symbol* SymbolTable::allocate_symbol(const char* name, int len, bool c_heap) {
 220   assert (len <= Symbol::max_length(), "should be checked by caller");
 221 
 222   Symbol* sym;
 223   if (Arguments::is_dumping_archive()) {
 224     c_heap = false;
 225   }
 226   if (c_heap) {
 227     // refcount starts as 1
 228     sym = new (len) Symbol((const u1*)name, len, 1);
 229     assert(sym != NULL, "new should call vm_exit_out_of_memory if C_HEAP is exhausted");
 230   } else {
 231     // Allocate to global arena
 232     MutexLocker ml(SymbolArena_lock, Mutex::_no_safepoint_check_flag); // Protect arena
 233     sym = new (len, arena()) Symbol((const u1*)name, len, PERM_REFCOUNT);
 234   }
 235   return sym;
 236 }
 237 
 238 class SymbolsDo : StackObj {
 239   SymbolClosure *_cl;
 240 public:
 241   SymbolsDo(SymbolClosure *cl) : _cl(cl) {}
 242   bool operator()(Symbol** value) {
 243     assert(value != NULL, "expected valid value");


 266   // all symbols from the dynamic table
 267   SymbolsDo sd(cl);
 268   if (!_local_table->try_scan(Thread::current(), sd)) {
 269     log_info(symboltable)("symbols_do unavailable at this moment");
 270   }
 271 }
 272 
 273 class MetaspacePointersDo : StackObj {
 274   MetaspaceClosure *_it;
 275 public:
 276   MetaspacePointersDo(MetaspaceClosure *it) : _it(it) {}
 277   bool operator()(Symbol** value) {
 278     assert(value != NULL, "expected valid value");
 279     assert(*value != NULL, "value should point to a symbol");
 280     _it->push(value);
 281     return true;
 282   };
 283 };
 284 
 285 void SymbolTable::metaspace_pointers_do(MetaspaceClosure* it) {
 286   assert(Arguments::is_dumping_archive(), "called only during dump time");
 287   MetaspacePointersDo mpd(it);
 288   _local_table->do_safepoint_scan(mpd);
 289 }
 290 
 291 Symbol* SymbolTable::lookup_dynamic(const char* name,
 292                                     int len, unsigned int hash) {
 293   Symbol* sym = do_lookup(name, len, hash);
 294   assert((sym == NULL) || sym->refcount() != 0, "refcount must not be zero");
 295   return sym;
 296 }
 297 
 298 #if INCLUDE_CDS
 299 Symbol* SymbolTable::lookup_shared(const char* name,
 300                                    int len, unsigned int hash) {
 301   Symbol* sym = NULL;
 302   if (!_shared_table.empty()) {
 303     if (_alt_hash) {
 304       // hash_code parameter may use alternate hashing algorithm but the shared table
 305       // always uses the same original hash code.
 306       hash = hash_shared_symbol(name, len);


< prev index next >