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