Mercurial > hg > graal-compiler
annotate src/share/vm/gc_implementation/g1/g1Allocator.hpp @ 20795:ae52ee069062
8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
Summary: Making sure committed memory is cleared when re-committed, even if using large pages.
Reviewed-by: jwilhelm, tschatzl
author | sjohanss |
---|---|
date | Mon, 12 Jan 2015 15:24:29 +0100 |
parents | d35872270666 |
children |
rev | line source |
---|---|
20404
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
1 /* |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
4 * |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
8 * |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
13 * accompanied this code). |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
14 * |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
18 * |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
21 * questions. |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
22 * |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
23 */ |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
24 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1ALLOCATOR_HPP |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1ALLOCATOR_HPP |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
27 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
28 #include "gc_implementation/g1/g1AllocationContext.hpp" |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
29 #include "gc_implementation/g1/g1AllocRegion.hpp" |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
30 #include "gc_implementation/shared/parGCAllocBuffer.hpp" |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
31 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
32 enum GCAllocPurpose { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
33 GCAllocForTenured, |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
34 GCAllocForSurvived, |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
35 GCAllocPurposeCount |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
36 }; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
37 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
38 // Base class for G1 allocators. |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
39 class G1Allocator : public CHeapObj<mtGC> { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
40 friend class VMStructs; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
41 protected: |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
42 G1CollectedHeap* _g1h; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
43 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
44 // Outside of GC pauses, the number of bytes used in all regions other |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
45 // than the current allocation region. |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
46 size_t _summary_bytes_used; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
47 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
48 public: |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
49 G1Allocator(G1CollectedHeap* heap) : |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
50 _g1h(heap), _summary_bytes_used(0) { } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
51 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
52 static G1Allocator* create_allocator(G1CollectedHeap* g1h); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
53 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
54 virtual void init_mutator_alloc_region() = 0; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
55 virtual void release_mutator_alloc_region() = 0; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
56 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
57 virtual void init_gc_alloc_regions(EvacuationInfo& evacuation_info) = 0; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
58 virtual void release_gc_alloc_regions(uint no_of_gc_workers, EvacuationInfo& evacuation_info) = 0; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
59 virtual void abandon_gc_alloc_regions() = 0; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
60 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
61 virtual MutatorAllocRegion* mutator_alloc_region(AllocationContext_t context) = 0; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
62 virtual SurvivorGCAllocRegion* survivor_gc_alloc_region(AllocationContext_t context) = 0; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
63 virtual OldGCAllocRegion* old_gc_alloc_region(AllocationContext_t context) = 0; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
64 virtual size_t used() = 0; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
65 virtual bool is_retained_old_region(HeapRegion* hr) = 0; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
66 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
67 void reuse_retained_old_region(EvacuationInfo& evacuation_info, |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
68 OldGCAllocRegion* old, |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
69 HeapRegion** retained); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
70 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
71 size_t used_unlocked() const { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
72 return _summary_bytes_used; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
73 } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
74 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
75 void increase_used(size_t bytes) { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
76 _summary_bytes_used += bytes; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
77 } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
78 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
79 void decrease_used(size_t bytes) { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
80 assert(_summary_bytes_used >= bytes, |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
81 err_msg("invariant: _summary_bytes_used: "SIZE_FORMAT" should be >= bytes: "SIZE_FORMAT, |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
82 _summary_bytes_used, bytes)); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
83 _summary_bytes_used -= bytes; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
84 } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
85 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
86 void set_used(size_t bytes) { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
87 _summary_bytes_used = bytes; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
88 } |
20417 | 89 |
90 virtual HeapRegion* new_heap_region(uint hrs_index, | |
91 G1BlockOffsetSharedArray* sharedOffsetArray, | |
92 MemRegion mr) { | |
93 return new HeapRegion(hrs_index, sharedOffsetArray, mr); | |
94 } | |
20404
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
95 }; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
96 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
97 // The default allocator for G1. |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
98 class G1DefaultAllocator : public G1Allocator { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
99 protected: |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
100 // Alloc region used to satisfy mutator allocation requests. |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
101 MutatorAllocRegion _mutator_alloc_region; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
102 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
103 // Alloc region used to satisfy allocation requests by the GC for |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
104 // survivor objects. |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
105 SurvivorGCAllocRegion _survivor_gc_alloc_region; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
106 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
107 // Alloc region used to satisfy allocation requests by the GC for |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
108 // old objects. |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
109 OldGCAllocRegion _old_gc_alloc_region; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
110 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
111 HeapRegion* _retained_old_gc_alloc_region; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
112 public: |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
113 G1DefaultAllocator(G1CollectedHeap* heap) : G1Allocator(heap), _retained_old_gc_alloc_region(NULL) { } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
114 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
115 virtual void init_mutator_alloc_region(); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
116 virtual void release_mutator_alloc_region(); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
117 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
118 virtual void init_gc_alloc_regions(EvacuationInfo& evacuation_info); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
119 virtual void release_gc_alloc_regions(uint no_of_gc_workers, EvacuationInfo& evacuation_info); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
120 virtual void abandon_gc_alloc_regions(); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
121 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
122 virtual bool is_retained_old_region(HeapRegion* hr) { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
123 return _retained_old_gc_alloc_region == hr; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
124 } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
125 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
126 virtual MutatorAllocRegion* mutator_alloc_region(AllocationContext_t context) { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
127 return &_mutator_alloc_region; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
128 } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
129 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
130 virtual SurvivorGCAllocRegion* survivor_gc_alloc_region(AllocationContext_t context) { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
131 return &_survivor_gc_alloc_region; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
132 } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
133 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
134 virtual OldGCAllocRegion* old_gc_alloc_region(AllocationContext_t context) { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
135 return &_old_gc_alloc_region; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
136 } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
137 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
138 virtual size_t used() { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
139 assert(Heap_lock->owner() != NULL, |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
140 "Should be owned on this thread's behalf."); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
141 size_t result = _summary_bytes_used; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
142 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
143 // Read only once in case it is set to NULL concurrently |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
144 HeapRegion* hr = mutator_alloc_region(AllocationContext::current())->get(); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
145 if (hr != NULL) { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
146 result += hr->used(); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
147 } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
148 return result; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
149 } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
150 }; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
151 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
152 class G1ParGCAllocBuffer: public ParGCAllocBuffer { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
153 private: |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
154 bool _retired; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
155 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
156 public: |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
157 G1ParGCAllocBuffer(size_t gclab_word_size); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
158 virtual ~G1ParGCAllocBuffer() { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
159 guarantee(_retired, "Allocation buffer has not been retired"); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
160 } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
161 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
162 virtual void set_buf(HeapWord* buf) { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
163 ParGCAllocBuffer::set_buf(buf); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
164 _retired = false; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
165 } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
166 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
167 virtual void retire(bool end_of_gc, bool retain) { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
168 if (_retired) { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
169 return; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
170 } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
171 ParGCAllocBuffer::retire(end_of_gc, retain); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
172 _retired = true; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
173 } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
174 }; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
175 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
176 class G1ParGCAllocator : public CHeapObj<mtGC> { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
177 friend class G1ParScanThreadState; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
178 protected: |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
179 G1CollectedHeap* _g1h; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
180 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
181 size_t _alloc_buffer_waste; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
182 size_t _undo_waste; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
183 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
184 void add_to_alloc_buffer_waste(size_t waste) { _alloc_buffer_waste += waste; } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
185 void add_to_undo_waste(size_t waste) { _undo_waste += waste; } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
186 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
187 HeapWord* allocate_slow(GCAllocPurpose purpose, size_t word_sz, AllocationContext_t context); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
188 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
189 virtual void retire_alloc_buffers() = 0; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
190 virtual G1ParGCAllocBuffer* alloc_buffer(GCAllocPurpose purpose, AllocationContext_t context) = 0; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
191 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
192 public: |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
193 G1ParGCAllocator(G1CollectedHeap* g1h) : |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
194 _g1h(g1h), _alloc_buffer_waste(0), _undo_waste(0) { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
195 } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
196 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
197 static G1ParGCAllocator* create_allocator(G1CollectedHeap* g1h); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
198 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
199 size_t alloc_buffer_waste() { return _alloc_buffer_waste; } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
200 size_t undo_waste() {return _undo_waste; } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
201 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
202 HeapWord* allocate(GCAllocPurpose purpose, size_t word_sz, AllocationContext_t context) { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
203 HeapWord* obj = NULL; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
204 if (purpose == GCAllocForSurvived) { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
205 obj = alloc_buffer(purpose, context)->allocate_aligned(word_sz, SurvivorAlignmentInBytes); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
206 } else { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
207 obj = alloc_buffer(purpose, context)->allocate(word_sz); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
208 } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
209 if (obj != NULL) { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
210 return obj; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
211 } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
212 return allocate_slow(purpose, word_sz, context); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
213 } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
214 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
215 void undo_allocation(GCAllocPurpose purpose, HeapWord* obj, size_t word_sz, AllocationContext_t context) { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
216 if (alloc_buffer(purpose, context)->contains(obj)) { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
217 assert(alloc_buffer(purpose, context)->contains(obj + word_sz - 1), |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
218 "should contain whole object"); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
219 alloc_buffer(purpose, context)->undo_allocation(obj, word_sz); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
220 } else { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
221 CollectedHeap::fill_with_object(obj, word_sz); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
222 add_to_undo_waste(word_sz); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
223 } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
224 } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
225 }; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
226 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
227 class G1DefaultParGCAllocator : public G1ParGCAllocator { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
228 G1ParGCAllocBuffer _surviving_alloc_buffer; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
229 G1ParGCAllocBuffer _tenured_alloc_buffer; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
230 G1ParGCAllocBuffer* _alloc_buffers[GCAllocPurposeCount]; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
231 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
232 public: |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
233 G1DefaultParGCAllocator(G1CollectedHeap* g1h); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
234 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
235 virtual G1ParGCAllocBuffer* alloc_buffer(GCAllocPurpose purpose, AllocationContext_t context) { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
236 return _alloc_buffers[purpose]; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
237 } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
238 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
239 virtual void retire_alloc_buffers() ; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
240 }; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
241 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
242 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1ALLOCATOR_HPP |