0
|
1 /*
|
|
2 * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
|
|
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 *
|
|
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
20 * CA 95054 USA or visit www.sun.com if you need additional information or
|
|
21 * have any questions.
|
|
22 *
|
|
23 */
|
|
24
|
|
25 class GCTaskManager;
|
|
26 class GCTaskQueue;
|
|
27 class OopStack;
|
|
28 class ReferenceProcessor;
|
|
29 class ParallelScavengeHeap;
|
|
30 class PSIsAliveClosure;
|
|
31 class PSRefProcTaskExecutor;
|
|
32
|
|
33 class PSScavenge: AllStatic {
|
|
34 friend class PSIsAliveClosure;
|
|
35 friend class PSKeepAliveClosure;
|
|
36 friend class PSPromotionManager;
|
|
37
|
|
38 enum ScavengeSkippedCause {
|
|
39 not_skipped = 0,
|
|
40 to_space_not_empty,
|
|
41 promoted_too_large,
|
|
42 full_follows_scavenge
|
|
43 };
|
|
44
|
|
45 // Saved value of to_space->top(), used to prevent objects in to_space from
|
|
46 // being rescanned.
|
|
47 static HeapWord* _to_space_top_before_gc;
|
|
48
|
|
49 // Number of consecutive attempts to scavenge that were skipped
|
|
50 static int _consecutive_skipped_scavenges;
|
|
51
|
|
52
|
|
53 protected:
|
|
54 // Flags/counters
|
|
55 static ReferenceProcessor* _ref_processor; // Reference processor for scavenging.
|
|
56 static PSIsAliveClosure _is_alive_closure; // Closure used for reference processing
|
|
57 static CardTableExtension* _card_table; // We cache the card table for fast access.
|
|
58 static bool _survivor_overflow; // Overflow this collection
|
|
59 static int _tenuring_threshold; // tenuring threshold for next scavenge
|
|
60 static elapsedTimer _accumulated_time; // total time spent on scavenge
|
|
61 static HeapWord* _young_generation_boundary; // The lowest address possible for the young_gen.
|
|
62 // This is used to decide if an oop should be scavenged,
|
|
63 // cards should be marked, etc.
|
|
64 static GrowableArray<markOop>* _preserved_mark_stack; // List of marks to be restored after failed promotion
|
|
65 static GrowableArray<oop>* _preserved_oop_stack; // List of oops that need their mark restored.
|
|
66 static CollectorCounters* _counters; // collector performance counters
|
|
67
|
|
68 static void clean_up_failed_promotion();
|
|
69
|
|
70 static bool should_attempt_scavenge();
|
|
71
|
|
72 static HeapWord* to_space_top_before_gc() { return _to_space_top_before_gc; }
|
|
73 static inline void save_to_space_top_before_gc();
|
|
74
|
|
75 // Private accessors
|
|
76 static CardTableExtension* const card_table() { assert(_card_table != NULL, "Sanity"); return _card_table; }
|
|
77
|
|
78 public:
|
|
79 // Accessors
|
|
80 static int tenuring_threshold() { return _tenuring_threshold; }
|
|
81 static elapsedTimer* accumulated_time() { return &_accumulated_time; }
|
|
82 static bool promotion_failed()
|
|
83 { return _preserved_mark_stack != NULL; }
|
|
84 static int consecutive_skipped_scavenges()
|
|
85 { return _consecutive_skipped_scavenges; }
|
|
86
|
|
87 // Performance Counters
|
|
88 static CollectorCounters* counters() { return _counters; }
|
|
89
|
|
90 // Used by scavenge_contents && psMarkSweep
|
|
91 static ReferenceProcessor* const reference_processor() {
|
|
92 assert(_ref_processor != NULL, "Sanity");
|
|
93 return _ref_processor;
|
|
94 }
|
|
95 // Used to add tasks
|
|
96 static GCTaskManager* const gc_task_manager();
|
|
97 // The promotion managers tell us if they encountered overflow
|
|
98 static void set_survivor_overflow(bool state) {
|
|
99 _survivor_overflow = state;
|
|
100 }
|
|
101 // Adaptive size policy support. When the young generation/old generation
|
|
102 // boundary moves, _young_generation_boundary must be reset
|
|
103 static void set_young_generation_boundary(HeapWord* v) {
|
|
104 _young_generation_boundary = v;
|
|
105 }
|
|
106
|
|
107 // Called by parallelScavengeHeap to init the tenuring threshold
|
|
108 static void initialize();
|
|
109
|
|
110 // Scavenge entry point
|
|
111 static void invoke();
|
|
112 // Return true is a collection was done. Return
|
|
113 // false if the collection was skipped.
|
|
114 static bool invoke_no_policy();
|
|
115
|
|
116 // If an attempt to promote fails, this method is invoked
|
|
117 static void oop_promotion_failed(oop obj, markOop obj_mark);
|
|
118
|
|
119 static inline bool should_scavenge(oop p);
|
|
120
|
|
121 // These call should_scavenge() above and, if it returns true, also check that
|
|
122 // the object was not newly copied into to_space. The version with the bool
|
|
123 // argument is a convenience wrapper that fetches the to_space pointer from
|
|
124 // the heap and calls the other version (if the arg is true).
|
|
125 static inline bool should_scavenge(oop p, MutableSpace* to_space);
|
|
126 static inline bool should_scavenge(oop p, bool check_to_space);
|
|
127
|
|
128 inline static void copy_and_push_safe_barrier(PSPromotionManager* pm, oop* p);
|
|
129
|
|
130 // Is an object in the young generation
|
|
131 // This assumes that the HeapWord argument is in the heap,
|
|
132 // so it only checks one side of the complete predicate.
|
|
133 inline static bool is_obj_in_young(HeapWord* o) {
|
|
134 const bool result = (o >= _young_generation_boundary);
|
|
135 return result;
|
|
136 }
|
|
137 };
|