@@ -46,15 +46,23 @@ class SATBBufferClosure : public StackObj {
46
46
47
47
// A PtrQueue whose elements are (possibly stale) pointers to object heads.
48
48
class SATBMarkQueue : public PtrQueue {
49
+ friend class VMStructs ;
49
50
friend class SATBMarkQueueSet ;
50
51
51
52
private:
53
+ // Per-queue (so thread-local) cache of the SATBMarkQueueSet's
54
+ // active state, to support inline barriers in compiled code.
55
+ bool _active;
56
+
52
57
// Filter out unwanted entries from the buffer.
53
58
inline void filter ();
54
59
55
60
public:
56
61
SATBMarkQueue (SATBMarkQueueSet* qset);
57
62
63
+ bool is_active () const { return _active; }
64
+ void set_active (bool value) { _active = value; }
65
+
58
66
// Process queue entries and free resources.
59
67
void flush ();
60
68
@@ -81,10 +89,10 @@ class SATBMarkQueue: public PtrQueue {
81
89
using PtrQueue::byte_width_of_buf;
82
90
83
91
static ByteSize byte_offset_of_active () {
84
- return PtrQueue::byte_offset_of_active<SATBMarkQueue>( );
92
+ return byte_offset_of (SATBMarkQueue, _active );
85
93
}
86
- using PtrQueue::byte_width_of_active;
87
94
95
+ static ByteSize byte_width_of_active () { return in_ByteSize (sizeof (bool )); }
88
96
};
89
97
90
98
class SATBMarkQueueSet : public PtrQueueSet {
@@ -95,7 +103,9 @@ class SATBMarkQueueSet: public PtrQueueSet {
95
103
// These are rarely (if ever) changed, so same cache line as count.
96
104
size_t _process_completed_buffers_threshold;
97
105
size_t _buffer_enqueue_threshold;
98
- DEFINE_PAD_MINUS_SIZE (2 , DEFAULT_CACHE_LINE_SIZE, 3 * sizeof (size_t ));
106
+ // SATB is only active during marking. Enqueuing is only done when active.
107
+ bool _all_active;
108
+ DEFINE_PAD_MINUS_SIZE (2 , DEFAULT_CACHE_LINE_SIZE, 4 * sizeof (size_t ));
99
109
100
110
BufferNode* get_completed_buffer ();
101
111
void abandon_completed_buffers ();
@@ -121,6 +131,8 @@ class SATBMarkQueueSet: public PtrQueueSet {
121
131
public:
122
132
virtual SATBMarkQueue& satb_queue_for_thread (Thread* const t) const = 0;
123
133
134
+ bool is_active () const { return _all_active; }
135
+
124
136
// Apply "set_active(active)" to all SATB queues in the set. It should be
125
137
// called only with the world stopped. The method will assert that the
126
138
// SATB queues of all threads it visits, as well as the SATB queue
@@ -138,9 +150,11 @@ class SATBMarkQueueSet: public PtrQueueSet {
138
150
// buffer; the leading entries may be excluded due to filtering.
139
151
bool apply_closure_to_completed_buffer (SATBBufferClosure* cl);
140
152
153
+ // When active, add obj to queue by calling enqueue_known_active.
141
154
void enqueue (SATBMarkQueue& queue, oop obj) {
142
155
if (queue.is_active ()) enqueue_known_active (queue, obj);
143
156
}
157
+ // Add obj to queue. This qset and the queue must be active.
144
158
void enqueue_known_active (SATBMarkQueue& queue, oop obj);
145
159
virtual void filter (SATBMarkQueue& queue) = 0;
146
160
virtual void enqueue_completed_buffer (BufferNode* node);
0 commit comments