403 // the card is not young. And we only clean the card if we have been
404 // asked to (i.e., card_ptr != NULL).
405 if (card_ptr != NULL) {
406 *card_ptr = CardTableModRefBS::clean_card_val();
407 // We must complete this write before we do any of the reads below.
408 OrderAccess::storeload();
409 }
410
411 // Cache the boundaries of the memory region in some const locals
412 HeapWord* const start = mr.start();
413 HeapWord* const end = mr.end();
414
415 // We used to use "block_start_careful" here. But we're actually happy
416 // to update the BOT while we do this...
417 HeapWord* cur = block_start(start);
418 assert(cur <= start, "Postcondition");
419
420 oop obj;
421
422 HeapWord* next = cur;
423 while (next <= start) {
424 cur = next;
425 obj = oop(cur);
426 if (obj->klass_or_null() == NULL) {
427 // Ran into an unparseable point.
428 return cur;
429 }
430 // Otherwise...
431 next = cur + block_size(cur);
432 }
433
434 // If we finish the above loop...We have a parseable object that
435 // begins on or before the start of the memory region, and ends
436 // inside or spans the entire region.
437 assert(cur <= start, "Loop postcondition");
438 assert(obj->klass_or_null() != NULL, "Loop invariant");
439
440 do {
441 obj = oop(cur);
442 assert((cur + block_size(cur)) > (HeapWord*)obj, "Loop invariant");
443 if (obj->klass_or_null() == NULL) {
444 // Ran into an unparseable point.
445 return cur;
446 }
447
448 // Advance the current pointer. "obj" still points to the object to iterate.
449 cur = cur + block_size(cur);
450
451 if (!g1h->is_obj_dead(obj)) {
452 // Non-objArrays are sometimes marked imprecise at the object start. We
453 // always need to iterate over them in full.
454 // We only iterate over object arrays in full if they are completely contained
455 // in the memory region.
456 if (!obj->is_objArray() || (((HeapWord*)obj) >= start && cur < end)) {
457 obj->oop_iterate(cl);
458 } else {
459 obj->oop_iterate(cl, mr);
460 }
461 }
462 } while (cur < end);
463
464 return NULL;
465 }
466
467 // Code roots support
468
469 void HeapRegion::add_strong_code_root(nmethod* nm) {
470 HeapRegionRemSet* hrrs = rem_set();
471 hrrs->add_strong_code_root(nm);
472 }
473
474 void HeapRegion::add_strong_code_root_locked(nmethod* nm) {
475 assert_locked_or_safepoint(CodeCache_lock);
476 HeapRegionRemSet* hrrs = rem_set();
|
403 // the card is not young. And we only clean the card if we have been
404 // asked to (i.e., card_ptr != NULL).
405 if (card_ptr != NULL) {
406 *card_ptr = CardTableModRefBS::clean_card_val();
407 // We must complete this write before we do any of the reads below.
408 OrderAccess::storeload();
409 }
410
411 // Cache the boundaries of the memory region in some const locals
412 HeapWord* const start = mr.start();
413 HeapWord* const end = mr.end();
414
415 // We used to use "block_start_careful" here. But we're actually happy
416 // to update the BOT while we do this...
417 HeapWord* cur = block_start(start);
418 assert(cur <= start, "Postcondition");
419
420 oop obj;
421
422 HeapWord* next = cur;
423 do {
424 cur = next;
425 obj = oop(cur);
426 if (obj->klass_or_null() == NULL) {
427 // Ran into an unparseable point.
428 return cur;
429 }
430 // Otherwise...
431 next = cur + block_size(cur);
432 } while (next <= start);
433
434 // If we finish the above loop...We have a parseable object that
435 // begins on or before the start of the memory region, and ends
436 // inside or spans the entire region.
437 assert(cur <= start, "Loop postcondition");
438 assert(obj->klass_or_null() != NULL, "Loop postcondition");
439
440 do {
441 obj = oop(cur);
442 assert((cur + block_size(cur)) > (HeapWord*)obj, "Loop invariant");
443 if (obj->klass_or_null() == NULL) {
444 // Ran into an unparseable point.
445 return cur;
446 }
447
448 // Advance the current pointer. "obj" still points to the object to iterate.
449 cur = cur + block_size(cur);
450
451 if (!g1h->is_obj_dead(obj)) {
452 // Non-objArrays are sometimes marked imprecise at the object start. We
453 // always need to iterate over them in full.
454 // We only iterate over object arrays in full if they are completely contained
455 // in the memory region.
456 if (!obj->is_objArray() || (((HeapWord*)obj) >= start && cur <= end)) {
457 obj->oop_iterate(cl);
458 } else {
459 obj->oop_iterate(cl, mr);
460 }
461 }
462 } while (cur < end);
463
464 return NULL;
465 }
466
467 // Code roots support
468
469 void HeapRegion::add_strong_code_root(nmethod* nm) {
470 HeapRegionRemSet* hrrs = rem_set();
471 hrrs->add_strong_code_root(nm);
472 }
473
474 void HeapRegion::add_strong_code_root_locked(nmethod* nm) {
475 assert_locked_or_safepoint(CodeCache_lock);
476 HeapRegionRemSet* hrrs = rem_set();
|