461 sym = SymbolTable::the_table()->do_add_if_needed(name, len, hash, c_heap, CHECK); 462 } 463 assert(sym->refcount() != 0, "lookup should have incremented the count"); 464 cp->symbol_at_put(cp_indices[i], sym); 465 } 466 } 467 468 class SymbolTableCreateEntry : public StackObj { 469 private: 470 Thread* _thread; 471 const char* _name; 472 int _len; 473 bool _heap; 474 Symbol* _return; 475 Symbol* _created; 476 477 void assert_for_name(Symbol* sym, const char* where) const { 478 #ifdef ASSERT 479 assert(sym->utf8_length() == _len, "%s [%d,%d]", where, sym->utf8_length(), _len); 480 for (int i = 0; i < _len; i++) { 481 assert(sym->byte_at(i) == (jbyte) _name[i], 482 "%s [%d,%d,%d]", where, i, sym->byte_at(i), _name[i]); 483 } 484 #endif 485 } 486 487 public: 488 SymbolTableCreateEntry(Thread* thread, const char* name, int len, bool heap) 489 : _thread(thread), _name(name) , _len(len), _heap(heap), _return(NULL) , _created(NULL) { 490 assert(_name != NULL, "expected valid name"); 491 } 492 Symbol* operator()() { 493 _created = SymbolTable::the_table()->allocate_symbol(_name, _len, _heap, _thread); 494 assert(_created != NULL, "expected created symbol"); 495 assert_for_name(_created, "operator()()"); 496 assert(_created->equals(_name, _len), 497 "symbol must be properly initialized [%p,%d,%d]", _name, _len, (int)_heap); 498 return _created; 499 } 500 void operator()(bool inserted, Symbol** value) { 501 assert(value != NULL, "expected valid value"); 502 assert(*value != NULL, "value should point to a symbol"); | 461 sym = SymbolTable::the_table()->do_add_if_needed(name, len, hash, c_heap, CHECK); 462 } 463 assert(sym->refcount() != 0, "lookup should have incremented the count"); 464 cp->symbol_at_put(cp_indices[i], sym); 465 } 466 } 467 468 class SymbolTableCreateEntry : public StackObj { 469 private: 470 Thread* _thread; 471 const char* _name; 472 int _len; 473 bool _heap; 474 Symbol* _return; 475 Symbol* _created; 476 477 void assert_for_name(Symbol* sym, const char* where) const { 478 #ifdef ASSERT 479 assert(sym->utf8_length() == _len, "%s [%d,%d]", where, sym->utf8_length(), _len); 480 for (int i = 0; i < _len; i++) { 481 assert(sym->char_at(i) == _name[i], 482 "%s [%d,%d,%d]", where, i, sym->char_at(i), _name[i]); 483 } 484 #endif 485 } 486 487 public: 488 SymbolTableCreateEntry(Thread* thread, const char* name, int len, bool heap) 489 : _thread(thread), _name(name) , _len(len), _heap(heap), _return(NULL) , _created(NULL) { 490 assert(_name != NULL, "expected valid name"); 491 } 492 Symbol* operator()() { 493 _created = SymbolTable::the_table()->allocate_symbol(_name, _len, _heap, _thread); 494 assert(_created != NULL, "expected created symbol"); 495 assert_for_name(_created, "operator()()"); 496 assert(_created->equals(_name, _len), 497 "symbol must be properly initialized [%p,%d,%d]", _name, _len, (int)_heap); 498 return _created; 499 } 500 void operator()(bool inserted, Symbol** value) { 501 assert(value != NULL, "expected valid value"); 502 assert(*value != NULL, "value should point to a symbol"); |