< prev index next >

test/hotspot/gtest/classfile/test_symbolTable.cpp

Print this page




  42 
  43   Symbol* efg = SymbolTable::new_symbol("efg");
  44   Symbol* hij = SymbolTable::new_symbol("hij");
  45   int efgcount = efg->refcount();
  46   int hijcount = hij->refcount();
  47 
  48   TempNewSymbol s1 = efg;
  49   TempNewSymbol s2 = hij;
  50   ASSERT_EQ(s1->refcount(), efgcount) << "one efg";
  51   ASSERT_EQ(s2->refcount(), hijcount) << "one hij";
  52 
  53   // Assignment operator
  54   s1 = s2;
  55   ASSERT_EQ(hij->refcount(), hijcount + 1) << "should be two hij";
  56   ASSERT_EQ(efg->refcount(), efgcount - 1) << "should be no efg";
  57 
  58   s1 = ss; // s1 is abc
  59   ASSERT_EQ(s1->refcount(), abccount + 1) << "should be two abc (s1 and ss)";
  60   ASSERT_EQ(hij->refcount(), hijcount) << "should only have one hij now (s2)";
  61 
  62   s1 = s1; // self assignment
  63   ASSERT_EQ(s1->refcount(), abccount + 1) << "should still be two abc (s1 and ss)";
  64 
  65   TempNewSymbol s3;
  66   Symbol* klm = SymbolTable::new_symbol("klm");
  67   int klmcount = klm->refcount();
  68   s3 = klm; // assignment
  69   ASSERT_EQ(s3->refcount(), klmcount) << "only one klm now";
  70 
  71   Symbol* xyz = SymbolTable::new_symbol("xyz");
  72   int xyzcount = xyz->refcount();
  73   { // inner scope
  74     TempNewSymbol s_inner = xyz;
  75   }
  76   ASSERT_EQ(xyz->refcount(), xyzcount - 1)
  77           << "Should have been decremented by dtor in inner scope";
  78 
  79   // Test overflowing refcount making symbol permanent
  80   Symbol* bigsym = SymbolTable::new_symbol("bigsym");
  81   for (int i = 0; i < PERM_REFCOUNT + 100; i++) {
  82     bigsym->increment_refcount();




  42 
  43   Symbol* efg = SymbolTable::new_symbol("efg");
  44   Symbol* hij = SymbolTable::new_symbol("hij");
  45   int efgcount = efg->refcount();
  46   int hijcount = hij->refcount();
  47 
  48   TempNewSymbol s1 = efg;
  49   TempNewSymbol s2 = hij;
  50   ASSERT_EQ(s1->refcount(), efgcount) << "one efg";
  51   ASSERT_EQ(s2->refcount(), hijcount) << "one hij";
  52 
  53   // Assignment operator
  54   s1 = s2;
  55   ASSERT_EQ(hij->refcount(), hijcount + 1) << "should be two hij";
  56   ASSERT_EQ(efg->refcount(), efgcount - 1) << "should be no efg";
  57 
  58   s1 = ss; // s1 is abc
  59   ASSERT_EQ(s1->refcount(), abccount + 1) << "should be two abc (s1 and ss)";
  60   ASSERT_EQ(hij->refcount(), hijcount) << "should only have one hij now (s2)";
  61 
  62   s1 = *&s1; // self assignment
  63   ASSERT_EQ(s1->refcount(), abccount + 1) << "should still be two abc (s1 and ss)";
  64 
  65   TempNewSymbol s3;
  66   Symbol* klm = SymbolTable::new_symbol("klm");
  67   int klmcount = klm->refcount();
  68   s3 = klm; // assignment
  69   ASSERT_EQ(s3->refcount(), klmcount) << "only one klm now";
  70 
  71   Symbol* xyz = SymbolTable::new_symbol("xyz");
  72   int xyzcount = xyz->refcount();
  73   { // inner scope
  74     TempNewSymbol s_inner = xyz;
  75   }
  76   ASSERT_EQ(xyz->refcount(), xyzcount - 1)
  77           << "Should have been decremented by dtor in inner scope";
  78 
  79   // Test overflowing refcount making symbol permanent
  80   Symbol* bigsym = SymbolTable::new_symbol("bigsym");
  81   for (int i = 0; i < PERM_REFCOUNT + 100; i++) {
  82     bigsym->increment_refcount();


< prev index next >