< prev index next >
src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp
Print this page
rev 55608 : Rename ShenandoahBrooksPointer to ShenandoahForwarding
rev 55609 : Eliminate extra forwarding pointer per object
@@ -232,54 +232,49 @@
return ShenandoahBarrierSet::resolve_forwarded(p);
}
assert(ShenandoahThreadLocalData::is_evac_allowed(thread), "must be enclosed in oom-evac scope");
- size_t size_no_fwdptr = (size_t) p->size();
- size_t size_with_fwdptr = size_no_fwdptr + ShenandoahForwarding::word_size();
+ size_t size = p->size();
assert(!heap_region_containing(p)->is_humongous(), "never evacuate humongous objects");
bool alloc_from_gclab = true;
- HeapWord* filler = NULL;
+ HeapWord* copy = NULL;
#ifdef ASSERT
if (ShenandoahOOMDuringEvacALot &&
(os::random() & 1) == 0) { // Simulate OOM every ~2nd slow-path call
- filler = NULL;
+ copy = NULL;
} else {
#endif
if (UseTLAB) {
- filler = allocate_from_gclab(thread, size_with_fwdptr);
+ copy = allocate_from_gclab(thread, size);
}
- if (filler == NULL) {
- ShenandoahAllocRequest req = ShenandoahAllocRequest::for_shared_gc(size_with_fwdptr);
- filler = allocate_memory(req);
+ if (copy == NULL) {
+ ShenandoahAllocRequest req = ShenandoahAllocRequest::for_shared_gc(size);
+ copy = allocate_memory(req);
alloc_from_gclab = false;
}
#ifdef ASSERT
}
#endif
- if (filler == NULL) {
- control_thread()->handle_alloc_failure_evac(size_with_fwdptr);
+ if (copy == NULL) {
+ control_thread()->handle_alloc_failure_evac(size);
_oom_evac_handler.handle_out_of_memory_during_evacuation();
return ShenandoahBarrierSet::resolve_forwarded(p);
}
- // Copy the object and initialize its forwarding ptr:
- HeapWord* copy = filler + ShenandoahForwarding::word_size();
- oop copy_val = oop(copy);
-
- Copy::aligned_disjoint_words((HeapWord*) p, copy, size_no_fwdptr);
- ShenandoahForwarding::initialize(oop(copy));
+ // Copy the object:
+ Copy::aligned_disjoint_words((HeapWord*) p, copy, size);
// Try to install the new forwarding pointer.
+ oop copy_val = oop(copy);
oop result = ShenandoahForwarding::try_update_forwardee(p, copy_val);
-
if (oopDesc::equals_raw(result, p)) {
// Successfully evacuated. Our copy is now the public one!
shenandoah_assert_correct(NULL, copy_val);
return copy_val;
} else {
@@ -293,15 +288,15 @@
// object will overwrite this stale copy, or the filler object on LAB retirement will
// do this. For non-GCLAB allocations, we have no way to retract the allocation, and
// have to explicitly overwrite the copy with the filler object. With that overwrite,
// we have to keep the fwdptr initialized and pointing to our (stale) copy.
if (alloc_from_gclab) {
- ShenandoahThreadLocalData::gclab(thread)->undo_allocation(filler, size_with_fwdptr);
+ ShenandoahThreadLocalData::gclab(thread)->undo_allocation(copy, size);
} else {
- fill_with_object(copy, size_no_fwdptr);
- }
+ fill_with_object(copy, size);
shenandoah_assert_correct(NULL, copy_val);
+ }
shenandoah_assert_correct(NULL, result);
return result;
}
}
@@ -368,23 +363,21 @@
marked_object_iterate(region, cl, region->top());
}
template<class T>
inline void ShenandoahHeap::marked_object_iterate(ShenandoahHeapRegion* region, T* cl, HeapWord* limit) {
- assert(ShenandoahForwarding::word_offset() < 0, "skip_delta calculation below assumes the forwarding ptr is before obj");
assert(! region->is_humongous_continuation(), "no humongous continuation regions here");
ShenandoahMarkingContext* const ctx = complete_marking_context();
assert(ctx->is_complete(), "sanity");
MarkBitMap* mark_bit_map = ctx->mark_bit_map();
HeapWord* tams = ctx->top_at_mark_start(region);
- size_t skip_bitmap_delta = ShenandoahForwarding::word_size() + 1;
- size_t skip_objsize_delta = ShenandoahForwarding::word_size() /* + actual obj.size() below */;
- HeapWord* start = region->bottom() + ShenandoahForwarding::word_size();
- HeapWord* end = MIN2(tams + ShenandoahForwarding::word_size(), region->end());
+ size_t skip_bitmap_delta = 1;
+ HeapWord* start = region->bottom();
+ HeapWord* end = MIN2(tams, region->end());
// Step 1. Scan below the TAMS based on bitmap data.
HeapWord* limit_bitmap = MIN2(limit, tams);
// Try to scan the initial candidate. If the candidate is above the TAMS, it would
@@ -410,11 +403,11 @@
int avail;
do {
avail = 0;
for (int c = 0; (c < dist) && (cb < limit_bitmap); c++) {
- Prefetch::read(cb, ShenandoahForwarding::byte_offset());
+ Prefetch::read(cb, oopDesc::mark_offset_in_bytes());
slots[avail++] = cb;
cb += skip_bitmap_delta;
if (cb < limit_bitmap) {
cb = mark_bit_map->get_next_marked_addr(cb, limit_bitmap);
}
@@ -445,20 +438,20 @@
}
// Step 2. Accurate size-based traversal, happens past the TAMS.
// This restarts the scan at TAMS, which makes sure we traverse all objects,
// regardless of what happened at Step 1.
- HeapWord* cs = tams + ShenandoahForwarding::word_size();
+ HeapWord* cs = tams;
while (cs < limit) {
- assert (cs > tams, "only objects past TAMS here: " PTR_FORMAT " (" PTR_FORMAT ")", p2i(cs), p2i(tams));
+ assert (cs >= tams, "only objects past TAMS here: " PTR_FORMAT " (" PTR_FORMAT ")", p2i(cs), p2i(tams));
assert (cs < limit, "only objects below limit here: " PTR_FORMAT " (" PTR_FORMAT ")", p2i(cs), p2i(limit));
oop obj = oop(cs);
assert(oopDesc::is_oop(obj), "sanity");
assert(ctx->is_marked(obj), "object expected to be marked");
int size = obj->size();
cl->do_object(obj);
- cs += size + skip_objsize_delta;
+ cs += size;
}
}
template <class T>
class ShenandoahObjectToOopClosure : public ObjectClosure {
< prev index next >