author | stefank |
Tue, 04 Jul 2017 15:58:10 +0200 | |
changeset 46619 | a3919f5e8d2b |
parent 46565 | 8dcbf532ea00 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
30170 | 2 |
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
670
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
670
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
670
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
30764 | 25 |
#ifndef SHARE_VM_GC_PARALLEL_PSPROMOTIONLAB_HPP |
26 |
#define SHARE_VM_GC_PARALLEL_PSPROMOTIONLAB_HPP |
|
7397 | 27 |
|
30764 | 28 |
#include "gc/parallel/objectStartArray.hpp" |
29 |
#include "gc/shared/collectedHeap.hpp" |
|
7397 | 30 |
#include "memory/allocation.hpp" |
31 |
||
1 | 32 |
// |
33 |
// PSPromotionLAB is a parallel scavenge promotion lab. This class acts very |
|
34 |
// much like a MutableSpace. We couldn't embed a MutableSpace, though, as |
|
35 |
// it has a considerable number of asserts and invariants that are violated. |
|
36 |
// |
|
37 |
||
38 |
class ObjectStartArray; |
|
39 |
||
13195 | 40 |
class PSPromotionLAB : public CHeapObj<mtGC> { |
1 | 41 |
protected: |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
42 |
static size_t filler_header_size; |
1 | 43 |
|
44 |
enum LabState { |
|
45 |
needs_flush, |
|
46 |
flushed, |
|
47 |
zero_size |
|
48 |
}; |
|
49 |
||
50 |
HeapWord* _top; |
|
51 |
HeapWord* _bottom; |
|
52 |
HeapWord* _end; |
|
53 |
LabState _state; |
|
54 |
||
55 |
void set_top(HeapWord* value) { _top = value; } |
|
56 |
void set_bottom(HeapWord* value) { _bottom = value; } |
|
57 |
void set_end(HeapWord* value) { _end = value; } |
|
58 |
||
59 |
// The shared initialize code invokes this. |
|
60 |
debug_only(virtual bool lab_is_valid(MemRegion lab) { return false; }); |
|
61 |
||
30170 | 62 |
PSPromotionLAB() : _top(NULL), _bottom(NULL), _end(NULL), _state(zero_size) { } |
1 | 63 |
|
64 |
public: |
|
65 |
// Filling and flushing. |
|
66 |
void initialize(MemRegion lab); |
|
67 |
||
68 |
virtual void flush(); |
|
69 |
||
70 |
// Accessors |
|
71 |
HeapWord* bottom() const { return _bottom; } |
|
72 |
HeapWord* end() const { return _end; } |
|
73 |
HeapWord* top() const { return _top; } |
|
74 |
||
75 |
bool is_flushed() { return _state == flushed; } |
|
76 |
||
10676
1e1510b8031a
7021322: assert(object_end <= top()) failed: Object crosses promotion LAB boundary
stefank
parents:
7397
diff
changeset
|
77 |
bool unallocate_object(HeapWord* obj, size_t obj_size); |
1 | 78 |
|
79 |
// Returns a subregion containing all objects in this space. |
|
80 |
MemRegion used_region() { return MemRegion(bottom(), top()); } |
|
81 |
||
22551 | 82 |
// Boolean queries. |
1 | 83 |
bool is_empty() const { return used() == 0; } |
84 |
bool not_empty() const { return used() > 0; } |
|
85 |
bool contains(const void* p) const { return _bottom <= p && p < _end; } |
|
86 |
||
87 |
// Size computations. Sizes are in bytes. |
|
88 |
size_t capacity() const { return byte_size(bottom(), end()); } |
|
89 |
size_t used() const { return byte_size(bottom(), top()); } |
|
90 |
size_t free() const { return byte_size(top(), end()); } |
|
91 |
}; |
|
92 |
||
93 |
class PSYoungPromotionLAB : public PSPromotionLAB { |
|
94 |
public: |
|
95 |
PSYoungPromotionLAB() { } |
|
96 |
||
97 |
// Not MT safe |
|
25905
04a3d83cc752
8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
22551
diff
changeset
|
98 |
inline HeapWord* allocate(size_t size); |
1 | 99 |
|
25905
04a3d83cc752
8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
22551
diff
changeset
|
100 |
debug_only(virtual bool lab_is_valid(MemRegion lab);) |
1 | 101 |
}; |
102 |
||
103 |
class PSOldPromotionLAB : public PSPromotionLAB { |
|
104 |
private: |
|
105 |
ObjectStartArray* _start_array; |
|
106 |
||
107 |
public: |
|
108 |
PSOldPromotionLAB() : _start_array(NULL) { } |
|
109 |
PSOldPromotionLAB(ObjectStartArray* start_array) : _start_array(start_array) { } |
|
110 |
||
111 |
void set_start_array(ObjectStartArray* start_array) { _start_array = start_array; } |
|
112 |
||
113 |
void flush(); |
|
114 |
||
115 |
// Not MT safe |
|
116 |
HeapWord* allocate(size_t size) { |
|
117 |
// Cannot test for this now that we're doing promotion failures |
|
118 |
// assert(_state != flushed, "Sanity"); |
|
119 |
assert(_start_array != NULL, "Sanity"); |
|
120 |
HeapWord* obj = top(); |
|
121 |
HeapWord* new_top = obj + size; |
|
122 |
// The 'new_top>obj' check is needed to detect overflow of obj+size. |
|
123 |
if (new_top > obj && new_top <= end()) { |
|
124 |
set_top(new_top); |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46565
diff
changeset
|
125 |
assert(is_object_aligned(obj) && is_object_aligned(new_top), |
1 | 126 |
"checking alignment"); |
127 |
_start_array->allocate_block(obj); |
|
128 |
return obj; |
|
129 |
} |
|
130 |
||
131 |
return NULL; |
|
132 |
} |
|
133 |
||
134 |
debug_only(virtual bool lab_is_valid(MemRegion lab)); |
|
135 |
}; |
|
7397 | 136 |
|
30764 | 137 |
#endif // SHARE_VM_GC_PARALLEL_PSPROMOTIONLAB_HPP |