author | tschatzl |
Wed, 18 Apr 2018 11:36:48 +0200 | |
changeset 49806 | 2d62570a615c |
parent 49392 | 2956d0ece7a9 |
child 50676 | 8c0a5b51559b |
permissions | -rw-r--r-- |
26160 | 1 |
/* |
49392
2956d0ece7a9
8199282: Remove ValueObj class for allocation subclassing for gc code
coleenp
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. |
26160 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
* |
|
23 |
*/ |
|
24 |
||
30764 | 25 |
#ifndef SHARE_VM_GC_G1_G1PAGEBASEDVIRTUALSPACE_HPP |
26 |
#define SHARE_VM_GC_G1_G1PAGEBASEDVIRTUALSPACE_HPP |
|
26160 | 27 |
|
28 |
#include "memory/memRegion.hpp" |
|
30291
54cdc5c1a9cb
8068352: Move virtualspace.* out of src/share/vm/runtime to memory directory
coleenp
parents:
30158
diff
changeset
|
29 |
#include "memory/virtualspace.hpp" |
46625 | 30 |
#include "utilities/align.hpp" |
26160 | 31 |
#include "utilities/bitMap.hpp" |
32 |
||
41178 | 33 |
class WorkGang; |
34 |
||
26160 | 35 |
// Virtual space management helper for a virtual space with an OS page allocation |
36 |
// granularity. |
|
37 |
// (De-)Allocation requests are always OS page aligned by passing a page index |
|
38 |
// and multiples of pages. |
|
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
39 |
// For systems that only commits of memory in a given size (always greater than |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
40 |
// page size) the base address is required to be aligned to that page size. |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
41 |
// The actual size requested need not be aligned to that page size, but the size |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
42 |
// of the reservation passed may be rounded up to this page size. Any fragment |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
43 |
// (less than the page size) of the actual size at the tail of the request will |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
44 |
// be committed using OS small pages. |
26160 | 45 |
// The implementation gives an error when trying to commit or uncommit pages that |
46 |
// have already been committed or uncommitted. |
|
49392
2956d0ece7a9
8199282: Remove ValueObj class for allocation subclassing for gc code
coleenp
parents:
47216
diff
changeset
|
47 |
class G1PageBasedVirtualSpace { |
26160 | 48 |
friend class VMStructs; |
49 |
private: |
|
50 |
// Reserved area addresses. |
|
51 |
char* _low_boundary; |
|
52 |
char* _high_boundary; |
|
53 |
||
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
54 |
// The size of the tail in bytes of the handled space that needs to be committed |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
55 |
// using small pages. |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
56 |
size_t _tail_size; |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
57 |
|
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
58 |
// The preferred page size used for commit/uncommit in bytes. |
26160 | 59 |
size_t _page_size; |
60 |
||
61 |
// Bitmap used for verification of commit/uncommit operations. |
|
38177 | 62 |
CHeapBitMap _committed; |
26160 | 63 |
|
28482
e1a8d03c342f
8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents:
26160
diff
changeset
|
64 |
// Bitmap used to keep track of which pages are dirty or not for _special |
e1a8d03c342f
8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents:
26160
diff
changeset
|
65 |
// spaces. This is needed because for those spaces the underlying memory |
e1a8d03c342f
8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents:
26160
diff
changeset
|
66 |
// will only be zero filled the first time it is committed. Calls to commit |
e1a8d03c342f
8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents:
26160
diff
changeset
|
67 |
// will use this bitmap and return whether or not the memory is zero filled. |
38177 | 68 |
CHeapBitMap _dirty; |
28482
e1a8d03c342f
8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents:
26160
diff
changeset
|
69 |
|
26160 | 70 |
// Indicates that the entire space has been committed and pinned in memory, |
71 |
// os::commit_memory() or os::uncommit_memory() have no function. |
|
72 |
bool _special; |
|
73 |
||
74 |
// Indicates whether the committed space should be executable. |
|
75 |
bool _executable; |
|
76 |
||
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
77 |
// Helper function for committing memory. Commit the given memory range by using |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
78 |
// _page_size pages as much as possible and the remainder with small sized pages. |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
79 |
void commit_internal(size_t start_page, size_t end_page); |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
80 |
// Commit num_pages pages of _page_size size starting from start. All argument |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
81 |
// checking has been performed. |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
82 |
void commit_preferred_pages(size_t start_page, size_t end_page); |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
83 |
// Commit space at the high end of the space that needs to be committed with small |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
84 |
// sized pages. |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
85 |
void commit_tail(); |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
86 |
|
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
87 |
// Uncommit the given memory range. |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
88 |
void uncommit_internal(size_t start_page, size_t end_page); |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
89 |
|
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
90 |
// Pretouch the given memory range. |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
91 |
void pretouch_internal(size_t start_page, size_t end_page); |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
92 |
|
26160 | 93 |
// Returns the index of the page which contains the given address. |
94 |
uintptr_t addr_to_page_index(char* addr) const; |
|
95 |
// Returns the address of the given page index. |
|
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
96 |
char* page_start(size_t index) const; |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
97 |
|
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
98 |
// Is the given page index the last page? |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
99 |
bool is_last_page(size_t index) const { return index == (_committed.size() - 1); } |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
100 |
// Is the given page index the first after last page? |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
101 |
bool is_after_last_page(size_t index) const; |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
102 |
// Is the last page only partially covered by this space? |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
41178
diff
changeset
|
103 |
bool is_last_page_partial() const { return !is_aligned(_high_boundary, _page_size); } |
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
104 |
// Returns the end address of the given page bounded by the reserved space. |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
105 |
char* bounded_end_addr(size_t end_page) const; |
26160 | 106 |
|
107 |
// Returns true if the entire area is backed by committed memory. |
|
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
108 |
bool is_area_committed(size_t start_page, size_t size_in_pages) const; |
26160 | 109 |
// Returns true if the entire area is not backed by committed memory. |
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
110 |
bool is_area_uncommitted(size_t start_page, size_t size_in_pages) const; |
26160 | 111 |
|
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
112 |
void initialize_with_page_size(ReservedSpace rs, size_t used_size, size_t page_size); |
26160 | 113 |
public: |
114 |
||
115 |
// Commit the given area of pages starting at start being size_in_pages large. |
|
28482
e1a8d03c342f
8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents:
26160
diff
changeset
|
116 |
// Returns true if the given area is zero filled upon completion. |
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
117 |
bool commit(size_t start_page, size_t size_in_pages); |
26160 | 118 |
|
119 |
// Uncommit the given area of pages starting at start being size_in_pages large. |
|
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
120 |
void uncommit(size_t start_page, size_t size_in_pages); |
26160 | 121 |
|
41178 | 122 |
void pretouch(size_t start_page, size_t size_in_pages, WorkGang* pretouch_gang = NULL); |
123 |
||
30158
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
124 |
// Initialize the given reserved space with the given base address and the size |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
125 |
// actually used. |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
126 |
// Prefer to commit in page_size chunks. |
bd6094906ef8
8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents:
28482
diff
changeset
|
127 |
G1PageBasedVirtualSpace(ReservedSpace rs, size_t used_size, size_t page_size); |
26160 | 128 |
|
129 |
// Destruction |
|
130 |
~G1PageBasedVirtualSpace(); |
|
131 |
||
132 |
// Amount of reserved memory. |
|
133 |
size_t reserved_size() const; |
|
134 |
// Memory used in this virtual space. |
|
135 |
size_t committed_size() const; |
|
136 |
// Memory left to use/expand in this virtual space. |
|
137 |
size_t uncommitted_size() const; |
|
138 |
||
139 |
bool contains(const void* p) const; |
|
140 |
||
141 |
MemRegion reserved() { |
|
142 |
MemRegion x((HeapWord*)_low_boundary, reserved_size() / HeapWordSize); |
|
143 |
return x; |
|
144 |
} |
|
145 |
||
146 |
void check_for_contiguity() PRODUCT_RETURN; |
|
147 |
||
148 |
// Debugging |
|
149 |
void print_on(outputStream* out) PRODUCT_RETURN; |
|
150 |
void print(); |
|
151 |
}; |
|
152 |
||
30764 | 153 |
#endif // SHARE_VM_GC_G1_G1PAGEBASEDVIRTUALSPACE_HPP |