Mercurial > hg > truffle
annotate src/share/vm/gc_implementation/parallelScavenge/psScavenge.hpp @ 10370:47bdfb3d010f
8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
Summary: Compare compressed oops to a compressed young gen boundary instead of uncompressing the oops before doing the young gen boundary check.
Reviewed-by: brutisso, jmasa
author | stefank |
---|---|
date | Thu, 30 May 2013 10:58:16 +0200 |
parents | 22b8d3d181d9 |
children | f2110083203d |
rev | line source |
---|---|
0 | 1 /* |
4909 | 2 * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. |
0 | 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:
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 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSSCAVENGE_HPP |
26 #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSSCAVENGE_HPP | |
27 | |
28 #include "gc_implementation/parallelScavenge/cardTableExtension.hpp" | |
29 #include "gc_implementation/parallelScavenge/psVirtualspace.hpp" | |
30 #include "gc_implementation/shared/collectorCounters.hpp" | |
31 #include "memory/allocation.hpp" | |
32 #include "oops/oop.hpp" | |
33 #include "utilities/stack.hpp" | |
34 | |
0 | 35 class GCTaskManager; |
36 class GCTaskQueue; | |
37 class OopStack; | |
38 class ReferenceProcessor; | |
39 class ParallelScavengeHeap; | |
40 class PSIsAliveClosure; | |
41 class PSRefProcTaskExecutor; | |
42 | |
43 class PSScavenge: AllStatic { | |
44 friend class PSIsAliveClosure; | |
45 friend class PSKeepAliveClosure; | |
46 friend class PSPromotionManager; | |
47 | |
48 enum ScavengeSkippedCause { | |
49 not_skipped = 0, | |
50 to_space_not_empty, | |
51 promoted_too_large, | |
52 full_follows_scavenge | |
53 }; | |
54 | |
55 // Saved value of to_space->top(), used to prevent objects in to_space from | |
56 // being rescanned. | |
57 static HeapWord* _to_space_top_before_gc; | |
58 | |
59 // Number of consecutive attempts to scavenge that were skipped | |
60 static int _consecutive_skipped_scavenges; | |
61 | |
62 | |
63 protected: | |
64 // Flags/counters | |
10370
47bdfb3d010f
8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents:
6818
diff
changeset
|
65 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
|
66 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
|
67 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
|
68 static bool _survivor_overflow; // Overflow this collection |
47bdfb3d010f
8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents:
6818
diff
changeset
|
69 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
|
70 static elapsedTimer _accumulated_time; // total time spent on scavenge |
47bdfb3d010f
8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents:
6818
diff
changeset
|
71 // 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
|
72 // 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
|
73 // cards should be marked, etc. |
47bdfb3d010f
8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents:
6818
diff
changeset
|
74 static HeapWord* _young_generation_boundary; |
47bdfb3d010f
8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents:
6818
diff
changeset
|
75 // 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
|
76 static uintptr_t _young_generation_boundary_compressed; |
6197 | 77 static Stack<markOop, mtGC> _preserved_mark_stack; // List of marks to be restored after failed promotion |
78 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
|
79 static CollectorCounters* _counters; // collector performance counters |
47bdfb3d010f
8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents:
6818
diff
changeset
|
80 static bool _promotion_failed; |
0 | 81 |
82 static void clean_up_failed_promotion(); | |
83 | |
84 static bool should_attempt_scavenge(); | |
85 | |
86 static HeapWord* to_space_top_before_gc() { return _to_space_top_before_gc; } | |
87 static inline void save_to_space_top_before_gc(); | |
88 | |
89 // Private accessors | |
90 static CardTableExtension* const card_table() { assert(_card_table != NULL, "Sanity"); return _card_table; } | |
91 | |
92 public: | |
93 // Accessors | |
6818 | 94 static uint tenuring_threshold() { return _tenuring_threshold; } |
0 | 95 static elapsedTimer* accumulated_time() { return &_accumulated_time; } |
1836
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
96 static bool promotion_failed() { return _promotion_failed; } |
0 | 97 static int consecutive_skipped_scavenges() |
98 { return _consecutive_skipped_scavenges; } | |
99 | |
100 // Performance Counters | |
101 static CollectorCounters* counters() { return _counters; } | |
102 | |
103 // Used by scavenge_contents && psMarkSweep | |
104 static ReferenceProcessor* const reference_processor() { | |
105 assert(_ref_processor != NULL, "Sanity"); | |
106 return _ref_processor; | |
107 } | |
108 // Used to add tasks | |
109 static GCTaskManager* const gc_task_manager(); | |
110 // The promotion managers tell us if they encountered overflow | |
111 static void set_survivor_overflow(bool state) { | |
112 _survivor_overflow = state; | |
113 } | |
114 // Adaptive size policy support. When the young generation/old generation | |
115 // boundary moves, _young_generation_boundary must be reset | |
116 static void set_young_generation_boundary(HeapWord* v) { | |
117 _young_generation_boundary = v; | |
10370
47bdfb3d010f
8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents:
6818
diff
changeset
|
118 if (UseCompressedOops) { |
47bdfb3d010f
8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents:
6818
diff
changeset
|
119 _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
|
120 } |
0 | 121 } |
122 | |
123 // Called by parallelScavengeHeap to init the tenuring threshold | |
124 static void initialize(); | |
125 | |
4913
ab4422d0ed59
7146343: PS invoke methods should indicate the type of gc done
jcoomes
parents:
4909
diff
changeset
|
126 // 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
|
127 static bool invoke(); |
ab4422d0ed59
7146343: PS invoke methods should indicate the type of gc done
jcoomes
parents:
4909
diff
changeset
|
128 // Return true if a collection was done; false otherwise. |
0 | 129 static bool invoke_no_policy(); |
130 | |
131 // If an attempt to promote fails, this method is invoked | |
132 static void oop_promotion_failed(oop obj, markOop obj_mark); | |
133 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
134 template <class T> static inline bool should_scavenge(T* p); |
0 | 135 |
136 // These call should_scavenge() above and, if it returns true, also check that | |
137 // the object was not newly copied into to_space. The version with the bool | |
138 // argument is a convenience wrapper that fetches the to_space pointer from | |
139 // 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
|
140 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
|
141 template <class T> static inline bool should_scavenge(T* p, bool check_to_space); |
0 | 142 |
4909 | 143 template <class T, bool promote_immediately> |
144 inline static void copy_and_push_safe_barrier(PSPromotionManager* pm, T* p); | |
0 | 145 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
146 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
|
147 |
0 | 148 // 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
|
149 // This assumes that the 'o' is in the heap, |
0 | 150 // 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
|
151 |
47bdfb3d010f
8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents:
6818
diff
changeset
|
152 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
|
153 return (HeapWord*)o >= _young_generation_boundary; |
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 |
47bdfb3d010f
8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents:
6818
diff
changeset
|
156 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
|
157 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
|
158 } |
47bdfb3d010f
8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents:
6818
diff
changeset
|
159 |
0 | 160 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
|
161 return o >= _young_generation_boundary; |
0 | 162 } |
163 }; | |
1972 | 164 |
165 #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSSCAVENGE_HPP |