Mercurial > hg > truffle
annotate src/share/vm/oops/cpCacheOop.hpp @ 1775:30f67acf635d
6765718: Indicate which thread throwing OOME when generating the heap dump at OOME
Summary: Emit a fake frame that makes it look like the thread is in the OutOfMemoryError zero-parameter constructor
Reviewed-by: dcubed
author | thurka |
---|---|
date | Sat, 11 Sep 2010 08:18:31 +0200 |
parents | e0ba4e04c839 |
children | 87d6a4d1ecbc |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1507
diff
changeset
|
2 * Copyright (c) 1998, 2009, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1507
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1507
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:
1507
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 // A ConstantPoolCacheEntry describes an individual entry of the constant | |
26 // pool cache. There's 2 principal kinds of entries: field entries for in- | |
27 // stance & static field access, and method entries for invokes. Some of | |
28 // the entry layout is shared and looks as follows: | |
29 // | |
30 // bit number |31 0| | |
31 // bit length |-8--|-8--|---16----| | |
32 // -------------------------------- | |
33 // _indices [ b2 | b1 | index ] | |
34 // _f1 [ entry specific ] | |
35 // _f2 [ entry specific ] | |
36 // _flags [t|f|vf|v|m|h|unused|field_index] (for field entries) | |
37 // bit length |4|1|1 |1|1|0|---7--|----16-----] | |
38 // _flags [t|f|vf|v|m|h|unused|eidx|psze] (for method entries) | |
39 // bit length |4|1|1 |1|1|1|---7--|-8--|-8--] | |
40 | |
41 // -------------------------------- | |
42 // | |
43 // with: | |
44 // index = original constant pool index | |
45 // b1 = bytecode 1 | |
46 // b2 = bytecode 2 | |
47 // psze = parameters size (method entries only) | |
48 // eidx = interpreter entry index (method entries only) | |
49 // field_index = index into field information in holder instanceKlass | |
50 // The index max is 0xffff (max number of fields in constant pool) | |
51 // and is multiplied by (instanceKlass::next_offset) when accessing. | |
52 // t = TosState (see below) | |
53 // f = field is marked final (see below) | |
54 // vf = virtual, final (method entries only : is_vfinal()) | |
55 // v = field is volatile (see below) | |
56 // m = invokeinterface used for method in class Object (see below) | |
57 // h = RedefineClasses/Hotswap bit (see below) | |
58 // | |
59 // The flags after TosState have the following interpretation: | |
60 // bit 27: f flag true if field is marked final | |
61 // bit 26: vf flag true if virtual final method | |
62 // bit 25: v flag true if field is volatile (only for fields) | |
63 // bit 24: m flag true if invokeinterface used for method in class Object | |
64 // bit 23: 0 for fields, 1 for methods | |
65 // | |
66 // The flags 31, 30, 29, 28 together build a 4 bit number 0 to 8 with the | |
67 // following mapping to the TosState states: | |
68 // | |
69 // btos: 0 | |
70 // ctos: 1 | |
71 // stos: 2 | |
72 // itos: 3 | |
73 // ltos: 4 | |
74 // ftos: 5 | |
75 // dtos: 6 | |
76 // atos: 7 | |
77 // vtos: 8 | |
78 // | |
79 // Entry specific: field entries: | |
80 // _indices = get (b1 section) and put (b2 section) bytecodes, original constant pool index | |
81 // _f1 = field holder | |
82 // _f2 = field offset in words | |
83 // _flags = field type information, original field index in field holder | |
84 // (field_index section) | |
85 // | |
86 // Entry specific: method entries: | |
87 // _indices = invoke code for f1 (b1 section), invoke code for f2 (b2 section), | |
88 // original constant pool index | |
89 // _f1 = method for all but virtual calls, unused by virtual calls | |
90 // (note: for interface calls, which are essentially virtual, | |
91 // contains klassOop for the corresponding interface. | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
92 // for invokedynamic, f1 contains the CallSite object for the invocation |
0 | 93 // _f2 = method/vtable index for virtual calls only, unused by all other |
94 // calls. The vf flag indicates this is a method pointer not an | |
95 // index. | |
96 // _flags = field type info (f section), | |
97 // virtual final entry (vf), | |
98 // interpreter entry index (eidx section), | |
99 // parameter size (psze section) | |
100 // | |
101 // Note: invokevirtual & invokespecial bytecodes can share the same constant | |
102 // pool entry and thus the same constant pool cache entry. All invoke | |
103 // bytecodes but invokevirtual use only _f1 and the corresponding b1 | |
104 // bytecode, while invokevirtual uses only _f2 and the corresponding | |
105 // b2 bytecode. The value of _flags is shared for both types of entries. | |
106 // | |
107 // The fields are volatile so that they are stored in the order written in the | |
108 // source code. The _indices field with the bytecode must be written last. | |
109 | |
110 class ConstantPoolCacheEntry VALUE_OBJ_CLASS_SPEC { | |
111 friend class VMStructs; | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
112 friend class constantPoolCacheKlass; |
1602 | 113 friend class constantPoolOopDesc; //resolve_constant_at_impl => set_f1 |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
114 |
0 | 115 private: |
116 volatile intx _indices; // constant pool index & rewrite bytecodes | |
117 volatile oop _f1; // entry specific oop field | |
118 volatile intx _f2; // entry specific int/oop field | |
119 volatile intx _flags; // flags | |
120 | |
121 | |
122 #ifdef ASSERT | |
123 bool same_methodOop(oop cur_f1, oop f1); | |
124 #endif | |
125 | |
126 void set_bytecode_1(Bytecodes::Code code); | |
127 void set_bytecode_2(Bytecodes::Code code); | |
128 void set_f1(oop f1) { | |
129 oop existing_f1 = _f1; // read once | |
130 assert(existing_f1 == NULL || existing_f1 == f1, "illegal field change"); | |
131 oop_store(&_f1, f1); | |
132 } | |
133 void set_f2(intx f2) { assert(_f2 == 0 || _f2 == f2, "illegal field change"); _f2 = f2; } | |
134 int as_flags(TosState state, bool is_final, bool is_vfinal, bool is_volatile, | |
135 bool is_method_interface, bool is_method); | |
136 void set_flags(intx flags) { _flags = flags; } | |
137 | |
138 public: | |
139 // specific bit values in flag field | |
140 // Note: the interpreter knows this layout! | |
141 enum FlagBitValues { | |
142 hotSwapBit = 23, | |
143 methodInterface = 24, | |
144 volatileField = 25, | |
145 vfinalMethod = 26, | |
146 finalField = 27 | |
147 }; | |
148 | |
149 enum { field_index_mask = 0xFFFF }; | |
150 | |
151 // start of type bits in flags | |
152 // Note: the interpreter knows this layout! | |
153 enum FlagValues { | |
154 tosBits = 28 | |
155 }; | |
156 | |
157 // Initialization | |
1059
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
158 void initialize_entry(int original_index); // initialize primary entry |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
159 void initialize_secondary_entry(int main_index); // initialize secondary entry |
0 | 160 |
161 void set_field( // sets entry to resolved field state | |
162 Bytecodes::Code get_code, // the bytecode used for reading the field | |
163 Bytecodes::Code put_code, // the bytecode used for writing the field | |
164 KlassHandle field_holder, // the object/klass holding the field | |
165 int orig_field_index, // the original field index in the field holder | |
166 int field_offset, // the field offset in words in the field holder | |
167 TosState field_type, // the (machine) field type | |
168 bool is_final, // the field is final | |
169 bool is_volatile // the field is volatile | |
170 ); | |
171 | |
172 void set_method( // sets entry to resolved method entry | |
173 Bytecodes::Code invoke_code, // the bytecode used for invoking the method | |
174 methodHandle method, // the method/prototype if any (NULL, otherwise) | |
175 int vtable_index // the vtable index if any, else negative | |
176 ); | |
177 | |
178 void set_interface_call( | |
179 methodHandle method, // Resolved method | |
180 int index // Method index into interface | |
181 ); | |
182 | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
183 void set_dynamic_call( |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
184 Handle call_site, // Resolved java.dyn.CallSite (f1) |
1507
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1059
diff
changeset
|
185 methodHandle signature_invoker // determines signature information |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
186 ); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
187 |
1660
083fde3b838e
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
1602
diff
changeset
|
188 // For JVM_CONSTANT_InvokeDynamic cache entries: |
083fde3b838e
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
1602
diff
changeset
|
189 void initialize_bootstrap_method_index_in_cache(int bsm_cache_index); |
083fde3b838e
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
1602
diff
changeset
|
190 int bootstrap_method_index_in_cache(); |
083fde3b838e
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
1602
diff
changeset
|
191 |
0 | 192 void set_parameter_size(int value) { |
193 assert(parameter_size() == 0 || parameter_size() == value, | |
194 "size must not change"); | |
195 // Setting the parameter size by itself is only safe if the | |
196 // current value of _flags is 0, otherwise another thread may have | |
197 // updated it and we don't want to overwrite that value. Don't | |
198 // bother trying to update it once it's nonzero but always make | |
199 // sure that the final parameter size agrees with what was passed. | |
200 if (_flags == 0) { | |
201 Atomic::cmpxchg_ptr((value & 0xFF), &_flags, 0); | |
202 } | |
203 guarantee(parameter_size() == value, "size must not change"); | |
204 } | |
205 | |
206 // Which bytecode number (1 or 2) in the index field is valid for this bytecode? | |
207 // Returns -1 if neither is valid. | |
208 static int bytecode_number(Bytecodes::Code code) { | |
209 switch (code) { | |
210 case Bytecodes::_getstatic : // fall through | |
211 case Bytecodes::_getfield : // fall through | |
212 case Bytecodes::_invokespecial : // fall through | |
213 case Bytecodes::_invokestatic : // fall through | |
1662
e0ba4e04c839
6969574: invokedynamic call sites deoptimize instead of executing
jrose
parents:
1660
diff
changeset
|
214 case Bytecodes::_invokedynamic : // fall through |
0 | 215 case Bytecodes::_invokeinterface : return 1; |
216 case Bytecodes::_putstatic : // fall through | |
217 case Bytecodes::_putfield : // fall through | |
218 case Bytecodes::_invokevirtual : return 2; | |
219 default : break; | |
220 } | |
221 return -1; | |
222 } | |
223 | |
224 // Has this bytecode been resolved? Only valid for invokes and get/put field/static. | |
225 bool is_resolved(Bytecodes::Code code) const { | |
226 switch (bytecode_number(code)) { | |
227 case 1: return (bytecode_1() == code); | |
228 case 2: return (bytecode_2() == code); | |
229 } | |
230 return false; // default: not resolved | |
231 } | |
232 | |
233 // Accessors | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
234 bool is_secondary_entry() const { return (_indices & 0xFFFF) == 0; } |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
235 int constant_pool_index() const { assert((_indices & 0xFFFF) != 0, "must be main entry"); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
236 return (_indices & 0xFFFF); } |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
237 int main_entry_index() const { assert((_indices & 0xFFFF) == 0, "must be secondary entry"); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
238 return ((uintx)_indices >> 16); } |
0 | 239 Bytecodes::Code bytecode_1() const { return Bytecodes::cast((_indices >> 16) & 0xFF); } |
240 Bytecodes::Code bytecode_2() const { return Bytecodes::cast((_indices >> 24) & 0xFF); } | |
241 volatile oop f1() const { return _f1; } | |
1660
083fde3b838e
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
1602
diff
changeset
|
242 bool is_f1_null() const { return (oop)_f1 == NULL; } // classifies a CPC entry as unbound |
0 | 243 intx f2() const { return _f2; } |
244 int field_index() const; | |
245 int parameter_size() const { return _flags & 0xFF; } | |
246 bool is_vfinal() const { return ((_flags & (1 << vfinalMethod)) == (1 << vfinalMethod)); } | |
247 bool is_volatile() const { return ((_flags & (1 << volatileField)) == (1 << volatileField)); } | |
248 bool is_methodInterface() const { return ((_flags & (1 << methodInterface)) == (1 << methodInterface)); } | |
249 bool is_byte() const { return (((uintx) _flags >> tosBits) == btos); } | |
250 bool is_char() const { return (((uintx) _flags >> tosBits) == ctos); } | |
251 bool is_short() const { return (((uintx) _flags >> tosBits) == stos); } | |
252 bool is_int() const { return (((uintx) _flags >> tosBits) == itos); } | |
253 bool is_long() const { return (((uintx) _flags >> tosBits) == ltos); } | |
254 bool is_float() const { return (((uintx) _flags >> tosBits) == ftos); } | |
255 bool is_double() const { return (((uintx) _flags >> tosBits) == dtos); } | |
256 bool is_object() const { return (((uintx) _flags >> tosBits) == atos); } | |
257 TosState flag_state() const { assert( ( (_flags >> tosBits) & 0x0F ) < number_of_states, "Invalid state in as_flags"); | |
258 return (TosState)((_flags >> tosBits) & 0x0F); } | |
259 | |
260 // Code generation support | |
261 static WordSize size() { return in_WordSize(sizeof(ConstantPoolCacheEntry) / HeapWordSize); } | |
1059
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
262 static ByteSize size_in_bytes() { return in_ByteSize(sizeof(ConstantPoolCacheEntry)); } |
0 | 263 static ByteSize indices_offset() { return byte_offset_of(ConstantPoolCacheEntry, _indices); } |
264 static ByteSize f1_offset() { return byte_offset_of(ConstantPoolCacheEntry, _f1); } | |
265 static ByteSize f2_offset() { return byte_offset_of(ConstantPoolCacheEntry, _f2); } | |
266 static ByteSize flags_offset() { return byte_offset_of(ConstantPoolCacheEntry, _flags); } | |
267 | |
268 // GC Support | |
269 void oops_do(void f(oop*)); | |
270 void oop_iterate(OopClosure* blk); | |
271 void oop_iterate_m(OopClosure* blk, MemRegion mr); | |
272 void follow_contents(); | |
273 void adjust_pointers(); | |
274 | |
275 #ifndef SERIALGC | |
276 // Parallel Old | |
277 void follow_contents(ParCompactionManager* cm); | |
278 #endif // SERIALGC | |
279 | |
280 void update_pointers(); | |
281 void update_pointers(HeapWord* beg_addr, HeapWord* end_addr); | |
282 | |
283 // RedefineClasses() API support: | |
284 // If this constantPoolCacheEntry refers to old_method then update it | |
285 // to refer to new_method. | |
286 // trace_name_printed is set to true if the current call has | |
287 // printed the klass name so that other routines in the adjust_* | |
288 // group don't print the klass name. | |
289 bool adjust_method_entry(methodOop old_method, methodOop new_method, | |
290 bool * trace_name_printed); | |
291 bool is_interesting_method_entry(klassOop k); | |
292 bool is_field_entry() const { return (_flags & (1 << hotSwapBit)) == 0; } | |
293 bool is_method_entry() const { return (_flags & (1 << hotSwapBit)) != 0; } | |
294 | |
295 // Debugging & Printing | |
296 void print (outputStream* st, int index) const; | |
297 void verify(outputStream* st) const; | |
298 | |
299 static void verify_tosBits() { | |
300 assert(tosBits == 28, "interpreter now assumes tosBits is 28"); | |
301 } | |
302 }; | |
303 | |
304 | |
305 // A constant pool cache is a runtime data structure set aside to a constant pool. The cache | |
306 // holds interpreter runtime information for all field access and invoke bytecodes. The cache | |
307 // is created and initialized before a class is actively used (i.e., initialized), the indivi- | |
308 // dual cache entries are filled at resolution (i.e., "link") time (see also: rewriter.*). | |
309 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
310 class constantPoolCacheOopDesc: public oopDesc { |
0 | 311 friend class VMStructs; |
312 private: | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
313 int _length; |
0 | 314 constantPoolOop _constant_pool; // the corresponding constant pool |
542
9a25e0c45327
6792421: assert(_bitMap->isMarked(addr+size-1),inconsistent Printezis mark)
jmasa
parents:
196
diff
changeset
|
315 // If true, safe for concurrent GC processing, |
9a25e0c45327
6792421: assert(_bitMap->isMarked(addr+size-1),inconsistent Printezis mark)
jmasa
parents:
196
diff
changeset
|
316 // Set unconditionally in constantPoolCacheKlass::allocate() |
9a25e0c45327
6792421: assert(_bitMap->isMarked(addr+size-1),inconsistent Printezis mark)
jmasa
parents:
196
diff
changeset
|
317 volatile bool _is_conc_safe; |
0 | 318 |
319 // Sizing | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
320 debug_only(friend class ClassVerifier;) |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
321 int length() const { return _length; } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
322 void set_length(int length) { _length = length; } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
323 |
0 | 324 static int header_size() { return sizeof(constantPoolCacheOopDesc) / HeapWordSize; } |
325 static int object_size(int length) { return align_object_size(header_size() + length * in_words(ConstantPoolCacheEntry::size())); } | |
326 int object_size() { return object_size(length()); } | |
327 | |
328 // Helpers | |
329 constantPoolOop* constant_pool_addr() { return &_constant_pool; } | |
330 ConstantPoolCacheEntry* base() const { return (ConstantPoolCacheEntry*)((address)this + in_bytes(base_offset())); } | |
331 | |
332 friend class constantPoolCacheKlass; | |
1059
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
333 friend class ConstantPoolCacheEntry; |
0 | 334 |
335 public: | |
336 // Initialization | |
337 void initialize(intArray& inverse_index_map); | |
338 | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
339 // Secondary indexes. |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
340 // They must look completely different from normal indexes. |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
341 // The main reason is that byte swapping is sometimes done on normal indexes. |
1059
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
342 // Also, some of the CP accessors do different things for secondary indexes. |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
343 // Finally, it is helpful for debugging to tell the two apart. |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
344 static bool is_secondary_index(int i) { return (i < 0); } |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
345 static int decode_secondary_index(int i) { assert(is_secondary_index(i), ""); return ~i; } |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
346 static int encode_secondary_index(int i) { assert(!is_secondary_index(i), ""); return ~i; } |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
347 |
0 | 348 // Accessors |
349 void set_constant_pool(constantPoolOop pool) { oop_store_without_check((oop*)&_constant_pool, (oop)pool); } | |
350 constantPoolOop constant_pool() const { return _constant_pool; } | |
1059
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
351 // Fetches the entry at the given index. |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
352 // The entry may be either primary or secondary. |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
353 // In either case the index must not be encoded or byte-swapped in any way. |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
354 ConstantPoolCacheEntry* entry_at(int i) const { |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
355 assert(0 <= i && i < length(), "index out of bounds"); |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
356 return base() + i; |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
357 } |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
358 // Fetches the secondary entry referred to by index. |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
359 // The index may be a secondary index, and must not be byte-swapped. |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
360 ConstantPoolCacheEntry* secondary_entry_at(int i) const { |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
361 int raw_index = i; |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
362 if (is_secondary_index(i)) { // correct these on the fly |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
363 raw_index = decode_secondary_index(i); |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
364 } |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
365 assert(entry_at(raw_index)->is_secondary_entry(), "not a secondary entry"); |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
366 return entry_at(raw_index); |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
367 } |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
368 // Given a primary or secondary index, fetch the corresponding primary entry. |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
369 // Indirect through the secondary entry, if the index is encoded as a secondary index. |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
370 // The index must not be byte-swapped. |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
371 ConstantPoolCacheEntry* main_entry_at(int i) const { |
1059
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
372 int primary_index = i; |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
373 if (is_secondary_index(i)) { |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
374 // run through an extra level of indirection: |
1059
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
375 int raw_index = decode_secondary_index(i); |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
376 primary_index = entry_at(raw_index)->main_entry_index(); |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
377 } |
1059
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
378 assert(!entry_at(primary_index)->is_secondary_entry(), "only one level of indirection"); |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
379 return entry_at(primary_index); |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
380 } |
0 | 381 |
542
9a25e0c45327
6792421: assert(_bitMap->isMarked(addr+size-1),inconsistent Printezis mark)
jmasa
parents:
196
diff
changeset
|
382 // GC support |
9a25e0c45327
6792421: assert(_bitMap->isMarked(addr+size-1),inconsistent Printezis mark)
jmasa
parents:
196
diff
changeset
|
383 // If the _length field has not been set, the size of the |
9a25e0c45327
6792421: assert(_bitMap->isMarked(addr+size-1),inconsistent Printezis mark)
jmasa
parents:
196
diff
changeset
|
384 // constantPoolCache cannot be correctly calculated. |
9a25e0c45327
6792421: assert(_bitMap->isMarked(addr+size-1),inconsistent Printezis mark)
jmasa
parents:
196
diff
changeset
|
385 bool is_conc_safe() { return _is_conc_safe; } |
9a25e0c45327
6792421: assert(_bitMap->isMarked(addr+size-1),inconsistent Printezis mark)
jmasa
parents:
196
diff
changeset
|
386 void set_is_conc_safe(bool v) { _is_conc_safe = v; } |
9a25e0c45327
6792421: assert(_bitMap->isMarked(addr+size-1),inconsistent Printezis mark)
jmasa
parents:
196
diff
changeset
|
387 |
0 | 388 // Code generation |
389 static ByteSize base_offset() { return in_ByteSize(sizeof(constantPoolCacheOopDesc)); } | |
1059
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
390 static ByteSize entry_offset(int raw_index) { |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
391 int index = raw_index; |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
392 if (is_secondary_index(raw_index)) |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
393 index = decode_secondary_index(raw_index); |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
394 return (base_offset() + ConstantPoolCacheEntry::size_in_bytes() * index); |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
395 } |
0 | 396 |
397 // RedefineClasses() API support: | |
398 // If any entry of this constantPoolCache points to any of | |
399 // old_methods, replace it with the corresponding new_method. | |
400 // trace_name_printed is set to true if the current call has | |
401 // printed the klass name so that other routines in the adjust_* | |
402 // group don't print the klass name. | |
403 void adjust_method_entries(methodOop* old_methods, methodOop* new_methods, | |
404 int methods_length, bool * trace_name_printed); | |
405 }; |