Mercurial > hg > truffle
annotate src/share/vm/gc_implementation/g1/bufferingOopClosure.hpp @ 20417:d35872270666
8057658: Enable G1 FullGC extensions
Summary: Refactored the G1 FullGC code to enable it to be extended.
Reviewed-by: mgerdin, brutisso
author | sjohanss |
---|---|
date | Tue, 09 Sep 2014 00:05:25 +0200 |
parents | 02e61cf08ab3 |
children | 7848fc12602b |
rev | line source |
---|---|
342 | 1 /* |
20255
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
2 * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. |
342 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
845
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
845
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
845
diff
changeset
|
21 * questions. |
342 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_BUFFERINGOOPCLOSURE_HPP |
26 #define SHARE_VM_GC_IMPLEMENTATION_G1_BUFFERINGOOPCLOSURE_HPP | |
27 | |
20255
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
28 #include "memory/iterator.hpp" |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
29 #include "oops/oopsHierarchy.hpp" |
1972 | 30 #include "runtime/os.hpp" |
20255
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
31 #include "utilities/debug.hpp" |
1972 | 32 |
342 | 33 // A BufferingOops closure tries to separate out the cost of finding roots |
34 // from the cost of applying closures to them. It maintains an array of | |
35 // ref-containing locations. Until the array is full, applying the closure | |
36 // to an oop* merely records that location in the array. Since this | |
37 // closure app cost is small, an elapsed timer can approximately attribute | |
38 // all of this cost to the cost of finding the roots. When the array fills | |
39 // up, the wrapped closure is applied to all elements, keeping track of | |
40 // this elapsed time of this process, and leaving the array empty. | |
41 // The caller must be sure to call "done" to process any unprocessed | |
42 // buffered entriess. | |
43 | |
44 class BufferingOopClosure: public OopClosure { | |
20255
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
45 friend class TestBufferingOopClosure; |
342 | 46 protected: |
20255
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
47 static const size_t BufferLength = 1024; |
342 | 48 |
20255
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
49 // We need to know if the buffered addresses contain oops or narrowOops. |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
50 // We can't tag the addresses the way StarTask does, because we need to |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
51 // be able to handle unaligned addresses coming from oops embedded in code. |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
52 // |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
53 // The addresses for the full-sized oops are filled in from the bottom, |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
54 // while the addresses for the narrowOops are filled in from the top. |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
55 OopOrNarrowOopStar _buffer[BufferLength]; |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
56 OopOrNarrowOopStar* _oop_top; |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
57 OopOrNarrowOopStar* _narrowOop_bottom; |
342 | 58 |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
342
diff
changeset
|
59 OopClosure* _oc; |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
342
diff
changeset
|
60 double _closure_app_seconds; |
342 | 61 |
20255
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
62 |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
63 bool is_buffer_empty() { |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
64 return _oop_top == _buffer && _narrowOop_bottom == (_buffer + BufferLength - 1); |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
65 } |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
66 |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
67 bool is_buffer_full() { |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
68 return _narrowOop_bottom < _oop_top; |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
69 } |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
70 |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
71 // Process addresses containing full-sized oops. |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
72 void process_oops() { |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
73 for (OopOrNarrowOopStar* curr = _buffer; curr < _oop_top; ++curr) { |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
74 _oc->do_oop((oop*)(*curr)); |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
75 } |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
76 _oop_top = _buffer; |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
77 } |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
78 |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
79 // Process addresses containing narrow oops. |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
80 void process_narrowOops() { |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
81 for (OopOrNarrowOopStar* curr = _buffer + BufferLength - 1; curr > _narrowOop_bottom; --curr) { |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
82 _oc->do_oop((narrowOop*)(*curr)); |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
83 } |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
84 _narrowOop_bottom = _buffer + BufferLength - 1; |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
85 } |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
86 |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
87 // Apply the closure to all oops and clear the buffer. |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
88 // Accumulate the time it took. |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
89 void process_buffer() { |
342 | 90 double start = os::elapsedTime(); |
20255
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
91 |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
92 process_oops(); |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
93 process_narrowOops(); |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
94 |
342 | 95 _closure_app_seconds += (os::elapsedTime() - start); |
96 } | |
97 | |
20255
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
98 void process_buffer_if_full() { |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
99 if (is_buffer_full()) { |
342 | 100 process_buffer(); |
101 } | |
20255
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
102 } |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
103 |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
104 void add_narrowOop(narrowOop* p) { |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
105 assert(!is_buffer_full(), "Buffer should not be full"); |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
106 *_narrowOop_bottom = (OopOrNarrowOopStar)p; |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
107 _narrowOop_bottom--; |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
108 } |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
109 |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
110 void add_oop(oop* p) { |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
111 assert(!is_buffer_full(), "Buffer should not be full"); |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
112 *_oop_top = (OopOrNarrowOopStar)p; |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
113 _oop_top++; |
342 | 114 } |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
342
diff
changeset
|
115 |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
342
diff
changeset
|
116 public: |
20255
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
117 virtual void do_oop(narrowOop* p) { |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
118 process_buffer_if_full(); |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
119 add_narrowOop(p); |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
120 } |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
342
diff
changeset
|
121 |
20255
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
122 virtual void do_oop(oop* p) { |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
123 process_buffer_if_full(); |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
124 add_oop(p); |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
125 } |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
126 |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
127 void done() { |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
128 if (!is_buffer_empty()) { |
342 | 129 process_buffer(); |
130 } | |
131 } | |
20255
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
132 |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
133 double closure_app_seconds() { |
342 | 134 return _closure_app_seconds; |
135 } | |
20255
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
136 |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
137 BufferingOopClosure(OopClosure *oc) : |
342 | 138 _oc(oc), |
20255
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
139 _oop_top(_buffer), |
02e61cf08ab3
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
17636
diff
changeset
|
140 _narrowOop_bottom(_buffer + BufferLength - 1), |
342 | 141 _closure_app_seconds(0.0) { } |
142 }; | |
143 | |
1972 | 144 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_BUFFERINGOOPCLOSURE_HPP |