Mercurial > hg > truffle
annotate src/share/vm/gc_implementation/g1/g1AllocRegion.hpp @ 20522:d3fd73295885
8059466: Force young GC to initiate marking cycle when stat update is requested
Summary: Enable yc to be forced for stat update.
Reviewed-by: mgerdin, jcoomes
author | sjohanss |
---|---|
date | Mon, 06 Oct 2014 10:11:13 +0200 |
parents | 227a9e5e4b4a |
children | 7848fc12602b |
rev | line source |
---|---|
2433
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
1 /* |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17467
diff
changeset
|
2 * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. |
2433
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
4 * |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
8 * |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
13 * accompanied this code). |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
14 * |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
18 * |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
21 * questions. |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
22 * |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
23 */ |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
24 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1ALLOCREGION_HPP |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1ALLOCREGION_HPP |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
27 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
28 #include "gc_implementation/g1/heapRegion.hpp" |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
29 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
30 class G1CollectedHeap; |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
31 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
32 // 0 -> no tracing, 1 -> basic tracing, 2 -> basic + allocation tracing |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
33 #define G1_ALLOC_REGION_TRACING 0 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
34 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
35 class ar_ext_msg; |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
36 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
37 // A class that holds a region that is active in satisfying allocation |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
38 // requests, potentially issued in parallel. When the active region is |
3830
f44782f04dd4
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
2433
diff
changeset
|
39 // full it will be retired and replaced with a new one. The |
2433
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
40 // implementation assumes that fast-path allocations will be lock-free |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
41 // and a lock will need to be taken when the active region needs to be |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
42 // replaced. |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
43 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
44 class G1AllocRegion VALUE_OBJ_CLASS_SPEC { |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
45 friend class ar_ext_msg; |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
46 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
47 private: |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
48 // The active allocating region we are currently allocating out |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
49 // of. The invariant is that if this object is initialized (i.e., |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
50 // init() has been called and release() has not) then _alloc_region |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
51 // is either an active allocating region or the dummy region (i.e., |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
52 // it can never be NULL) and this object can be used to satisfy |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
53 // allocation requests. If this object is not initialized |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
54 // (i.e. init() has not been called or release() has been called) |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
55 // then _alloc_region is NULL and this object should not be used to |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
56 // satisfy allocation requests (it was done this way to force the |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
57 // correct use of init() and release()). |
12986
1b422ef5288a
8025728: Missing volatile specifier for field G1AllocRegion::_alloc_region
tschatzl
parents:
6010
diff
changeset
|
58 HeapRegion* volatile _alloc_region; |
2433
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
59 |
20404
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
60 // Allocation context associated with this alloc region. |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
61 AllocationContext_t _allocation_context; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
62 |
3830
f44782f04dd4
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
2433
diff
changeset
|
63 // It keeps track of the distinct number of regions that are used |
f44782f04dd4
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
2433
diff
changeset
|
64 // for allocation in the active interval of this object, i.e., |
f44782f04dd4
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
2433
diff
changeset
|
65 // between a call to init() and a call to release(). The count |
f44782f04dd4
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
2433
diff
changeset
|
66 // mostly includes regions that are freshly allocated, as well as |
f44782f04dd4
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
2433
diff
changeset
|
67 // the region that is re-used using the set() method. This count can |
f44782f04dd4
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
2433
diff
changeset
|
68 // be used in any heuristics that might want to bound how many |
f44782f04dd4
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
2433
diff
changeset
|
69 // distinct regions this object can used during an active interval. |
6010
720b6a76dd9d
7157073: G1: type change size_t -> uint for region counts / indexes
tonyp
parents:
3830
diff
changeset
|
70 uint _count; |
3830
f44782f04dd4
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
2433
diff
changeset
|
71 |
2433
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
72 // When we set up a new active region we save its used bytes in this |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
73 // field so that, when we retire it, we can calculate how much space |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
74 // we allocated in it. |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
75 size_t _used_bytes_before; |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
76 |
3830
f44782f04dd4
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
2433
diff
changeset
|
77 // When true, indicates that allocate calls should do BOT updates. |
f44782f04dd4
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
2433
diff
changeset
|
78 const bool _bot_updates; |
2433
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
79 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
80 // Useful for debugging and tracing. |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
81 const char* _name; |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
82 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
83 // A dummy region (i.e., it's been allocated specially for this |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
84 // purpose and it is not part of the heap) that is full (i.e., top() |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
85 // == end()). When we don't have a valid active region we make |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
86 // _alloc_region point to this. This allows us to skip checking |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
87 // whether the _alloc_region is NULL or not. |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
88 static HeapRegion* _dummy_region; |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
89 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
90 // Some of the methods below take a bot_updates parameter. Its value |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
91 // should be the same as the _bot_updates field. The idea is that |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
92 // the parameter will be a constant for a particular alloc region |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
93 // and, given that these methods will be hopefully inlined, the |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
94 // compiler should compile out the test. |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
95 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
96 // Perform a non-MT-safe allocation out of the given region. |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
97 static inline HeapWord* allocate(HeapRegion* alloc_region, |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
98 size_t word_size, |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
99 bool bot_updates); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
100 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
101 // Perform a MT-safe allocation out of the given region. |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
102 static inline HeapWord* par_allocate(HeapRegion* alloc_region, |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
103 size_t word_size, |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
104 bool bot_updates); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
105 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
106 // Ensure that the region passed as a parameter has been filled up |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
107 // so that noone else can allocate out of it any more. |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
108 static void fill_up_remaining_space(HeapRegion* alloc_region, |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
109 bool bot_updates); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
110 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
111 // Retire the active allocating region. If fill_up is true then make |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
112 // sure that the region is full before we retire it so that noone |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
113 // else can allocate out of it. |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
114 void retire(bool fill_up); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
115 |
20404
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
116 // After a region is allocated by alloc_new_region, this |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
117 // method is used to set it as the active alloc_region |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
118 void update_alloc_region(HeapRegion* alloc_region); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
119 |
2433
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
120 // Allocate a new active region and use it to perform a word_size |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
121 // allocation. The force parameter will be passed on to |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
122 // G1CollectedHeap::allocate_new_alloc_region() and tells it to try |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
123 // to allocate a new region even if the max has been reached. |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
124 HeapWord* new_alloc_region_and_allocate(size_t word_size, bool force); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
125 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
126 void fill_in_ext_msg(ar_ext_msg* msg, const char* message); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
127 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
128 protected: |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
129 // For convenience as subclasses use it. |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
130 static G1CollectedHeap* _g1h; |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
131 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
132 virtual HeapRegion* allocate_new_region(size_t word_size, bool force) = 0; |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
133 virtual void retire_region(HeapRegion* alloc_region, |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
134 size_t allocated_bytes) = 0; |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
135 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
136 G1AllocRegion(const char* name, bool bot_updates); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
137 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
138 public: |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
139 static void setup(G1CollectedHeap* g1h, HeapRegion* dummy_region); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
140 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
141 HeapRegion* get() const { |
12986
1b422ef5288a
8025728: Missing volatile specifier for field G1AllocRegion::_alloc_region
tschatzl
parents:
6010
diff
changeset
|
142 HeapRegion * hr = _alloc_region; |
2433
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
143 // Make sure that the dummy region does not escape this class. |
12986
1b422ef5288a
8025728: Missing volatile specifier for field G1AllocRegion::_alloc_region
tschatzl
parents:
6010
diff
changeset
|
144 return (hr == _dummy_region) ? NULL : hr; |
2433
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
145 } |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
146 |
20404
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
147 void set_allocation_context(AllocationContext_t context) { _allocation_context = context; } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
148 AllocationContext_t allocation_context() { return _allocation_context; } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
149 |
6010
720b6a76dd9d
7157073: G1: type change size_t -> uint for region counts / indexes
tonyp
parents:
3830
diff
changeset
|
150 uint count() { return _count; } |
3830
f44782f04dd4
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
2433
diff
changeset
|
151 |
2433
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
152 // The following two are the building blocks for the allocation method. |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
153 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
154 // First-level allocation: Should be called without holding a |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
155 // lock. It will try to allocate lock-free out of the active region, |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
156 // or return NULL if it was unable to. |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
157 inline HeapWord* attempt_allocation(size_t word_size, bool bot_updates); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
158 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
159 // Second-level allocation: Should be called while holding a |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
160 // lock. It will try to first allocate lock-free out of the active |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
161 // region or, if it's unable to, it will try to replace the active |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
162 // alloc region with a new one. We require that the caller takes the |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
163 // appropriate lock before calling this so that it is easier to make |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
164 // it conform to its locking protocol. |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
165 inline HeapWord* attempt_allocation_locked(size_t word_size, |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
166 bool bot_updates); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
167 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
168 // Should be called to allocate a new region even if the max of this |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
169 // type of regions has been reached. Should only be called if other |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
170 // allocation attempts have failed and we are not holding a valid |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
171 // active region. |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
172 inline HeapWord* attempt_allocation_force(size_t word_size, |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
173 bool bot_updates); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
174 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
175 // Should be called before we start using this object. |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
176 void init(); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
177 |
3830
f44782f04dd4
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
2433
diff
changeset
|
178 // This can be used to set the active region to a specific |
f44782f04dd4
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
2433
diff
changeset
|
179 // region. (Use Example: we try to retain the last old GC alloc |
f44782f04dd4
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
2433
diff
changeset
|
180 // region that we've used during a GC and we can use set() to |
f44782f04dd4
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
2433
diff
changeset
|
181 // re-instate it at the beginning of the next GC.) |
f44782f04dd4
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
2433
diff
changeset
|
182 void set(HeapRegion* alloc_region); |
f44782f04dd4
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
2433
diff
changeset
|
183 |
2433
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
184 // Should be called when we want to release the active region which |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
185 // is returned after it's been retired. |
20331
18bf0b66de52
8044406: JVM crash with JDK8 (build 1.8.0-b132) with G1 GC
poonam
parents:
17937
diff
changeset
|
186 virtual HeapRegion* release(); |
2433
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
187 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
188 #if G1_ALLOC_REGION_TRACING |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
189 void trace(const char* str, size_t word_size = 0, HeapWord* result = NULL); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
190 #else // G1_ALLOC_REGION_TRACING |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
191 void trace(const char* str, size_t word_size = 0, HeapWord* result = NULL) { } |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
192 #endif // G1_ALLOC_REGION_TRACING |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
193 }; |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
194 |
20404
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
195 class MutatorAllocRegion : public G1AllocRegion { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
196 protected: |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
197 virtual HeapRegion* allocate_new_region(size_t word_size, bool force); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
198 virtual void retire_region(HeapRegion* alloc_region, size_t allocated_bytes); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
199 public: |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
200 MutatorAllocRegion() |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
201 : G1AllocRegion("Mutator Alloc Region", false /* bot_updates */) { } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
202 }; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
203 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
204 class SurvivorGCAllocRegion : public G1AllocRegion { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
205 protected: |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
206 virtual HeapRegion* allocate_new_region(size_t word_size, bool force); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
207 virtual void retire_region(HeapRegion* alloc_region, size_t allocated_bytes); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
208 public: |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
209 SurvivorGCAllocRegion() |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
210 : G1AllocRegion("Survivor GC Alloc Region", false /* bot_updates */) { } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
211 }; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
212 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
213 class OldGCAllocRegion : public G1AllocRegion { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
214 protected: |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
215 virtual HeapRegion* allocate_new_region(size_t word_size, bool force); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
216 virtual void retire_region(HeapRegion* alloc_region, size_t allocated_bytes); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
217 public: |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
218 OldGCAllocRegion() |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
219 : G1AllocRegion("Old GC Alloc Region", true /* bot_updates */) { } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
220 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
221 // This specialization of release() makes sure that the last card that has |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
222 // been allocated into has been completely filled by a dummy object. This |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
223 // avoids races when remembered set scanning wants to update the BOT of the |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
224 // last card in the retained old gc alloc region, and allocation threads |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
225 // allocating into that card at the same time. |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
226 virtual HeapRegion* release(); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
227 }; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20331
diff
changeset
|
228 |
2433
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
229 class ar_ext_msg : public err_msg { |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
230 public: |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17467
diff
changeset
|
231 ar_ext_msg(G1AllocRegion* alloc_region, const char *message) : err_msg("%s", "") { |
2433
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
232 alloc_region->fill_in_ext_msg(this, message); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
233 } |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
234 }; |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
235 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
236 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1ALLOCREGION_HPP |