Skip to content

Instantly share code, notes, and snippets.

@aragozin
Created July 6, 2011 10:48
Show Gist options
  • Save aragozin/1066989 to your computer and use it in GitHub Desktop.
Save aragozin/1066989 to your computer and use it in GitHub Desktop.
OpenJDK GC patch, modified code
void ClearNoncleanCardWrapper::do_MemRegion(MemRegion mr) {
assert(mr.word_size() > 0, "Error");
assert(_ct->is_aligned(mr.start()), "mr.start() should be card aligned");
// mr.end() may not necessarily be card aligned.
jbyte* cur_entry = _ct->byte_for(mr.last());
const jbyte* limit = _ct->byte_for(mr.start());
HeapWord* end_of_non_clean = mr.end();
HeapWord* start_of_non_clean = end_of_non_clean;
while (cur_entry >= limit) {
HeapWord* cur_hw = _ct->addr_for(cur_entry);
if ((*cur_entry != CardTableRS::clean_card_val()) && clear_card(cur_entry)) {
// Continue the dirty range by opening the
// dirty window one card to the left.
start_of_non_clean = cur_hw;
cur_entry--;
} else {
// We hit a "clean" card; process any non-empty
// "dirty" range accumulated so far.
if (start_of_non_clean < end_of_non_clean) {
const MemRegion mrd(start_of_non_clean, end_of_non_clean);
_dirty_card_closure->do_MemRegion(mrd);
}
// fast forward via continuous range of clean cards
// hardcoded 64 bit version
if ((((jlong)cur_entry) & 7) == 0) {
jbyte* cur_row = cur_entry - 8;
while(cur_row >= limit) {
if (*((jlong*)cur_row) == ((jlong)-1) /* hardcoded row of 8 clean cards */) {
cur_row -= 8;
}
else {
break;
}
}
cur_entry = cur_row + 7;
HeapWord* last_hw = _ct->addr_for(cur_row + 8);
end_of_non_clean = last_hw;
start_of_non_clean = last_hw;
}
else {
// Reset the dirty window, while continuing to look
// for the next dirty card that will start a
// new dirty window.
end_of_non_clean = cur_hw;
start_of_non_clean = cur_hw;
cur_entry--;
}
}
// Note that "cur_entry" leads "start_of_non_clean" in
// its leftward excursion after this point
// in the loop and, when we hit the left end of "mr",
// will point off of the left end of the card-table
// for "mr".
}
// If the first card of "mr" was dirty, we will have
// been left with a dirty window, co-initial with "mr",
// which we now process.
if (start_of_non_clean < end_of_non_clean) {
const MemRegion mrd(start_of_non_clean, end_of_non_clean);
_dirty_card_closure->do_MemRegion(mrd);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment