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 // Closures used to scan dirty cards should take these
42 // considerations into account.
43
44 class CardTableBarrierSet: public ModRefBarrierSet {
45 // Some classes get to look at some private stuff.
46 friend class VMStructs;
47 protected:
48
49 // Used in support of ReduceInitialCardMarks; only consulted if COMPILER2
50 // or INCLUDE_JVMCI is being used
51 bool _defer_initial_card_mark;
52 CardTable* _card_table;
53
54 CardTableBarrierSet(BarrierSetAssembler* barrier_set_assembler,
55 BarrierSetC1* barrier_set_c1,
56 CardTable* card_table,
57 const BarrierSet::FakeRtti& fake_rtti);
58
59 public:
60 CardTableBarrierSet(CardTable* card_table);
61 ~CardTableBarrierSet();
62
63 CardTable* card_table() const { return _card_table; }
64
65 virtual void initialize();
66
67 void write_region(MemRegion mr) {
68 invalidate(mr);
69 }
70
71 void write_ref_array_work(MemRegion mr);
72
73 public:
74 // Record a reference update. Note that these versions are precise!
75 // The scanning code has to handle the fact that the write barrier may be
76 // either precise or imprecise. We make non-virtual inline variants of
77 // these functions here for performance.
78 template <DecoratorSet decorators, typename T>
79 void write_ref_field_post(T* field, oop newVal);
80
81 virtual void invalidate(MemRegion mr);
82
83 // ReduceInitialCardMarks
84 void initialize_deferred_card_mark_barriers();
85
86 // If the CollectedHeap was asked to defer a store barrier above,
87 // this informs it to flush such a deferred store barrier to the
88 // remembered set.
89 void flush_deferred_card_mark_barrier(JavaThread* thread);
90
91 // Can a compiler initialize a new object without store barriers?
92 // This permission only extends from the creation of a new object
93 // via a TLAB up to the first subsequent safepoint. If such permission
94 // is granted for this heap type, the compiler promises to call
95 // defer_store_barrier() below on any slow path allocation of
96 // a new object for which such initializing store barriers will
97 // have been elided. G1, like CMS, allows this, but should be
98 // ready to provide a compensating write barrier as necessary
99 // if that storage came out of a non-young region. The efficiency
100 // of this implementation depends crucially on being able to
101 // answer very efficiently in constant time whether a piece of
102 // storage in the heap comes from a young region or not.
103 // See ReduceInitialCardMarks.
104 virtual bool can_elide_tlab_store_barriers() const {
105 return true;
106 }
107
108 // If a compiler is eliding store barriers for TLAB-allocated objects,
109 // we will be informed of a slow-path allocation by a call
110 // to on_slowpath_allocation_exit() below. Such a call precedes the
111 // initialization of the object itself, and no post-store-barriers will
112 // be issued. Some heap types require that the barrier strictly follows
113 // the initializing stores. (This is currently implemented by deferring the
114 // barrier until the next slow-path allocation or gc-related safepoint.)
115 // This interface answers whether a particular barrier type needs the card
116 // mark to be thus strictly sequenced after the stores.
117 virtual bool card_mark_must_follow_store() const;
118
119 virtual void on_slowpath_allocation_exit(JavaThread* thread, oop new_obj);
120 virtual void on_thread_detach(JavaThread* thread);
121
122 virtual void make_parsable(JavaThread* thread) { flush_deferred_card_mark_barrier(thread); }
123
124 virtual void print_on(outputStream* st) const;
125
|
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 // Closures used to scan dirty cards should take these
42 // considerations into account.
43
44 class CardTableBarrierSet: public ModRefBarrierSet {
45 // Some classes get to look at some private stuff.
46 friend class VMStructs;
47 protected:
48
49 // Used in support of ReduceInitialCardMarks; only consulted if COMPILER2
50 // or INCLUDE_JVMCI is being used
51 bool _defer_initial_card_mark;
52 CardTable* _card_table;
53
54 CardTableBarrierSet(BarrierSetAssembler* barrier_set_assembler,
55 BarrierSetC1* barrier_set_c1,
56 BarrierSetC2* barrier_set_c2,
57 CardTable* card_table,
58 const BarrierSet::FakeRtti& fake_rtti);
59
60 public:
61 CardTableBarrierSet(CardTable* card_table);
62 ~CardTableBarrierSet();
63
64 CardTable* card_table() const { return _card_table; }
65
66 virtual void initialize();
67
68 void write_region(MemRegion mr) {
69 invalidate(mr);
70 }
71
72 void write_ref_array_work(MemRegion mr);
73
74 public:
75 // Record a reference update. Note that these versions are precise!
76 // The scanning code has to handle the fact that the write barrier may be
77 // either precise or imprecise. We make non-virtual inline variants of
78 // these functions here for performance.
79 template <DecoratorSet decorators, typename T>
80 void write_ref_field_post(T* field, oop newVal);
81
82 virtual void invalidate(MemRegion mr);
83
84 // ReduceInitialCardMarks
85 void initialize_deferred_card_mark_barriers();
86
87 // If the CollectedHeap was asked to defer a store barrier above,
88 // this informs it to flush such a deferred store barrier to the
89 // remembered set.
90 void flush_deferred_card_mark_barrier(JavaThread* thread);
91
92 // If a compiler is eliding store barriers for TLAB-allocated objects,
93 // we will be informed of a slow-path allocation by a call
94 // to on_slowpath_allocation_exit() below. Such a call precedes the
95 // initialization of the object itself, and no post-store-barriers will
96 // be issued. Some heap types require that the barrier strictly follows
97 // the initializing stores. (This is currently implemented by deferring the
98 // barrier until the next slow-path allocation or gc-related safepoint.)
99 // This interface answers whether a particular barrier type needs the card
100 // mark to be thus strictly sequenced after the stores.
101 virtual bool card_mark_must_follow_store() const;
102
103 virtual void on_slowpath_allocation_exit(JavaThread* thread, oop new_obj);
104 virtual void on_thread_detach(JavaThread* thread);
105
106 virtual void make_parsable(JavaThread* thread) { flush_deferred_card_mark_barrier(thread); }
107
108 virtual void print_on(outputStream* st) const;
109
|