< prev index next >

test/hotspot/gtest/oops/test_markWord.cpp

Print this page

 75   JavaThread* THREAD = JavaThread::current();
 76   ThreadInVMfromNative invm(THREAD);
 77   ResourceMark rm(THREAD);
 78 
 79   oop obj = vmClasses::Byte_klass()->allocate_instance(THREAD);
 80 
 81   FlagSetting fs(WizardMode, true);
 82 
 83   HandleMark hm(THREAD);
 84   Handle h_obj(THREAD, obj);
 85 
 86   // Thread tries to lock it.
 87   {
 88     ObjectLocker ol(h_obj, THREAD);
 89     assert_test_pattern(h_obj, "locked");
 90   }
 91   assert_test_pattern(h_obj, "is_unlocked no_hash");
 92 
 93   // Hash the object then print it.
 94   intx hash = h_obj->identity_hash();
 95   assert_test_pattern(h_obj, "is_unlocked hash=0x");




 96 
 97   // Wait gets the lock inflated.
 98   {
 99     ObjectLocker ol(h_obj, THREAD);
100 
101     Semaphore done(0);
102     LockerThread* st;
103     st = new LockerThread(&done, h_obj());
104     st->doit();
105 
106     ol.wait(THREAD);
107     assert_test_pattern(h_obj, "monitor");
108     done.wait_with_safepoint_check(THREAD);  // wait till the thread is done.
109   }
110 }
111 #endif // PRODUCT

 75   JavaThread* THREAD = JavaThread::current();
 76   ThreadInVMfromNative invm(THREAD);
 77   ResourceMark rm(THREAD);
 78 
 79   oop obj = vmClasses::Byte_klass()->allocate_instance(THREAD);
 80 
 81   FlagSetting fs(WizardMode, true);
 82 
 83   HandleMark hm(THREAD);
 84   Handle h_obj(THREAD, obj);
 85 
 86   // Thread tries to lock it.
 87   {
 88     ObjectLocker ol(h_obj, THREAD);
 89     assert_test_pattern(h_obj, "locked");
 90   }
 91   assert_test_pattern(h_obj, "is_unlocked no_hash");
 92 
 93   // Hash the object then print it.
 94   intx hash = h_obj->identity_hash();
 95   if (UseCompactObjectHeaders) {
 96     assert_test_pattern(h_obj, "is_unlocked hash is-hashed=true is-copied=false");
 97   } else {
 98     assert_test_pattern(h_obj, "is_unlocked hash=0x");
 99   }
100 
101   // Wait gets the lock inflated.
102   {
103     ObjectLocker ol(h_obj, THREAD);
104 
105     Semaphore done(0);
106     LockerThread* st;
107     st = new LockerThread(&done, h_obj());
108     st->doit();
109 
110     ol.wait(THREAD);
111     assert_test_pattern(h_obj, "monitor");
112     done.wait_with_safepoint_check(THREAD);  // wait till the thread is done.
113   }
114 }
115 #endif // PRODUCT
< prev index next >