annotate src/share/vm/memory/resourceArea.hpp @ 10241:d17700c82d7d

8006088: Incompatible heap size flags accepted by VM Summary: Make processing of minimum, initial and maximum heap size more intiutive by removing previous limitations on allowed values, and make error reporting consistent. Further, fix errors in ergonomic heap sizing. Reviewed-by: johnc, jwilhelm, tamao
author tschatzl
date Mon, 06 May 2013 17:19:42 +0200
parents f34d701e952e
children dbc0b5dc08f5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 3960
diff changeset
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
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
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #ifndef SHARE_VM_MEMORY_RESOURCEAREA_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_MEMORY_RESOURCEAREA_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "memory/allocation.hpp"
7180
f34d701e952e 8003935: Simplify the needed includes for using Thread::current()
stefank
parents: 6882
diff changeset
29 #include "runtime/thread.inline.hpp"
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30
0
a61af66fc99e Initial load
duke
parents:
diff changeset
31 // The resource area holds temporary data structures in the VM.
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // The actual allocation areas are thread local. Typical usage:
a61af66fc99e Initial load
duke
parents:
diff changeset
33 //
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // ...
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // {
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // int foo[] = NEW_RESOURCE_ARRAY(int, 64);
a61af66fc99e Initial load
duke
parents:
diff changeset
38 // ...
a61af66fc99e Initial load
duke
parents:
diff changeset
39 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
40 // ...
a61af66fc99e Initial load
duke
parents:
diff changeset
41
a61af66fc99e Initial load
duke
parents:
diff changeset
42 //------------------------------ResourceArea-----------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // A ResourceArea is an Arena that supports safe usage of ResourceMark.
a61af66fc99e Initial load
duke
parents:
diff changeset
44 class ResourceArea: public Arena {
a61af66fc99e Initial load
duke
parents:
diff changeset
45 friend class ResourceMark;
a61af66fc99e Initial load
duke
parents:
diff changeset
46 friend class DeoptResourceMark;
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1972
diff changeset
47 friend class VMStructs;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
48 debug_only(int _nesting;) // current # of nested ResourceMarks
a61af66fc99e Initial load
duke
parents:
diff changeset
49 debug_only(static int _warned;) // to suppress multiple warnings
a61af66fc99e Initial load
duke
parents:
diff changeset
50
a61af66fc99e Initial load
duke
parents:
diff changeset
51 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
52 ResourceArea() {
a61af66fc99e Initial load
duke
parents:
diff changeset
53 debug_only(_nesting = 0;)
a61af66fc99e Initial load
duke
parents:
diff changeset
54 }
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 ResourceArea(size_t init_size) : Arena(init_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
57 debug_only(_nesting = 0;);
a61af66fc99e Initial load
duke
parents:
diff changeset
58 }
a61af66fc99e Initial load
duke
parents:
diff changeset
59
6872
7b5885dadbdc 8000617: It should be possible to allocate memory without the VM dying.
nloodin
parents: 6197
diff changeset
60 char* allocate_bytes(size_t size, AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
61 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
62 if (_nesting < 1 && !_warned++)
a61af66fc99e Initial load
duke
parents:
diff changeset
63 fatal("memory leak: allocating without ResourceMark");
a61af66fc99e Initial load
duke
parents:
diff changeset
64 if (UseMallocOnly) {
a61af66fc99e Initial load
duke
parents:
diff changeset
65 // use malloc, but save pointer in res. area for later freeing
a61af66fc99e Initial load
duke
parents:
diff changeset
66 char** save = (char**)internal_malloc_4(sizeof(char*));
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 3960
diff changeset
67 return (*save = (char*)os::malloc(size, mtThread));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
68 }
a61af66fc99e Initial load
duke
parents:
diff changeset
69 #endif
6872
7b5885dadbdc 8000617: It should be possible to allocate memory without the VM dying.
nloodin
parents: 6197
diff changeset
70 return (char*)Amalloc(size, alloc_failmode);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
71 }
a61af66fc99e Initial load
duke
parents:
diff changeset
72
a61af66fc99e Initial load
duke
parents:
diff changeset
73 debug_only(int nesting() const { return _nesting; });
a61af66fc99e Initial load
duke
parents:
diff changeset
74 };
a61af66fc99e Initial load
duke
parents:
diff changeset
75
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 //------------------------------ResourceMark-----------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // A resource mark releases all resources allocated after it was constructed
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // when the destructor is called. Typically used as a local variable.
a61af66fc99e Initial load
duke
parents:
diff changeset
80 class ResourceMark: public StackObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
81 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
82 ResourceArea *_area; // Resource area to stack allocate
a61af66fc99e Initial load
duke
parents:
diff changeset
83 Chunk *_chunk; // saved arena chunk
a61af66fc99e Initial load
duke
parents:
diff changeset
84 char *_hwm, *_max;
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 3960
diff changeset
85 size_t _size_in_bytes;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 void initialize(Thread *thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
88 _area = thread->resource_area();
a61af66fc99e Initial load
duke
parents:
diff changeset
89 _chunk = _area->_chunk;
a61af66fc99e Initial load
duke
parents:
diff changeset
90 _hwm = _area->_hwm;
a61af66fc99e Initial load
duke
parents:
diff changeset
91 _max= _area->_max;
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 3960
diff changeset
92 _size_in_bytes = _area->size_in_bytes();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
93 debug_only(_area->_nesting++;)
a61af66fc99e Initial load
duke
parents:
diff changeset
94 assert( _area->_nesting > 0, "must stack allocate RMs" );
a61af66fc99e Initial load
duke
parents:
diff changeset
95 }
a61af66fc99e Initial load
duke
parents:
diff changeset
96 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
97
a61af66fc99e Initial load
duke
parents:
diff changeset
98 #ifndef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
99 ResourceMark(Thread *thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
100 assert(thread == Thread::current(), "not the current thread");
a61af66fc99e Initial load
duke
parents:
diff changeset
101 initialize(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
102 }
a61af66fc99e Initial load
duke
parents:
diff changeset
103 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
104 ResourceMark(Thread *thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
105 #endif // ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
106
a61af66fc99e Initial load
duke
parents:
diff changeset
107 ResourceMark() { initialize(Thread::current()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109 ResourceMark( ResourceArea *r ) :
a61af66fc99e Initial load
duke
parents:
diff changeset
110 _area(r), _chunk(r->_chunk), _hwm(r->_hwm), _max(r->_max) {
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 3960
diff changeset
111 _size_in_bytes = r->_size_in_bytes;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
112 debug_only(_area->_nesting++;)
a61af66fc99e Initial load
duke
parents:
diff changeset
113 assert( _area->_nesting > 0, "must stack allocate RMs" );
a61af66fc99e Initial load
duke
parents:
diff changeset
114 }
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 void reset_to_mark() {
a61af66fc99e Initial load
duke
parents:
diff changeset
117 if (UseMallocOnly) free_malloced_objects();
a61af66fc99e Initial load
duke
parents:
diff changeset
118
6882
716c64bda5ba 7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents: 6872
diff changeset
119 if( _chunk->next() ) { // Delete later chunks
716c64bda5ba 7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents: 6872
diff changeset
120 // reset arena size before delete chunks. Otherwise, the total
716c64bda5ba 7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents: 6872
diff changeset
121 // arena size could exceed total chunk size
716c64bda5ba 7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents: 6872
diff changeset
122 assert(_area->size_in_bytes() > size_in_bytes(), "Sanity check");
716c64bda5ba 7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents: 6872
diff changeset
123 _area->set_size_in_bytes(size_in_bytes());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
124 _chunk->next_chop();
6882
716c64bda5ba 7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents: 6872
diff changeset
125 } else {
716c64bda5ba 7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents: 6872
diff changeset
126 assert(_area->size_in_bytes() == size_in_bytes(), "Sanity check");
716c64bda5ba 7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents: 6872
diff changeset
127 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
128 _area->_chunk = _chunk; // Roll back arena to saved chunk
a61af66fc99e Initial load
duke
parents:
diff changeset
129 _area->_hwm = _hwm;
a61af66fc99e Initial load
duke
parents:
diff changeset
130 _area->_max = _max;
a61af66fc99e Initial load
duke
parents:
diff changeset
131
a61af66fc99e Initial load
duke
parents:
diff changeset
132 // clear out this chunk (to detect allocation bugs)
a61af66fc99e Initial load
duke
parents:
diff changeset
133 if (ZapResourceArea) memset(_hwm, badResourceValue, _max - _hwm);
a61af66fc99e Initial load
duke
parents:
diff changeset
134 }
a61af66fc99e Initial load
duke
parents:
diff changeset
135
a61af66fc99e Initial load
duke
parents:
diff changeset
136 ~ResourceMark() {
a61af66fc99e Initial load
duke
parents:
diff changeset
137 assert( _area->_nesting > 0, "must stack allocate RMs" );
a61af66fc99e Initial load
duke
parents:
diff changeset
138 debug_only(_area->_nesting--;)
a61af66fc99e Initial load
duke
parents:
diff changeset
139 reset_to_mark();
a61af66fc99e Initial load
duke
parents:
diff changeset
140 }
a61af66fc99e Initial load
duke
parents:
diff changeset
141
a61af66fc99e Initial load
duke
parents:
diff changeset
142
a61af66fc99e Initial load
duke
parents:
diff changeset
143 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
144 void free_malloced_objects() PRODUCT_RETURN;
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 3960
diff changeset
145 size_t size_in_bytes() { return _size_in_bytes; }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
146 };
a61af66fc99e Initial load
duke
parents:
diff changeset
147
a61af66fc99e Initial load
duke
parents:
diff changeset
148 //------------------------------DeoptResourceMark-----------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
149 // A deopt resource mark releases all resources allocated after it was constructed
a61af66fc99e Initial load
duke
parents:
diff changeset
150 // when the destructor is called. Typically used as a local variable. It differs
a61af66fc99e Initial load
duke
parents:
diff changeset
151 // from a typical resource more in that it is C-Heap allocated so that deoptimization
a61af66fc99e Initial load
duke
parents:
diff changeset
152 // can use data structures that are arena based but are not amenable to vanilla
a61af66fc99e Initial load
duke
parents:
diff changeset
153 // ResourceMarks because deoptimization can not use a stack allocated mark. During
a61af66fc99e Initial load
duke
parents:
diff changeset
154 // deoptimization we go thru the following steps:
a61af66fc99e Initial load
duke
parents:
diff changeset
155 //
a61af66fc99e Initial load
duke
parents:
diff changeset
156 // 0: start in assembly stub and call either uncommon_trap/fetch_unroll_info
a61af66fc99e Initial load
duke
parents:
diff changeset
157 // 1: create the vframeArray (contains pointers to Resource allocated structures)
a61af66fc99e Initial load
duke
parents:
diff changeset
158 // This allocates the DeoptResourceMark.
a61af66fc99e Initial load
duke
parents:
diff changeset
159 // 2: return to assembly stub and remove stub frame and deoptee frame and create
a61af66fc99e Initial load
duke
parents:
diff changeset
160 // the new skeletal frames.
a61af66fc99e Initial load
duke
parents:
diff changeset
161 // 3: push new stub frame and call unpack_frames
a61af66fc99e Initial load
duke
parents:
diff changeset
162 // 4: retrieve information from the vframeArray to populate the skeletal frames
a61af66fc99e Initial load
duke
parents:
diff changeset
163 // 5: release the DeoptResourceMark
a61af66fc99e Initial load
duke
parents:
diff changeset
164 // 6: return to stub and eventually to interpreter
a61af66fc99e Initial load
duke
parents:
diff changeset
165 //
a61af66fc99e Initial load
duke
parents:
diff changeset
166 // With old style eager deoptimization the vframeArray was created by the vmThread there
a61af66fc99e Initial load
duke
parents:
diff changeset
167 // was no way for the vframeArray to contain resource allocated objects and so
a61af66fc99e Initial load
duke
parents:
diff changeset
168 // a complex set of data structures to simulate an array of vframes in CHeap memory
a61af66fc99e Initial load
duke
parents:
diff changeset
169 // was used. With new style lazy deoptimization the vframeArray is created in the
a61af66fc99e Initial load
duke
parents:
diff changeset
170 // the thread that will use it and we can use a much simpler scheme for the vframeArray
a61af66fc99e Initial load
duke
parents:
diff changeset
171 // leveraging existing data structures if we simply create a way to manage this one
a61af66fc99e Initial load
duke
parents:
diff changeset
172 // special need for a ResourceMark. If ResourceMark simply inherited from CHeapObj
a61af66fc99e Initial load
duke
parents:
diff changeset
173 // then existing ResourceMarks would work fine since no one use new to allocate them
a61af66fc99e Initial load
duke
parents:
diff changeset
174 // and they would be stack allocated. This leaves open the possibilty of accidental
a61af66fc99e Initial load
duke
parents:
diff changeset
175 // misuse so we simple duplicate the ResourceMark functionality here.
a61af66fc99e Initial load
duke
parents:
diff changeset
176
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 3960
diff changeset
177 class DeoptResourceMark: public CHeapObj<mtInternal> {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
178 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
179 ResourceArea *_area; // Resource area to stack allocate
a61af66fc99e Initial load
duke
parents:
diff changeset
180 Chunk *_chunk; // saved arena chunk
a61af66fc99e Initial load
duke
parents:
diff changeset
181 char *_hwm, *_max;
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 3960
diff changeset
182 size_t _size_in_bytes;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
183
a61af66fc99e Initial load
duke
parents:
diff changeset
184 void initialize(Thread *thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
185 _area = thread->resource_area();
a61af66fc99e Initial load
duke
parents:
diff changeset
186 _chunk = _area->_chunk;
a61af66fc99e Initial load
duke
parents:
diff changeset
187 _hwm = _area->_hwm;
a61af66fc99e Initial load
duke
parents:
diff changeset
188 _max= _area->_max;
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 3960
diff changeset
189 _size_in_bytes = _area->size_in_bytes();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
190 debug_only(_area->_nesting++;)
a61af66fc99e Initial load
duke
parents:
diff changeset
191 assert( _area->_nesting > 0, "must stack allocate RMs" );
a61af66fc99e Initial load
duke
parents:
diff changeset
192 }
a61af66fc99e Initial load
duke
parents:
diff changeset
193
a61af66fc99e Initial load
duke
parents:
diff changeset
194 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
195
a61af66fc99e Initial load
duke
parents:
diff changeset
196 #ifndef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
197 DeoptResourceMark(Thread *thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
198 assert(thread == Thread::current(), "not the current thread");
a61af66fc99e Initial load
duke
parents:
diff changeset
199 initialize(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
200 }
a61af66fc99e Initial load
duke
parents:
diff changeset
201 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
202 DeoptResourceMark(Thread *thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
203 #endif // ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
204
a61af66fc99e Initial load
duke
parents:
diff changeset
205 DeoptResourceMark() { initialize(Thread::current()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
206
a61af66fc99e Initial load
duke
parents:
diff changeset
207 DeoptResourceMark( ResourceArea *r ) :
a61af66fc99e Initial load
duke
parents:
diff changeset
208 _area(r), _chunk(r->_chunk), _hwm(r->_hwm), _max(r->_max) {
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 3960
diff changeset
209 _size_in_bytes = _area->size_in_bytes();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
210 debug_only(_area->_nesting++;)
a61af66fc99e Initial load
duke
parents:
diff changeset
211 assert( _area->_nesting > 0, "must stack allocate RMs" );
a61af66fc99e Initial load
duke
parents:
diff changeset
212 }
a61af66fc99e Initial load
duke
parents:
diff changeset
213
a61af66fc99e Initial load
duke
parents:
diff changeset
214 void reset_to_mark() {
a61af66fc99e Initial load
duke
parents:
diff changeset
215 if (UseMallocOnly) free_malloced_objects();
a61af66fc99e Initial load
duke
parents:
diff changeset
216
6882
716c64bda5ba 7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents: 6872
diff changeset
217 if( _chunk->next() ) { // Delete later chunks
716c64bda5ba 7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents: 6872
diff changeset
218 // reset arena size before delete chunks. Otherwise, the total
716c64bda5ba 7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents: 6872
diff changeset
219 // arena size could exceed total chunk size
716c64bda5ba 7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents: 6872
diff changeset
220 assert(_area->size_in_bytes() > size_in_bytes(), "Sanity check");
716c64bda5ba 7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents: 6872
diff changeset
221 _area->set_size_in_bytes(size_in_bytes());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
222 _chunk->next_chop();
6882
716c64bda5ba 7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents: 6872
diff changeset
223 } else {
716c64bda5ba 7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents: 6872
diff changeset
224 assert(_area->size_in_bytes() == size_in_bytes(), "Sanity check");
716c64bda5ba 7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents: 6872
diff changeset
225 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
226 _area->_chunk = _chunk; // Roll back arena to saved chunk
a61af66fc99e Initial load
duke
parents:
diff changeset
227 _area->_hwm = _hwm;
a61af66fc99e Initial load
duke
parents:
diff changeset
228 _area->_max = _max;
a61af66fc99e Initial load
duke
parents:
diff changeset
229
a61af66fc99e Initial load
duke
parents:
diff changeset
230 // clear out this chunk (to detect allocation bugs)
a61af66fc99e Initial load
duke
parents:
diff changeset
231 if (ZapResourceArea) memset(_hwm, badResourceValue, _max - _hwm);
a61af66fc99e Initial load
duke
parents:
diff changeset
232 }
a61af66fc99e Initial load
duke
parents:
diff changeset
233
a61af66fc99e Initial load
duke
parents:
diff changeset
234 ~DeoptResourceMark() {
a61af66fc99e Initial load
duke
parents:
diff changeset
235 assert( _area->_nesting > 0, "must stack allocate RMs" );
a61af66fc99e Initial load
duke
parents:
diff changeset
236 debug_only(_area->_nesting--;)
a61af66fc99e Initial load
duke
parents:
diff changeset
237 reset_to_mark();
a61af66fc99e Initial load
duke
parents:
diff changeset
238 }
a61af66fc99e Initial load
duke
parents:
diff changeset
239
a61af66fc99e Initial load
duke
parents:
diff changeset
240
a61af66fc99e Initial load
duke
parents:
diff changeset
241 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
242 void free_malloced_objects() PRODUCT_RETURN;
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 3960
diff changeset
243 size_t size_in_bytes() { return _size_in_bytes; };
0
a61af66fc99e Initial load
duke
parents:
diff changeset
244 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
245
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
246 #endif // SHARE_VM_MEMORY_RESOURCEAREA_HPP