author | stefank |
Fri, 14 Feb 2014 09:29:56 +0100 | |
changeset 22883 | 5378704451dc |
parent 19696 | bd5a0131bde1 |
child 25946 | 1572c9f03fb9 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
19696
bd5a0131bde1
8021954: VM SIGSEGV during classloading on MacOS; hs_err_pid file produced
coleenp
parents:
17376
diff
changeset
|
2 |
* Copyright (c) 2000, 2013, 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 |
||
7397 | 25 |
#include "precompiled.hpp" |
17376 | 26 |
#include "memory/allocation.hpp" |
27 |
#include "memory/allocation.inline.hpp" |
|
7397 | 28 |
#include "memory/memRegion.hpp" |
29 |
#include "runtime/globals.hpp" |
|
30 |
||
1 | 31 |
// A very simple data structure representing a contigous word-aligned |
32 |
// region of address space. |
|
33 |
||
34 |
MemRegion MemRegion::intersection(const MemRegion mr2) const { |
|
35 |
MemRegion res; |
|
36 |
HeapWord* res_start = MAX2(start(), mr2.start()); |
|
37 |
HeapWord* res_end = MIN2(end(), mr2.end()); |
|
38 |
if (res_start < res_end) { |
|
39 |
res.set_start(res_start); |
|
40 |
res.set_end(res_end); |
|
41 |
} |
|
42 |
return res; |
|
43 |
} |
|
44 |
||
45 |
MemRegion MemRegion::_union(const MemRegion mr2) const { |
|
46 |
// If one region is empty, return the other |
|
47 |
if (is_empty()) return mr2; |
|
48 |
if (mr2.is_empty()) return MemRegion(start(), end()); |
|
49 |
||
50 |
// Otherwise, regions must overlap or be adjacent |
|
51 |
assert(((start() <= mr2.start()) && (end() >= mr2.start())) || |
|
52 |
((mr2.start() <= start()) && (mr2.end() >= start())), |
|
53 |
"non-adjacent or overlapping regions"); |
|
54 |
MemRegion res; |
|
55 |
HeapWord* res_start = MIN2(start(), mr2.start()); |
|
56 |
HeapWord* res_end = MAX2(end(), mr2.end()); |
|
57 |
res.set_start(res_start); |
|
58 |
res.set_end(res_end); |
|
59 |
return res; |
|
60 |
} |
|
61 |
||
62 |
MemRegion MemRegion::minus(const MemRegion mr2) const { |
|
63 |
// There seem to be 6 cases: |
|
64 |
// |this MemRegion| |
|
65 |
// |strictly below| |
|
66 |
// |overlap beginning| |
|
67 |
// |interior| |
|
68 |
// |overlap ending| |
|
69 |
// |strictly above| |
|
70 |
// |completely overlapping| |
|
71 |
// We can't deal with an interior case because it would |
|
72 |
// produce two disjoint regions as a result. |
|
73 |
// We aren't trying to be optimal in the number of tests below, |
|
74 |
// but the order is important to distinguish the strictly cases |
|
75 |
// from the overlapping cases. |
|
76 |
if (mr2.end() <= start()) { |
|
77 |
// strictly below |
|
78 |
return MemRegion(start(), end()); |
|
79 |
} |
|
80 |
if (mr2.start() <= start() && mr2.end() <= end()) { |
|
81 |
// overlap beginning |
|
82 |
return MemRegion(mr2.end(), end()); |
|
83 |
} |
|
84 |
if (mr2.start() >= end()) { |
|
85 |
// strictly above |
|
86 |
return MemRegion(start(), end()); |
|
87 |
} |
|
88 |
if (mr2.start() >= start() && mr2.end() >= end()) { |
|
89 |
// overlap ending |
|
90 |
return MemRegion(start(), mr2.start()); |
|
91 |
} |
|
92 |
if (mr2.start() <= start() && mr2.end() >= end()) { |
|
93 |
// completely overlapping |
|
94 |
return MemRegion(); |
|
95 |
} |
|
96 |
if (mr2.start() > start() && mr2.end() < end()) { |
|
97 |
// interior |
|
98 |
guarantee(false, "MemRegion::minus, but interior"); |
|
99 |
return MemRegion(); |
|
100 |
} |
|
101 |
ShouldNotReachHere(); |
|
102 |
return MemRegion(); |
|
103 |
} |
|
17376 | 104 |
|
19696
bd5a0131bde1
8021954: VM SIGSEGV during classloading on MacOS; hs_err_pid file produced
coleenp
parents:
17376
diff
changeset
|
105 |
void* MemRegion::operator new(size_t size) throw() { |
17376 | 106 |
return (address)AllocateHeap(size, mtGC, 0, AllocFailStrategy::RETURN_NULL); |
107 |
} |
|
108 |
||
19696
bd5a0131bde1
8021954: VM SIGSEGV during classloading on MacOS; hs_err_pid file produced
coleenp
parents:
17376
diff
changeset
|
109 |
void* MemRegion::operator new [](size_t size) throw() { |
17376 | 110 |
return (address)AllocateHeap(size, mtGC, 0, AllocFailStrategy::RETURN_NULL); |
111 |
} |
|
112 |
void MemRegion::operator delete(void* p) { |
|
113 |
FreeHeap(p, mtGC); |
|
114 |
} |
|
115 |
||
116 |
void MemRegion::operator delete [](void* p) { |
|
117 |
FreeHeap(p, mtGC); |
|
118 |
} |
|
119 |