author | tschatzl |
Wed, 08 Aug 2018 15:31:06 +0200 | |
changeset 51333 | f6641fcf7b7e |
parent 51078 | fc6cfe40e32a |
child 52070 | e4d72440d60e |
permissions | -rw-r--r-- |
1 | 1 |
/* |
49393 | 2 |
* Copyright (c) 1998, 2018, 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:
3795
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3795
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:
3795
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "code/codeBlob.hpp" |
|
27 |
#include "code/codeCache.hpp" |
|
28 |
#include "code/nmethod.hpp" |
|
29 |
#include "code/scopeDesc.hpp" |
|
30 |
#include "compiler/oopMap.hpp" |
|
30764 | 31 |
#include "gc/shared/collectedHeap.hpp" |
7397 | 32 |
#include "memory/allocation.inline.hpp" |
47676
b1c020fc35a3
8189748: More precise closures for WeakProcessor::weak_oops_do calls
stefank
parents:
47547
diff
changeset
|
33 |
#include "memory/iterator.hpp" |
7397 | 34 |
#include "memory/resourceArea.hpp" |
35 |
#include "runtime/frame.inline.hpp" |
|
49393 | 36 |
#include "runtime/handles.inline.hpp" |
7397 | 37 |
#include "runtime/signature.hpp" |
46625 | 38 |
#include "utilities/align.hpp" |
7397 | 39 |
#ifdef COMPILER1 |
40 |
#include "c1/c1_Defs.hpp" |
|
41 |
#endif |
|
25715
d5a8dbdc5150
8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents:
24424
diff
changeset
|
42 |
#ifdef COMPILER2 |
d5a8dbdc5150
8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents:
24424
diff
changeset
|
43 |
#include "opto/optoreg.hpp" |
d5a8dbdc5150
8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents:
24424
diff
changeset
|
44 |
#endif |
1 | 45 |
|
46 |
// OopMapStream |
|
47 |
||
30590 | 48 |
OopMapStream::OopMapStream(OopMap* oop_map, int oop_types_mask) { |
49 |
_stream = new CompressedReadStream(oop_map->write_stream()->buffer()); |
|
50 |
_mask = oop_types_mask; |
|
1 | 51 |
_size = oop_map->omv_count(); |
52 |
_position = 0; |
|
53 |
_valid_omv = false; |
|
54 |
} |
|
55 |
||
30590 | 56 |
OopMapStream::OopMapStream(const ImmutableOopMap* oop_map, int oop_types_mask) { |
57 |
_stream = new CompressedReadStream(oop_map->data_addr()); |
|
1 | 58 |
_mask = oop_types_mask; |
30590 | 59 |
_size = oop_map->count(); |
1 | 60 |
_position = 0; |
61 |
_valid_omv = false; |
|
62 |
} |
|
63 |
||
64 |
void OopMapStream::find_next() { |
|
65 |
while(_position++ < _size) { |
|
66 |
_omv.read_from(_stream); |
|
67 |
if(((int)_omv.type() & _mask) > 0) { |
|
68 |
_valid_omv = true; |
|
69 |
return; |
|
70 |
} |
|
71 |
} |
|
72 |
_valid_omv = false; |
|
73 |
} |
|
74 |
||
75 |
||
76 |
// OopMap |
|
77 |
||
78 |
// frame_size units are stack-slots (4 bytes) NOT intptr_t; we can name odd |
|
79 |
// slots to hold 4-byte values like ints and floats in the LP64 build. |
|
80 |
OopMap::OopMap(int frame_size, int arg_count) { |
|
81 |
// OopMaps are usually quite so small, so pick a small initial size |
|
82 |
set_write_stream(new CompressedWriteStream(32)); |
|
83 |
set_omv_count(0); |
|
84 |
||
85 |
#ifdef ASSERT |
|
86 |
_locs_length = VMRegImpl::stack2reg(0)->value() + frame_size + arg_count; |
|
87 |
_locs_used = NEW_RESOURCE_ARRAY(OopMapValue::oop_types, _locs_length); |
|
88 |
for(int i = 0; i < _locs_length; i++) _locs_used[i] = OopMapValue::unused_value; |
|
89 |
#endif |
|
90 |
} |
|
91 |
||
92 |
||
93 |
OopMap::OopMap(OopMap::DeepCopyToken, OopMap* source) { |
|
94 |
// This constructor does a deep copy |
|
95 |
// of the source OopMap. |
|
96 |
set_write_stream(new CompressedWriteStream(source->omv_count() * 2)); |
|
97 |
set_omv_count(0); |
|
98 |
set_offset(source->offset()); |
|
99 |
||
100 |
#ifdef ASSERT |
|
101 |
_locs_length = source->_locs_length; |
|
102 |
_locs_used = NEW_RESOURCE_ARRAY(OopMapValue::oop_types, _locs_length); |
|
103 |
for(int i = 0; i < _locs_length; i++) _locs_used[i] = OopMapValue::unused_value; |
|
104 |
#endif |
|
105 |
||
106 |
// We need to copy the entries too. |
|
107 |
for (OopMapStream oms(source); !oms.is_done(); oms.next()) { |
|
108 |
OopMapValue omv = oms.current(); |
|
109 |
omv.write_on(write_stream()); |
|
110 |
increment_count(); |
|
111 |
} |
|
112 |
} |
|
113 |
||
114 |
||
115 |
OopMap* OopMap::deep_copy() { |
|
116 |
return new OopMap(_deep_copy_token, this); |
|
117 |
} |
|
118 |
||
30590 | 119 |
void OopMap::copy_data_to(address addr) const { |
120 |
memcpy(addr, write_stream()->buffer(), write_stream()->position()); |
|
1 | 121 |
} |
122 |
||
123 |
int OopMap::heap_size() const { |
|
124 |
int size = sizeof(OopMap); |
|
125 |
int align = sizeof(void *) - 1; |
|
30590 | 126 |
size += write_stream()->position(); |
1 | 127 |
// Align to a reasonable ending point |
128 |
size = ((size+align) & ~align); |
|
129 |
return size; |
|
130 |
} |
|
131 |
||
132 |
// frame_size units are stack-slots (4 bytes) NOT intptr_t; we can name odd |
|
133 |
// slots to hold 4-byte values like ints and floats in the LP64 build. |
|
134 |
void OopMap::set_xxx(VMReg reg, OopMapValue::oop_types x, VMReg optional) { |
|
135 |
||
136 |
assert(reg->value() < _locs_length, "too big reg value for stack size"); |
|
137 |
assert( _locs_used[reg->value()] == OopMapValue::unused_value, "cannot insert twice" ); |
|
138 |
debug_only( _locs_used[reg->value()] = x; ) |
|
139 |
||
140 |
OopMapValue o(reg, x); |
|
141 |
||
142 |
if(x == OopMapValue::callee_saved_value) { |
|
143 |
// This can never be a stack location, so we don't need to transform it. |
|
144 |
assert(optional->is_reg(), "Trying to callee save a stack location"); |
|
145 |
o.set_content_reg(optional); |
|
146 |
} else if(x == OopMapValue::derived_oop_value) { |
|
147 |
o.set_content_reg(optional); |
|
148 |
} |
|
149 |
||
150 |
o.write_on(write_stream()); |
|
151 |
increment_count(); |
|
152 |
} |
|
153 |
||
154 |
||
155 |
void OopMap::set_oop(VMReg reg) { |
|
156 |
set_xxx(reg, OopMapValue::oop_value, VMRegImpl::Bad()); |
|
157 |
} |
|
158 |
||
159 |
||
160 |
void OopMap::set_value(VMReg reg) { |
|
33063 | 161 |
// At this time, we don't need value entries in our OopMap. |
1 | 162 |
} |
163 |
||
164 |
||
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
347
diff
changeset
|
165 |
void OopMap::set_narrowoop(VMReg reg) { |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
347
diff
changeset
|
166 |
set_xxx(reg, OopMapValue::narrowoop_value, VMRegImpl::Bad()); |
1 | 167 |
} |
168 |
||
169 |
||
170 |
void OopMap::set_callee_saved(VMReg reg, VMReg caller_machine_register ) { |
|
171 |
set_xxx(reg, OopMapValue::callee_saved_value, caller_machine_register); |
|
172 |
} |
|
173 |
||
174 |
||
175 |
void OopMap::set_derived_oop(VMReg reg, VMReg derived_from_local_register ) { |
|
176 |
if( reg == derived_from_local_register ) { |
|
177 |
// Actually an oop, derived shares storage with base, |
|
178 |
set_oop(reg); |
|
179 |
} else { |
|
180 |
set_xxx(reg, OopMapValue::derived_oop_value, derived_from_local_register); |
|
181 |
} |
|
182 |
} |
|
183 |
||
184 |
// OopMapSet |
|
185 |
||
186 |
OopMapSet::OopMapSet() { |
|
187 |
set_om_size(MinOopMapAllocation); |
|
188 |
set_om_count(0); |
|
189 |
OopMap** temp = NEW_RESOURCE_ARRAY(OopMap*, om_size()); |
|
190 |
set_om_data(temp); |
|
191 |
} |
|
192 |
||
193 |
||
194 |
void OopMapSet::grow_om_data() { |
|
195 |
int new_size = om_size() * 2; |
|
196 |
OopMap** new_data = NEW_RESOURCE_ARRAY(OopMap*, new_size); |
|
197 |
memcpy(new_data,om_data(),om_size() * sizeof(OopMap*)); |
|
198 |
set_om_size(new_size); |
|
199 |
set_om_data(new_data); |
|
200 |
} |
|
201 |
||
202 |
void OopMapSet::add_gc_map(int pc_offset, OopMap *map ) { |
|
203 |
assert(om_size() != -1,"Cannot grow a fixed OopMapSet"); |
|
204 |
||
205 |
if(om_count() >= om_size()) { |
|
206 |
grow_om_data(); |
|
207 |
} |
|
208 |
map->set_offset(pc_offset); |
|
209 |
||
210 |
#ifdef ASSERT |
|
211 |
if(om_count() > 0) { |
|
212 |
OopMap* last = at(om_count()-1); |
|
213 |
if (last->offset() == map->offset() ) { |
|
214 |
fatal("OopMap inserted twice"); |
|
215 |
} |
|
216 |
if(last->offset() > map->offset()) { |
|
217 |
tty->print_cr( "WARNING, maps not sorted: pc[%d]=%d, pc[%d]=%d", |
|
218 |
om_count(),last->offset(),om_count()+1,map->offset()); |
|
219 |
} |
|
220 |
} |
|
221 |
#endif // ASSERT |
|
222 |
||
223 |
set(om_count(),map); |
|
224 |
increment_count(); |
|
225 |
} |
|
226 |
||
227 |
||
228 |
int OopMapSet::heap_size() const { |
|
229 |
// The space we use |
|
230 |
int size = sizeof(OopMap); |
|
231 |
int align = sizeof(void *) - 1; |
|
232 |
size = ((size+align) & ~align); |
|
233 |
size += om_count() * sizeof(OopMap*); |
|
234 |
||
235 |
// Now add in the space needed for the indivdiual OopMaps |
|
236 |
for(int i=0; i < om_count(); i++) { |
|
237 |
size += at(i)->heap_size(); |
|
238 |
} |
|
239 |
// We don't need to align this, it will be naturally pointer aligned |
|
240 |
return size; |
|
241 |
} |
|
242 |
||
243 |
||
244 |
OopMap* OopMapSet::singular_oop_map() { |
|
245 |
guarantee(om_count() == 1, "Make sure we only have a single gc point"); |
|
246 |
return at(0); |
|
247 |
} |
|
248 |
||
249 |
||
250 |
OopMap* OopMapSet::find_map_at_offset(int pc_offset) const { |
|
251 |
int i, len = om_count(); |
|
252 |
assert( len > 0, "must have pointer maps" ); |
|
253 |
||
254 |
// Scan through oopmaps. Stop when current offset is either equal or greater |
|
255 |
// than the one we are looking for. |
|
256 |
for( i = 0; i < len; i++) { |
|
257 |
if( at(i)->offset() >= pc_offset ) |
|
258 |
break; |
|
259 |
} |
|
260 |
||
261 |
assert( i < len, "oopmap not found" ); |
|
262 |
||
263 |
OopMap* m = at(i); |
|
264 |
assert( m->offset() == pc_offset, "oopmap not found" ); |
|
265 |
return m; |
|
266 |
} |
|
267 |
||
268 |
static void add_derived_oop(oop* base, oop* derived) { |
|
49972
37b2446d7f86
8202552: [AOT][JVMCI] Incorrect usage of INCLUDE_JVMCI and INCLUDE_AOT
kvn
parents:
49393
diff
changeset
|
269 |
#if !defined(TIERED) && !INCLUDE_JVMCI |
1 | 270 |
COMPILER1_PRESENT(ShouldNotReachHere();) |
49972
37b2446d7f86
8202552: [AOT][JVMCI] Incorrect usage of INCLUDE_JVMCI and INCLUDE_AOT
kvn
parents:
49393
diff
changeset
|
271 |
#endif // !defined(TIERED) && !INCLUDE_JVMCI |
47799 | 272 |
#if COMPILER2_OR_JVMCI |
1 | 273 |
DerivedPointerTable::add(derived, base); |
47799 | 274 |
#endif // COMPILER2_OR_JVMCI |
1 | 275 |
} |
276 |
||
277 |
||
278 |
#ifndef PRODUCT |
|
279 |
static void trace_codeblob_maps(const frame *fr, const RegisterMap *reg_map) { |
|
280 |
// Print oopmap and regmap |
|
281 |
tty->print_cr("------ "); |
|
282 |
CodeBlob* cb = fr->cb(); |
|
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
283 |
const ImmutableOopMapSet* maps = cb->oop_maps(); |
30590 | 284 |
const ImmutableOopMap* map = cb->oop_map_for_return_address(fr->pc()); |
1 | 285 |
map->print(); |
286 |
if( cb->is_nmethod() ) { |
|
287 |
nmethod* nm = (nmethod*)cb; |
|
288 |
// native wrappers have no scope data, it is implied |
|
289 |
if (nm->is_native_method()) { |
|
290 |
tty->print("bci: 0 (native)"); |
|
291 |
} else { |
|
292 |
ScopeDesc* scope = nm->scope_desc_at(fr->pc()); |
|
293 |
tty->print("bci: %d ",scope->bci()); |
|
294 |
} |
|
295 |
} |
|
296 |
tty->cr(); |
|
297 |
fr->print_on(tty); |
|
298 |
tty->print(" "); |
|
299 |
cb->print_value_on(tty); tty->cr(); |
|
300 |
reg_map->print(); |
|
301 |
tty->print_cr("------ "); |
|
302 |
||
303 |
} |
|
304 |
#endif // PRODUCT |
|
305 |
||
306 |
void OopMapSet::oops_do(const frame *fr, const RegisterMap* reg_map, OopClosure* f) { |
|
307 |
// add derived oops to a table |
|
47676
b1c020fc35a3
8189748: More precise closures for WeakProcessor::weak_oops_do calls
stefank
parents:
47547
diff
changeset
|
308 |
all_do(fr, reg_map, f, add_derived_oop, &do_nothing_cl); |
1 | 309 |
} |
310 |
||
311 |
||
312 |
void OopMapSet::all_do(const frame *fr, const RegisterMap *reg_map, |
|
313 |
OopClosure* oop_fn, void derived_oop_fn(oop*, oop*), |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
347
diff
changeset
|
314 |
OopClosure* value_fn) { |
1 | 315 |
CodeBlob* cb = fr->cb(); |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
347
diff
changeset
|
316 |
assert(cb != NULL, "no codeblob"); |
1 | 317 |
|
318 |
NOT_PRODUCT(if (TraceCodeBlobStacks) trace_codeblob_maps(fr, reg_map);) |
|
319 |
||
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
320 |
const ImmutableOopMapSet* maps = cb->oop_maps(); |
30590 | 321 |
const ImmutableOopMap* map = cb->oop_map_for_return_address(fr->pc()); |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
347
diff
changeset
|
322 |
assert(map != NULL, "no ptr map found"); |
1 | 323 |
|
324 |
// handle derived pointers first (otherwise base pointer may be |
|
325 |
// changed before derived pointer offset has been collected) |
|
326 |
OopMapValue omv; |
|
327 |
{ |
|
328 |
OopMapStream oms(map,OopMapValue::derived_oop_value); |
|
329 |
if (!oms.is_done()) { |
|
330 |
#ifndef TIERED |
|
331 |
COMPILER1_PRESENT(ShouldNotReachHere();) |
|
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
332 |
#if INCLUDE_JVMCI |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
333 |
if (UseJVMCICompiler) { |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
334 |
ShouldNotReachHere(); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
335 |
} |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
336 |
#endif |
1 | 337 |
#endif // !TIERED |
338 |
// Protect the operation on the derived pointers. This |
|
339 |
// protects the addition of derived pointers to the shared |
|
340 |
// derived pointer table in DerivedPointerTable::add(). |
|
341 |
MutexLockerEx x(DerivedPointerTableGC_lock, Mutex::_no_safepoint_check_flag); |
|
342 |
do { |
|
343 |
omv = oms.current(); |
|
344 |
oop* loc = fr->oopmapreg_to_location(omv.reg(),reg_map); |
|
33063 | 345 |
guarantee(loc != NULL, "missing saved register"); |
45327
ec60e7df88cd
8180855: Null pointer dereference in OopMapSet::all_do of oopMap.cpp:394
zmajo
parents:
40046
diff
changeset
|
346 |
oop *derived_loc = loc; |
33063 | 347 |
oop *base_loc = fr->oopmapreg_to_location(omv.content_reg(), reg_map); |
45327
ec60e7df88cd
8180855: Null pointer dereference in OopMapSet::all_do of oopMap.cpp:394
zmajo
parents:
40046
diff
changeset
|
348 |
// Ignore NULL oops and decoded NULL narrow oops which |
ec60e7df88cd
8180855: Null pointer dereference in OopMapSet::all_do of oopMap.cpp:394
zmajo
parents:
40046
diff
changeset
|
349 |
// equal to Universe::narrow_oop_base when a narrow oop |
ec60e7df88cd
8180855: Null pointer dereference in OopMapSet::all_do of oopMap.cpp:394
zmajo
parents:
40046
diff
changeset
|
350 |
// implicit null check is used in compiled code. |
ec60e7df88cd
8180855: Null pointer dereference in OopMapSet::all_do of oopMap.cpp:394
zmajo
parents:
40046
diff
changeset
|
351 |
// The narrow_oop_base could be NULL or be the address |
ec60e7df88cd
8180855: Null pointer dereference in OopMapSet::all_do of oopMap.cpp:394
zmajo
parents:
40046
diff
changeset
|
352 |
// of the page below heap depending on compressed oops mode. |
ec60e7df88cd
8180855: Null pointer dereference in OopMapSet::all_do of oopMap.cpp:394
zmajo
parents:
40046
diff
changeset
|
353 |
if (base_loc != NULL && *base_loc != (oop)NULL && !Universe::is_narrow_oop_base(*base_loc)) { |
33063 | 354 |
derived_oop_fn(base_loc, derived_loc); |
1 | 355 |
} |
356 |
oms.next(); |
|
357 |
} while (!oms.is_done()); |
|
358 |
} |
|
359 |
} |
|
360 |
||
33063 | 361 |
// We want coop and oop oop_types |
362 |
int mask = OopMapValue::oop_value | OopMapValue::narrowoop_value; |
|
1 | 363 |
{ |
364 |
for (OopMapStream oms(map,mask); !oms.is_done(); oms.next()) { |
|
365 |
omv = oms.current(); |
|
366 |
oop* loc = fr->oopmapreg_to_location(omv.reg(),reg_map); |
|
33063 | 367 |
// It should be an error if no location can be found for a |
368 |
// register mentioned as contained an oop of some kind. Maybe |
|
369 |
// this was allowed previously because value_value items might |
|
370 |
// be missing? |
|
371 |
guarantee(loc != NULL, "missing saved register"); |
|
372 |
if ( omv.type() == OopMapValue::oop_value ) { |
|
373 |
oop val = *loc; |
|
374 |
if (val == (oop)NULL || Universe::is_narrow_oop_base(val)) { |
|
375 |
// Ignore NULL oops and decoded NULL narrow oops which |
|
376 |
// equal to Universe::narrow_oop_base when a narrow oop |
|
377 |
// implicit null check is used in compiled code. |
|
378 |
// The narrow_oop_base could be NULL or be the address |
|
379 |
// of the page below heap depending on compressed oops mode. |
|
380 |
continue; |
|
381 |
} |
|
1 | 382 |
#ifdef ASSERT |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
49972
diff
changeset
|
383 |
// We can not verify the oop here if we are using ZGC, the oop |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
49972
diff
changeset
|
384 |
// will be bad in case we had a safepoint between a load and a |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
49972
diff
changeset
|
385 |
// load barrier. |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
49972
diff
changeset
|
386 |
if (!UseZGC && |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
49972
diff
changeset
|
387 |
((((uintptr_t)loc & (sizeof(*loc)-1)) != 0) || |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
49972
diff
changeset
|
388 |
!Universe::heap()->is_in_or_null(*loc))) { |
33063 | 389 |
tty->print_cr("# Found non oop pointer. Dumping state at failure"); |
390 |
// try to dump out some helpful debugging information |
|
391 |
trace_codeblob_maps(fr, reg_map); |
|
392 |
omv.print(); |
|
393 |
tty->print_cr("register r"); |
|
394 |
omv.reg()->print(); |
|
395 |
tty->print_cr("loc = %p *loc = %p\n", loc, (address)*loc); |
|
396 |
// do the real assert. |
|
397 |
assert(Universe::heap()->is_in_or_null(*loc), "found non oop pointer"); |
|
398 |
} |
|
1 | 399 |
#endif // ASSERT |
33063 | 400 |
oop_fn->do_oop(loc); |
401 |
} else if ( omv.type() == OopMapValue::narrowoop_value ) { |
|
402 |
narrowOop *nl = (narrowOop*)loc; |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
347
diff
changeset
|
403 |
#ifndef VM_LITTLE_ENDIAN |
33063 | 404 |
VMReg vmReg = omv.reg(); |
405 |
// Don't do this on SPARC float registers as they can be individually addressed |
|
406 |
if (!vmReg->is_stack() SPARC_ONLY(&& !vmReg->is_FloatRegister())) { |
|
407 |
// compressed oops in registers only take up 4 bytes of an |
|
408 |
// 8 byte register but they are in the wrong part of the |
|
409 |
// word so adjust loc to point at the right place. |
|
410 |
nl = (narrowOop*)((address)nl + 4); |
|
411 |
} |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
347
diff
changeset
|
412 |
#endif |
33063 | 413 |
oop_fn->do_oop(nl); |
1 | 414 |
} |
415 |
} |
|
416 |
} |
|
417 |
} |
|
418 |
||
419 |
||
420 |
// Update callee-saved register info for the following frame |
|
421 |
void OopMapSet::update_register_map(const frame *fr, RegisterMap *reg_map) { |
|
422 |
ResourceMark rm; |
|
423 |
CodeBlob* cb = fr->cb(); |
|
424 |
assert(cb != NULL, "no codeblob"); |
|
425 |
||
426 |
// Any reg might be saved by a safepoint handler (see generate_handler_blob). |
|
427 |
assert( reg_map->_update_for_id == NULL || fr->is_older(reg_map->_update_for_id), |
|
428 |
"already updated this map; do not 'update' it twice!" ); |
|
429 |
debug_only(reg_map->_update_for_id = fr->id()); |
|
430 |
||
431 |
// Check if caller must update oop argument |
|
432 |
assert((reg_map->include_argument_oops() || |
|
433 |
!cb->caller_must_gc_arguments(reg_map->thread())), |
|
434 |
"include_argument_oops should already be set"); |
|
435 |
||
436 |
// Scan through oopmap and find location of all callee-saved registers |
|
437 |
// (we do not do update in place, since info could be overwritten) |
|
438 |
||
439 |
address pc = fr->pc(); |
|
30590 | 440 |
const ImmutableOopMap* map = cb->oop_map_for_return_address(pc); |
24320
394d55c783dc
8040919: Uninitialised memory in hotspot/src/share/vm/compiler/oopMap.cpp
morris
parents:
20282
diff
changeset
|
441 |
assert(map != NULL, "no ptr map found"); |
394d55c783dc
8040919: Uninitialised memory in hotspot/src/share/vm/compiler/oopMap.cpp
morris
parents:
20282
diff
changeset
|
442 |
DEBUG_ONLY(int nof_callee = 0;) |
1 | 443 |
|
24320
394d55c783dc
8040919: Uninitialised memory in hotspot/src/share/vm/compiler/oopMap.cpp
morris
parents:
20282
diff
changeset
|
444 |
for (OopMapStream oms(map, OopMapValue::callee_saved_value); !oms.is_done(); oms.next()) { |
394d55c783dc
8040919: Uninitialised memory in hotspot/src/share/vm/compiler/oopMap.cpp
morris
parents:
20282
diff
changeset
|
445 |
OopMapValue omv = oms.current(); |
394d55c783dc
8040919: Uninitialised memory in hotspot/src/share/vm/compiler/oopMap.cpp
morris
parents:
20282
diff
changeset
|
446 |
VMReg reg = omv.content_reg(); |
394d55c783dc
8040919: Uninitialised memory in hotspot/src/share/vm/compiler/oopMap.cpp
morris
parents:
20282
diff
changeset
|
447 |
oop* loc = fr->oopmapreg_to_location(omv.reg(), reg_map); |
394d55c783dc
8040919: Uninitialised memory in hotspot/src/share/vm/compiler/oopMap.cpp
morris
parents:
20282
diff
changeset
|
448 |
reg_map->set_location(reg, (address) loc); |
394d55c783dc
8040919: Uninitialised memory in hotspot/src/share/vm/compiler/oopMap.cpp
morris
parents:
20282
diff
changeset
|
449 |
DEBUG_ONLY(nof_callee++;) |
1 | 450 |
} |
451 |
||
452 |
// Check that runtime stubs save all callee-saved registers |
|
453 |
#ifdef COMPILER2 |
|
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
454 |
assert(cb->is_compiled_by_c1() || cb->is_compiled_by_jvmci() || !cb->is_runtime_stub() || |
1 | 455 |
(nof_callee >= SAVED_ON_ENTRY_REG_COUNT || nof_callee >= C_SAVED_ON_ENTRY_REG_COUNT), |
456 |
"must save all"); |
|
457 |
#endif // COMPILER2 |
|
458 |
} |
|
459 |
||
460 |
//============================================================================= |
|
461 |
// Non-Product code |
|
462 |
||
463 |
#ifndef PRODUCT |
|
464 |
||
30590 | 465 |
bool ImmutableOopMap::has_derived_pointer() const { |
49972
37b2446d7f86
8202552: [AOT][JVMCI] Incorrect usage of INCLUDE_JVMCI and INCLUDE_AOT
kvn
parents:
49393
diff
changeset
|
466 |
#if !defined(TIERED) && !INCLUDE_JVMCI |
1 | 467 |
COMPILER1_PRESENT(return false); |
468 |
#endif // !TIERED |
|
47799 | 469 |
#if COMPILER2_OR_JVMCI |
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
470 |
OopMapStream oms(this,OopMapValue::derived_oop_value); |
1 | 471 |
return oms.is_done(); |
472 |
#else |
|
473 |
return false; |
|
47799 | 474 |
#endif // COMPILER2_OR_JVMCI |
1 | 475 |
} |
476 |
||
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
198
diff
changeset
|
477 |
#endif //PRODUCT |
1 | 478 |
|
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
198
diff
changeset
|
479 |
// Printing code is present in product build for -XX:+PrintAssembly. |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
198
diff
changeset
|
480 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
198
diff
changeset
|
481 |
static |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
198
diff
changeset
|
482 |
void print_register_type(OopMapValue::oop_types x, VMReg optional, |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
198
diff
changeset
|
483 |
outputStream* st) { |
1 | 484 |
switch( x ) { |
485 |
case OopMapValue::oop_value: |
|
198
8601165a33c3
6621094: PrintOptoAssembly is broken for oops information in DebugInfo
kvn
parents:
1
diff
changeset
|
486 |
st->print("Oop"); |
1 | 487 |
break; |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
347
diff
changeset
|
488 |
case OopMapValue::narrowoop_value: |
15241
87d217c2d183
8005055: pass outputStream to more opto debug routines
kvn
parents:
13963
diff
changeset
|
489 |
st->print("NarrowOop"); |
1 | 490 |
break; |
491 |
case OopMapValue::callee_saved_value: |
|
15241
87d217c2d183
8005055: pass outputStream to more opto debug routines
kvn
parents:
13963
diff
changeset
|
492 |
st->print("Callers_"); |
198
8601165a33c3
6621094: PrintOptoAssembly is broken for oops information in DebugInfo
kvn
parents:
1
diff
changeset
|
493 |
optional->print_on(st); |
1 | 494 |
break; |
495 |
case OopMapValue::derived_oop_value: |
|
15241
87d217c2d183
8005055: pass outputStream to more opto debug routines
kvn
parents:
13963
diff
changeset
|
496 |
st->print("Derived_oop_"); |
198
8601165a33c3
6621094: PrintOptoAssembly is broken for oops information in DebugInfo
kvn
parents:
1
diff
changeset
|
497 |
optional->print_on(st); |
1 | 498 |
break; |
499 |
default: |
|
500 |
ShouldNotReachHere(); |
|
501 |
} |
|
502 |
} |
|
503 |
||
198
8601165a33c3
6621094: PrintOptoAssembly is broken for oops information in DebugInfo
kvn
parents:
1
diff
changeset
|
504 |
void OopMapValue::print_on(outputStream* st) const { |
8601165a33c3
6621094: PrintOptoAssembly is broken for oops information in DebugInfo
kvn
parents:
1
diff
changeset
|
505 |
reg()->print_on(st); |
8601165a33c3
6621094: PrintOptoAssembly is broken for oops information in DebugInfo
kvn
parents:
1
diff
changeset
|
506 |
st->print("="); |
8601165a33c3
6621094: PrintOptoAssembly is broken for oops information in DebugInfo
kvn
parents:
1
diff
changeset
|
507 |
print_register_type(type(),content_reg(),st); |
8601165a33c3
6621094: PrintOptoAssembly is broken for oops information in DebugInfo
kvn
parents:
1
diff
changeset
|
508 |
st->print(" "); |
1 | 509 |
} |
510 |
||
30590 | 511 |
void ImmutableOopMap::print_on(outputStream* st) const { |
512 |
OopMapValue omv; |
|
513 |
st->print("ImmutableOopMap{"); |
|
514 |
for(OopMapStream oms(this); !oms.is_done(); oms.next()) { |
|
515 |
omv = oms.current(); |
|
516 |
omv.print_on(st); |
|
517 |
} |
|
518 |
st->print("}"); |
|
519 |
} |
|
1 | 520 |
|
521 |
void OopMap::print_on(outputStream* st) const { |
|
522 |
OopMapValue omv; |
|
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
198
diff
changeset
|
523 |
st->print("OopMap{"); |
1 | 524 |
for(OopMapStream oms((OopMap*)this); !oms.is_done(); oms.next()) { |
525 |
omv = oms.current(); |
|
526 |
omv.print_on(st); |
|
527 |
} |
|
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
198
diff
changeset
|
528 |
st->print("off=%d}", (int) offset()); |
1 | 529 |
} |
530 |
||
30590 | 531 |
void ImmutableOopMapSet::print_on(outputStream* st) const { |
532 |
const ImmutableOopMap* last = NULL; |
|
533 |
for (int i = 0; i < _count; ++i) { |
|
534 |
const ImmutableOopMapPair* pair = pair_at(i); |
|
535 |
const ImmutableOopMap* map = pair->get_from(this); |
|
536 |
if (map != last) { |
|
537 |
st->cr(); |
|
538 |
map->print_on(st); |
|
539 |
st->print("pc offsets: "); |
|
540 |
} |
|
541 |
last = map; |
|
542 |
st->print("%d ", pair->pc_offset()); |
|
543 |
} |
|
544 |
} |
|
1 | 545 |
|
546 |
void OopMapSet::print_on(outputStream* st) const { |
|
547 |
int i, len = om_count(); |
|
548 |
||
549 |
st->print_cr("OopMapSet contains %d OopMaps\n",len); |
|
550 |
||
551 |
for( i = 0; i < len; i++) { |
|
552 |
OopMap* m = at(i); |
|
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
198
diff
changeset
|
553 |
st->print_cr("#%d ",i); |
1 | 554 |
m->print_on(st); |
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
198
diff
changeset
|
555 |
st->cr(); |
1 | 556 |
} |
557 |
} |
|
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
198
diff
changeset
|
558 |
|
30590 | 559 |
bool OopMap::equals(const OopMap* other) const { |
560 |
if (other->_omv_count != _omv_count) { |
|
561 |
return false; |
|
562 |
} |
|
563 |
if (other->write_stream()->position() != write_stream()->position()) { |
|
564 |
return false; |
|
565 |
} |
|
566 |
if (memcmp(other->write_stream()->buffer(), write_stream()->buffer(), write_stream()->position()) != 0) { |
|
567 |
return false; |
|
568 |
} |
|
569 |
return true; |
|
570 |
} |
|
571 |
||
572 |
const ImmutableOopMap* ImmutableOopMapSet::find_map_at_offset(int pc_offset) const { |
|
573 |
ImmutableOopMapPair* pairs = get_pairs(); |
|
574 |
||
51078 | 575 |
int i; |
576 |
for (i = 0; i < _count; ++i) { |
|
30590 | 577 |
if (pairs[i].pc_offset() >= pc_offset) { |
578 |
break; |
|
579 |
} |
|
580 |
} |
|
51078 | 581 |
ImmutableOopMapPair* last = &pairs[i]; |
30590 | 582 |
|
583 |
assert(last->pc_offset() == pc_offset, "oopmap not found"); |
|
584 |
return last->get_from(this); |
|
585 |
} |
|
586 |
||
587 |
const ImmutableOopMap* ImmutableOopMapPair::get_from(const ImmutableOopMapSet* set) const { |
|
588 |
return set->oopmap_at_offset(_oopmap_offset); |
|
589 |
} |
|
590 |
||
591 |
ImmutableOopMap::ImmutableOopMap(const OopMap* oopmap) : _count(oopmap->count()) { |
|
592 |
address addr = data_addr(); |
|
593 |
oopmap->copy_data_to(addr); |
|
594 |
} |
|
595 |
||
30774 | 596 |
#ifdef ASSERT |
597 |
int ImmutableOopMap::nr_of_bytes() const { |
|
598 |
OopMapStream oms(this); |
|
599 |
||
600 |
while (!oms.is_done()) { |
|
601 |
oms.next(); |
|
602 |
} |
|
603 |
return sizeof(ImmutableOopMap) + oms.stream_position(); |
|
604 |
} |
|
605 |
#endif |
|
606 |
||
51333
f6641fcf7b7e
8208670: Compiler changes to allow enabling -Wreorder
tschatzl
parents:
51078
diff
changeset
|
607 |
ImmutableOopMapBuilder::ImmutableOopMapBuilder(const OopMapSet* set) : _set(set), _empty(NULL), _last(NULL), _empty_offset(-1), _last_offset(-1), _offset(0), _required(-1), _new_set(NULL) { |
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
608 |
_mapping = NEW_RESOURCE_ARRAY(Mapping, _set->size()); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
609 |
} |
30590 | 610 |
|
611 |
int ImmutableOopMapBuilder::size_for(const OopMap* map) const { |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
612 |
return align_up((int)sizeof(ImmutableOopMap) + map->data_size(), 8); |
30590 | 613 |
} |
614 |
||
615 |
int ImmutableOopMapBuilder::heap_size() { |
|
616 |
int base = sizeof(ImmutableOopMapSet); |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
617 |
base = align_up(base, 8); |
30590 | 618 |
|
619 |
// all of ours pc / offset pairs |
|
620 |
int pairs = _set->size() * sizeof(ImmutableOopMapPair); |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
621 |
pairs = align_up(pairs, 8); |
30590 | 622 |
|
623 |
for (int i = 0; i < _set->size(); ++i) { |
|
624 |
int size = 0; |
|
625 |
OopMap* map = _set->at(i); |
|
626 |
||
627 |
if (is_empty(map)) { |
|
628 |
/* only keep a single empty map in the set */ |
|
629 |
if (has_empty()) { |
|
630 |
_mapping[i].set(Mapping::OOPMAP_EMPTY, _empty_offset, 0, map, _empty); |
|
631 |
} else { |
|
632 |
_empty_offset = _offset; |
|
633 |
_empty = map; |
|
634 |
size = size_for(map); |
|
635 |
_mapping[i].set(Mapping::OOPMAP_NEW, _offset, size, map); |
|
636 |
} |
|
637 |
} else if (is_last_duplicate(map)) { |
|
638 |
/* if this entry is identical to the previous one, just point it there */ |
|
639 |
_mapping[i].set(Mapping::OOPMAP_DUPLICATE, _last_offset, 0, map, _last); |
|
640 |
} else { |
|
641 |
/* not empty, not an identical copy of the previous entry */ |
|
642 |
size = size_for(map); |
|
643 |
_mapping[i].set(Mapping::OOPMAP_NEW, _offset, size, map); |
|
644 |
_last_offset = _offset; |
|
645 |
_last = map; |
|
646 |
} |
|
647 |
||
648 |
assert(_mapping[i]._map == map, "check"); |
|
649 |
_offset += size; |
|
650 |
} |
|
651 |
||
652 |
int total = base + pairs + _offset; |
|
653 |
DEBUG_ONLY(total += 8); |
|
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
654 |
_required = total; |
30590 | 655 |
return total; |
656 |
} |
|
657 |
||
30774 | 658 |
void ImmutableOopMapBuilder::fill_pair(ImmutableOopMapPair* pair, const OopMap* map, int offset, const ImmutableOopMapSet* set) { |
659 |
assert(offset < set->nr_of_bytes(), "check"); |
|
30590 | 660 |
new ((address) pair) ImmutableOopMapPair(map->offset(), offset); |
661 |
} |
|
662 |
||
30774 | 663 |
int ImmutableOopMapBuilder::fill_map(ImmutableOopMapPair* pair, const OopMap* map, int offset, const ImmutableOopMapSet* set) { |
664 |
fill_pair(pair, map, offset, set); |
|
30590 | 665 |
address addr = (address) pair->get_from(_new_set); // location of the ImmutableOopMap |
666 |
||
667 |
new (addr) ImmutableOopMap(map); |
|
46618
d503911aa948
8178489: Make align functions more type safe and consistent
stefank
parents:
45327
diff
changeset
|
668 |
return size_for(map); |
30590 | 669 |
} |
670 |
||
671 |
void ImmutableOopMapBuilder::fill(ImmutableOopMapSet* set, int sz) { |
|
672 |
ImmutableOopMapPair* pairs = set->get_pairs(); |
|
673 |
||
674 |
for (int i = 0; i < set->count(); ++i) { |
|
675 |
const OopMap* map = _mapping[i]._map; |
|
676 |
ImmutableOopMapPair* pair = NULL; |
|
677 |
int size = 0; |
|
678 |
||
679 |
if (_mapping[i]._kind == Mapping::OOPMAP_NEW) { |
|
30774 | 680 |
size = fill_map(&pairs[i], map, _mapping[i]._offset, set); |
30590 | 681 |
} else if (_mapping[i]._kind == Mapping::OOPMAP_DUPLICATE || _mapping[i]._kind == Mapping::OOPMAP_EMPTY) { |
30774 | 682 |
fill_pair(&pairs[i], map, _mapping[i]._offset, set); |
30590 | 683 |
} |
684 |
||
685 |
const ImmutableOopMap* nv = set->find_map_at_offset(map->offset()); |
|
686 |
assert(memcmp(map->data(), nv->data_addr(), map->data_size()) == 0, "check identity"); |
|
687 |
} |
|
688 |
} |
|
689 |
||
690 |
#ifdef ASSERT |
|
30774 | 691 |
void ImmutableOopMapBuilder::verify(address buffer, int size, const ImmutableOopMapSet* set) { |
30590 | 692 |
for (int i = 0; i < 8; ++i) { |
693 |
assert(buffer[size - 8 + i] == (unsigned char) 0xff, "overwritten memory check"); |
|
694 |
} |
|
30774 | 695 |
|
696 |
for (int i = 0; i < set->count(); ++i) { |
|
697 |
const ImmutableOopMapPair* pair = set->pair_at(i); |
|
698 |
assert(pair->oopmap_offset() < set->nr_of_bytes(), "check size"); |
|
699 |
const ImmutableOopMap* map = pair->get_from(set); |
|
700 |
int nr_of_bytes = map->nr_of_bytes(); |
|
701 |
assert(pair->oopmap_offset() + nr_of_bytes <= set->nr_of_bytes(), "check size + size"); |
|
702 |
} |
|
30590 | 703 |
} |
704 |
#endif |
|
705 |
||
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
706 |
ImmutableOopMapSet* ImmutableOopMapBuilder::generate_into(address buffer) { |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
707 |
DEBUG_ONLY(memset(&buffer[_required-8], 0xff, 8)); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
708 |
|
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
709 |
_new_set = new (buffer) ImmutableOopMapSet(_set, _required); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
710 |
fill(_new_set, _required); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
711 |
|
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
712 |
DEBUG_ONLY(verify(buffer, _required, _new_set)); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
713 |
|
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
714 |
return _new_set; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
715 |
} |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
716 |
|
30590 | 717 |
ImmutableOopMapSet* ImmutableOopMapBuilder::build() { |
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
718 |
_required = heap_size(); |
30590 | 719 |
|
720 |
// We need to allocate a chunk big enough to hold the ImmutableOopMapSet and all of its ImmutableOopMaps |
|
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
721 |
address buffer = (address) NEW_C_HEAP_ARRAY(unsigned char, _required, mtCode); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
722 |
return generate_into(buffer); |
30590 | 723 |
} |
724 |
||
725 |
ImmutableOopMapSet* ImmutableOopMapSet::build_from(const OopMapSet* oopmap_set) { |
|
726 |
ResourceMark mark; |
|
727 |
ImmutableOopMapBuilder builder(oopmap_set); |
|
728 |
return builder.build(); |
|
729 |
} |
|
1 | 730 |
|
731 |
||
732 |
//------------------------------DerivedPointerTable--------------------------- |
|
733 |
||
47799 | 734 |
#if COMPILER2_OR_JVMCI |
1 | 735 |
|
13195 | 736 |
class DerivedPointerEntry : public CHeapObj<mtCompiler> { |
1 | 737 |
private: |
738 |
oop* _location; // Location of derived pointer (also pointing to the base) |
|
739 |
intptr_t _offset; // Offset from base pointer |
|
740 |
public: |
|
741 |
DerivedPointerEntry(oop* location, intptr_t offset) { _location = location; _offset = offset; } |
|
742 |
oop* location() { return _location; } |
|
743 |
intptr_t offset() { return _offset; } |
|
744 |
}; |
|
745 |
||
746 |
||
747 |
GrowableArray<DerivedPointerEntry*>* DerivedPointerTable::_list = NULL; |
|
748 |
bool DerivedPointerTable::_active = false; |
|
749 |
||
750 |
||
751 |
void DerivedPointerTable::clear() { |
|
752 |
// The first time, we create the list. Otherwise it should be |
|
753 |
// empty. If not, then we have probably forgotton to call |
|
754 |
// update_pointers after last GC/Scavenge. |
|
755 |
assert (!_active, "should not be active"); |
|
756 |
assert(_list == NULL || _list->length() == 0, "table not empty"); |
|
757 |
if (_list == NULL) { |
|
13195 | 758 |
_list = new (ResourceObj::C_HEAP, mtCompiler) GrowableArray<DerivedPointerEntry*>(10, true); // Allocated on C heap |
1 | 759 |
} |
760 |
_active = true; |
|
761 |
} |
|
762 |
||
763 |
||
764 |
// Returns value of location as an int |
|
20282
7f9cbdf89af2
7195622: CheckUnhandledOops has limited usefulness now
hseigel
parents:
15241
diff
changeset
|
765 |
intptr_t value_of_loc(oop *pointer) { return cast_from_oop<intptr_t>((*pointer)); } |
1 | 766 |
|
767 |
||
768 |
void DerivedPointerTable::add(oop *derived_loc, oop *base_loc) { |
|
769 |
assert(Universe::heap()->is_in_or_null(*base_loc), "not an oop"); |
|
770 |
assert(derived_loc != base_loc, "Base and derived in same location"); |
|
771 |
if (_active) { |
|
772 |
assert(*derived_loc != (oop)base_loc, "location already added"); |
|
773 |
assert(_list != NULL, "list must exist"); |
|
774 |
intptr_t offset = value_of_loc(derived_loc) - value_of_loc(base_loc); |
|
9976
6fef34e63df1
7045514: SPARC assembly code for JSR 292 ricochet frames
never
parents:
7397
diff
changeset
|
775 |
// This assert is invalid because derived pointers can be |
6fef34e63df1
7045514: SPARC assembly code for JSR 292 ricochet frames
never
parents:
7397
diff
changeset
|
776 |
// arbitrarily far away from their base. |
6fef34e63df1
7045514: SPARC assembly code for JSR 292 ricochet frames
never
parents:
7397
diff
changeset
|
777 |
// assert(offset >= -1000000, "wrong derived pointer info"); |
1 | 778 |
|
779 |
if (TraceDerivedPointers) { |
|
780 |
tty->print_cr( |
|
781 |
"Add derived pointer@" INTPTR_FORMAT |
|
782 |
" - Derived: " INTPTR_FORMAT |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24320
diff
changeset
|
783 |
" Base: " INTPTR_FORMAT " (@" INTPTR_FORMAT ") (Offset: " INTX_FORMAT ")", |
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24320
diff
changeset
|
784 |
p2i(derived_loc), p2i((address)*derived_loc), p2i((address)*base_loc), p2i(base_loc), offset |
1 | 785 |
); |
786 |
} |
|
787 |
// Set derived oop location to point to base. |
|
788 |
*derived_loc = (oop)base_loc; |
|
789 |
assert_lock_strong(DerivedPointerTableGC_lock); |
|
790 |
DerivedPointerEntry *entry = new DerivedPointerEntry(derived_loc, offset); |
|
791 |
_list->append(entry); |
|
792 |
} |
|
793 |
} |
|
794 |
||
795 |
||
796 |
void DerivedPointerTable::update_pointers() { |
|
797 |
assert(_list != NULL, "list must exist"); |
|
798 |
for(int i = 0; i < _list->length(); i++) { |
|
799 |
DerivedPointerEntry* entry = _list->at(i); |
|
800 |
oop* derived_loc = entry->location(); |
|
801 |
intptr_t offset = entry->offset(); |
|
802 |
// The derived oop was setup to point to location of base |
|
803 |
oop base = **(oop**)derived_loc; |
|
804 |
assert(Universe::heap()->is_in_or_null(base), "must be an oop"); |
|
805 |
||
806 |
*derived_loc = (oop)(((address)base) + offset); |
|
807 |
assert(value_of_loc(derived_loc) - value_of_loc(&base) == offset, "sanity check"); |
|
808 |
||
809 |
if (TraceDerivedPointers) { |
|
810 |
tty->print_cr("Updating derived pointer@" INTPTR_FORMAT |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24320
diff
changeset
|
811 |
" - Derived: " INTPTR_FORMAT " Base: " INTPTR_FORMAT " (Offset: " INTX_FORMAT ")", |
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24320
diff
changeset
|
812 |
p2i(derived_loc), p2i((address)*derived_loc), p2i((address)base), offset); |
1 | 813 |
} |
814 |
||
815 |
// Delete entry |
|
816 |
delete entry; |
|
817 |
_list->at_put(i, NULL); |
|
818 |
} |
|
819 |
// Clear list, so it is ready for next traversal (this is an invariant) |
|
820 |
if (TraceDerivedPointers && !_list->is_empty()) { |
|
821 |
tty->print_cr("--------------------------"); |
|
822 |
} |
|
823 |
_list->clear(); |
|
824 |
_active = false; |
|
825 |
} |
|
826 |
||
47799 | 827 |
#endif // COMPILER2_OR_JVMCI |