Mercurial > hg > truffle
annotate src/share/vm/memory/memRegion.hpp @ 7598:f9bda35f4226
8005816: Shark: fix volatile float field access
Reviewed-by: twisti
Contributed-by: Roman Kennke <rkennke@redhat.com>
author | twisti |
---|---|
date | Fri, 11 Jan 2013 16:47:23 -0800 |
parents | da91efe96a93 |
children | f9be75d21404 |
rev | line source |
---|---|
0 | 1 /* |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_MEMORY_MEMREGION_HPP |
26 #define SHARE_VM_MEMORY_MEMREGION_HPP | |
27 | |
28 #include "memory/allocation.hpp" | |
29 #include "utilities/debug.hpp" | |
30 #include "utilities/globalDefinitions.hpp" | |
31 | |
0 | 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 | |
37 // objects. | |
38 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
39 class MetaWord; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
40 |
0 | 41 class MemRegion VALUE_OBJ_CLASS_SPEC { |
42 friend class VMStructs; | |
43 private: | |
44 HeapWord* _start; | |
45 size_t _word_size; | |
46 | |
47 public: | |
48 MemRegion() : _start(NULL), _word_size(0) {}; | |
49 MemRegion(HeapWord* start, size_t word_size) : | |
50 _start(start), _word_size(word_size) {}; | |
51 MemRegion(HeapWord* start, HeapWord* end) : | |
52 _start(start), _word_size(pointer_delta(end, start)) { | |
53 assert(end >= start, "incorrect constructor arguments"); | |
54 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
55 MemRegion(MetaWord* start, MetaWord* end) : |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
56 _start((HeapWord*)start), _word_size(pointer_delta(end, start)) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
57 assert(end >= start, "incorrect constructor arguments"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
58 } |
0 | 59 |
60 MemRegion(const MemRegion& mr): _start(mr._start), _word_size(mr._word_size) {} | |
61 | |
62 MemRegion intersection(const MemRegion mr2) const; | |
63 // regions must overlap or be adjacent | |
64 MemRegion _union(const MemRegion mr2) const; | |
65 // minus will fail a guarantee if mr2 is interior to this, | |
66 // since there's no way to return 2 disjoint regions. | |
67 MemRegion minus(const MemRegion mr2) const; | |
68 | |
69 HeapWord* start() const { return _start; } | |
70 HeapWord* end() const { return _start + _word_size; } | |
71 HeapWord* last() const { return _start + _word_size - 1; } | |
72 | |
73 void set_start(HeapWord* start) { _start = start; } | |
74 void set_end(HeapWord* end) { _word_size = pointer_delta(end, _start); } | |
75 void set_word_size(size_t word_size) { | |
76 _word_size = word_size; | |
77 } | |
78 | |
79 bool contains(const MemRegion mr2) const { | |
80 return _start <= mr2._start && end() >= mr2.end(); | |
81 } | |
82 bool contains(const void* addr) const { | |
83 return addr >= (void*)_start && addr < (void*)end(); | |
84 } | |
85 bool equals(const MemRegion mr2) const { | |
86 // first disjunct since we do not have a canonical empty set | |
87 return ((is_empty() && mr2.is_empty()) || | |
88 (start() == mr2.start() && end() == mr2.end())); | |
89 } | |
90 | |
91 size_t byte_size() const { return _word_size * sizeof(HeapWord); } | |
92 size_t word_size() const { return _word_size; } | |
93 | |
94 bool is_empty() const { return word_size() == 0; } | |
95 }; | |
96 | |
97 // For iteration over MemRegion's. | |
98 | |
99 class MemRegionClosure : public StackObj { | |
100 public: | |
101 virtual void do_MemRegion(MemRegion mr) = 0; | |
102 }; | |
103 | |
104 // A ResourceObj version of MemRegionClosure | |
105 | |
106 class MemRegionClosureRO: public MemRegionClosure { | |
107 public: | |
6197 | 108 void* operator new(size_t size, ResourceObj::allocation_type type, MEMFLAGS flags) { |
109 return ResourceObj::operator new(size, type, flags); | |
0 | 110 } |
111 void* operator new(size_t size, Arena *arena) { | |
112 return ResourceObj::operator new(size, arena); | |
113 } | |
114 void* operator new(size_t size) { | |
115 return ResourceObj::operator new(size); | |
116 } | |
117 | |
118 void operator delete(void* p) {} // nothing to do | |
119 }; | |
1972 | 120 |
121 #endif // SHARE_VM_MEMORY_MEMREGION_HPP |