< prev index next >

src/share/vm/gc/shared/space.cpp

Print this page




 375   assert(this == cp->space, "'this' should be current compaction space.");
 376   size_t compaction_max_size = pointer_delta(end(), compact_top);
 377   while (size > compaction_max_size) {
 378     // switch to next compaction space
 379     cp->space->set_compaction_top(compact_top);
 380     cp->space = cp->space->next_compaction_space();
 381     if (cp->space == NULL) {
 382       cp->gen = GenCollectedHeap::heap()->young_gen();
 383       assert(cp->gen != NULL, "compaction must succeed");
 384       cp->space = cp->gen->first_compaction_space();
 385       assert(cp->space != NULL, "generation must have a first compaction space");
 386     }
 387     compact_top = cp->space->bottom();
 388     cp->space->set_compaction_top(compact_top);
 389     cp->threshold = cp->space->initialize_threshold();
 390     compaction_max_size = pointer_delta(cp->space->end(), compact_top);
 391   }
 392 
 393   // store the forwarding pointer into the mark word
 394   if ((HeapWord*)q != compact_top) {
 395     q->forward_to(oop(compact_top));
 396     assert(q->is_gc_marked(), "encoding the pointer should preserve the mark");
 397   } else {
 398     // if the object isn't moving we can just set the mark to the default
 399     // mark and handle it specially later on.
 400     q->init_mark();
 401     assert(q->forwardee() == NULL, "should be forwarded to NULL");
 402   }
 403 
 404   compact_top += size;
 405 
 406   // we need to update the offset table so that the beginnings of objects can be
 407   // found during scavenge.  Note that we are updating the offset table based on
 408   // where the object will be once the compaction phase finishes.
 409   if (compact_top > cp->threshold)
 410     cp->threshold =
 411       cp->space->cross_threshold(compact_top - size, compact_top);
 412   return compact_top;
 413 }
 414 
 415 




 375   assert(this == cp->space, "'this' should be current compaction space.");
 376   size_t compaction_max_size = pointer_delta(end(), compact_top);
 377   while (size > compaction_max_size) {
 378     // switch to next compaction space
 379     cp->space->set_compaction_top(compact_top);
 380     cp->space = cp->space->next_compaction_space();
 381     if (cp->space == NULL) {
 382       cp->gen = GenCollectedHeap::heap()->young_gen();
 383       assert(cp->gen != NULL, "compaction must succeed");
 384       cp->space = cp->gen->first_compaction_space();
 385       assert(cp->space != NULL, "generation must have a first compaction space");
 386     }
 387     compact_top = cp->space->bottom();
 388     cp->space->set_compaction_top(compact_top);
 389     cp->threshold = cp->space->initialize_threshold();
 390     compaction_max_size = pointer_delta(cp->space->end(), compact_top);
 391   }
 392 
 393   // store the forwarding pointer into the mark word
 394   if ((HeapWord*)q != compact_top) {
 395     q->forward_to(compact_oop(compact_top));
 396     assert(q->is_gc_marked(), "encoding the pointer should preserve the mark");
 397   } else {
 398     // if the object isn't moving we can just set the mark to the default
 399     // mark and handle it specially later on.
 400     q->init_mark();
 401     assert(q->forwardee() == NULL, "should be forwarded to NULL");
 402   }
 403 
 404   compact_top += size;
 405 
 406   // we need to update the offset table so that the beginnings of objects can be
 407   // found during scavenge.  Note that we are updating the offset table based on
 408   // where the object will be once the compaction phase finishes.
 409   if (compact_top > cp->threshold)
 410     cp->threshold =
 411       cp->space->cross_threshold(compact_top - size, compact_top);
 412   return compact_top;
 413 }
 414 
 415 


< prev index next >