author | tschatzl |
Wed, 25 Nov 2015 14:43:29 +0100 | |
changeset 34300 | 6075c1e0e913 |
parent 34148 | 6efbc7ffd767 |
child 37065 | c00d1c2ffb7c |
permissions | -rw-r--r-- |
1374 | 1 |
/* |
30255
f43e306ec51e
8075466: SATB queue pre-filter verify found reclaimed humongous object
kbarrett
parents:
28507
diff
changeset
|
2 |
* Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. |
1374 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5082
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5082
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5082
diff
changeset
|
21 |
* questions. |
1374 | 22 |
* |
23 |
*/ |
|
24 |
||
33792 | 25 |
#ifndef SHARE_VM_GC_G1_SATBMARKQUEUE_HPP |
26 |
#define SHARE_VM_GC_G1_SATBMARKQUEUE_HPP |
|
7397 | 27 |
|
30764 | 28 |
#include "gc/g1/ptrQueue.hpp" |
30577
de9fa7ccc1bc
8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents:
30279
diff
changeset
|
29 |
#include "memory/allocation.hpp" |
7397 | 30 |
|
1374 | 31 |
class JavaThread; |
11455
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
7920
diff
changeset
|
32 |
class SATBMarkQueueSet; |
1374 | 33 |
|
30577
de9fa7ccc1bc
8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents:
30279
diff
changeset
|
34 |
// Base class for processing the contents of a SATB buffer. |
de9fa7ccc1bc
8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents:
30279
diff
changeset
|
35 |
class SATBBufferClosure : public StackObj { |
de9fa7ccc1bc
8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents:
30279
diff
changeset
|
36 |
protected: |
de9fa7ccc1bc
8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents:
30279
diff
changeset
|
37 |
~SATBBufferClosure() { } |
de9fa7ccc1bc
8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents:
30279
diff
changeset
|
38 |
|
de9fa7ccc1bc
8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents:
30279
diff
changeset
|
39 |
public: |
de9fa7ccc1bc
8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents:
30279
diff
changeset
|
40 |
// Process the SATB entries in the designated buffer range. |
de9fa7ccc1bc
8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents:
30279
diff
changeset
|
41 |
virtual void do_buffer(void** buffer, size_t size) = 0; |
de9fa7ccc1bc
8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents:
30279
diff
changeset
|
42 |
}; |
de9fa7ccc1bc
8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents:
30279
diff
changeset
|
43 |
|
33792 | 44 |
// A PtrQueue whose elements are (possibly stale) pointers to object heads. |
45 |
class SATBMarkQueue: public PtrQueue { |
|
11455
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
7920
diff
changeset
|
46 |
friend class SATBMarkQueueSet; |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
7920
diff
changeset
|
47 |
|
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
7920
diff
changeset
|
48 |
private: |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
7920
diff
changeset
|
49 |
// Filter out unwanted entries from the buffer. |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
7920
diff
changeset
|
50 |
void filter(); |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
7920
diff
changeset
|
51 |
|
1374 | 52 |
public: |
33792 | 53 |
SATBMarkQueue(SATBMarkQueueSet* qset, bool permanent = false); |
7920 | 54 |
|
28507 | 55 |
// Process queue entries and free resources. |
56 |
void flush(); |
|
11455
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
7920
diff
changeset
|
57 |
|
30577
de9fa7ccc1bc
8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents:
30279
diff
changeset
|
58 |
// Apply cl to the active part of the buffer. |
de9fa7ccc1bc
8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents:
30279
diff
changeset
|
59 |
// Prerequisite: Must be at a safepoint. |
de9fa7ccc1bc
8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents:
30279
diff
changeset
|
60 |
void apply_closure_and_empty(SATBBufferClosure* cl); |
de9fa7ccc1bc
8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents:
30279
diff
changeset
|
61 |
|
7920 | 62 |
// Overrides PtrQueue::should_enqueue_buffer(). See the method's |
63 |
// definition for more information. |
|
64 |
virtual bool should_enqueue_buffer(); |
|
65 |
||
11455
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
7920
diff
changeset
|
66 |
#ifndef PRODUCT |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
7920
diff
changeset
|
67 |
// Helpful for debugging |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
7920
diff
changeset
|
68 |
void print(const char* name); |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
7920
diff
changeset
|
69 |
static void print(const char* name, void** buf, size_t index, size_t sz); |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
7920
diff
changeset
|
70 |
#endif // PRODUCT |
34148
6efbc7ffd767
8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents:
33792
diff
changeset
|
71 |
|
6efbc7ffd767
8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents:
33792
diff
changeset
|
72 |
// Compiler support. |
6efbc7ffd767
8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents:
33792
diff
changeset
|
73 |
static ByteSize byte_offset_of_index() { |
6efbc7ffd767
8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents:
33792
diff
changeset
|
74 |
return PtrQueue::byte_offset_of_index<SATBMarkQueue>(); |
6efbc7ffd767
8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents:
33792
diff
changeset
|
75 |
} |
6efbc7ffd767
8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents:
33792
diff
changeset
|
76 |
using PtrQueue::byte_width_of_index; |
6efbc7ffd767
8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents:
33792
diff
changeset
|
77 |
|
6efbc7ffd767
8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents:
33792
diff
changeset
|
78 |
static ByteSize byte_offset_of_buf() { |
6efbc7ffd767
8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents:
33792
diff
changeset
|
79 |
return PtrQueue::byte_offset_of_buf<SATBMarkQueue>(); |
6efbc7ffd767
8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents:
33792
diff
changeset
|
80 |
} |
6efbc7ffd767
8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents:
33792
diff
changeset
|
81 |
using PtrQueue::byte_width_of_buf; |
6efbc7ffd767
8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents:
33792
diff
changeset
|
82 |
|
6efbc7ffd767
8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents:
33792
diff
changeset
|
83 |
static ByteSize byte_offset_of_active() { |
6efbc7ffd767
8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents:
33792
diff
changeset
|
84 |
return PtrQueue::byte_offset_of_active<SATBMarkQueue>(); |
6efbc7ffd767
8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents:
33792
diff
changeset
|
85 |
} |
6efbc7ffd767
8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents:
33792
diff
changeset
|
86 |
using PtrQueue::byte_width_of_active; |
6efbc7ffd767
8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents:
33792
diff
changeset
|
87 |
|
1374 | 88 |
}; |
89 |
||
90 |
class SATBMarkQueueSet: public PtrQueueSet { |
|
33792 | 91 |
SATBMarkQueue _shared_satb_queue; |
1374 | 92 |
|
5082
19e725a3d2eb
6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents:
4481
diff
changeset
|
93 |
#ifdef ASSERT |
22497 | 94 |
void dump_active_states(bool expected_active); |
95 |
void verify_active_states(bool expected_active); |
|
5082
19e725a3d2eb
6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents:
4481
diff
changeset
|
96 |
#endif // ASSERT |
1374 | 97 |
|
98 |
public: |
|
99 |
SATBMarkQueueSet(); |
|
100 |
||
101 |
void initialize(Monitor* cbl_mon, Mutex* fl_lock, |
|
4481 | 102 |
int process_completed_threshold, |
103 |
Mutex* lock); |
|
1374 | 104 |
|
105 |
static void handle_zero_index_for_thread(JavaThread* t); |
|
106 |
||
22497 | 107 |
// Apply "set_active(active)" to all SATB queues in the set. It should be |
5082
19e725a3d2eb
6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents:
4481
diff
changeset
|
108 |
// called only with the world stopped. The method will assert that the |
19e725a3d2eb
6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents:
4481
diff
changeset
|
109 |
// SATB queues of all threads it visits, as well as the SATB queue |
19e725a3d2eb
6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents:
4481
diff
changeset
|
110 |
// set itself, has an active value same as expected_active. |
22497 | 111 |
void set_active_all_threads(bool active, bool expected_active); |
1374 | 112 |
|
11455
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
7920
diff
changeset
|
113 |
// Filter all the currently-active SATB buffers. |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
7920
diff
changeset
|
114 |
void filter_thread_buffers(); |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
7920
diff
changeset
|
115 |
|
30577
de9fa7ccc1bc
8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents:
30279
diff
changeset
|
116 |
// If there exists some completed buffer, pop and process it, and |
de9fa7ccc1bc
8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents:
30279
diff
changeset
|
117 |
// return true. Otherwise return false. Processing a buffer |
de9fa7ccc1bc
8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents:
30279
diff
changeset
|
118 |
// consists of applying the closure to the buffer range starting |
de9fa7ccc1bc
8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents:
30279
diff
changeset
|
119 |
// with the first non-NULL entry to the end of the buffer; the |
de9fa7ccc1bc
8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents:
30279
diff
changeset
|
120 |
// leading entries may be NULL due to filtering. |
de9fa7ccc1bc
8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents:
30279
diff
changeset
|
121 |
bool apply_closure_to_completed_buffer(SATBBufferClosure* cl); |
1374 | 122 |
|
11455
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
7920
diff
changeset
|
123 |
#ifndef PRODUCT |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
7920
diff
changeset
|
124 |
// Helpful for debugging |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
7920
diff
changeset
|
125 |
void print_all(const char* msg); |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
7920
diff
changeset
|
126 |
#endif // PRODUCT |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
7920
diff
changeset
|
127 |
|
33792 | 128 |
SATBMarkQueue* shared_satb_queue() { return &_shared_satb_queue; } |
1374 | 129 |
|
130 |
// If a marking is being abandoned, reset any unprocessed log buffers. |
|
131 |
void abandon_partial_marking(); |
|
132 |
}; |
|
7397 | 133 |
|
33792 | 134 |
#endif // SHARE_VM_GC_G1_SATBMARKQUEUE_HPP |