< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahAsserts.cpp

Print this page

180   ShenandoahHeap* heap = ShenandoahHeap::heap();
181 
182   if (obj != NULL && !heap->is_in(obj)) {
183     print_failure(_safe_unknown, obj, interior_loc, NULL, "Shenandoah assert_in_heap_or_null failed",
184                   "oop must point to a heap address",
185                   file, line);
186   }
187 }
188 
189 void ShenandoahAsserts::assert_correct(void* interior_loc, oop obj, const char* file, int line) {
190   ShenandoahHeap* heap = ShenandoahHeap::heap();
191 
192   // Step 1. Check that obj is correct.
193   // After this step, it is safe to call heap_region_containing().
194   if (!heap->is_in(obj)) {
195     print_failure(_safe_unknown, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
196                   "oop must point to a heap address",
197                   file, line);
198   }
199 
200   Klass* obj_klass = obj->klass_or_null();
201   if (obj_klass == NULL) {
202     print_failure(_safe_unknown, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
203                   "Object klass pointer should not be NULL",
204                   file,line);
205   }
206 
207   if (!Metaspace::contains(obj_klass)) {
208     print_failure(_safe_unknown, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
209                   "Object klass pointer must go to metaspace",
210                   file,line);
211   }
212 
213   oop fwd = ShenandoahForwarding::get_forwardee_raw_unchecked(obj);
214 
215   if (obj != fwd) {
216     // When Full GC moves the objects, we cannot trust fwdptrs. If we got here, it means something
217     // tries fwdptr manipulation when Full GC is running. The only exception is using the fwdptr
218     // that still points to the object itself.
219     if (heap->is_full_gc_move_in_progress()) {
220       print_failure(_safe_oop, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
221                     "Non-trivial forwarding pointer during Full GC moves, probable bug.",
222                     file, line);
223     }
224 
225     // Step 2. Check that forwardee is correct
226     if (!heap->is_in(fwd)) {
227       print_failure(_safe_oop, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
228                     "Forwardee must point to a heap address",
229                     file, line);
230     }
231 
232     if (obj_klass != fwd->klass()) {
233       print_failure(_safe_oop, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
234                     "Forwardee klass disagrees with object class",
235                     file, line);
236     }
237 
238     // Step 3. Check that forwardee points to correct region
239     if (heap->heap_region_index_containing(fwd) == heap->heap_region_index_containing(obj)) {
240       print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
241                     "Non-trivial forwardee should in another region",
242                     file, line);
243     }
244 
245     // Step 4. Check for multiple forwardings
246     oop fwd2 = ShenandoahForwarding::get_forwardee_raw_unchecked(fwd);
247     if (fwd != fwd2) {
248       print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
249                     "Multiple forwardings",
250                     file, line);
251     }
252   }

180   ShenandoahHeap* heap = ShenandoahHeap::heap();
181 
182   if (obj != NULL && !heap->is_in(obj)) {
183     print_failure(_safe_unknown, obj, interior_loc, NULL, "Shenandoah assert_in_heap_or_null failed",
184                   "oop must point to a heap address",
185                   file, line);
186   }
187 }
188 
189 void ShenandoahAsserts::assert_correct(void* interior_loc, oop obj, const char* file, int line) {
190   ShenandoahHeap* heap = ShenandoahHeap::heap();
191 
192   // Step 1. Check that obj is correct.
193   // After this step, it is safe to call heap_region_containing().
194   if (!heap->is_in(obj)) {
195     print_failure(_safe_unknown, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
196                   "oop must point to a heap address",
197                   file, line);
198   }
199 
200   Klass* obj_klass = obj->forward_safe_klass();
201   if (obj_klass == NULL) {
202     print_failure(_safe_unknown, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
203                   "Object klass pointer should not be NULL",
204                   file,line);
205   }
206 
207   if (!Metaspace::contains(obj_klass)) {
208     print_failure(_safe_unknown, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
209                   "Object klass pointer must go to metaspace",
210                   file,line);
211   }
212 
213   oop fwd = ShenandoahForwarding::get_forwardee_raw_unchecked(obj);
214 
215   if (obj != fwd) {
216     // When Full GC moves the objects, we cannot trust fwdptrs. If we got here, it means something
217     // tries fwdptr manipulation when Full GC is running. The only exception is using the fwdptr
218     // that still points to the object itself.
219     if (heap->is_full_gc_move_in_progress()) {
220       print_failure(_safe_oop, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
221                     "Non-trivial forwarding pointer during Full GC moves, probable bug.",
222                     file, line);
223     }
224 
225     // Step 2. Check that forwardee is correct
226     if (!heap->is_in(fwd)) {
227       print_failure(_safe_oop, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
228                     "Forwardee must point to a heap address",
229                     file, line);
230     }
231 
232     if (obj_klass != fwd->forward_safe_klass()) {
233       print_failure(_safe_oop, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
234                     "Forwardee klass disagrees with object class",
235                     file, line);
236     }
237 
238     // Step 3. Check that forwardee points to correct region
239     if (heap->heap_region_index_containing(fwd) == heap->heap_region_index_containing(obj)) {
240       print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
241                     "Non-trivial forwardee should in another region",
242                     file, line);
243     }
244 
245     // Step 4. Check for multiple forwardings
246     oop fwd2 = ShenandoahForwarding::get_forwardee_raw_unchecked(fwd);
247     if (fwd != fwd2) {
248       print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
249                     "Multiple forwardings",
250                     file, line);
251     }
252   }
< prev index next >