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 *
23 */
24
25 #ifndef SHARE_VM_MEMORY_CARDTABLEMODREFBS_HPP
26 #define SHARE_VM_MEMORY_CARDTABLEMODREFBS_HPP
27
28 #include "memory/modRefBarrierSet.hpp"
29 #include "oops/oop.hpp"
30 #include "oops/oop.inline2.hpp"
31
32 // This kind of "BarrierSet" allows a "CollectedHeap" to detect and
33 // enumerate ref fields that have been modified (since the last
34 // enumeration.)
35
36 // As it currently stands, this barrier is *imprecise*: when a ref field in
37 // an object "o" is modified, the card table entry for the card containing
38 // the head of "o" is dirtied, not necessarily the card containing the
39 // modified field itself. For object arrays, however, the barrier *is*
40 // precise; only the card containing the modified element is dirtied.
41 // Any MemRegionClosures used to scan dirty cards should take these
42 // considerations into account.
43
44 class Generation;
45 class OopsInGenClosure;
46 class DirtyCardToOopClosure;
47 class ClearNoncleanCardWrapper;
48
49 class CardTableModRefBS: public ModRefBarrierSet {
50 // Some classes get to look at some private stuff.
51 friend class BytecodeInterpreter;
52 friend class VMStructs;
53 friend class CardTableRS;
54 friend class CheckForUnmarkedOops; // Needs access to raw card bytes.
55 friend class SharkBuilder;
56 #ifndef PRODUCT
57 // For debugging.
58 friend class GuaranteeNotModClosure;
59 #endif
60 protected:
61
62 enum CardValues {
63 clean_card = -1,
64 // The mask contains zeros in places for all other values.
65 clean_card_mask = clean_card - 31,
66
67 dirty_card = 0,
316 }
317 public:
318
319 inline void inline_write_ref_array(MemRegion mr) {
320 dirty_MemRegion(mr);
321 }
322 protected:
323 void write_ref_array_work(MemRegion mr) {
324 inline_write_ref_array(mr);
325 }
326 public:
327
328 bool is_aligned(HeapWord* addr) {
329 return is_card_aligned(addr);
330 }
331
332 // *** Card-table-barrier-specific things.
333
334 template <class T> inline void inline_write_ref_field_pre(T* field, oop newVal) {}
335
336 template <class T> inline void inline_write_ref_field(T* field, oop newVal, bool release) {
337 jbyte* byte = byte_for((void*)field);
338 if (release) {
339 // Perform a releasing store if requested.
340 OrderAccess::release_store((volatile jbyte*) byte, dirty_card);
341 } else {
342 *byte = dirty_card;
343 }
344 }
345
346 // These are used by G1, when it uses the card table as a temporary data
347 // structure for card claiming.
348 bool is_card_dirty(size_t card_index) {
349 return _byte_map[card_index] == dirty_card_val();
350 }
351
352 void mark_card_dirty(size_t card_index) {
353 _byte_map[card_index] = dirty_card_val();
354 }
355
356 bool is_card_clean(size_t card_index) {
357 return _byte_map[card_index] == clean_card_val();
358 }
359
360 // Card marking array base (adjusted for heap low boundary)
361 // This would be the 0th element of _byte_map, if the heap started at 0x0.
362 // But since the heap starts at some higher address, this points to somewhere
363 // before the beginning of the actual _byte_map.
364 jbyte* byte_map_base;
|
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 *
23 */
24
25 #ifndef SHARE_VM_MEMORY_CARDTABLEMODREFBS_HPP
26 #define SHARE_VM_MEMORY_CARDTABLEMODREFBS_HPP
27
28 #include "memory/modRefBarrierSet.hpp"
29 #include "oops/oop.hpp"
30
31 // This kind of "BarrierSet" allows a "CollectedHeap" to detect and
32 // enumerate ref fields that have been modified (since the last
33 // enumeration.)
34
35 // As it currently stands, this barrier is *imprecise*: when a ref field in
36 // an object "o" is modified, the card table entry for the card containing
37 // the head of "o" is dirtied, not necessarily the card containing the
38 // modified field itself. For object arrays, however, the barrier *is*
39 // precise; only the card containing the modified element is dirtied.
40 // Any MemRegionClosures used to scan dirty cards should take these
41 // considerations into account.
42
43 class Generation;
44 class OopsInGenClosure;
45 class DirtyCardToOopClosure;
46 class ClearNoncleanCardWrapper;
47 class CardTableRS;
48
49 class CardTableModRefBS: public ModRefBarrierSet {
50 // Some classes get to look at some private stuff.
51 friend class BytecodeInterpreter;
52 friend class VMStructs;
53 friend class CardTableRS;
54 friend class CheckForUnmarkedOops; // Needs access to raw card bytes.
55 friend class SharkBuilder;
56 #ifndef PRODUCT
57 // For debugging.
58 friend class GuaranteeNotModClosure;
59 #endif
60 protected:
61
62 enum CardValues {
63 clean_card = -1,
64 // The mask contains zeros in places for all other values.
65 clean_card_mask = clean_card - 31,
66
67 dirty_card = 0,
316 }
317 public:
318
319 inline void inline_write_ref_array(MemRegion mr) {
320 dirty_MemRegion(mr);
321 }
322 protected:
323 void write_ref_array_work(MemRegion mr) {
324 inline_write_ref_array(mr);
325 }
326 public:
327
328 bool is_aligned(HeapWord* addr) {
329 return is_card_aligned(addr);
330 }
331
332 // *** Card-table-barrier-specific things.
333
334 template <class T> inline void inline_write_ref_field_pre(T* field, oop newVal) {}
335
336 template <class T> inline void inline_write_ref_field(T* field, oop newVal, bool release);
337
338 // These are used by G1, when it uses the card table as a temporary data
339 // structure for card claiming.
340 bool is_card_dirty(size_t card_index) {
341 return _byte_map[card_index] == dirty_card_val();
342 }
343
344 void mark_card_dirty(size_t card_index) {
345 _byte_map[card_index] = dirty_card_val();
346 }
347
348 bool is_card_clean(size_t card_index) {
349 return _byte_map[card_index] == clean_card_val();
350 }
351
352 // Card marking array base (adjusted for heap low boundary)
353 // This would be the 0th element of _byte_map, if the heap started at 0x0.
354 // But since the heap starts at some higher address, this points to somewhere
355 // before the beginning of the actual _byte_map.
356 jbyte* byte_map_base;
|