1 /*
2 * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
265 // will point off of the left end of the card-table
266 // for "mr".
267 cur_entry--;
268 }
269 // If the first card of "mr" was dirty, we will have
270 // been left with a dirty window, co-initial with "mr",
271 // which we now process.
272 if (start_of_non_clean < end_of_non_clean) {
273 const MemRegion mrd(start_of_non_clean, end_of_non_clean);
274 _dirty_card_closure->do_MemRegion(mrd);
275 }
276 }
277
278 // clean (by dirty->clean before) ==> cur_younger_gen
279 // dirty ==> cur_youngergen_and_prev_nonclean_card
280 // precleaned ==> cur_youngergen_and_prev_nonclean_card
281 // prev-younger-gen ==> cur_youngergen_and_prev_nonclean_card
282 // cur-younger-gen ==> cur_younger_gen
283 // cur_youngergen_and_prev_nonclean_card ==> no change.
284 void CardTableRS::write_ref_field_gc_par(void* field, oop new_val) {
285 jbyte* entry = _ct_bs->byte_for(field);
286 do {
287 jbyte entry_val = *entry;
288 // We put this first because it's probably the most common case.
289 if (entry_val == clean_card_val()) {
290 // No threat of contention with cleaning threads.
291 *entry = cur_youngergen_card_val();
292 return;
293 } else if (card_is_dirty_wrt_gen_iter(entry_val)
294 || is_prev_youngergen_card_val(entry_val)) {
295 // Mark it as both cur and prev youngergen; card cleaning thread will
296 // eventually remove the previous stuff.
297 jbyte new_val = cur_youngergen_and_prev_nonclean_card;
298 jbyte res = Atomic::cmpxchg(new_val, entry, entry_val);
299 // Did the CAS succeed?
300 if (res == entry_val) return;
301 // Otherwise, retry, to see the new value.
302 continue;
303 } else {
304 assert(entry_val == cur_youngergen_and_prev_nonclean_card
305 || entry_val == cur_youngergen_card_val(),
|
1 /*
2 * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
265 // will point off of the left end of the card-table
266 // for "mr".
267 cur_entry--;
268 }
269 // If the first card of "mr" was dirty, we will have
270 // been left with a dirty window, co-initial with "mr",
271 // which we now process.
272 if (start_of_non_clean < end_of_non_clean) {
273 const MemRegion mrd(start_of_non_clean, end_of_non_clean);
274 _dirty_card_closure->do_MemRegion(mrd);
275 }
276 }
277
278 // clean (by dirty->clean before) ==> cur_younger_gen
279 // dirty ==> cur_youngergen_and_prev_nonclean_card
280 // precleaned ==> cur_youngergen_and_prev_nonclean_card
281 // prev-younger-gen ==> cur_youngergen_and_prev_nonclean_card
282 // cur-younger-gen ==> cur_younger_gen
283 // cur_youngergen_and_prev_nonclean_card ==> no change.
284 void CardTableRS::write_ref_field_gc_par(void* field, oop new_val) {
285 volatile jbyte* entry = _ct_bs->byte_for(field);
286 do {
287 jbyte entry_val = *entry;
288 // We put this first because it's probably the most common case.
289 if (entry_val == clean_card_val()) {
290 // No threat of contention with cleaning threads.
291 *entry = cur_youngergen_card_val();
292 return;
293 } else if (card_is_dirty_wrt_gen_iter(entry_val)
294 || is_prev_youngergen_card_val(entry_val)) {
295 // Mark it as both cur and prev youngergen; card cleaning thread will
296 // eventually remove the previous stuff.
297 jbyte new_val = cur_youngergen_and_prev_nonclean_card;
298 jbyte res = Atomic::cmpxchg(new_val, entry, entry_val);
299 // Did the CAS succeed?
300 if (res == entry_val) return;
301 // Otherwise, retry, to see the new value.
302 continue;
303 } else {
304 assert(entry_val == cur_youngergen_and_prev_nonclean_card
305 || entry_val == cur_youngergen_card_val(),
|