< prev index next >

test/hotspot/gtest/oops/test_markWord.cpp

Print this page

 94   assert_test_pattern(h_obj, "is_neutral no_hash");
 95 
 96   // Hash the object then print it.
 97   intx hash = h_obj->identity_hash();
 98   assert_test_pattern(h_obj, "is_neutral hash=0x");
 99 
100   // Wait gets the lock inflated.
101   {
102     ObjectLocker ol(h_obj, THREAD);
103 
104     Semaphore done(0);
105     LockerThread* st;
106     st = new LockerThread(&done, h_obj());
107     st->doit();
108 
109     ol.wait(THREAD);
110     assert_test_pattern(h_obj, "monitor");
111     done.wait_with_safepoint_check(THREAD);  // wait till the thread is done.
112   }
113 }





















































































































114 #endif // PRODUCT

 94   assert_test_pattern(h_obj, "is_neutral no_hash");
 95 
 96   // Hash the object then print it.
 97   intx hash = h_obj->identity_hash();
 98   assert_test_pattern(h_obj, "is_neutral hash=0x");
 99 
100   // Wait gets the lock inflated.
101   {
102     ObjectLocker ol(h_obj, THREAD);
103 
104     Semaphore done(0);
105     LockerThread* st;
106     st = new LockerThread(&done, h_obj());
107     st->doit();
108 
109     ol.wait(THREAD);
110     assert_test_pattern(h_obj, "monitor");
111     done.wait_with_safepoint_check(THREAD);  // wait till the thread is done.
112   }
113 }
114 
115 static void assert_unlocked_state(markWord mark) {
116   EXPECT_FALSE(mark.has_displaced_mark_helper());
117   EXPECT_FALSE(mark.has_locker());
118   EXPECT_FALSE(mark.has_monitor());
119   EXPECT_FALSE(mark.is_being_inflated());
120   EXPECT_FALSE(mark.is_locked());
121   EXPECT_TRUE(mark.is_unlocked());
122 }
123 
124 static void assert_copy_set_hash(markWord mark) {
125   const intptr_t hash = 4711;
126   EXPECT_TRUE(mark.has_no_hash());
127   markWord copy = mark.copy_set_hash(hash);
128   EXPECT_EQ(hash, copy.hash());
129   EXPECT_FALSE(copy.has_no_hash());
130 }
131 
132 static void assert_type(markWord mark) {
133   EXPECT_FALSE(mark.is_flat_array());
134   EXPECT_FALSE(mark.is_inline_type());
135   EXPECT_FALSE(mark.is_larval_state());
136   EXPECT_FALSE(mark.is_null_free_array());
137 }
138 
139 TEST_VM(markWord, prototype) {
140   markWord mark = markWord::prototype();
141   assert_unlocked_state(mark);
142   EXPECT_TRUE(mark.is_neutral());
143 
144   assert_type(mark);
145 
146   EXPECT_TRUE(mark.has_no_hash());
147   EXPECT_FALSE(mark.is_marked());
148   EXPECT_TRUE(mark.decode_pointer() == NULL);
149 
150   assert_copy_set_hash(mark);
151   assert_type(mark);
152 }
153 
154 static void assert_inline_type(markWord mark) {
155   EXPECT_FALSE(mark.is_flat_array());
156   EXPECT_TRUE(mark.is_inline_type());
157   EXPECT_FALSE(mark.is_null_free_array());
158 }
159 
160 TEST_VM(markWord, inline_type_prototype) {
161   markWord mark = markWord::inline_type_prototype();
162   assert_unlocked_state(mark);
163   EXPECT_FALSE(mark.is_neutral());
164 
165   assert_inline_type(mark);
166   EXPECT_FALSE(mark.is_larval_state());
167 
168   EXPECT_TRUE(mark.has_no_hash());
169   EXPECT_FALSE(mark.is_marked());
170   EXPECT_TRUE(mark.decode_pointer() == NULL);
171 
172   markWord larval = mark.enter_larval_state();
173   EXPECT_TRUE(larval.is_larval_state());
174   assert_inline_type(larval);
175   mark = larval.exit_larval_state();
176   EXPECT_FALSE(mark.is_larval_state());
177   assert_inline_type(mark);
178 
179   EXPECT_TRUE(mark.has_no_hash());
180   EXPECT_FALSE(mark.is_marked());
181   EXPECT_TRUE(mark.decode_pointer() == NULL);
182 }
183 
184 #if _LP64
185 
186 static void assert_flat_array_type(markWord mark) {
187   EXPECT_TRUE(mark.is_flat_array());
188   EXPECT_FALSE(mark.is_inline_type());
189   EXPECT_FALSE(mark.is_larval_state());
190   EXPECT_TRUE(mark.is_null_free_array());
191 }
192 
193 TEST_VM(markWord, flat_array_prototype) {
194   markWord mark = markWord::flat_array_prototype();
195   assert_unlocked_state(mark);
196   EXPECT_TRUE(mark.is_neutral());
197 
198   assert_flat_array_type(mark);
199 
200   EXPECT_TRUE(mark.has_no_hash());
201   EXPECT_FALSE(mark.is_marked());
202   EXPECT_TRUE(mark.decode_pointer() == NULL);
203 
204   assert_copy_set_hash(mark);
205   assert_flat_array_type(mark);
206 }
207 
208 static void assert_null_free_array_type(markWord mark) {
209   EXPECT_FALSE(mark.is_flat_array());
210   EXPECT_FALSE(mark.is_inline_type());
211   EXPECT_FALSE(mark.is_larval_state());
212   EXPECT_TRUE(mark.is_null_free_array());
213 }
214 
215 TEST_VM(markWord, null_free_array_prototype) {
216   markWord mark = markWord::null_free_array_prototype();
217   assert_unlocked_state(mark);
218   EXPECT_TRUE(mark.is_neutral());
219 
220   assert_null_free_array_type(mark);
221 
222   EXPECT_TRUE(mark.has_no_hash());
223   EXPECT_FALSE(mark.is_marked());
224   EXPECT_TRUE(mark.decode_pointer() == NULL);
225 
226   assert_copy_set_hash(mark);
227   assert_null_free_array_type(mark);
228 }
229 #endif // _LP64
230 
231 #endif // PRODUCT
< prev index next >