annotate src/share/vm/memory/sharedHeap.hpp @ 20543:e7d0505c8a30

8059758: Footprint regressions with JDK-8038423 Summary: Changes in JDK-8038423 always initialize (zero out) virtual memory used for auxiliary data structures. This causes a footprint regression for G1 in startup benchmarks. This is because they do not touch that memory at all, so the operating system does not actually commit these pages. The fix is to, if the initialization value of the data structures matches the default value of just committed memory (=0), do not do anything. Reviewed-by: jwilhelm, brutisso
author tschatzl
date Fri, 10 Oct 2014 15:51:58 +0200
parents 2c6ef90f030a
children 7848fc12602b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
17467
55fb97c4c58d 8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents: 11096
diff changeset
2 * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1088
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1088
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: 1088
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
25 #ifndef SHARE_VM_MEMORY_SHAREDHEAP_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
26 #define SHARE_VM_MEMORY_SHAREDHEAP_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
28 #include "gc_interface/collectedHeap.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
29 #include "memory/generation.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
30
0
a61af66fc99e Initial load
duke
parents:
diff changeset
31 // A "SharedHeap" is an implementation of a java heap for HotSpot. This
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // is an abstract class: there may be many different kinds of heaps. This
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // class defines the functions that a heap must implement, and contains
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // infrastructure common to all heaps.
a61af66fc99e Initial load
duke
parents:
diff changeset
35
a61af66fc99e Initial load
duke
parents:
diff changeset
36 class Generation;
a61af66fc99e Initial load
duke
parents:
diff changeset
37 class BarrierSet;
a61af66fc99e Initial load
duke
parents:
diff changeset
38 class GenRemSet;
a61af66fc99e Initial load
duke
parents:
diff changeset
39 class Space;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 class SpaceClosure;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 class OopClosure;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 class OopsInGenClosure;
a61af66fc99e Initial load
duke
parents:
diff changeset
43 class ObjectClosure;
a61af66fc99e Initial load
duke
parents:
diff changeset
44 class SubTasksDone;
a61af66fc99e Initial load
duke
parents:
diff changeset
45 class WorkGang;
1833
8b10f48633dc 6984287: Regularize how GC parallel workers are specified.
jmasa
parents: 1552
diff changeset
46 class FlexibleWorkGang;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
47 class CollectorPolicy;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 4728
diff changeset
48 class KlassClosure;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
49
4095
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
50 // Note on use of FlexibleWorkGang's for GC.
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
51 // There are three places where task completion is determined.
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
52 // In
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
53 // 1) ParallelTaskTerminator::offer_termination() where _n_threads
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
54 // must be set to the correct value so that count of workers that
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
55 // have offered termination will exactly match the number
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
56 // working on the task. Tasks such as those derived from GCTask
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
57 // use ParallelTaskTerminator's. Tasks that want load balancing
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
58 // by work stealing use this method to gauge completion.
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
59 // 2) SubTasksDone has a variable _n_threads that is used in
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
60 // all_tasks_completed() to determine completion. all_tasks_complete()
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
61 // counts the number of tasks that have been done and then reset
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
62 // the SubTasksDone so that it can be used again. When the number of
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
63 // tasks is set to the number of GC workers, then _n_threads must
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
64 // be set to the number of active GC workers. G1CollectedHeap,
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
65 // HRInto_G1RemSet, GenCollectedHeap and SharedHeap have SubTasksDone.
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
66 // This seems too many.
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
67 // 3) SequentialSubTasksDone has an _n_threads that is used in
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
68 // a way similar to SubTasksDone and has the same dependency on the
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
69 // number of active GC workers. CompactibleFreeListSpace and Space
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
70 // have SequentialSubTasksDone's.
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
71 // Example of using SubTasksDone and SequentialSubTasksDone
20278
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
72 // G1CollectedHeap::g1_process_roots()
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
73 // to SharedHeap::process_roots() and uses
4095
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
74 // SubTasksDone* _process_strong_tasks to claim tasks.
20278
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
75 // process_roots() calls
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 4728
diff changeset
76 // rem_set()->younger_refs_iterate()
4095
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
77 // to scan the card table and which eventually calls down into
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
78 // CardTableModRefBS::par_non_clean_card_iterate_work(). This method
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
79 // uses SequentialSubTasksDone* _pst to claim tasks.
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
80 // Both SubTasksDone and SequentialSubTasksDone call their method
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
81 // all_tasks_completed() to count the number of GC workers that have
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
82 // finished their work. That logic is "when all the workers are
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
83 // finished the tasks are finished".
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
84 //
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
85 // The pattern that appears in the code is to set _n_threads
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
86 // to a value > 1 before a task that you would like executed in parallel
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
87 // and then to set it to 0 after that task has completed. A value of
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
88 // 0 is a "special" value in set_n_threads() which translates to
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
89 // setting _n_threads to 1.
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
90 //
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
91 // Some code uses _n_terminiation to decide if work should be done in
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
92 // parallel. The notorious possibly_parallel_oops_do() in threads.cpp
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
93 // is an example of such code. Look for variable "is_par" for other
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
94 // examples.
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
95 //
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
96 // The active_workers is not reset to 0 after a parallel phase. It's
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
97 // value may be used in later phases and in one instance at least
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
98 // (the parallel remark) it has to be used (the parallel remark depends
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
99 // on the partitioning done in the previous parallel scavenge).
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
100
0
a61af66fc99e Initial load
duke
parents:
diff changeset
101 class SharedHeap : public CollectedHeap {
a61af66fc99e Initial load
duke
parents:
diff changeset
102 friend class VMStructs;
a61af66fc99e Initial load
duke
parents:
diff changeset
103
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
104 friend class VM_GC_Operation;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
105 friend class VM_CGC_Operation;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
106
0
a61af66fc99e Initial load
duke
parents:
diff changeset
107 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
108 // For claiming strong_roots tasks.
a61af66fc99e Initial load
duke
parents:
diff changeset
109 SubTasksDone* _process_strong_tasks;
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // There should be only a single instance of "SharedHeap" in a program.
a61af66fc99e Initial load
duke
parents:
diff changeset
113 // This is enforced with the protected constructor below, which will also
a61af66fc99e Initial load
duke
parents:
diff changeset
114 // set the static pointer "_sh" to that instance.
a61af66fc99e Initial load
duke
parents:
diff changeset
115 static SharedHeap* _sh;
a61af66fc99e Initial load
duke
parents:
diff changeset
116
a61af66fc99e Initial load
duke
parents:
diff changeset
117 // and the Gen Remembered Set, at least one good enough to scan the perm
a61af66fc99e Initial load
duke
parents:
diff changeset
118 // gen.
a61af66fc99e Initial load
duke
parents:
diff changeset
119 GenRemSet* _rem_set;
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121 // A gc policy, controls global gc resource issues
a61af66fc99e Initial load
duke
parents:
diff changeset
122 CollectorPolicy *_collector_policy;
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124 // See the discussion below, in the specification of the reader function
a61af66fc99e Initial load
duke
parents:
diff changeset
125 // for this variable.
a61af66fc99e Initial load
duke
parents:
diff changeset
126 int _strong_roots_parity;
a61af66fc99e Initial load
duke
parents:
diff changeset
127
a61af66fc99e Initial load
duke
parents:
diff changeset
128 // If we're doing parallel GC, use this gang of threads.
1833
8b10f48633dc 6984287: Regularize how GC parallel workers are specified.
jmasa
parents: 1552
diff changeset
129 FlexibleWorkGang* _workers;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
130
a61af66fc99e Initial load
duke
parents:
diff changeset
131 // Full initialization is done in a concrete subtype's "initialize"
a61af66fc99e Initial load
duke
parents:
diff changeset
132 // function.
a61af66fc99e Initial load
duke
parents:
diff changeset
133 SharedHeap(CollectorPolicy* policy_);
a61af66fc99e Initial load
duke
parents:
diff changeset
134
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
135 // Returns true if the calling thread holds the heap lock,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
136 // or the calling thread is a par gc thread and the heap_lock is held
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
137 // by the vm thread doing a gc operation.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
138 bool heap_lock_held_for_gc();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
139 // True if the heap_lock is held by the a non-gc thread invoking a gc
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
140 // operation.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
141 bool _thread_holds_heap_lock_for_gc;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
142
0
a61af66fc99e Initial load
duke
parents:
diff changeset
143 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
144 static SharedHeap* heap() { return _sh; }
a61af66fc99e Initial load
duke
parents:
diff changeset
145
a61af66fc99e Initial load
duke
parents:
diff changeset
146 void set_barrier_set(BarrierSet* bs);
4095
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
147 SubTasksDone* process_strong_tasks() { return _process_strong_tasks; }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
148
a61af66fc99e Initial load
duke
parents:
diff changeset
149 // Does operations required after initialization has been done.
a61af66fc99e Initial load
duke
parents:
diff changeset
150 virtual void post_initialize();
a61af66fc99e Initial load
duke
parents:
diff changeset
151
a61af66fc99e Initial load
duke
parents:
diff changeset
152 // Initialization of ("weak") reference processing support
a61af66fc99e Initial load
duke
parents:
diff changeset
153 virtual void ref_processing_init();
a61af66fc99e Initial load
duke
parents:
diff changeset
154
a61af66fc99e Initial load
duke
parents:
diff changeset
155 // This function returns the "GenRemSet" object that allows us to scan
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 4728
diff changeset
156 // generations in a fully generational heap.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
157 GenRemSet* rem_set() { return _rem_set; }
a61af66fc99e Initial load
duke
parents:
diff changeset
158
a61af66fc99e Initial load
duke
parents:
diff changeset
159 // Iteration functions.
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 4728
diff changeset
160 void oop_iterate(ExtendedOopClosure* cl) = 0;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
161
a61af66fc99e Initial load
duke
parents:
diff changeset
162 // Iterate over all spaces in use in the heap, in an undefined order.
a61af66fc99e Initial load
duke
parents:
diff changeset
163 virtual void space_iterate(SpaceClosure* cl) = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
164
a61af66fc99e Initial load
duke
parents:
diff changeset
165 // A SharedHeap will contain some number of spaces. This finds the
a61af66fc99e Initial load
duke
parents:
diff changeset
166 // space whose reserved area contains the given address, or else returns
a61af66fc99e Initial load
duke
parents:
diff changeset
167 // NULL.
a61af66fc99e Initial load
duke
parents:
diff changeset
168 virtual Space* space_containing(const void* addr) const = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
169
a61af66fc99e Initial load
duke
parents:
diff changeset
170 bool no_gc_in_progress() { return !is_gc_active(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
171
a61af66fc99e Initial load
duke
parents:
diff changeset
172 // Some collectors will perform "process_strong_roots" in parallel.
a61af66fc99e Initial load
duke
parents:
diff changeset
173 // Such a call will involve claiming some fine-grained tasks, such as
a61af66fc99e Initial load
duke
parents:
diff changeset
174 // scanning of threads. To make this process simpler, we provide the
a61af66fc99e Initial load
duke
parents:
diff changeset
175 // "strong_roots_parity()" method. Collectors that start parallel tasks
a61af66fc99e Initial load
duke
parents:
diff changeset
176 // whose threads invoke "process_strong_roots" must
a61af66fc99e Initial load
duke
parents:
diff changeset
177 // call "change_strong_roots_parity" in sequential code starting such a
a61af66fc99e Initial load
duke
parents:
diff changeset
178 // task. (This also means that a parallel thread may only call
a61af66fc99e Initial load
duke
parents:
diff changeset
179 // process_strong_roots once.)
a61af66fc99e Initial load
duke
parents:
diff changeset
180 //
20278
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
181 // For calls to process_roots by sequential code, the parity is
0
a61af66fc99e Initial load
duke
parents:
diff changeset
182 // updated automatically.
a61af66fc99e Initial load
duke
parents:
diff changeset
183 //
a61af66fc99e Initial load
duke
parents:
diff changeset
184 // The idea is that objects representing fine-grained tasks, such as
a61af66fc99e Initial load
duke
parents:
diff changeset
185 // threads, will contain a "parity" field. A task will is claimed in the
20278
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
186 // current "process_roots" call only if its parity field is the
0
a61af66fc99e Initial load
duke
parents:
diff changeset
187 // same as the "strong_roots_parity"; task claiming is accomplished by
a61af66fc99e Initial load
duke
parents:
diff changeset
188 // updating the parity field to the strong_roots_parity with a CAS.
a61af66fc99e Initial load
duke
parents:
diff changeset
189 //
a61af66fc99e Initial load
duke
parents:
diff changeset
190 // If the client meats this spec, then strong_roots_parity() will have
a61af66fc99e Initial load
duke
parents:
diff changeset
191 // the following properties:
a61af66fc99e Initial load
duke
parents:
diff changeset
192 // a) to return a different value than was returned before the last
a61af66fc99e Initial load
duke
parents:
diff changeset
193 // call to change_strong_roots_parity, and
a61af66fc99e Initial load
duke
parents:
diff changeset
194 // c) to never return a distinguished value (zero) with which such
a61af66fc99e Initial load
duke
parents:
diff changeset
195 // task-claiming variables may be initialized, to indicate "never
a61af66fc99e Initial load
duke
parents:
diff changeset
196 // claimed".
989
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 579
diff changeset
197 public:
0
a61af66fc99e Initial load
duke
parents:
diff changeset
198 int strong_roots_parity() { return _strong_roots_parity; }
a61af66fc99e Initial load
duke
parents:
diff changeset
199
20278
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
200 // Call these in sequential code around process_roots.
989
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 579
diff changeset
201 // strong_roots_prologue calls change_strong_roots_parity, if
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 579
diff changeset
202 // parallel tasks are enabled.
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 579
diff changeset
203 class StrongRootsScope : public MarkingCodeBlobClosure::MarkScope {
20278
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
204 // Used to implement the Thread work barrier.
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
205 static Monitor* _lock;
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
206
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
207 SharedHeap* _sh;
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
208 volatile jint _n_workers_done_with_threads;
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
209
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
210 public:
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
211 StrongRootsScope(SharedHeap* heap, bool activate = true);
989
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 579
diff changeset
212 ~StrongRootsScope();
20278
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
213
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
214 // Mark that this thread is done with the Threads work.
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
215 void mark_worker_done_with_threads(uint n_workers);
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
216 // Wait until all n_workers are done with the Threads work.
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
217 void wait_until_all_workers_done_with_threads(uint n_workers);
989
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 579
diff changeset
218 };
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 579
diff changeset
219 friend class StrongRootsScope;
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 579
diff changeset
220
20278
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
221 // The current active StrongRootScope
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
222 StrongRootsScope* _strong_roots_scope;
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
223
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
224 StrongRootsScope* active_strong_roots_scope() const;
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
225
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
226 private:
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
227 void register_strong_roots_scope(StrongRootsScope* scope);
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
228 void unregister_strong_roots_scope(StrongRootsScope* scope);
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
229 void change_strong_roots_parity();
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
230
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
231 public:
0
a61af66fc99e Initial load
duke
parents:
diff changeset
232 enum ScanningOption {
20278
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
233 SO_None = 0x0,
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
234 SO_AllCodeCache = 0x8,
20254
9fec19bb0659 8032379: Remove the is_scavenging flag to process_strong_roots
mgerdin
parents: 17467
diff changeset
235 SO_ScavengeCodeCache = 0x10
0
a61af66fc99e Initial load
duke
parents:
diff changeset
236 };
a61af66fc99e Initial load
duke
parents:
diff changeset
237
1833
8b10f48633dc 6984287: Regularize how GC parallel workers are specified.
jmasa
parents: 1552
diff changeset
238 FlexibleWorkGang* workers() const { return _workers; }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
239
a61af66fc99e Initial load
duke
parents:
diff changeset
240 // Invoke the "do_oop" method the closure "roots" on all root locations.
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 4728
diff changeset
241 // The "so" argument determines which roots the closure is applied to:
0
a61af66fc99e Initial load
duke
parents:
diff changeset
242 // "SO_None" does none;
20254
9fec19bb0659 8032379: Remove the is_scavenging flag to process_strong_roots
mgerdin
parents: 17467
diff changeset
243 // "SO_AllCodeCache" applies the closure to all elements of the CodeCache.
9fec19bb0659 8032379: Remove the is_scavenging flag to process_strong_roots
mgerdin
parents: 17467
diff changeset
244 // "SO_ScavengeCodeCache" applies the closure to elements on the scavenge root list in the CodeCache.
20278
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
245 void process_roots(bool activate_scope,
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
246 ScanningOption so,
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
247 OopClosure* strong_roots,
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
248 OopClosure* weak_roots,
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
249 CLDClosure* strong_cld_closure,
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
250 CLDClosure* weak_cld_closure,
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
251 CodeBlobClosure* code_roots);
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
252 void process_all_roots(bool activate_scope,
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
253 ScanningOption so,
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
254 OopClosure* roots,
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
255 CLDClosure* cld_closure,
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
256 CodeBlobClosure* code_roots);
989
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 579
diff changeset
257 void process_strong_roots(bool activate_scope,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
258 ScanningOption so,
a61af66fc99e Initial load
duke
parents:
diff changeset
259 OopClosure* roots,
20278
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
260 CLDClosure* cld_closure,
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
261 CodeBlobClosure* code_roots);
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
262
0
a61af66fc99e Initial load
duke
parents:
diff changeset
263
20258
64ac9c55d666 8034764: Use process_strong_roots to adjust the StringTable
stefank
parents: 20257
diff changeset
264 // Apply "root_closure" to the JNI weak roots..
20257
7426d8d76305 8034761: Remove the do_code_roots parameter from process_strong_roots
stefank
parents: 20254
diff changeset
265 void process_weak_roots(OopClosure* root_closure);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
266
a61af66fc99e Initial load
duke
parents:
diff changeset
267 // The functions below are helper functions that a subclass of
a61af66fc99e Initial load
duke
parents:
diff changeset
268 // "SharedHeap" can use in the implementation of its virtual
a61af66fc99e Initial load
duke
parents:
diff changeset
269 // functions.
a61af66fc99e Initial load
duke
parents:
diff changeset
270
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
271 public:
0
a61af66fc99e Initial load
duke
parents:
diff changeset
272
a61af66fc99e Initial load
duke
parents:
diff changeset
273 // Do anything common to GC's.
a61af66fc99e Initial load
duke
parents:
diff changeset
274 virtual void gc_prologue(bool full) = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
275 virtual void gc_epilogue(bool full) = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
276
4095
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
277 // Sets the number of parallel threads that will be doing tasks
20278
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20264
diff changeset
278 // (such as process roots) subsequently.
4728
441e946dc1af 7121618: Change type of number of GC workers to unsigned int.
jmasa
parents: 4095
diff changeset
279 virtual void set_par_threads(uint t);
4095
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
280
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
281 int n_termination();
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
282 void set_n_termination(int t);
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 3293
diff changeset
283
0
a61af66fc99e Initial load
duke
parents:
diff changeset
284 //
a61af66fc99e Initial load
duke
parents:
diff changeset
285 // New methods from CollectedHeap
a61af66fc99e Initial load
duke
parents:
diff changeset
286 //
a61af66fc99e Initial load
duke
parents:
diff changeset
287
a61af66fc99e Initial load
duke
parents:
diff changeset
288 // Some utilities.
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
289 void print_size_transition(outputStream* out,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
290 size_t bytes_before,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
291 size_t bytes_after,
a61af66fc99e Initial load
duke
parents:
diff changeset
292 size_t capacity);
a61af66fc99e Initial load
duke
parents:
diff changeset
293 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
294
20257
7426d8d76305 8034761: Remove the do_code_roots parameter from process_strong_roots
stefank
parents: 20254
diff changeset
295 inline SharedHeap::ScanningOption operator|(SharedHeap::ScanningOption so0, SharedHeap::ScanningOption so1) {
7426d8d76305 8034761: Remove the do_code_roots parameter from process_strong_roots
stefank
parents: 20254
diff changeset
296 return static_cast<SharedHeap::ScanningOption>(static_cast<int>(so0) | static_cast<int>(so1));
7426d8d76305 8034761: Remove the do_code_roots parameter from process_strong_roots
stefank
parents: 20254
diff changeset
297 }
7426d8d76305 8034761: Remove the do_code_roots parameter from process_strong_roots
stefank
parents: 20254
diff changeset
298
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
299 #endif // SHARE_VM_MEMORY_SHAREDHEAP_HPP