< prev index next >

src/share/vm/classfile/symbolTable.cpp

Print this page
rev 11935 : 8165439: Convert Test_TempNewSymbol to GTest
Reviewed-by: duke


 693            "BOOLEAN", false, "false") {
 694   _dcmdparser.add_dcmd_option(&_verbose);
 695 }
 696 
 697 void SymboltableDCmd::execute(DCmdSource source, TRAPS) {
 698   VM_DumpHashtable dumper(output(), VM_DumpHashtable::DumpSymbols,
 699                          _verbose.value());
 700   VMThread::execute(&dumper);
 701 }
 702 
 703 int SymboltableDCmd::num_arguments() {
 704   ResourceMark rm;
 705   SymboltableDCmd* dcmd = new SymboltableDCmd(NULL, false);
 706   if (dcmd != NULL) {
 707     DCmdMark mark(dcmd);
 708     return dcmd->_dcmdparser.num_arguments();
 709   } else {
 710     return 0;
 711   }
 712 }
 713 
 714 #ifndef PRODUCT
 715 // Internal test of TempNewSymbol
 716 void Test_TempNewSymbol() {
 717   // Assert messages assume these symbols are unique, and the refcounts start at
 718   // one, but code does not rely on this.
 719   Thread* THREAD = Thread::current();
 720   Symbol* abc = SymbolTable::new_symbol("abc", CATCH);
 721   int abccount = abc->refcount();
 722   TempNewSymbol ss = abc;
 723   assert(ss->refcount() == abccount, "only one abc");
 724   assert(ss->refcount() == abc->refcount(), "should match TempNewSymbol");
 725 
 726   Symbol* efg = SymbolTable::new_symbol("efg", CATCH);
 727   Symbol* hij = SymbolTable::new_symbol("hij", CATCH);
 728   int efgcount = efg->refcount();
 729   int hijcount = hij->refcount();
 730 
 731   TempNewSymbol s1 = efg;
 732   TempNewSymbol s2 = hij;
 733   assert(s1->refcount() == efgcount, "one efg");
 734   assert(s2->refcount() == hijcount, "one hij");
 735 
 736   // Assignment operator
 737   s1 = s2;
 738   assert(hij->refcount() == hijcount + 1, "should be two hij");
 739   assert(efg->refcount() == efgcount - 1, "should be no efg");
 740 
 741   s1 = ss;  // s1 is abc
 742   assert(s1->refcount() == abccount + 1, "should be two abc (s1 and ss)");
 743   assert(hij->refcount() == hijcount, "should only have one hij now (s2)");
 744 
 745   s1 = s1; // self assignment
 746   assert(s1->refcount() == abccount + 1, "should still be two abc (s1 and ss)");
 747 
 748   TempNewSymbol s3;
 749   Symbol* klm = SymbolTable::new_symbol("klm", CATCH);
 750   int klmcount = klm->refcount();
 751   s3 = klm;   // assignment
 752   assert(s3->refcount() == klmcount, "only one klm now");
 753 
 754   Symbol* xyz = SymbolTable::new_symbol("xyz", CATCH);
 755   int xyzcount = xyz->refcount();
 756   { // inner scope
 757      TempNewSymbol s_inner = xyz;
 758   }
 759   assert(xyz->refcount() == (xyzcount - 1),
 760          "Should have been decremented by dtor in inner scope");
 761 }
 762 #endif // PRODUCT


 693            "BOOLEAN", false, "false") {
 694   _dcmdparser.add_dcmd_option(&_verbose);
 695 }
 696 
 697 void SymboltableDCmd::execute(DCmdSource source, TRAPS) {
 698   VM_DumpHashtable dumper(output(), VM_DumpHashtable::DumpSymbols,
 699                          _verbose.value());
 700   VMThread::execute(&dumper);
 701 }
 702 
 703 int SymboltableDCmd::num_arguments() {
 704   ResourceMark rm;
 705   SymboltableDCmd* dcmd = new SymboltableDCmd(NULL, false);
 706   if (dcmd != NULL) {
 707     DCmdMark mark(dcmd);
 708     return dcmd->_dcmdparser.num_arguments();
 709   } else {
 710     return 0;
 711   }
 712 }


















































< prev index next >