src/share/vm/memory/space.cpp

Print this page
rev 7084 : [mq]: demacro


 421       cp->space->cross_threshold(compact_top - size, compact_top);
 422   return compact_top;
 423 }
 424 
 425 
 426 bool CompactibleSpace::insert_deadspace(size_t& allowed_deadspace_words,
 427                                         HeapWord* q, size_t deadlength) {
 428   if (allowed_deadspace_words >= deadlength) {
 429     allowed_deadspace_words -= deadlength;
 430     CollectedHeap::fill_with_object(q, deadlength);
 431     oop(q)->set_mark(oop(q)->mark()->set_marked());
 432     assert((int) deadlength == oop(q)->size(), "bad filler object size");
 433     // Recall that we required "q == compaction_top".
 434     return true;
 435   } else {
 436     allowed_deadspace_words = 0;
 437     return false;
 438   }
 439 }
 440 
 441 #define block_is_always_obj(q) true
 442 #define obj_size(q) oop(q)->size()
 443 #define adjust_obj_size(s) s
 444 
 445 void CompactibleSpace::prepare_for_compaction(CompactPoint* cp) {
 446   SCAN_AND_FORWARD(cp, end, block_is_obj, block_size);
 447 }
 448 
 449 // Faster object search.
 450 void ContiguousSpace::prepare_for_compaction(CompactPoint* cp) {
 451   SCAN_AND_FORWARD(cp, top, block_is_always_obj, obj_size);
 452 }
 453 
 454 void Space::adjust_pointers() {
 455   // adjust all the interior pointers to point at the new locations of objects
 456   // Used by MarkSweep::mark_sweep_phase3()
 457 
 458   // First check to see if there is any work to be done.
 459   if (used() == 0) {
 460     return;  // Nothing to do.
 461   }
 462 
 463   // Otherwise...
 464   HeapWord* q = bottom();
 465   HeapWord* t = end();
 466 
 467   debug_only(HeapWord* prev_q = NULL);
 468   while (q < t) {
 469     if (oop(q)->is_gc_marked()) {
 470       // q is alive
 471 


 475       debug_only(prev_q = q);
 476 
 477       q += size;
 478     } else {
 479       // q is not a live object.  But we're not in a compactible space,
 480       // So we don't have live ranges.
 481       debug_only(prev_q = q);
 482       q += block_size(q);
 483       assert(q > prev_q, "we should be moving forward through memory");
 484     }
 485   }
 486   assert(q == t, "just checking");
 487 }
 488 
 489 void CompactibleSpace::adjust_pointers() {
 490   // Check first is there is any work to do.
 491   if (used() == 0) {
 492     return;   // Nothing to do.
 493   }
 494 
 495   SCAN_AND_ADJUST_POINTERS(adjust_obj_size);
 496 }
 497 
 498 void CompactibleSpace::compact() {
 499   SCAN_AND_COMPACT(obj_size);
 500 }
 501 
 502 void Space::print_short() const { print_short_on(tty); }
 503 
 504 void Space::print_short_on(outputStream* st) const {
 505   st->print(" space " SIZE_FORMAT "K, %3d%% used", capacity() / K,
 506               (int) ((double) used() * 100 / capacity()));
 507 }
 508 
 509 void Space::print() const { print_on(tty); }
 510 
 511 void Space::print_on(outputStream* st) const {
 512   print_short_on(st);
 513   st->print_cr(" [" INTPTR_FORMAT ", " INTPTR_FORMAT ")",
 514                 bottom(), end());
 515 }
 516 
 517 void ContiguousSpace::print_on(outputStream* st) const {
 518   print_short_on(st);
 519   st->print_cr(" [" INTPTR_FORMAT ", " INTPTR_FORMAT ", " INTPTR_FORMAT ")",




 421       cp->space->cross_threshold(compact_top - size, compact_top);
 422   return compact_top;
 423 }
 424 
 425 
 426 bool CompactibleSpace::insert_deadspace(size_t& allowed_deadspace_words,
 427                                         HeapWord* q, size_t deadlength) {
 428   if (allowed_deadspace_words >= deadlength) {
 429     allowed_deadspace_words -= deadlength;
 430     CollectedHeap::fill_with_object(q, deadlength);
 431     oop(q)->set_mark(oop(q)->mark()->set_marked());
 432     assert((int) deadlength == oop(q)->size(), "bad filler object size");
 433     // Recall that we required "q == compaction_top".
 434     return true;
 435   } else {
 436     allowed_deadspace_words = 0;
 437     return false;
 438   }
 439 }
 440 









 441 void ContiguousSpace::prepare_for_compaction(CompactPoint* cp) {
 442   scan_and_forward(this, cp);
 443 }
 444 
 445 void Space::adjust_pointers() {
 446   // adjust all the interior pointers to point at the new locations of objects
 447   // Used by MarkSweep::mark_sweep_phase3()
 448 
 449   // First check to see if there is any work to be done.
 450   if (used() == 0) {
 451     return;  // Nothing to do.
 452   }
 453 
 454   // Otherwise...
 455   HeapWord* q = bottom();
 456   HeapWord* t = end();
 457 
 458   debug_only(HeapWord* prev_q = NULL);
 459   while (q < t) {
 460     if (oop(q)->is_gc_marked()) {
 461       // q is alive
 462 


 466       debug_only(prev_q = q);
 467 
 468       q += size;
 469     } else {
 470       // q is not a live object.  But we're not in a compactible space,
 471       // So we don't have live ranges.
 472       debug_only(prev_q = q);
 473       q += block_size(q);
 474       assert(q > prev_q, "we should be moving forward through memory");
 475     }
 476   }
 477   assert(q == t, "just checking");
 478 }
 479 
 480 void CompactibleSpace::adjust_pointers() {
 481   // Check first is there is any work to do.
 482   if (used() == 0) {
 483     return;   // Nothing to do.
 484   }
 485 
 486   scan_and_adjust_pointers(this);
 487 }
 488 
 489 void CompactibleSpace::compact() {
 490   scan_and_compact(this);
 491 }
 492 
 493 void Space::print_short() const { print_short_on(tty); }
 494 
 495 void Space::print_short_on(outputStream* st) const {
 496   st->print(" space " SIZE_FORMAT "K, %3d%% used", capacity() / K,
 497               (int) ((double) used() * 100 / capacity()));
 498 }
 499 
 500 void Space::print() const { print_on(tty); }
 501 
 502 void Space::print_on(outputStream* st) const {
 503   print_short_on(st);
 504   st->print_cr(" [" INTPTR_FORMAT ", " INTPTR_FORMAT ")",
 505                 bottom(), end());
 506 }
 507 
 508 void ContiguousSpace::print_on(outputStream* st) const {
 509   print_short_on(st);
 510   st->print_cr(" [" INTPTR_FORMAT ", " INTPTR_FORMAT ", " INTPTR_FORMAT ")",