annotate src/share/vm/compiler/oopMap.cpp @ 24234:ea6f94ab283b default tip

Added tag jvmci-0.36 for changeset 8128b98d4736
author Gilles Duboscq <gilles.m.duboscq@oracle.com>
date Mon, 18 Sep 2017 18:49:45 +0200
parents 1051fbaca88b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 12316
diff changeset
2 * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 948
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 948
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 948
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #include "code/codeBlob.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27 #include "code/codeCache.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "code/nmethod.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "code/scopeDesc.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "compiler/oopMap.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #include "gc_interface/collectedHeap.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32 #include "memory/allocation.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
33 #include "memory/resourceArea.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
34 #include "runtime/frame.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
35 #include "runtime/signature.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
36 #ifdef COMPILER1
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
37 #include "c1/c1_Defs.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
38 #endif
22407
708a95bb443c All SPARC float registers can be addressed in 4 byte portions; hence don't add 4 bytes to pointer pointing to a Narrow Oop
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 22298
diff changeset
39 #ifdef SPARC
708a95bb443c All SPARC float registers can be addressed in 4 byte portions; hence don't add 4 bytes to pointer pointing to a Narrow Oop
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 22298
diff changeset
40 #include "vmreg_sparc.inline.hpp"
708a95bb443c All SPARC float registers can be addressed in 4 byte portions; hence don't add 4 bytes to pointer pointing to a Narrow Oop
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 22298
diff changeset
41 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // OopMapStream
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 OopMapStream::OopMapStream(OopMap* oop_map) {
a61af66fc99e Initial load
duke
parents:
diff changeset
46 if(oop_map->omv_data() == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
47 _stream = new CompressedReadStream(oop_map->write_stream()->buffer());
a61af66fc99e Initial load
duke
parents:
diff changeset
48 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
49 _stream = new CompressedReadStream(oop_map->omv_data());
a61af66fc99e Initial load
duke
parents:
diff changeset
50 }
a61af66fc99e Initial load
duke
parents:
diff changeset
51 _mask = OopMapValue::type_mask_in_place;
a61af66fc99e Initial load
duke
parents:
diff changeset
52 _size = oop_map->omv_count();
a61af66fc99e Initial load
duke
parents:
diff changeset
53 _position = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
54 _valid_omv = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
55 }
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 OopMapStream::OopMapStream(OopMap* oop_map, int oop_types_mask) {
a61af66fc99e Initial load
duke
parents:
diff changeset
59 if(oop_map->omv_data() == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
60 _stream = new CompressedReadStream(oop_map->write_stream()->buffer());
a61af66fc99e Initial load
duke
parents:
diff changeset
61 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
62 _stream = new CompressedReadStream(oop_map->omv_data());
a61af66fc99e Initial load
duke
parents:
diff changeset
63 }
a61af66fc99e Initial load
duke
parents:
diff changeset
64 _mask = oop_types_mask;
a61af66fc99e Initial load
duke
parents:
diff changeset
65 _size = oop_map->omv_count();
a61af66fc99e Initial load
duke
parents:
diff changeset
66 _position = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
67 _valid_omv = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
68 }
a61af66fc99e Initial load
duke
parents:
diff changeset
69
a61af66fc99e Initial load
duke
parents:
diff changeset
70
a61af66fc99e Initial load
duke
parents:
diff changeset
71 void OopMapStream::find_next() {
a61af66fc99e Initial load
duke
parents:
diff changeset
72 while(_position++ < _size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
73 _omv.read_from(_stream);
a61af66fc99e Initial load
duke
parents:
diff changeset
74 if(((int)_omv.type() & _mask) > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
75 _valid_omv = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
76 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
77 }
a61af66fc99e Initial load
duke
parents:
diff changeset
78 }
a61af66fc99e Initial load
duke
parents:
diff changeset
79 _valid_omv = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
80 }
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // OopMap
a61af66fc99e Initial load
duke
parents:
diff changeset
84
a61af66fc99e Initial load
duke
parents:
diff changeset
85 // frame_size units are stack-slots (4 bytes) NOT intptr_t; we can name odd
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // slots to hold 4-byte values like ints and floats in the LP64 build.
a61af66fc99e Initial load
duke
parents:
diff changeset
87 OopMap::OopMap(int frame_size, int arg_count) {
a61af66fc99e Initial load
duke
parents:
diff changeset
88 // OopMaps are usually quite so small, so pick a small initial size
a61af66fc99e Initial load
duke
parents:
diff changeset
89 set_write_stream(new CompressedWriteStream(32));
a61af66fc99e Initial load
duke
parents:
diff changeset
90 set_omv_data(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
91 set_omv_count(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
94 _locs_length = VMRegImpl::stack2reg(0)->value() + frame_size + arg_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
95 _locs_used = NEW_RESOURCE_ARRAY(OopMapValue::oop_types, _locs_length);
a61af66fc99e Initial load
duke
parents:
diff changeset
96 for(int i = 0; i < _locs_length; i++) _locs_used[i] = OopMapValue::unused_value;
a61af66fc99e Initial load
duke
parents:
diff changeset
97 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
98 }
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101 OopMap::OopMap(OopMap::DeepCopyToken, OopMap* source) {
a61af66fc99e Initial load
duke
parents:
diff changeset
102 // This constructor does a deep copy
a61af66fc99e Initial load
duke
parents:
diff changeset
103 // of the source OopMap.
a61af66fc99e Initial load
duke
parents:
diff changeset
104 set_write_stream(new CompressedWriteStream(source->omv_count() * 2));
a61af66fc99e Initial load
duke
parents:
diff changeset
105 set_omv_data(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
106 set_omv_count(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
107 set_offset(source->offset());
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
110 _locs_length = source->_locs_length;
a61af66fc99e Initial load
duke
parents:
diff changeset
111 _locs_used = NEW_RESOURCE_ARRAY(OopMapValue::oop_types, _locs_length);
a61af66fc99e Initial load
duke
parents:
diff changeset
112 for(int i = 0; i < _locs_length; i++) _locs_used[i] = OopMapValue::unused_value;
a61af66fc99e Initial load
duke
parents:
diff changeset
113 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // We need to copy the entries too.
a61af66fc99e Initial load
duke
parents:
diff changeset
116 for (OopMapStream oms(source); !oms.is_done(); oms.next()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
117 OopMapValue omv = oms.current();
a61af66fc99e Initial load
duke
parents:
diff changeset
118 omv.write_on(write_stream());
a61af66fc99e Initial load
duke
parents:
diff changeset
119 increment_count();
a61af66fc99e Initial load
duke
parents:
diff changeset
120 }
a61af66fc99e Initial load
duke
parents:
diff changeset
121 }
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124 OopMap* OopMap::deep_copy() {
a61af66fc99e Initial load
duke
parents:
diff changeset
125 return new OopMap(_deep_copy_token, this);
a61af66fc99e Initial load
duke
parents:
diff changeset
126 }
a61af66fc99e Initial load
duke
parents:
diff changeset
127
a61af66fc99e Initial load
duke
parents:
diff changeset
128
a61af66fc99e Initial load
duke
parents:
diff changeset
129 void OopMap::copy_to(address addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
130 memcpy(addr,this,sizeof(OopMap));
a61af66fc99e Initial load
duke
parents:
diff changeset
131 memcpy(addr + sizeof(OopMap),write_stream()->buffer(),write_stream()->position());
a61af66fc99e Initial load
duke
parents:
diff changeset
132 OopMap* new_oop = (OopMap*)addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
133 new_oop->set_omv_data_size(write_stream()->position());
a61af66fc99e Initial load
duke
parents:
diff changeset
134 new_oop->set_omv_data((unsigned char *)(addr + sizeof(OopMap)));
a61af66fc99e Initial load
duke
parents:
diff changeset
135 new_oop->set_write_stream(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
136 }
a61af66fc99e Initial load
duke
parents:
diff changeset
137
a61af66fc99e Initial load
duke
parents:
diff changeset
138
a61af66fc99e Initial load
duke
parents:
diff changeset
139 int OopMap::heap_size() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
140 int size = sizeof(OopMap);
a61af66fc99e Initial load
duke
parents:
diff changeset
141 int align = sizeof(void *) - 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
142 if(write_stream() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
143 size += write_stream()->position();
a61af66fc99e Initial load
duke
parents:
diff changeset
144 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
145 size += omv_data_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
146 }
a61af66fc99e Initial load
duke
parents:
diff changeset
147 // Align to a reasonable ending point
a61af66fc99e Initial load
duke
parents:
diff changeset
148 size = ((size+align) & ~align);
a61af66fc99e Initial load
duke
parents:
diff changeset
149 return size;
a61af66fc99e Initial load
duke
parents:
diff changeset
150 }
a61af66fc99e Initial load
duke
parents:
diff changeset
151
a61af66fc99e Initial load
duke
parents:
diff changeset
152 // frame_size units are stack-slots (4 bytes) NOT intptr_t; we can name odd
a61af66fc99e Initial load
duke
parents:
diff changeset
153 // slots to hold 4-byte values like ints and floats in the LP64 build.
a61af66fc99e Initial load
duke
parents:
diff changeset
154 void OopMap::set_xxx(VMReg reg, OopMapValue::oop_types x, VMReg optional) {
a61af66fc99e Initial load
duke
parents:
diff changeset
155
a61af66fc99e Initial load
duke
parents:
diff changeset
156 assert(reg->value() < _locs_length, "too big reg value for stack size");
a61af66fc99e Initial load
duke
parents:
diff changeset
157 assert( _locs_used[reg->value()] == OopMapValue::unused_value, "cannot insert twice" );
a61af66fc99e Initial load
duke
parents:
diff changeset
158 debug_only( _locs_used[reg->value()] = x; )
a61af66fc99e Initial load
duke
parents:
diff changeset
159
a61af66fc99e Initial load
duke
parents:
diff changeset
160 OopMapValue o(reg, x);
a61af66fc99e Initial load
duke
parents:
diff changeset
161
a61af66fc99e Initial load
duke
parents:
diff changeset
162 if(x == OopMapValue::callee_saved_value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
163 // This can never be a stack location, so we don't need to transform it.
a61af66fc99e Initial load
duke
parents:
diff changeset
164 assert(optional->is_reg(), "Trying to callee save a stack location");
a61af66fc99e Initial load
duke
parents:
diff changeset
165 o.set_content_reg(optional);
a61af66fc99e Initial load
duke
parents:
diff changeset
166 } else if(x == OopMapValue::derived_oop_value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
167 o.set_content_reg(optional);
a61af66fc99e Initial load
duke
parents:
diff changeset
168 }
a61af66fc99e Initial load
duke
parents:
diff changeset
169
a61af66fc99e Initial load
duke
parents:
diff changeset
170 o.write_on(write_stream());
a61af66fc99e Initial load
duke
parents:
diff changeset
171 increment_count();
a61af66fc99e Initial load
duke
parents:
diff changeset
172 }
a61af66fc99e Initial load
duke
parents:
diff changeset
173
a61af66fc99e Initial load
duke
parents:
diff changeset
174
a61af66fc99e Initial load
duke
parents:
diff changeset
175 void OopMap::set_oop(VMReg reg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
176 set_xxx(reg, OopMapValue::oop_value, VMRegImpl::Bad());
a61af66fc99e Initial load
duke
parents:
diff changeset
177 }
a61af66fc99e Initial load
duke
parents:
diff changeset
178
a61af66fc99e Initial load
duke
parents:
diff changeset
179
a61af66fc99e Initial load
duke
parents:
diff changeset
180 void OopMap::set_value(VMReg reg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
181 // At this time, we only need value entries in our OopMap when ZapDeadCompiledLocals is active.
a61af66fc99e Initial load
duke
parents:
diff changeset
182 }
a61af66fc99e Initial load
duke
parents:
diff changeset
183
a61af66fc99e Initial load
duke
parents:
diff changeset
184
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 100
diff changeset
185 void OopMap::set_narrowoop(VMReg reg) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 100
diff changeset
186 set_xxx(reg, OopMapValue::narrowoop_value, VMRegImpl::Bad());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
187 }
a61af66fc99e Initial load
duke
parents:
diff changeset
188
a61af66fc99e Initial load
duke
parents:
diff changeset
189
a61af66fc99e Initial load
duke
parents:
diff changeset
190 void OopMap::set_callee_saved(VMReg reg, VMReg caller_machine_register ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
191 set_xxx(reg, OopMapValue::callee_saved_value, caller_machine_register);
a61af66fc99e Initial load
duke
parents:
diff changeset
192 }
a61af66fc99e Initial load
duke
parents:
diff changeset
193
a61af66fc99e Initial load
duke
parents:
diff changeset
194
a61af66fc99e Initial load
duke
parents:
diff changeset
195 void OopMap::set_derived_oop(VMReg reg, VMReg derived_from_local_register ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
196 if( reg == derived_from_local_register ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
197 // Actually an oop, derived shares storage with base,
a61af66fc99e Initial load
duke
parents:
diff changeset
198 set_oop(reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
199 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
200 set_xxx(reg, OopMapValue::derived_oop_value, derived_from_local_register);
a61af66fc99e Initial load
duke
parents:
diff changeset
201 }
a61af66fc99e Initial load
duke
parents:
diff changeset
202 }
a61af66fc99e Initial load
duke
parents:
diff changeset
203
a61af66fc99e Initial load
duke
parents:
diff changeset
204 // OopMapSet
a61af66fc99e Initial load
duke
parents:
diff changeset
205
a61af66fc99e Initial load
duke
parents:
diff changeset
206 OopMapSet::OopMapSet() {
a61af66fc99e Initial load
duke
parents:
diff changeset
207 set_om_size(MinOopMapAllocation);
a61af66fc99e Initial load
duke
parents:
diff changeset
208 set_om_count(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
209 OopMap** temp = NEW_RESOURCE_ARRAY(OopMap*, om_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
210 set_om_data(temp);
a61af66fc99e Initial load
duke
parents:
diff changeset
211 }
a61af66fc99e Initial load
duke
parents:
diff changeset
212
a61af66fc99e Initial load
duke
parents:
diff changeset
213
a61af66fc99e Initial load
duke
parents:
diff changeset
214 void OopMapSet::grow_om_data() {
a61af66fc99e Initial load
duke
parents:
diff changeset
215 int new_size = om_size() * 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
216 OopMap** new_data = NEW_RESOURCE_ARRAY(OopMap*, new_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
217 memcpy(new_data,om_data(),om_size() * sizeof(OopMap*));
a61af66fc99e Initial load
duke
parents:
diff changeset
218 set_om_size(new_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
219 set_om_data(new_data);
a61af66fc99e Initial load
duke
parents:
diff changeset
220 }
a61af66fc99e Initial load
duke
parents:
diff changeset
221
a61af66fc99e Initial load
duke
parents:
diff changeset
222
a61af66fc99e Initial load
duke
parents:
diff changeset
223 void OopMapSet::copy_to(address addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
224 address temp = addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
225 int align = sizeof(void *) - 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
226 // Copy this
a61af66fc99e Initial load
duke
parents:
diff changeset
227 memcpy(addr,this,sizeof(OopMapSet));
a61af66fc99e Initial load
duke
parents:
diff changeset
228 temp += sizeof(OopMapSet);
a61af66fc99e Initial load
duke
parents:
diff changeset
229 temp = (address)((intptr_t)(temp + align) & ~align);
a61af66fc99e Initial load
duke
parents:
diff changeset
230 // Do the needed fixups to the new OopMapSet
a61af66fc99e Initial load
duke
parents:
diff changeset
231 OopMapSet* new_set = (OopMapSet*)addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
232 new_set->set_om_data((OopMap**)temp);
a61af66fc99e Initial load
duke
parents:
diff changeset
233 // Allow enough space for the OopMap pointers
a61af66fc99e Initial load
duke
parents:
diff changeset
234 temp += (om_count() * sizeof(OopMap*));
a61af66fc99e Initial load
duke
parents:
diff changeset
235
a61af66fc99e Initial load
duke
parents:
diff changeset
236 for(int i=0; i < om_count(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
237 OopMap* map = at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
238 map->copy_to((address)temp);
a61af66fc99e Initial load
duke
parents:
diff changeset
239 new_set->set(i,(OopMap*)temp);
a61af66fc99e Initial load
duke
parents:
diff changeset
240 temp += map->heap_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
241 }
a61af66fc99e Initial load
duke
parents:
diff changeset
242 // This "locks" the OopMapSet
a61af66fc99e Initial load
duke
parents:
diff changeset
243 new_set->set_om_size(-1);
a61af66fc99e Initial load
duke
parents:
diff changeset
244 }
a61af66fc99e Initial load
duke
parents:
diff changeset
245
a61af66fc99e Initial load
duke
parents:
diff changeset
246
a61af66fc99e Initial load
duke
parents:
diff changeset
247 void OopMapSet::add_gc_map(int pc_offset, OopMap *map ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
248 assert(om_size() != -1,"Cannot grow a fixed OopMapSet");
a61af66fc99e Initial load
duke
parents:
diff changeset
249
a61af66fc99e Initial load
duke
parents:
diff changeset
250 if(om_count() >= om_size()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
251 grow_om_data();
a61af66fc99e Initial load
duke
parents:
diff changeset
252 }
a61af66fc99e Initial load
duke
parents:
diff changeset
253 map->set_offset(pc_offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
254
a61af66fc99e Initial load
duke
parents:
diff changeset
255 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
256 if(om_count() > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
257 OopMap* last = at(om_count()-1);
a61af66fc99e Initial load
duke
parents:
diff changeset
258 if (last->offset() == map->offset() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
259 fatal("OopMap inserted twice");
a61af66fc99e Initial load
duke
parents:
diff changeset
260 }
a61af66fc99e Initial load
duke
parents:
diff changeset
261 if(last->offset() > map->offset()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
262 tty->print_cr( "WARNING, maps not sorted: pc[%d]=%d, pc[%d]=%d",
a61af66fc99e Initial load
duke
parents:
diff changeset
263 om_count(),last->offset(),om_count()+1,map->offset());
a61af66fc99e Initial load
duke
parents:
diff changeset
264 }
a61af66fc99e Initial load
duke
parents:
diff changeset
265 }
a61af66fc99e Initial load
duke
parents:
diff changeset
266 #endif // ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
267
a61af66fc99e Initial load
duke
parents:
diff changeset
268 set(om_count(),map);
a61af66fc99e Initial load
duke
parents:
diff changeset
269 increment_count();
a61af66fc99e Initial load
duke
parents:
diff changeset
270 }
a61af66fc99e Initial load
duke
parents:
diff changeset
271
a61af66fc99e Initial load
duke
parents:
diff changeset
272
a61af66fc99e Initial load
duke
parents:
diff changeset
273 int OopMapSet::heap_size() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
274 // The space we use
a61af66fc99e Initial load
duke
parents:
diff changeset
275 int size = sizeof(OopMap);
a61af66fc99e Initial load
duke
parents:
diff changeset
276 int align = sizeof(void *) - 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
277 size = ((size+align) & ~align);
a61af66fc99e Initial load
duke
parents:
diff changeset
278 size += om_count() * sizeof(OopMap*);
a61af66fc99e Initial load
duke
parents:
diff changeset
279
a61af66fc99e Initial load
duke
parents:
diff changeset
280 // Now add in the space needed for the indivdiual OopMaps
a61af66fc99e Initial load
duke
parents:
diff changeset
281 for(int i=0; i < om_count(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
282 size += at(i)->heap_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
283 }
a61af66fc99e Initial load
duke
parents:
diff changeset
284 // We don't need to align this, it will be naturally pointer aligned
a61af66fc99e Initial load
duke
parents:
diff changeset
285 return size;
a61af66fc99e Initial load
duke
parents:
diff changeset
286 }
a61af66fc99e Initial load
duke
parents:
diff changeset
287
a61af66fc99e Initial load
duke
parents:
diff changeset
288
a61af66fc99e Initial load
duke
parents:
diff changeset
289 OopMap* OopMapSet::singular_oop_map() {
a61af66fc99e Initial load
duke
parents:
diff changeset
290 guarantee(om_count() == 1, "Make sure we only have a single gc point");
a61af66fc99e Initial load
duke
parents:
diff changeset
291 return at(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
292 }
a61af66fc99e Initial load
duke
parents:
diff changeset
293
a61af66fc99e Initial load
duke
parents:
diff changeset
294
a61af66fc99e Initial load
duke
parents:
diff changeset
295 OopMap* OopMapSet::find_map_at_offset(int pc_offset) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
296 int i, len = om_count();
a61af66fc99e Initial load
duke
parents:
diff changeset
297 assert( len > 0, "must have pointer maps" );
a61af66fc99e Initial load
duke
parents:
diff changeset
298
a61af66fc99e Initial load
duke
parents:
diff changeset
299 // Scan through oopmaps. Stop when current offset is either equal or greater
a61af66fc99e Initial load
duke
parents:
diff changeset
300 // than the one we are looking for.
a61af66fc99e Initial load
duke
parents:
diff changeset
301 for( i = 0; i < len; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
302 if( at(i)->offset() >= pc_offset )
a61af66fc99e Initial load
duke
parents:
diff changeset
303 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
304 }
a61af66fc99e Initial load
duke
parents:
diff changeset
305
a61af66fc99e Initial load
duke
parents:
diff changeset
306 assert( i < len, "oopmap not found" );
a61af66fc99e Initial load
duke
parents:
diff changeset
307
a61af66fc99e Initial load
duke
parents:
diff changeset
308 OopMap* m = at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
309 assert( m->offset() == pc_offset, "oopmap not found" );
a61af66fc99e Initial load
duke
parents:
diff changeset
310 return m;
a61af66fc99e Initial load
duke
parents:
diff changeset
311 }
a61af66fc99e Initial load
duke
parents:
diff changeset
312
a61af66fc99e Initial load
duke
parents:
diff changeset
313 class DoNothingClosure: public OopClosure {
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 100
diff changeset
314 public:
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 100
diff changeset
315 void do_oop(oop* p) {}
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 100
diff changeset
316 void do_oop(narrowOop* p) {}
0
a61af66fc99e Initial load
duke
parents:
diff changeset
317 };
a61af66fc99e Initial load
duke
parents:
diff changeset
318 static DoNothingClosure do_nothing;
a61af66fc99e Initial load
duke
parents:
diff changeset
319
a61af66fc99e Initial load
duke
parents:
diff changeset
320 static void add_derived_oop(oop* base, oop* derived) {
23705
1051fbaca88b the client VM build is broken when INCLUDE_JVMCI is defined (JDK-8159888)
Doug Simon <doug.simon@oracle.com>
parents: 23404
diff changeset
321 #if !defined(TIERED) && !defined(INCLUDE_JVMCI)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
322 COMPILER1_PRESENT(ShouldNotReachHere();)
23705
1051fbaca88b the client VM build is broken when INCLUDE_JVMCI is defined (JDK-8159888)
Doug Simon <doug.simon@oracle.com>
parents: 23404
diff changeset
323 #endif // !defined(TIERED) && !defined(INCLUDE_JVMCI)
22298
c28cb37b2e1d Rename JVMCI to INCLUDE_JVMCI.
twisti
parents: 22294
diff changeset
324 #if defined(COMPILER2) || INCLUDE_JVMCI
0
a61af66fc99e Initial load
duke
parents:
diff changeset
325 DerivedPointerTable::add(derived, base);
22294
d86b226e331a Enable derived oop processing by the GC with JVMCI
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 21559
diff changeset
326 #endif // COMPILER2 || JVMCI
0
a61af66fc99e Initial load
duke
parents:
diff changeset
327 }
a61af66fc99e Initial load
duke
parents:
diff changeset
328
a61af66fc99e Initial load
duke
parents:
diff changeset
329
a61af66fc99e Initial load
duke
parents:
diff changeset
330 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
331 static void trace_codeblob_maps(const frame *fr, const RegisterMap *reg_map) {
a61af66fc99e Initial load
duke
parents:
diff changeset
332 // Print oopmap and regmap
a61af66fc99e Initial load
duke
parents:
diff changeset
333 tty->print_cr("------ ");
a61af66fc99e Initial load
duke
parents:
diff changeset
334 CodeBlob* cb = fr->cb();
a61af66fc99e Initial load
duke
parents:
diff changeset
335 OopMapSet* maps = cb->oop_maps();
a61af66fc99e Initial load
duke
parents:
diff changeset
336 OopMap* map = cb->oop_map_for_return_address(fr->pc());
a61af66fc99e Initial load
duke
parents:
diff changeset
337 map->print();
a61af66fc99e Initial load
duke
parents:
diff changeset
338 if( cb->is_nmethod() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
339 nmethod* nm = (nmethod*)cb;
a61af66fc99e Initial load
duke
parents:
diff changeset
340 // native wrappers have no scope data, it is implied
a61af66fc99e Initial load
duke
parents:
diff changeset
341 if (nm->is_native_method()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
342 tty->print("bci: 0 (native)");
a61af66fc99e Initial load
duke
parents:
diff changeset
343 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
344 ScopeDesc* scope = nm->scope_desc_at(fr->pc());
a61af66fc99e Initial load
duke
parents:
diff changeset
345 tty->print("bci: %d ",scope->bci());
a61af66fc99e Initial load
duke
parents:
diff changeset
346 }
a61af66fc99e Initial load
duke
parents:
diff changeset
347 }
a61af66fc99e Initial load
duke
parents:
diff changeset
348 tty->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
349 fr->print_on(tty);
a61af66fc99e Initial load
duke
parents:
diff changeset
350 tty->print(" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
351 cb->print_value_on(tty); tty->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
352 reg_map->print();
a61af66fc99e Initial load
duke
parents:
diff changeset
353 tty->print_cr("------ ");
a61af66fc99e Initial load
duke
parents:
diff changeset
354
a61af66fc99e Initial load
duke
parents:
diff changeset
355 }
a61af66fc99e Initial load
duke
parents:
diff changeset
356 #endif // PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
357
a61af66fc99e Initial load
duke
parents:
diff changeset
358 void OopMapSet::oops_do(const frame *fr, const RegisterMap* reg_map, OopClosure* f) {
a61af66fc99e Initial load
duke
parents:
diff changeset
359 // add derived oops to a table
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 100
diff changeset
360 all_do(fr, reg_map, f, add_derived_oop, &do_nothing);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
361 }
a61af66fc99e Initial load
duke
parents:
diff changeset
362
a61af66fc99e Initial load
duke
parents:
diff changeset
363
a61af66fc99e Initial load
duke
parents:
diff changeset
364 void OopMapSet::all_do(const frame *fr, const RegisterMap *reg_map,
a61af66fc99e Initial load
duke
parents:
diff changeset
365 OopClosure* oop_fn, void derived_oop_fn(oop*, oop*),
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 100
diff changeset
366 OopClosure* value_fn) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
367 CodeBlob* cb = fr->cb();
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 100
diff changeset
368 assert(cb != NULL, "no codeblob");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
369
a61af66fc99e Initial load
duke
parents:
diff changeset
370 NOT_PRODUCT(if (TraceCodeBlobStacks) trace_codeblob_maps(fr, reg_map);)
a61af66fc99e Initial load
duke
parents:
diff changeset
371
a61af66fc99e Initial load
duke
parents:
diff changeset
372 OopMapSet* maps = cb->oop_maps();
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 100
diff changeset
373 OopMap* map = cb->oop_map_for_return_address(fr->pc());
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 100
diff changeset
374 assert(map != NULL, "no ptr map found");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
375
a61af66fc99e Initial load
duke
parents:
diff changeset
376 // handle derived pointers first (otherwise base pointer may be
a61af66fc99e Initial load
duke
parents:
diff changeset
377 // changed before derived pointer offset has been collected)
a61af66fc99e Initial load
duke
parents:
diff changeset
378 OopMapValue omv;
a61af66fc99e Initial load
duke
parents:
diff changeset
379 {
a61af66fc99e Initial load
duke
parents:
diff changeset
380 OopMapStream oms(map,OopMapValue::derived_oop_value);
a61af66fc99e Initial load
duke
parents:
diff changeset
381 if (!oms.is_done()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
382 #ifndef TIERED
a61af66fc99e Initial load
duke
parents:
diff changeset
383 COMPILER1_PRESENT(ShouldNotReachHere();)
a61af66fc99e Initial load
duke
parents:
diff changeset
384 #endif // !TIERED
a61af66fc99e Initial load
duke
parents:
diff changeset
385 // Protect the operation on the derived pointers. This
a61af66fc99e Initial load
duke
parents:
diff changeset
386 // protects the addition of derived pointers to the shared
a61af66fc99e Initial load
duke
parents:
diff changeset
387 // derived pointer table in DerivedPointerTable::add().
a61af66fc99e Initial load
duke
parents:
diff changeset
388 MutexLockerEx x(DerivedPointerTableGC_lock, Mutex::_no_safepoint_check_flag);
a61af66fc99e Initial load
duke
parents:
diff changeset
389 do {
a61af66fc99e Initial load
duke
parents:
diff changeset
390 omv = oms.current();
a61af66fc99e Initial load
duke
parents:
diff changeset
391 oop* loc = fr->oopmapreg_to_location(omv.reg(),reg_map);
20969
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
392 guarantee(loc != NULL, "missing saved register");
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
393 oop *base_loc = fr->oopmapreg_to_location(omv.content_reg(), reg_map);
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
394 oop *derived_loc = loc;
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
395 oop val = *base_loc;
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
396 if (val == (oop)NULL || Universe::is_narrow_oop_base(val)) {
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
397 // Ignore NULL oops and decoded NULL narrow oops which
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
398 // equal to Universe::narrow_oop_base when a narrow oop
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
399 // implicit null check is used in compiled code.
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
400 // The narrow_oop_base could be NULL or be the address
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
401 // of the page below heap depending on compressed oops mode.
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
402 } else {
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
403 derived_oop_fn(base_loc, derived_loc);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
404 }
a61af66fc99e Initial load
duke
parents:
diff changeset
405 oms.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
406 } while (!oms.is_done());
a61af66fc99e Initial load
duke
parents:
diff changeset
407 }
a61af66fc99e Initial load
duke
parents:
diff changeset
408 }
a61af66fc99e Initial load
duke
parents:
diff changeset
409
20969
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
410 // We want narrowoop and oop oop_types
14988
82ff6c8c8f6e Increase maximum allocatable spill area by factor of 2.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14124
diff changeset
411 int mask = OopMapValue::oop_value | OopMapValue::narrowoop_value;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
412 {
a61af66fc99e Initial load
duke
parents:
diff changeset
413 for (OopMapStream oms(map,mask); !oms.is_done(); oms.next()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
414 omv = oms.current();
a61af66fc99e Initial load
duke
parents:
diff changeset
415 oop* loc = fr->oopmapreg_to_location(omv.reg(),reg_map);
20969
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
416 // It should be an error if no location can be found for a
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
417 // register mentioned as contained an oop of some kind. Maybe
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
418 // this was allowed previously because value_value items might
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
419 // be missing?
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
420 guarantee(loc != NULL, "missing saved register");
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
421 if ( omv.type() == OopMapValue::oop_value ) {
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
422 oop val = *loc;
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
423 if (val == (oop)NULL || Universe::is_narrow_oop_base(val)) {
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
424 // Ignore NULL oops and decoded NULL narrow oops which
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
425 // equal to Universe::narrow_oop_base when a narrow oop
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
426 // implicit null check is used in compiled code.
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
427 // The narrow_oop_base could be NULL or be the address
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
428 // of the page below heap depending on compressed oops mode.
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
429 continue;
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
430 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
431 #ifdef ASSERT
20969
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
432 if ((((uintptr_t)loc & (sizeof(*loc)-1)) != 0) ||
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
433 !Universe::heap()->is_in_or_null(*loc)) {
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
434 tty->print_cr("# Found non oop pointer. Dumping state at failure");
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
435 // try to dump out some helpful debugging information
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
436 trace_codeblob_maps(fr, reg_map);
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
437 omv.print();
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
438 tty->print_cr("register r");
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
439 omv.reg()->print();
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
440 tty->print_cr("loc = %p *loc = %p\n", loc, (address)*loc);
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
441 // do the real assert.
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
442 assert(Universe::heap()->is_in_or_null(*loc), "found non oop pointer");
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
443 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
444 #endif // ASSERT
20969
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
445 oop_fn->do_oop(loc);
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
446 } else if ( omv.type() == OopMapValue::narrowoop_value ) {
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
447 narrowOop *nl = (narrowOop*)loc;
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 100
diff changeset
448 #ifndef VM_LITTLE_ENDIAN
22407
708a95bb443c All SPARC float registers can be addressed in 4 byte portions; hence don't add 4 bytes to pointer pointing to a Narrow Oop
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 22298
diff changeset
449 VMReg vmReg = omv.reg();
708a95bb443c All SPARC float registers can be addressed in 4 byte portions; hence don't add 4 bytes to pointer pointing to a Narrow Oop
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 22298
diff changeset
450 // Don't do this on SPARC float registers as they can be individually addressed
708a95bb443c All SPARC float registers can be addressed in 4 byte portions; hence don't add 4 bytes to pointer pointing to a Narrow Oop
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 22298
diff changeset
451 if (!vmReg->is_stack() SPARC_ONLY(&& !vmReg->is_FloatRegister())) {
20969
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
452 // compressed oops in registers only take up 4 bytes of an
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
453 // 8 byte register but they are in the wrong part of the
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
454 // word so adjust loc to point at the right place.
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
455 nl = (narrowOop*)((address)nl + 4);
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
456 }
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 100
diff changeset
457 #endif
20969
534f0dde2810 It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20804
diff changeset
458 oop_fn->do_oop(nl);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
459 }
a61af66fc99e Initial load
duke
parents:
diff changeset
460 }
a61af66fc99e Initial load
duke
parents:
diff changeset
461 }
a61af66fc99e Initial load
duke
parents:
diff changeset
462 }
a61af66fc99e Initial load
duke
parents:
diff changeset
463
a61af66fc99e Initial load
duke
parents:
diff changeset
464
a61af66fc99e Initial load
duke
parents:
diff changeset
465 // Update callee-saved register info for the following frame
a61af66fc99e Initial load
duke
parents:
diff changeset
466 void OopMapSet::update_register_map(const frame *fr, RegisterMap *reg_map) {
a61af66fc99e Initial load
duke
parents:
diff changeset
467 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
468 CodeBlob* cb = fr->cb();
a61af66fc99e Initial load
duke
parents:
diff changeset
469 assert(cb != NULL, "no codeblob");
a61af66fc99e Initial load
duke
parents:
diff changeset
470
a61af66fc99e Initial load
duke
parents:
diff changeset
471 // Any reg might be saved by a safepoint handler (see generate_handler_blob).
a61af66fc99e Initial load
duke
parents:
diff changeset
472 assert( reg_map->_update_for_id == NULL || fr->is_older(reg_map->_update_for_id),
a61af66fc99e Initial load
duke
parents:
diff changeset
473 "already updated this map; do not 'update' it twice!" );
a61af66fc99e Initial load
duke
parents:
diff changeset
474 debug_only(reg_map->_update_for_id = fr->id());
a61af66fc99e Initial load
duke
parents:
diff changeset
475
a61af66fc99e Initial load
duke
parents:
diff changeset
476 // Check if caller must update oop argument
a61af66fc99e Initial load
duke
parents:
diff changeset
477 assert((reg_map->include_argument_oops() ||
a61af66fc99e Initial load
duke
parents:
diff changeset
478 !cb->caller_must_gc_arguments(reg_map->thread())),
a61af66fc99e Initial load
duke
parents:
diff changeset
479 "include_argument_oops should already be set");
a61af66fc99e Initial load
duke
parents:
diff changeset
480
a61af66fc99e Initial load
duke
parents:
diff changeset
481 // Scan through oopmap and find location of all callee-saved registers
a61af66fc99e Initial load
duke
parents:
diff changeset
482 // (we do not do update in place, since info could be overwritten)
a61af66fc99e Initial load
duke
parents:
diff changeset
483
a61af66fc99e Initial load
duke
parents:
diff changeset
484 address pc = fr->pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
485 OopMap* map = cb->oop_map_for_return_address(pc);
20226
6ad19ab94176 8050229: Uninitialised memory in hotspot/src/share/vm/compiler/oopMap.cpp
morris
parents: 17937
diff changeset
486 assert(map != NULL, "no ptr map found");
6ad19ab94176 8050229: Uninitialised memory in hotspot/src/share/vm/compiler/oopMap.cpp
morris
parents: 17937
diff changeset
487 DEBUG_ONLY(int nof_callee = 0;)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
488
20226
6ad19ab94176 8050229: Uninitialised memory in hotspot/src/share/vm/compiler/oopMap.cpp
morris
parents: 17937
diff changeset
489 for (OopMapStream oms(map, OopMapValue::callee_saved_value); !oms.is_done(); oms.next()) {
6ad19ab94176 8050229: Uninitialised memory in hotspot/src/share/vm/compiler/oopMap.cpp
morris
parents: 17937
diff changeset
490 OopMapValue omv = oms.current();
6ad19ab94176 8050229: Uninitialised memory in hotspot/src/share/vm/compiler/oopMap.cpp
morris
parents: 17937
diff changeset
491 VMReg reg = omv.content_reg();
6ad19ab94176 8050229: Uninitialised memory in hotspot/src/share/vm/compiler/oopMap.cpp
morris
parents: 17937
diff changeset
492 oop* loc = fr->oopmapreg_to_location(omv.reg(), reg_map);
6ad19ab94176 8050229: Uninitialised memory in hotspot/src/share/vm/compiler/oopMap.cpp
morris
parents: 17937
diff changeset
493 reg_map->set_location(reg, (address) loc);
6ad19ab94176 8050229: Uninitialised memory in hotspot/src/share/vm/compiler/oopMap.cpp
morris
parents: 17937
diff changeset
494 DEBUG_ONLY(nof_callee++;)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
495 }
a61af66fc99e Initial load
duke
parents:
diff changeset
496
a61af66fc99e Initial load
duke
parents:
diff changeset
497 // Check that runtime stubs save all callee-saved registers
a61af66fc99e Initial load
duke
parents:
diff changeset
498 #ifdef COMPILER2
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 20969
diff changeset
499 assert(cb->is_compiled_by_c1() || cb->is_compiled_by_jvmci() || !cb->is_runtime_stub() ||
0
a61af66fc99e Initial load
duke
parents:
diff changeset
500 (nof_callee >= SAVED_ON_ENTRY_REG_COUNT || nof_callee >= C_SAVED_ON_ENTRY_REG_COUNT),
a61af66fc99e Initial load
duke
parents:
diff changeset
501 "must save all");
a61af66fc99e Initial load
duke
parents:
diff changeset
502 #endif // COMPILER2
a61af66fc99e Initial load
duke
parents:
diff changeset
503 }
a61af66fc99e Initial load
duke
parents:
diff changeset
504
a61af66fc99e Initial load
duke
parents:
diff changeset
505 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
506 // Non-Product code
a61af66fc99e Initial load
duke
parents:
diff changeset
507
a61af66fc99e Initial load
duke
parents:
diff changeset
508 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
509
a61af66fc99e Initial load
duke
parents:
diff changeset
510 bool OopMap::has_derived_pointer() const {
23705
1051fbaca88b the client VM build is broken when INCLUDE_JVMCI is defined (JDK-8159888)
Doug Simon <doug.simon@oracle.com>
parents: 23404
diff changeset
511 #if !defined(TIERED) && !defined(INCLUDE_JVMCI)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
512 COMPILER1_PRESENT(return false);
a61af66fc99e Initial load
duke
parents:
diff changeset
513 #endif // !TIERED
22298
c28cb37b2e1d Rename JVMCI to INCLUDE_JVMCI.
twisti
parents: 22294
diff changeset
514 #if defined(COMPILER2) || INCLUDE_JVMCI
0
a61af66fc99e Initial load
duke
parents:
diff changeset
515 OopMapStream oms((OopMap*)this,OopMapValue::derived_oop_value);
a61af66fc99e Initial load
duke
parents:
diff changeset
516 return oms.is_done();
a61af66fc99e Initial load
duke
parents:
diff changeset
517 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
518 return false;
22294
d86b226e331a Enable derived oop processing by the GC with JVMCI
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 21559
diff changeset
519 #endif // COMPILER2 || JVMCI
0
a61af66fc99e Initial load
duke
parents:
diff changeset
520 }
a61af66fc99e Initial load
duke
parents:
diff changeset
521
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents: 25
diff changeset
522 #endif //PRODUCT
0
a61af66fc99e Initial load
duke
parents:
diff changeset
523
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents: 25
diff changeset
524 // Printing code is present in product build for -XX:+PrintAssembly.
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents: 25
diff changeset
525
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents: 25
diff changeset
526 static
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents: 25
diff changeset
527 void print_register_type(OopMapValue::oop_types x, VMReg optional,
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents: 25
diff changeset
528 outputStream* st) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
529 switch( x ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
530 case OopMapValue::oop_value:
25
c5cbd367e4d1 6621094: PrintOptoAssembly is broken for oops information in DebugInfo
kvn
parents: 0
diff changeset
531 st->print("Oop");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
532 break;
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 100
diff changeset
533 case OopMapValue::narrowoop_value:
7636
a7114d3d712e 8005055: pass outputStream to more opto debug routines
kvn
parents: 6842
diff changeset
534 st->print("NarrowOop");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
535 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
536 case OopMapValue::callee_saved_value:
7636
a7114d3d712e 8005055: pass outputStream to more opto debug routines
kvn
parents: 6842
diff changeset
537 st->print("Callers_");
25
c5cbd367e4d1 6621094: PrintOptoAssembly is broken for oops information in DebugInfo
kvn
parents: 0
diff changeset
538 optional->print_on(st);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
539 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
540 case OopMapValue::derived_oop_value:
7636
a7114d3d712e 8005055: pass outputStream to more opto debug routines
kvn
parents: 6842
diff changeset
541 st->print("Derived_oop_");
25
c5cbd367e4d1 6621094: PrintOptoAssembly is broken for oops information in DebugInfo
kvn
parents: 0
diff changeset
542 optional->print_on(st);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
543 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
544 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
545 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
546 }
a61af66fc99e Initial load
duke
parents:
diff changeset
547 }
a61af66fc99e Initial load
duke
parents:
diff changeset
548
a61af66fc99e Initial load
duke
parents:
diff changeset
549
25
c5cbd367e4d1 6621094: PrintOptoAssembly is broken for oops information in DebugInfo
kvn
parents: 0
diff changeset
550 void OopMapValue::print_on(outputStream* st) const {
c5cbd367e4d1 6621094: PrintOptoAssembly is broken for oops information in DebugInfo
kvn
parents: 0
diff changeset
551 reg()->print_on(st);
c5cbd367e4d1 6621094: PrintOptoAssembly is broken for oops information in DebugInfo
kvn
parents: 0
diff changeset
552 st->print("=");
c5cbd367e4d1 6621094: PrintOptoAssembly is broken for oops information in DebugInfo
kvn
parents: 0
diff changeset
553 print_register_type(type(),content_reg(),st);
c5cbd367e4d1 6621094: PrintOptoAssembly is broken for oops information in DebugInfo
kvn
parents: 0
diff changeset
554 st->print(" ");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
555 }
a61af66fc99e Initial load
duke
parents:
diff changeset
556
a61af66fc99e Initial load
duke
parents:
diff changeset
557
a61af66fc99e Initial load
duke
parents:
diff changeset
558 void OopMap::print_on(outputStream* st) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
559 OopMapValue omv;
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents: 25
diff changeset
560 st->print("OopMap{");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
561 for(OopMapStream oms((OopMap*)this); !oms.is_done(); oms.next()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
562 omv = oms.current();
a61af66fc99e Initial load
duke
parents:
diff changeset
563 omv.print_on(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
564 }
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents: 25
diff changeset
565 st->print("off=%d}", (int) offset());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
566 }
a61af66fc99e Initial load
duke
parents:
diff changeset
567
a61af66fc99e Initial load
duke
parents:
diff changeset
568
a61af66fc99e Initial load
duke
parents:
diff changeset
569 void OopMapSet::print_on(outputStream* st) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
570 int i, len = om_count();
a61af66fc99e Initial load
duke
parents:
diff changeset
571
a61af66fc99e Initial load
duke
parents:
diff changeset
572 st->print_cr("OopMapSet contains %d OopMaps\n",len);
a61af66fc99e Initial load
duke
parents:
diff changeset
573
a61af66fc99e Initial load
duke
parents:
diff changeset
574 for( i = 0; i < len; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
575 OopMap* m = at(i);
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents: 25
diff changeset
576 st->print_cr("#%d ",i);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
577 m->print_on(st);
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents: 25
diff changeset
578 st->cr();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
579 }
a61af66fc99e Initial load
duke
parents:
diff changeset
580 }
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents: 25
diff changeset
581
0
a61af66fc99e Initial load
duke
parents:
diff changeset
582
a61af66fc99e Initial load
duke
parents:
diff changeset
583
a61af66fc99e Initial load
duke
parents:
diff changeset
584 //------------------------------DerivedPointerTable---------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
585
22298
c28cb37b2e1d Rename JVMCI to INCLUDE_JVMCI.
twisti
parents: 22294
diff changeset
586 #if defined(COMPILER2) || INCLUDE_JVMCI
0
a61af66fc99e Initial load
duke
parents:
diff changeset
587
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 3442
diff changeset
588 class DerivedPointerEntry : public CHeapObj<mtCompiler> {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
589 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
590 oop* _location; // Location of derived pointer (also pointing to the base)
a61af66fc99e Initial load
duke
parents:
diff changeset
591 intptr_t _offset; // Offset from base pointer
a61af66fc99e Initial load
duke
parents:
diff changeset
592 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
593 DerivedPointerEntry(oop* location, intptr_t offset) { _location = location; _offset = offset; }
a61af66fc99e Initial load
duke
parents:
diff changeset
594 oop* location() { return _location; }
a61af66fc99e Initial load
duke
parents:
diff changeset
595 intptr_t offset() { return _offset; }
a61af66fc99e Initial load
duke
parents:
diff changeset
596 };
a61af66fc99e Initial load
duke
parents:
diff changeset
597
a61af66fc99e Initial load
duke
parents:
diff changeset
598
a61af66fc99e Initial load
duke
parents:
diff changeset
599 GrowableArray<DerivedPointerEntry*>* DerivedPointerTable::_list = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
600 bool DerivedPointerTable::_active = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
601
a61af66fc99e Initial load
duke
parents:
diff changeset
602
a61af66fc99e Initial load
duke
parents:
diff changeset
603 void DerivedPointerTable::clear() {
a61af66fc99e Initial load
duke
parents:
diff changeset
604 // The first time, we create the list. Otherwise it should be
a61af66fc99e Initial load
duke
parents:
diff changeset
605 // empty. If not, then we have probably forgotton to call
a61af66fc99e Initial load
duke
parents:
diff changeset
606 // update_pointers after last GC/Scavenge.
a61af66fc99e Initial load
duke
parents:
diff changeset
607 assert (!_active, "should not be active");
a61af66fc99e Initial load
duke
parents:
diff changeset
608 assert(_list == NULL || _list->length() == 0, "table not empty");
a61af66fc99e Initial load
duke
parents:
diff changeset
609 if (_list == NULL) {
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 3442
diff changeset
610 _list = new (ResourceObj::C_HEAP, mtCompiler) GrowableArray<DerivedPointerEntry*>(10, true); // Allocated on C heap
0
a61af66fc99e Initial load
duke
parents:
diff changeset
611 }
a61af66fc99e Initial load
duke
parents:
diff changeset
612 _active = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
613 }
a61af66fc99e Initial load
duke
parents:
diff changeset
614
a61af66fc99e Initial load
duke
parents:
diff changeset
615
a61af66fc99e Initial load
duke
parents:
diff changeset
616 // Returns value of location as an int
12316
190899198332 7195622: CheckUnhandledOops has limited usefulness now
hseigel
parents: 7636
diff changeset
617 intptr_t value_of_loc(oop *pointer) { return cast_from_oop<intptr_t>((*pointer)); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
618
a61af66fc99e Initial load
duke
parents:
diff changeset
619
a61af66fc99e Initial load
duke
parents:
diff changeset
620 void DerivedPointerTable::add(oop *derived_loc, oop *base_loc) {
a61af66fc99e Initial load
duke
parents:
diff changeset
621 assert(Universe::heap()->is_in_or_null(*base_loc), "not an oop");
a61af66fc99e Initial load
duke
parents:
diff changeset
622 assert(derived_loc != base_loc, "Base and derived in same location");
a61af66fc99e Initial load
duke
parents:
diff changeset
623 if (_active) {
a61af66fc99e Initial load
duke
parents:
diff changeset
624 assert(*derived_loc != (oop)base_loc, "location already added");
a61af66fc99e Initial load
duke
parents:
diff changeset
625 assert(_list != NULL, "list must exist");
a61af66fc99e Initial load
duke
parents:
diff changeset
626 intptr_t offset = value_of_loc(derived_loc) - value_of_loc(base_loc);
3442
f7d55ea6ee56 7045514: SPARC assembly code for JSR 292 ricochet frames
never
parents: 1972
diff changeset
627 // This assert is invalid because derived pointers can be
f7d55ea6ee56 7045514: SPARC assembly code for JSR 292 ricochet frames
never
parents: 1972
diff changeset
628 // arbitrarily far away from their base.
f7d55ea6ee56 7045514: SPARC assembly code for JSR 292 ricochet frames
never
parents: 1972
diff changeset
629 // assert(offset >= -1000000, "wrong derived pointer info");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
630
a61af66fc99e Initial load
duke
parents:
diff changeset
631 if (TraceDerivedPointers) {
a61af66fc99e Initial load
duke
parents:
diff changeset
632 tty->print_cr(
a61af66fc99e Initial load
duke
parents:
diff changeset
633 "Add derived pointer@" INTPTR_FORMAT
a61af66fc99e Initial load
duke
parents:
diff changeset
634 " - Derived: " INTPTR_FORMAT
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 12316
diff changeset
635 " Base: " INTPTR_FORMAT " (@" INTPTR_FORMAT ") (Offset: " INTX_FORMAT ")",
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 12316
diff changeset
636 p2i(derived_loc), p2i((address)*derived_loc), p2i((address)*base_loc), p2i(base_loc), offset
0
a61af66fc99e Initial load
duke
parents:
diff changeset
637 );
a61af66fc99e Initial load
duke
parents:
diff changeset
638 }
a61af66fc99e Initial load
duke
parents:
diff changeset
639 // Set derived oop location to point to base.
a61af66fc99e Initial load
duke
parents:
diff changeset
640 *derived_loc = (oop)base_loc;
a61af66fc99e Initial load
duke
parents:
diff changeset
641 assert_lock_strong(DerivedPointerTableGC_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
642 DerivedPointerEntry *entry = new DerivedPointerEntry(derived_loc, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
643 _list->append(entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
644 }
a61af66fc99e Initial load
duke
parents:
diff changeset
645 }
a61af66fc99e Initial load
duke
parents:
diff changeset
646
a61af66fc99e Initial load
duke
parents:
diff changeset
647
a61af66fc99e Initial load
duke
parents:
diff changeset
648 void DerivedPointerTable::update_pointers() {
a61af66fc99e Initial load
duke
parents:
diff changeset
649 assert(_list != NULL, "list must exist");
a61af66fc99e Initial load
duke
parents:
diff changeset
650 for(int i = 0; i < _list->length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
651 DerivedPointerEntry* entry = _list->at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
652 oop* derived_loc = entry->location();
a61af66fc99e Initial load
duke
parents:
diff changeset
653 intptr_t offset = entry->offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
654 // The derived oop was setup to point to location of base
a61af66fc99e Initial load
duke
parents:
diff changeset
655 oop base = **(oop**)derived_loc;
a61af66fc99e Initial load
duke
parents:
diff changeset
656 assert(Universe::heap()->is_in_or_null(base), "must be an oop");
a61af66fc99e Initial load
duke
parents:
diff changeset
657
a61af66fc99e Initial load
duke
parents:
diff changeset
658 *derived_loc = (oop)(((address)base) + offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
659 assert(value_of_loc(derived_loc) - value_of_loc(&base) == offset, "sanity check");
a61af66fc99e Initial load
duke
parents:
diff changeset
660
a61af66fc99e Initial load
duke
parents:
diff changeset
661 if (TraceDerivedPointers) {
a61af66fc99e Initial load
duke
parents:
diff changeset
662 tty->print_cr("Updating derived pointer@" INTPTR_FORMAT
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 12316
diff changeset
663 " - Derived: " INTPTR_FORMAT " Base: " INTPTR_FORMAT " (Offset: " INTX_FORMAT ")",
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 12316
diff changeset
664 p2i(derived_loc), p2i((address)*derived_loc), p2i((address)base), offset);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
665 }
a61af66fc99e Initial load
duke
parents:
diff changeset
666
a61af66fc99e Initial load
duke
parents:
diff changeset
667 // Delete entry
a61af66fc99e Initial load
duke
parents:
diff changeset
668 delete entry;
a61af66fc99e Initial load
duke
parents:
diff changeset
669 _list->at_put(i, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
670 }
a61af66fc99e Initial load
duke
parents:
diff changeset
671 // Clear list, so it is ready for next traversal (this is an invariant)
a61af66fc99e Initial load
duke
parents:
diff changeset
672 if (TraceDerivedPointers && !_list->is_empty()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
673 tty->print_cr("--------------------------");
a61af66fc99e Initial load
duke
parents:
diff changeset
674 }
a61af66fc99e Initial load
duke
parents:
diff changeset
675 _list->clear();
a61af66fc99e Initial load
duke
parents:
diff changeset
676 _active = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
677 }
a61af66fc99e Initial load
duke
parents:
diff changeset
678
22294
d86b226e331a Enable derived oop processing by the GC with JVMCI
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 21559
diff changeset
679 #endif // COMPILER2 || JVMCI