< prev index next >

test/hotspot/gtest/classfile/test_symbolTable.cpp

Print this page




 108       EXPECT_TRUE(sym->refcount() != 0) << "Symbol refcount unexpectedly zeroed";
 109     }
 110   }
 111 };
 112 
 113 #define SYM_TEST_THREAD_COUNT 5
 114 
 115 class DriverSymbolThread : public JavaTestThread {
 116 public:
 117   Semaphore _done;
 118   DriverSymbolThread(Semaphore* post) : JavaTestThread(post) { };
 119   virtual ~DriverSymbolThread(){}
 120 
 121   void main_run() {
 122     Semaphore done(0);
 123 
 124     Thread* THREAD = Thread::current();
 125 
 126     // Find a symbol where there will probably be only one instance.
 127     for (int i = 0; i < 100; i++) {
 128        snprintf(symbol_name, SYM_NAME_LENGTH, "some_symbol%d", i);
 129        TempNewSymbol ts = SymbolTable::new_symbol(symbol_name, CATCH);
 130        if (ts->refcount() == 1) {
 131          EXPECT_TRUE(ts->refcount() == 1) << "Symbol is just created";
 132          break;  // found a unique symbol
 133        }
 134     }
 135 
 136     SymbolThread* st[SYM_TEST_THREAD_COUNT];
 137     for (int i = 0; i < SYM_TEST_THREAD_COUNT; i++) {
 138       st[i] = new SymbolThread(&done);
 139       st[i]->doit();
 140     }
 141 
 142     for (int i = 0; i < 4; i++) {
 143       done.wait();
 144     }
 145   }
 146 };
 147 
 148 TEST_VM(SymbolTable, test_symbol_refcount_parallel) {


 108       EXPECT_TRUE(sym->refcount() != 0) << "Symbol refcount unexpectedly zeroed";
 109     }
 110   }
 111 };
 112 
 113 #define SYM_TEST_THREAD_COUNT 5
 114 
 115 class DriverSymbolThread : public JavaTestThread {
 116 public:
 117   Semaphore _done;
 118   DriverSymbolThread(Semaphore* post) : JavaTestThread(post) { };
 119   virtual ~DriverSymbolThread(){}
 120 
 121   void main_run() {
 122     Semaphore done(0);
 123 
 124     Thread* THREAD = Thread::current();
 125 
 126     // Find a symbol where there will probably be only one instance.
 127     for (int i = 0; i < 100; i++) {
 128        sprintf(symbol_name, "some_symbol%d", i);
 129        TempNewSymbol ts = SymbolTable::new_symbol(symbol_name, CATCH);
 130        if (ts->refcount() == 1) {
 131          EXPECT_TRUE(ts->refcount() == 1) << "Symbol is just created";
 132          break;  // found a unique symbol
 133        }
 134     }
 135 
 136     SymbolThread* st[SYM_TEST_THREAD_COUNT];
 137     for (int i = 0; i < SYM_TEST_THREAD_COUNT; i++) {
 138       st[i] = new SymbolThread(&done);
 139       st[i]->doit();
 140     }
 141 
 142     for (int i = 0; i < 4; i++) {
 143       done.wait();
 144     }
 145   }
 146 };
 147 
 148 TEST_VM(SymbolTable, test_symbol_refcount_parallel) {
< prev index next >