217 if (!heap->is_in(fwd)) {
218 print_failure(_safe_oop, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
219 "Forwardee must point to a heap address",
220 file, line);
221 }
222
223 if (obj_klass != fwd->klass()) {
224 print_failure(_safe_oop, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
225 "Forwardee klass disagrees with object class",
226 file, line);
227 }
228
229 // Step 3. Check that forwardee points to correct region
230 if (heap->heap_region_index_containing(fwd) == heap->heap_region_index_containing(obj)) {
231 print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
232 "Non-trivial forwardee should in another region",
233 file, line);
234 }
235
236 // Step 4. Check for multiple forwardings
237 oop fwd2 = oop(ShenandoahForwarding::get_forwardee_raw_unchecked(fwd));
238 if (fwd != fwd2) {
239 print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
240 "Multiple forwardings",
241 file, line);
242 }
243 }
244 }
245
246 void ShenandoahAsserts::assert_in_correct_region(void* interior_loc, oop obj, const char* file, int line) {
247 assert_correct(interior_loc, obj, file, line);
248
249 ShenandoahHeap* heap = ShenandoahHeap::heap_no_check();
250 ShenandoahHeapRegion* r = heap->heap_region_containing(obj);
251 if (!r->is_active()) {
252 print_failure(_safe_unknown, obj, interior_loc, NULL, "Shenandoah assert_in_correct_region failed",
253 "Object must reside in active region",
254 file, line);
255 }
256
257 size_t alloc_size = obj->size();
258 if (alloc_size > ShenandoahHeapRegion::humongous_threshold_words()) {
259 size_t idx = r->region_number();
260 size_t num_regions = ShenandoahHeapRegion::required_regions(alloc_size * HeapWordSize);
261 for (size_t i = idx; i < idx + num_regions; i++) {
262 ShenandoahHeapRegion* chain_reg = heap->get_region(i);
358 ShenandoahHeap* heap = ShenandoahHeap::heap();
359 ReferenceProcessor* rp = heap->ref_processor();
360 if (rp->is_alive_non_header() == NULL) {
361 print_rp_failure("Shenandoah assert_rp_isalive_installed failed", rp->is_alive_non_header(),
362 file, line);
363 }
364 }
365
366 void ShenandoahAsserts::assert_locked_or_shenandoah_safepoint(Mutex* lock, const char* file, int line) {
367 if (ShenandoahSafepoint::is_at_shenandoah_safepoint()) {
368 return;
369 }
370
371 if (lock->owned_by_self()) {
372 return;
373 }
374
375 ShenandoahMessageBuffer msg("Must ba at a Shenandoah safepoint or held %s lock", lock->name());
376 report_vm_error(file, line, msg.buffer());
377 }
|
217 if (!heap->is_in(fwd)) {
218 print_failure(_safe_oop, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
219 "Forwardee must point to a heap address",
220 file, line);
221 }
222
223 if (obj_klass != fwd->klass()) {
224 print_failure(_safe_oop, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
225 "Forwardee klass disagrees with object class",
226 file, line);
227 }
228
229 // Step 3. Check that forwardee points to correct region
230 if (heap->heap_region_index_containing(fwd) == heap->heap_region_index_containing(obj)) {
231 print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
232 "Non-trivial forwardee should in another region",
233 file, line);
234 }
235
236 // Step 4. Check for multiple forwardings
237 /*
238 Disable for now. JVMTI heap walking creates 'forwarded' pattern outside cset
239 oop fwd2 = oop(ShenandoahForwarding::get_forwardee_raw_unchecked(fwd));
240 if (fwd != fwd2) {
241 print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
242 "Multiple forwardings",
243 file, line);
244 }
245 */
246 }
247 }
248
249 void ShenandoahAsserts::assert_in_correct_region(void* interior_loc, oop obj, const char* file, int line) {
250 assert_correct(interior_loc, obj, file, line);
251
252 ShenandoahHeap* heap = ShenandoahHeap::heap_no_check();
253 ShenandoahHeapRegion* r = heap->heap_region_containing(obj);
254 if (!r->is_active()) {
255 print_failure(_safe_unknown, obj, interior_loc, NULL, "Shenandoah assert_in_correct_region failed",
256 "Object must reside in active region",
257 file, line);
258 }
259
260 size_t alloc_size = obj->size();
261 if (alloc_size > ShenandoahHeapRegion::humongous_threshold_words()) {
262 size_t idx = r->region_number();
263 size_t num_regions = ShenandoahHeapRegion::required_regions(alloc_size * HeapWordSize);
264 for (size_t i = idx; i < idx + num_regions; i++) {
265 ShenandoahHeapRegion* chain_reg = heap->get_region(i);
361 ShenandoahHeap* heap = ShenandoahHeap::heap();
362 ReferenceProcessor* rp = heap->ref_processor();
363 if (rp->is_alive_non_header() == NULL) {
364 print_rp_failure("Shenandoah assert_rp_isalive_installed failed", rp->is_alive_non_header(),
365 file, line);
366 }
367 }
368
369 void ShenandoahAsserts::assert_locked_or_shenandoah_safepoint(Mutex* lock, const char* file, int line) {
370 if (ShenandoahSafepoint::is_at_shenandoah_safepoint()) {
371 return;
372 }
373
374 if (lock->owned_by_self()) {
375 return;
376 }
377
378 ShenandoahMessageBuffer msg("Must ba at a Shenandoah safepoint or held %s lock", lock->name());
379 report_vm_error(file, line, msg.buffer());
380 }
381
382 #ifdef ASSERT
383 bool ShenandoahAsserts::can_verify_oop(oop obj) {
384 if (CompressedOops::is_null(obj)) return true;
385 ShenandoahHeap* const heap = ShenandoahHeap::heap_no_check();
386 if (heap->in_collection_set(obj)) return true;
387 return false;
388 }
389 #endif
|