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