Mercurial > hg > truffle
annotate src/share/vm/runtime/handles.cpp @ 6862:8a5ea0a9ccc4
7127708: G1: change task num types from int to uint in concurrent mark
Summary: Change the type of various task num fields, parameters etc to unsigned and rename them to be more consistent with the other collectors. Code changes were also reviewed by Vitaly Davidovich.
Reviewed-by: johnc
Contributed-by: Kaushik Srenevasan <kaushik@twitter.com>
author | johnc |
---|---|
date | Sat, 06 Oct 2012 01:17:44 -0700 |
parents | da91efe96a93 |
children | bdb5f8c9978b |
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) 1997, 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 #include "precompiled.hpp" |
26 #include "memory/allocation.inline.hpp" | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
27 #include "oops/constantPool.hpp" |
1972 | 28 #include "oops/oop.inline.hpp" |
29 #include "runtime/handles.inline.hpp" | |
30 #ifdef TARGET_OS_FAMILY_linux | |
31 # include "os_linux.inline.hpp" | |
32 # include "thread_linux.inline.hpp" | |
33 #endif | |
34 #ifdef TARGET_OS_FAMILY_solaris | |
35 # include "os_solaris.inline.hpp" | |
36 # include "thread_solaris.inline.hpp" | |
37 #endif | |
38 #ifdef TARGET_OS_FAMILY_windows | |
39 # include "os_windows.inline.hpp" | |
40 # include "thread_windows.inline.hpp" | |
41 #endif | |
3960 | 42 #ifdef TARGET_OS_FAMILY_bsd |
43 # include "os_bsd.inline.hpp" | |
44 # include "thread_bsd.inline.hpp" | |
45 #endif | |
0 | 46 |
47 #ifdef ASSERT | |
48 oop* HandleArea::allocate_handle(oop obj) { | |
49 assert(_handle_mark_nesting > 1, "memory leak: allocating handle outside HandleMark"); | |
50 assert(_no_handle_mark_nesting == 0, "allocating handle inside NoHandleMark"); | |
51 assert(SharedSkipVerify || obj->is_oop(), "sanity check"); | |
52 return real_allocate_handle(obj); | |
53 } | |
54 | |
55 Handle::Handle(Thread* thread, oop obj) { | |
56 assert(thread == Thread::current(), "sanity check"); | |
57 if (obj == NULL) { | |
58 _handle = NULL; | |
59 } else { | |
60 _handle = thread->handle_area()->allocate_handle(obj); | |
61 } | |
62 } | |
63 | |
64 #endif | |
65 | |
66 static uintx chunk_oops_do(OopClosure* f, Chunk* chunk, char* chunk_top) { | |
67 oop* bottom = (oop*) chunk->bottom(); | |
68 oop* top = (oop*) chunk_top; | |
69 uintx handles_visited = top - bottom; | |
70 assert(top >= bottom && top <= (oop*) chunk->top(), "just checking"); | |
71 // during GC phase 3, a handle may be a forward pointer that | |
72 // is not yet valid, so loosen the assertion | |
73 while (bottom < top) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
74 // This test can be moved up but for now check every oop. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
75 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
76 assert((*bottom)->is_oop(), "handle should point to oop"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
77 |
0 | 78 f->do_oop(bottom++); |
79 } | |
80 return handles_visited; | |
81 } | |
82 | |
83 // Used for debugging handle allocation. | |
84 NOT_PRODUCT(jint _nof_handlemarks = 0;) | |
85 | |
86 void HandleArea::oops_do(OopClosure* f) { | |
87 uintx handles_visited = 0; | |
88 // First handle the current chunk. It is filled to the high water mark. | |
89 handles_visited += chunk_oops_do(f, _chunk, _hwm); | |
90 // Then handle all previous chunks. They are completely filled. | |
91 Chunk* k = _first; | |
92 while(k != _chunk) { | |
93 handles_visited += chunk_oops_do(f, k, k->top()); | |
94 k = k->next(); | |
95 } | |
96 | |
97 // The thread local handle areas should not get very large | |
98 if (TraceHandleAllocation && handles_visited > TotalHandleAllocationLimit) { | |
99 #ifdef ASSERT | |
100 warning("%d: Visited in HandleMark : %d", | |
101 _nof_handlemarks, handles_visited); | |
102 #else | |
103 warning("Visited in HandleMark : %d", handles_visited); | |
104 #endif | |
105 } | |
106 if (_prev != NULL) _prev->oops_do(f); | |
107 } | |
108 | |
109 void HandleMark::initialize(Thread* thread) { | |
110 _thread = thread; | |
111 // Save area | |
112 _area = thread->handle_area(); | |
113 // Save current top | |
114 _chunk = _area->_chunk; | |
115 _hwm = _area->_hwm; | |
116 _max = _area->_max; | |
6197 | 117 _size_in_bytes = _area->_size_in_bytes; |
0 | 118 debug_only(_area->_handle_mark_nesting++); |
119 assert(_area->_handle_mark_nesting > 0, "must stack allocate HandleMarks"); | |
120 debug_only(Atomic::inc(&_nof_handlemarks);) | |
121 | |
122 // Link this in the thread | |
123 set_previous_handle_mark(thread->last_handle_mark()); | |
124 thread->set_last_handle_mark(this); | |
125 } | |
126 | |
127 | |
128 HandleMark::~HandleMark() { | |
129 HandleArea* area = _area; // help compilers with poor alias analysis | |
130 assert(area == _thread->handle_area(), "sanity check"); | |
131 assert(area->_handle_mark_nesting > 0, "must stack allocate HandleMarks" ); | |
132 debug_only(area->_handle_mark_nesting--); | |
133 | |
134 // Debug code to trace the number of handles allocated per mark/ | |
135 #ifdef ASSERT | |
136 if (TraceHandleAllocation) { | |
137 size_t handles = 0; | |
138 Chunk *c = _chunk->next(); | |
139 if (c == NULL) { | |
140 handles = area->_hwm - _hwm; // no new chunk allocated | |
141 } else { | |
142 handles = _max - _hwm; // add rest in first chunk | |
143 while(c != NULL) { | |
144 handles += c->length(); | |
145 c = c->next(); | |
146 } | |
147 handles -= area->_max - area->_hwm; // adjust for last trunk not full | |
148 } | |
149 handles /= sizeof(void *); // Adjust for size of a handle | |
150 if (handles > HandleAllocationLimit) { | |
151 // Note: _nof_handlemarks is only set in debug mode | |
152 warning("%d: Allocated in HandleMark : %d", _nof_handlemarks, handles); | |
153 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
154 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
155 tty->print_cr("Handles %d", handles); |
0 | 156 } |
157 #endif | |
158 | |
159 // Delete later chunks | |
160 if( _chunk->next() ) { | |
161 _chunk->next_chop(); | |
162 } | |
163 // Roll back arena to saved top markers | |
164 area->_chunk = _chunk; | |
165 area->_hwm = _hwm; | |
166 area->_max = _max; | |
6197 | 167 area->set_size_in_bytes(_size_in_bytes); |
0 | 168 #ifdef ASSERT |
169 // clear out first chunk (to detect allocation bugs) | |
170 if (ZapVMHandleArea) { | |
171 memset(_hwm, badHandleValue, _max - _hwm); | |
172 } | |
173 Atomic::dec(&_nof_handlemarks); | |
174 #endif | |
175 | |
176 // Unlink this from the thread | |
177 _thread->set_last_handle_mark(previous_handle_mark()); | |
178 } | |
179 | |
180 #ifdef ASSERT | |
181 | |
182 NoHandleMark::NoHandleMark() { | |
183 HandleArea* area = Thread::current()->handle_area(); | |
184 area->_no_handle_mark_nesting++; | |
185 assert(area->_no_handle_mark_nesting > 0, "must stack allocate NoHandleMark" ); | |
186 } | |
187 | |
188 | |
189 NoHandleMark::~NoHandleMark() { | |
190 HandleArea* area = Thread::current()->handle_area(); | |
191 assert(area->_no_handle_mark_nesting > 0, "must stack allocate NoHandleMark" ); | |
192 area->_no_handle_mark_nesting--; | |
193 } | |
194 | |
195 | |
196 ResetNoHandleMark::ResetNoHandleMark() { | |
197 HandleArea* area = Thread::current()->handle_area(); | |
198 _no_handle_mark_nesting = area->_no_handle_mark_nesting; | |
199 area->_no_handle_mark_nesting = 0; | |
200 } | |
201 | |
202 | |
203 ResetNoHandleMark::~ResetNoHandleMark() { | |
204 HandleArea* area = Thread::current()->handle_area(); | |
205 area->_no_handle_mark_nesting = _no_handle_mark_nesting; | |
206 } | |
207 | |
208 #endif |