author | manc |
Tue, 05 Feb 2019 08:20:09 -0800 | |
changeset 53758 | 026e1ea616c8 |
parent 53244 | 9807daeb47c4 |
child 53792 | 6fb43030a1b4 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
49455
diff
changeset
|
2 |
* Copyright (c) 2000, 2019, 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:
1
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
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:
1
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
49455
diff
changeset
|
25 |
#ifndef SHARE_MEMORY_MEMREGION_HPP |
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
49455
diff
changeset
|
26 |
#define SHARE_MEMORY_MEMREGION_HPP |
7397 | 27 |
|
28 |
#include "memory/allocation.hpp" |
|
29 |
#include "utilities/debug.hpp" |
|
30 |
#include "utilities/globalDefinitions.hpp" |
|
31 |
||
1 | 32 |
// A very simple data structure representing a contigous region |
33 |
// region of address space. |
|
34 |
||
35 |
// Note that MemRegions are passed by value, not by reference. |
|
36 |
// The intent is that they remain very small and contain no |
|
53758 | 37 |
// objects. The copy constructor and destructor must be trivial, |
38 |
// to support optimization for pass-by-value. |
|
39 |
// These should never be allocated in heap but we do |
|
49455
848864ed9b17
8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents:
49392
diff
changeset
|
40 |
// create MemRegions (in CardTableBarrierSet) in heap so operator |
17376
4ee999c3c007
8012902: remove use of global operator new - take 2
minqi
parents:
13728
diff
changeset
|
41 |
// new and operator new [] added for this special case. |
1 | 42 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
43 |
class MetaWord; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
44 |
|
49364
601146c66cad
8173070: Remove ValueObj class for allocation subclassing for runtime code
coleenp
parents:
47216
diff
changeset
|
45 |
class MemRegion { |
1 | 46 |
friend class VMStructs; |
47 |
private: |
|
48 |
HeapWord* _start; |
|
49 |
size_t _word_size; |
|
50 |
||
51 |
public: |
|
52 |
MemRegion() : _start(NULL), _word_size(0) {}; |
|
53 |
MemRegion(HeapWord* start, size_t word_size) : |
|
54 |
_start(start), _word_size(word_size) {}; |
|
55 |
MemRegion(HeapWord* start, HeapWord* end) : |
|
56 |
_start(start), _word_size(pointer_delta(end, start)) { |
|
57 |
assert(end >= start, "incorrect constructor arguments"); |
|
58 |
} |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
59 |
MemRegion(MetaWord* start, MetaWord* end) : |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
60 |
_start((HeapWord*)start), _word_size(pointer_delta(end, start)) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
61 |
assert(end >= start, "incorrect constructor arguments"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
62 |
} |
1 | 63 |
|
64 |
MemRegion intersection(const MemRegion mr2) const; |
|
65 |
// regions must overlap or be adjacent |
|
66 |
MemRegion _union(const MemRegion mr2) const; |
|
67 |
// minus will fail a guarantee if mr2 is interior to this, |
|
68 |
// since there's no way to return 2 disjoint regions. |
|
69 |
MemRegion minus(const MemRegion mr2) const; |
|
70 |
||
71 |
HeapWord* start() const { return _start; } |
|
72 |
HeapWord* end() const { return _start + _word_size; } |
|
73 |
HeapWord* last() const { return _start + _word_size - 1; } |
|
74 |
||
75 |
void set_start(HeapWord* start) { _start = start; } |
|
76 |
void set_end(HeapWord* end) { _word_size = pointer_delta(end, _start); } |
|
77 |
void set_word_size(size_t word_size) { |
|
78 |
_word_size = word_size; |
|
79 |
} |
|
80 |
||
81 |
bool contains(const MemRegion mr2) const { |
|
82 |
return _start <= mr2._start && end() >= mr2.end(); |
|
83 |
} |
|
84 |
bool contains(const void* addr) const { |
|
85 |
return addr >= (void*)_start && addr < (void*)end(); |
|
86 |
} |
|
87 |
bool equals(const MemRegion mr2) const { |
|
88 |
// first disjunct since we do not have a canonical empty set |
|
89 |
return ((is_empty() && mr2.is_empty()) || |
|
90 |
(start() == mr2.start() && end() == mr2.end())); |
|
91 |
} |
|
92 |
||
93 |
size_t byte_size() const { return _word_size * sizeof(HeapWord); } |
|
94 |
size_t word_size() const { return _word_size; } |
|
95 |
||
96 |
bool is_empty() const { return word_size() == 0; } |
|
19696
bd5a0131bde1
8021954: VM SIGSEGV during classloading on MacOS; hs_err_pid file produced
coleenp
parents:
17376
diff
changeset
|
97 |
void* operator new(size_t size) throw(); |
bd5a0131bde1
8021954: VM SIGSEGV during classloading on MacOS; hs_err_pid file produced
coleenp
parents:
17376
diff
changeset
|
98 |
void* operator new [](size_t size) throw(); |
17376
4ee999c3c007
8012902: remove use of global operator new - take 2
minqi
parents:
13728
diff
changeset
|
99 |
void operator delete(void* p); |
4ee999c3c007
8012902: remove use of global operator new - take 2
minqi
parents:
13728
diff
changeset
|
100 |
void operator delete [](void* p); |
1 | 101 |
}; |
102 |
||
103 |
// For iteration over MemRegion's. |
|
104 |
||
105 |
class MemRegionClosure : public StackObj { |
|
106 |
public: |
|
107 |
virtual void do_MemRegion(MemRegion mr) = 0; |
|
108 |
}; |
|
109 |
||
110 |
// A ResourceObj version of MemRegionClosure |
|
111 |
||
112 |
class MemRegionClosureRO: public MemRegionClosure { |
|
113 |
public: |
|
19696
bd5a0131bde1
8021954: VM SIGSEGV during classloading on MacOS; hs_err_pid file produced
coleenp
parents:
17376
diff
changeset
|
114 |
void* operator new(size_t size, ResourceObj::allocation_type type, MEMFLAGS flags) throw() { |
13195 | 115 |
return ResourceObj::operator new(size, type, flags); |
1 | 116 |
} |
19696
bd5a0131bde1
8021954: VM SIGSEGV during classloading on MacOS; hs_err_pid file produced
coleenp
parents:
17376
diff
changeset
|
117 |
void* operator new(size_t size, Arena *arena) throw() { |
1 | 118 |
return ResourceObj::operator new(size, arena); |
119 |
} |
|
19696
bd5a0131bde1
8021954: VM SIGSEGV during classloading on MacOS; hs_err_pid file produced
coleenp
parents:
17376
diff
changeset
|
120 |
void* operator new(size_t size) throw() { |
1 | 121 |
return ResourceObj::operator new(size); |
122 |
} |
|
123 |
||
124 |
void operator delete(void* p) {} // nothing to do |
|
125 |
}; |
|
7397 | 126 |
|
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
49455
diff
changeset
|
127 |
#endif // SHARE_MEMORY_MEMREGION_HPP |