annotate src/share/vm/gc_implementation/parallelScavenge/psScavenge.hpp @ 10405:f2110083203d

8005849: JEP 167: Event-Based JVM Tracing Reviewed-by: acorn, coleenp, sla Contributed-by: Karen Kinnear <karen.kinnear@oracle.com>, Bengt Rutisson <bengt.rutisson@oracle.com>, Calvin Cheung <calvin.cheung@oracle.com>, Erik Gahlin <erik.gahlin@oracle.com>, Erik Helin <erik.helin@oracle.com>, Jesper Wilhelmsson <jesper.wilhelmsson@oracle.com>, Keith McGuigan <keith.mcguigan@oracle.com>, Mattias Tobiasson <mattias.tobiasson@oracle.com>, Markus Gronlund <markus.gronlund@oracle.com>, Mikael Auno <mikael.auno@oracle.com>, Nils Eliasson <nils.eliasson@oracle.com>, Nils Loodin <nils.loodin@oracle.com>, Rickard Backman <rickard.backman@oracle.com>, Staffan Larsen <staffan.larsen@oracle.com>, Stefan Karlsson <stefan.karlsson@oracle.com>, Yekaterina Kantserova <yekaterina.kantserova@oracle.com>
author sla
date Mon, 10 Jun 2013 11:30:51 +0200
parents 47bdfb3d010f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
10405
f2110083203d 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 10370
diff changeset
2 * Copyright (c) 2002, 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: 196
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 196
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: 196
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: 1836
diff changeset
25 #ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSSCAVENGE_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1836
diff changeset
26 #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSSCAVENGE_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1836
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1836
diff changeset
28 #include "gc_implementation/parallelScavenge/cardTableExtension.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1836
diff changeset
29 #include "gc_implementation/parallelScavenge/psVirtualspace.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1836
diff changeset
30 #include "gc_implementation/shared/collectorCounters.hpp"
10405
f2110083203d 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 10370
diff changeset
31 #include "gc_implementation/shared/gcTrace.hpp"
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1836
diff changeset
32 #include "memory/allocation.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1836
diff changeset
33 #include "oops/oop.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1836
diff changeset
34 #include "utilities/stack.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1836
diff changeset
35
0
a61af66fc99e Initial load
duke
parents:
diff changeset
36 class GCTaskManager;
a61af66fc99e Initial load
duke
parents:
diff changeset
37 class GCTaskQueue;
a61af66fc99e Initial load
duke
parents:
diff changeset
38 class OopStack;
a61af66fc99e Initial load
duke
parents:
diff changeset
39 class ReferenceProcessor;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 class ParallelScavengeHeap;
10405
f2110083203d 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 10370
diff changeset
41 class ParallelScavengeTracer;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
42 class PSIsAliveClosure;
a61af66fc99e Initial load
duke
parents:
diff changeset
43 class PSRefProcTaskExecutor;
10405
f2110083203d 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 10370
diff changeset
44 class STWGCTimer;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 class PSScavenge: AllStatic {
a61af66fc99e Initial load
duke
parents:
diff changeset
47 friend class PSIsAliveClosure;
a61af66fc99e Initial load
duke
parents:
diff changeset
48 friend class PSKeepAliveClosure;
a61af66fc99e Initial load
duke
parents:
diff changeset
49 friend class PSPromotionManager;
a61af66fc99e Initial load
duke
parents:
diff changeset
50
a61af66fc99e Initial load
duke
parents:
diff changeset
51 enum ScavengeSkippedCause {
a61af66fc99e Initial load
duke
parents:
diff changeset
52 not_skipped = 0,
a61af66fc99e Initial load
duke
parents:
diff changeset
53 to_space_not_empty,
a61af66fc99e Initial load
duke
parents:
diff changeset
54 promoted_too_large,
a61af66fc99e Initial load
duke
parents:
diff changeset
55 full_follows_scavenge
a61af66fc99e Initial load
duke
parents:
diff changeset
56 };
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // Saved value of to_space->top(), used to prevent objects in to_space from
a61af66fc99e Initial load
duke
parents:
diff changeset
59 // being rescanned.
a61af66fc99e Initial load
duke
parents:
diff changeset
60 static HeapWord* _to_space_top_before_gc;
a61af66fc99e Initial load
duke
parents:
diff changeset
61
a61af66fc99e Initial load
duke
parents:
diff changeset
62 // Number of consecutive attempts to scavenge that were skipped
a61af66fc99e Initial load
duke
parents:
diff changeset
63 static int _consecutive_skipped_scavenges;
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
67 // Flags/counters
10370
47bdfb3d010f 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 6818
diff changeset
68 static ReferenceProcessor* _ref_processor; // Reference processor for scavenging.
47bdfb3d010f 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 6818
diff changeset
69 static PSIsAliveClosure _is_alive_closure; // Closure used for reference processing
47bdfb3d010f 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 6818
diff changeset
70 static CardTableExtension* _card_table; // We cache the card table for fast access.
47bdfb3d010f 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 6818
diff changeset
71 static bool _survivor_overflow; // Overflow this collection
47bdfb3d010f 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 6818
diff changeset
72 static uint _tenuring_threshold; // tenuring threshold for next scavenge
47bdfb3d010f 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 6818
diff changeset
73 static elapsedTimer _accumulated_time; // total time spent on scavenge
10405
f2110083203d 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 10370
diff changeset
74 static STWGCTimer _gc_timer; // GC time book keeper
f2110083203d 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 10370
diff changeset
75 static ParallelScavengeTracer _gc_tracer; // GC tracing
10370
47bdfb3d010f 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 6818
diff changeset
76 // The lowest address possible for the young_gen.
47bdfb3d010f 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 6818
diff changeset
77 // This is used to decide if an oop should be scavenged,
47bdfb3d010f 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 6818
diff changeset
78 // cards should be marked, etc.
47bdfb3d010f 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 6818
diff changeset
79 static HeapWord* _young_generation_boundary;
47bdfb3d010f 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 6818
diff changeset
80 // Used to optimize compressed oops young gen boundary checking.
47bdfb3d010f 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 6818
diff changeset
81 static uintptr_t _young_generation_boundary_compressed;
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 4913
diff changeset
82 static Stack<markOop, mtGC> _preserved_mark_stack; // List of marks to be restored after failed promotion
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 4913
diff changeset
83 static Stack<oop, mtGC> _preserved_oop_stack; // List of oops that need their mark restored.
10370
47bdfb3d010f 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 6818
diff changeset
84 static CollectorCounters* _counters; // collector performance counters
0
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 static void clean_up_failed_promotion();
a61af66fc99e Initial load
duke
parents:
diff changeset
87
a61af66fc99e Initial load
duke
parents:
diff changeset
88 static bool should_attempt_scavenge();
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90 static HeapWord* to_space_top_before_gc() { return _to_space_top_before_gc; }
a61af66fc99e Initial load
duke
parents:
diff changeset
91 static inline void save_to_space_top_before_gc();
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93 // Private accessors
a61af66fc99e Initial load
duke
parents:
diff changeset
94 static CardTableExtension* const card_table() { assert(_card_table != NULL, "Sanity"); return _card_table; }
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
97 // Accessors
6818
22b8d3d181d9 8000351: Tenuring threshold should be unsigned
jwilhelm
parents: 6725
diff changeset
98 static uint tenuring_threshold() { return _tenuring_threshold; }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
99 static elapsedTimer* accumulated_time() { return &_accumulated_time; }
a61af66fc99e Initial load
duke
parents:
diff changeset
100 static int consecutive_skipped_scavenges()
a61af66fc99e Initial load
duke
parents:
diff changeset
101 { return _consecutive_skipped_scavenges; }
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103 // Performance Counters
a61af66fc99e Initial load
duke
parents:
diff changeset
104 static CollectorCounters* counters() { return _counters; }
a61af66fc99e Initial load
duke
parents:
diff changeset
105
a61af66fc99e Initial load
duke
parents:
diff changeset
106 // Used by scavenge_contents && psMarkSweep
a61af66fc99e Initial load
duke
parents:
diff changeset
107 static ReferenceProcessor* const reference_processor() {
a61af66fc99e Initial load
duke
parents:
diff changeset
108 assert(_ref_processor != NULL, "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
109 return _ref_processor;
a61af66fc99e Initial load
duke
parents:
diff changeset
110 }
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // Used to add tasks
a61af66fc99e Initial load
duke
parents:
diff changeset
112 static GCTaskManager* const gc_task_manager();
a61af66fc99e Initial load
duke
parents:
diff changeset
113 // The promotion managers tell us if they encountered overflow
a61af66fc99e Initial load
duke
parents:
diff changeset
114 static void set_survivor_overflow(bool state) {
a61af66fc99e Initial load
duke
parents:
diff changeset
115 _survivor_overflow = state;
a61af66fc99e Initial load
duke
parents:
diff changeset
116 }
a61af66fc99e Initial load
duke
parents:
diff changeset
117 // Adaptive size policy support. When the young generation/old generation
a61af66fc99e Initial load
duke
parents:
diff changeset
118 // boundary moves, _young_generation_boundary must be reset
a61af66fc99e Initial load
duke
parents:
diff changeset
119 static void set_young_generation_boundary(HeapWord* v) {
a61af66fc99e Initial load
duke
parents:
diff changeset
120 _young_generation_boundary = v;
10370
47bdfb3d010f 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 6818
diff changeset
121 if (UseCompressedOops) {
47bdfb3d010f 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 6818
diff changeset
122 _young_generation_boundary_compressed = (uintptr_t)oopDesc::encode_heap_oop((oop)v);
47bdfb3d010f 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 6818
diff changeset
123 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
124 }
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 // Called by parallelScavengeHeap to init the tenuring threshold
a61af66fc99e Initial load
duke
parents:
diff changeset
127 static void initialize();
a61af66fc99e Initial load
duke
parents:
diff changeset
128
4913
ab4422d0ed59 7146343: PS invoke methods should indicate the type of gc done
jcoomes
parents: 4909
diff changeset
129 // Scavenge entry point. This may invoke a full gc; return true if so.
ab4422d0ed59 7146343: PS invoke methods should indicate the type of gc done
jcoomes
parents: 4909
diff changeset
130 static bool invoke();
ab4422d0ed59 7146343: PS invoke methods should indicate the type of gc done
jcoomes
parents: 4909
diff changeset
131 // Return true if a collection was done; false otherwise.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
132 static bool invoke_no_policy();
a61af66fc99e Initial load
duke
parents:
diff changeset
133
a61af66fc99e Initial load
duke
parents:
diff changeset
134 // If an attempt to promote fails, this method is invoked
a61af66fc99e Initial load
duke
parents:
diff changeset
135 static void oop_promotion_failed(oop obj, markOop obj_mark);
a61af66fc99e Initial load
duke
parents:
diff changeset
136
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
137 template <class T> static inline bool should_scavenge(T* p);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
138
a61af66fc99e Initial load
duke
parents:
diff changeset
139 // These call should_scavenge() above and, if it returns true, also check that
a61af66fc99e Initial load
duke
parents:
diff changeset
140 // the object was not newly copied into to_space. The version with the bool
a61af66fc99e Initial load
duke
parents:
diff changeset
141 // argument is a convenience wrapper that fetches the to_space pointer from
a61af66fc99e Initial load
duke
parents:
diff changeset
142 // the heap and calls the other version (if the arg is true).
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
143 template <class T> static inline bool should_scavenge(T* p, MutableSpace* to_space);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
144 template <class T> static inline bool should_scavenge(T* p, bool check_to_space);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
145
4909
95f6641e38e0 7144296: PS: Optimize nmethods processing
iveresov
parents: 1972
diff changeset
146 template <class T, bool promote_immediately>
95f6641e38e0 7144296: PS: Optimize nmethods processing
iveresov
parents: 1972
diff changeset
147 inline static void copy_and_push_safe_barrier(PSPromotionManager* pm, T* p);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
148
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
149 static void copy_and_push_safe_barrier_from_klass(PSPromotionManager* pm, oop* p);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
150
0
a61af66fc99e Initial load
duke
parents:
diff changeset
151 // Is an object in the young generation
10370
47bdfb3d010f 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 6818
diff changeset
152 // This assumes that the 'o' is in the heap,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
153 // so it only checks one side of the complete predicate.
10370
47bdfb3d010f 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 6818
diff changeset
154
47bdfb3d010f 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 6818
diff changeset
155 inline static bool is_obj_in_young(oop o) {
47bdfb3d010f 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 6818
diff changeset
156 return (HeapWord*)o >= _young_generation_boundary;
47bdfb3d010f 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 6818
diff changeset
157 }
47bdfb3d010f 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 6818
diff changeset
158
47bdfb3d010f 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 6818
diff changeset
159 inline static bool is_obj_in_young(narrowOop o) {
47bdfb3d010f 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 6818
diff changeset
160 return (uintptr_t)o >= _young_generation_boundary_compressed;
47bdfb3d010f 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 6818
diff changeset
161 }
47bdfb3d010f 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 6818
diff changeset
162
0
a61af66fc99e Initial load
duke
parents:
diff changeset
163 inline static bool is_obj_in_young(HeapWord* o) {
10370
47bdfb3d010f 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 6818
diff changeset
164 return o >= _young_generation_boundary;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
165 }
a61af66fc99e Initial load
duke
parents:
diff changeset
166 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1836
diff changeset
167
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1836
diff changeset
168 #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSSCAVENGE_HPP