< prev index next >

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

Print this page




 474   }
 475 }
 476 
 477 void Space::oop_iterate(ExtendedOopClosure* blk) {
 478   ObjectToOopClosure blk2(blk);
 479   object_iterate(&blk2);
 480 }
 481 
 482 bool Space::obj_is_alive(const HeapWord* p) const {
 483   assert (block_is_obj(p), "The address should point to an object");
 484   return true;
 485 }
 486 
 487 #if INCLUDE_ALL_GCS
 488 #define ContigSpace_PAR_OOP_ITERATE_DEFN(OopClosureType, nv_suffix)         \
 489                                                                             \
 490   void ContiguousSpace::par_oop_iterate(MemRegion mr, OopClosureType* blk) {\
 491     HeapWord* obj_addr = mr.start();                                        \
 492     HeapWord* t = mr.end();                                                 \
 493     while (obj_addr < t) {                                                  \
 494       assert(oop(obj_addr)->is_oop(), "Should be an oop");                  \
 495       obj_addr += oop(obj_addr)->oop_iterate_size(blk);                     \
 496     }                                                                       \
 497   }
 498 
 499   ALL_PAR_OOP_ITERATE_CLOSURES(ContigSpace_PAR_OOP_ITERATE_DEFN)
 500 
 501 #undef ContigSpace_PAR_OOP_ITERATE_DEFN
 502 #endif // INCLUDE_ALL_GCS
 503 
 504 void ContiguousSpace::oop_iterate(ExtendedOopClosure* blk) {
 505   if (is_empty()) return;
 506   HeapWord* obj_addr = bottom();
 507   HeapWord* t = top();
 508   // Could call objects iterate, but this is easier.
 509   while (obj_addr < t) {
 510     obj_addr += oop(obj_addr)->oop_iterate_size(blk);
 511   }
 512 }
 513 
 514 void ContiguousSpace::object_iterate(ObjectClosure* blk) {


 567 }
 568 
 569 ALL_SINCE_SAVE_MARKS_CLOSURES(ContigSpace_OOP_SINCE_SAVE_MARKS_DEFN)
 570 
 571 #undef ContigSpace_OOP_SINCE_SAVE_MARKS_DEFN
 572 
 573 // Very general, slow implementation.
 574 HeapWord* ContiguousSpace::block_start_const(const void* p) const {
 575   assert(MemRegion(bottom(), end()).contains(p),
 576          "p (" PTR_FORMAT ") not in space [" PTR_FORMAT ", " PTR_FORMAT ")",
 577          p2i(p), p2i(bottom()), p2i(end()));
 578   if (p >= top()) {
 579     return top();
 580   } else {
 581     HeapWord* last = bottom();
 582     HeapWord* cur = last;
 583     while (cur <= p) {
 584       last = cur;
 585       cur += oop(cur)->size();
 586     }
 587     assert(oop(last)->is_oop(), PTR_FORMAT " should be an object start", p2i(last));
 588     return last;
 589   }
 590 }
 591 
 592 size_t ContiguousSpace::block_size(const HeapWord* p) const {
 593   assert(MemRegion(bottom(), end()).contains(p),
 594          "p (" PTR_FORMAT ") not in space [" PTR_FORMAT ", " PTR_FORMAT ")",
 595          p2i(p), p2i(bottom()), p2i(end()));
 596   HeapWord* current_top = top();
 597   assert(p <= current_top,
 598          "p > current top - p: " PTR_FORMAT ", current top: " PTR_FORMAT,
 599          p2i(p), p2i(current_top));
 600   assert(p == current_top || oop(p)->is_oop(),
 601          "p (" PTR_FORMAT ") is not a block start - "
 602          "current_top: " PTR_FORMAT ", is_oop: %s",
 603          p2i(p), p2i(current_top), BOOL_TO_STR(oop(p)->is_oop()));
 604   if (p < current_top) {
 605     return oop(p)->size();
 606   } else {
 607     assert(p == current_top, "just checking");
 608     return pointer_delta(end(), (HeapWord*) p);
 609   }
 610 }
 611 
 612 // This version requires locking.
 613 inline HeapWord* ContiguousSpace::allocate_impl(size_t size) {
 614   assert(Heap_lock->owned_by_self() ||
 615          (SafepointSynchronize::is_at_safepoint() && Thread::current()->is_VM_thread()),
 616          "not locked");
 617   HeapWord* obj = top();
 618   if (pointer_delta(end(), obj) >= size) {
 619     HeapWord* new_top = obj + size;
 620     set_top(new_top);
 621     assert(is_aligned(obj) && is_aligned(new_top), "checking alignment");
 622     return obj;
 623   } else {




 474   }
 475 }
 476 
 477 void Space::oop_iterate(ExtendedOopClosure* blk) {
 478   ObjectToOopClosure blk2(blk);
 479   object_iterate(&blk2);
 480 }
 481 
 482 bool Space::obj_is_alive(const HeapWord* p) const {
 483   assert (block_is_obj(p), "The address should point to an object");
 484   return true;
 485 }
 486 
 487 #if INCLUDE_ALL_GCS
 488 #define ContigSpace_PAR_OOP_ITERATE_DEFN(OopClosureType, nv_suffix)         \
 489                                                                             \
 490   void ContiguousSpace::par_oop_iterate(MemRegion mr, OopClosureType* blk) {\
 491     HeapWord* obj_addr = mr.start();                                        \
 492     HeapWord* t = mr.end();                                                 \
 493     while (obj_addr < t) {                                                  \
 494       assert(oopDesc::is_oop(oop(obj_addr)), "Should be an oop");           \
 495       obj_addr += oop(obj_addr)->oop_iterate_size(blk);                     \
 496     }                                                                       \
 497   }
 498 
 499   ALL_PAR_OOP_ITERATE_CLOSURES(ContigSpace_PAR_OOP_ITERATE_DEFN)
 500 
 501 #undef ContigSpace_PAR_OOP_ITERATE_DEFN
 502 #endif // INCLUDE_ALL_GCS
 503 
 504 void ContiguousSpace::oop_iterate(ExtendedOopClosure* blk) {
 505   if (is_empty()) return;
 506   HeapWord* obj_addr = bottom();
 507   HeapWord* t = top();
 508   // Could call objects iterate, but this is easier.
 509   while (obj_addr < t) {
 510     obj_addr += oop(obj_addr)->oop_iterate_size(blk);
 511   }
 512 }
 513 
 514 void ContiguousSpace::object_iterate(ObjectClosure* blk) {


 567 }
 568 
 569 ALL_SINCE_SAVE_MARKS_CLOSURES(ContigSpace_OOP_SINCE_SAVE_MARKS_DEFN)
 570 
 571 #undef ContigSpace_OOP_SINCE_SAVE_MARKS_DEFN
 572 
 573 // Very general, slow implementation.
 574 HeapWord* ContiguousSpace::block_start_const(const void* p) const {
 575   assert(MemRegion(bottom(), end()).contains(p),
 576          "p (" PTR_FORMAT ") not in space [" PTR_FORMAT ", " PTR_FORMAT ")",
 577          p2i(p), p2i(bottom()), p2i(end()));
 578   if (p >= top()) {
 579     return top();
 580   } else {
 581     HeapWord* last = bottom();
 582     HeapWord* cur = last;
 583     while (cur <= p) {
 584       last = cur;
 585       cur += oop(cur)->size();
 586     }
 587     assert(oopDesc::is_oop(oop(last)), PTR_FORMAT " should be an object start", p2i(last));
 588     return last;
 589   }
 590 }
 591 
 592 size_t ContiguousSpace::block_size(const HeapWord* p) const {
 593   assert(MemRegion(bottom(), end()).contains(p),
 594          "p (" PTR_FORMAT ") not in space [" PTR_FORMAT ", " PTR_FORMAT ")",
 595          p2i(p), p2i(bottom()), p2i(end()));
 596   HeapWord* current_top = top();
 597   assert(p <= current_top,
 598          "p > current top - p: " PTR_FORMAT ", current top: " PTR_FORMAT,
 599          p2i(p), p2i(current_top));
 600   assert(p == current_top || oopDesc::is_oop(oop(p)),
 601          "p (" PTR_FORMAT ") is not a block start - "
 602          "current_top: " PTR_FORMAT ", is_oop: %s",
 603          p2i(p), p2i(current_top), BOOL_TO_STR(oopDesc::is_oop(oop(p))));
 604   if (p < current_top) {
 605     return oop(p)->size();
 606   } else {
 607     assert(p == current_top, "just checking");
 608     return pointer_delta(end(), (HeapWord*) p);
 609   }
 610 }
 611 
 612 // This version requires locking.
 613 inline HeapWord* ContiguousSpace::allocate_impl(size_t size) {
 614   assert(Heap_lock->owned_by_self() ||
 615          (SafepointSynchronize::is_at_safepoint() && Thread::current()->is_VM_thread()),
 616          "not locked");
 617   HeapWord* obj = top();
 618   if (pointer_delta(end(), obj) >= size) {
 619     HeapWord* new_top = obj + size;
 620     set_top(new_top);
 621     assert(is_aligned(obj) && is_aligned(new_top), "checking alignment");
 622     return obj;
 623   } else {


< prev index next >