Mercurial > hg > truffle
annotate src/share/vm/oops/cpCacheOop.hpp @ 3762:5c0a3c1858b1
7048782: CMS: assert(last_chunk_index_to_check<= last_chunk_index) failed: parCardTableModRefBS.cpp:359
Summary: The LNC array is sized before the start of a scavenge, while the heap may expand during a scavenge. With CMS, the last block of an arbitrary suffice of the LNC array may expand due to coalition with the expansion delta. We now take care not to attempt access past the end of the LNC array. LNC array code will be cleaned up and suitably encapsulated as part of the forthcoming performance RFE 7043675.
Reviewed-by: brutisso
author | ysr |
---|---|
date | Thu, 02 Jun 2011 10:23:36 -0700 |
parents | 8033953d67ff |
children | 81d815b05abb |
rev | line source |
---|---|
0 | 1 /* |
2227 | 2 * Copyright (c) 1998, 2011, 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 | |
1972 | 25 #ifndef SHARE_VM_OOPS_CPCACHEOOP_HPP |
26 #define SHARE_VM_OOPS_CPCACHEOOP_HPP | |
27 | |
28 #include "interpreter/bytecodes.hpp" | |
29 #include "memory/allocation.hpp" | |
30 #include "oops/arrayOop.hpp" | |
31 #include "utilities/array.hpp" | |
32 | |
0 | 33 // A ConstantPoolCacheEntry describes an individual entry of the constant |
34 // pool cache. There's 2 principal kinds of entries: field entries for in- | |
35 // stance & static field access, and method entries for invokes. Some of | |
36 // the entry layout is shared and looks as follows: | |
37 // | |
38 // bit number |31 0| | |
39 // bit length |-8--|-8--|---16----| | |
40 // -------------------------------- | |
41 // _indices [ b2 | b1 | index ] | |
42 // _f1 [ entry specific ] | |
43 // _f2 [ entry specific ] | |
44 // _flags [t|f|vf|v|m|h|unused|field_index] (for field entries) | |
45 // bit length |4|1|1 |1|1|0|---7--|----16-----] | |
46 // _flags [t|f|vf|v|m|h|unused|eidx|psze] (for method entries) | |
47 // bit length |4|1|1 |1|1|1|---7--|-8--|-8--] | |
48 | |
49 // -------------------------------- | |
50 // | |
51 // with: | |
52 // index = original constant pool index | |
53 // b1 = bytecode 1 | |
54 // b2 = bytecode 2 | |
55 // psze = parameters size (method entries only) | |
56 // eidx = interpreter entry index (method entries only) | |
57 // field_index = index into field information in holder instanceKlass | |
58 // The index max is 0xffff (max number of fields in constant pool) | |
59 // and is multiplied by (instanceKlass::next_offset) when accessing. | |
60 // t = TosState (see below) | |
61 // f = field is marked final (see below) | |
62 // vf = virtual, final (method entries only : is_vfinal()) | |
63 // v = field is volatile (see below) | |
64 // m = invokeinterface used for method in class Object (see below) | |
65 // h = RedefineClasses/Hotswap bit (see below) | |
66 // | |
67 // The flags after TosState have the following interpretation: | |
68 // bit 27: f flag true if field is marked final | |
69 // bit 26: vf flag true if virtual final method | |
70 // bit 25: v flag true if field is volatile (only for fields) | |
71 // bit 24: m flag true if invokeinterface used for method in class Object | |
72 // bit 23: 0 for fields, 1 for methods | |
73 // | |
74 // The flags 31, 30, 29, 28 together build a 4 bit number 0 to 8 with the | |
75 // following mapping to the TosState states: | |
76 // | |
77 // btos: 0 | |
78 // ctos: 1 | |
79 // stos: 2 | |
80 // itos: 3 | |
81 // ltos: 4 | |
82 // ftos: 5 | |
83 // dtos: 6 | |
84 // atos: 7 | |
85 // vtos: 8 | |
86 // | |
87 // Entry specific: field entries: | |
88 // _indices = get (b1 section) and put (b2 section) bytecodes, original constant pool index | |
89 // _f1 = field holder | |
90 // _f2 = field offset in words | |
91 // _flags = field type information, original field index in field holder | |
92 // (field_index section) | |
93 // | |
94 // Entry specific: method entries: | |
95 // _indices = invoke code for f1 (b1 section), invoke code for f2 (b2 section), | |
96 // original constant pool index | |
97 // _f1 = method for all but virtual calls, unused by virtual calls | |
98 // (note: for interface calls, which are essentially virtual, | |
99 // contains klassOop for the corresponding interface. | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
100 // for invokedynamic, f1 contains the CallSite object for the invocation |
0 | 101 // _f2 = method/vtable index for virtual calls only, unused by all other |
102 // calls. The vf flag indicates this is a method pointer not an | |
103 // index. | |
104 // _flags = field type info (f section), | |
105 // virtual final entry (vf), | |
106 // interpreter entry index (eidx section), | |
107 // parameter size (psze section) | |
108 // | |
109 // Note: invokevirtual & invokespecial bytecodes can share the same constant | |
110 // pool entry and thus the same constant pool cache entry. All invoke | |
111 // bytecodes but invokevirtual use only _f1 and the corresponding b1 | |
112 // bytecode, while invokevirtual uses only _f2 and the corresponding | |
113 // b2 bytecode. The value of _flags is shared for both types of entries. | |
114 // | |
115 // The fields are volatile so that they are stored in the order written in the | |
116 // source code. The _indices field with the bytecode must be written last. | |
117 | |
118 class ConstantPoolCacheEntry VALUE_OBJ_CLASS_SPEC { | |
119 friend class VMStructs; | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
120 friend class constantPoolCacheKlass; |
1602 | 121 friend class constantPoolOopDesc; //resolve_constant_at_impl => set_f1 |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
122 |
0 | 123 private: |
124 volatile intx _indices; // constant pool index & rewrite bytecodes | |
125 volatile oop _f1; // entry specific oop field | |
126 volatile intx _f2; // entry specific int/oop field | |
127 volatile intx _flags; // flags | |
128 | |
129 | |
130 #ifdef ASSERT | |
131 bool same_methodOop(oop cur_f1, oop f1); | |
132 #endif | |
133 | |
134 void set_bytecode_1(Bytecodes::Code code); | |
135 void set_bytecode_2(Bytecodes::Code code); | |
136 void set_f1(oop f1) { | |
137 oop existing_f1 = _f1; // read once | |
138 assert(existing_f1 == NULL || existing_f1 == f1, "illegal field change"); | |
139 oop_store(&_f1, f1); | |
140 } | |
1903 | 141 void set_f1_if_null_atomic(oop f1); |
0 | 142 void set_f2(intx f2) { assert(_f2 == 0 || _f2 == f2, "illegal field change"); _f2 = f2; } |
143 int as_flags(TosState state, bool is_final, bool is_vfinal, bool is_volatile, | |
144 bool is_method_interface, bool is_method); | |
145 void set_flags(intx flags) { _flags = flags; } | |
146 | |
147 public: | |
148 // specific bit values in flag field | |
149 // Note: the interpreter knows this layout! | |
150 enum FlagBitValues { | |
151 hotSwapBit = 23, | |
152 methodInterface = 24, | |
153 volatileField = 25, | |
154 vfinalMethod = 26, | |
155 finalField = 27 | |
156 }; | |
157 | |
158 enum { field_index_mask = 0xFFFF }; | |
159 | |
160 // start of type bits in flags | |
161 // Note: the interpreter knows this layout! | |
162 enum FlagValues { | |
163 tosBits = 28 | |
164 }; | |
165 | |
166 // Initialization | |
1059
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
167 void initialize_entry(int original_index); // initialize primary entry |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
168 void initialize_secondary_entry(int main_index); // initialize secondary entry |
0 | 169 |
170 void set_field( // sets entry to resolved field state | |
171 Bytecodes::Code get_code, // the bytecode used for reading the field | |
172 Bytecodes::Code put_code, // the bytecode used for writing the field | |
173 KlassHandle field_holder, // the object/klass holding the field | |
174 int orig_field_index, // the original field index in the field holder | |
175 int field_offset, // the field offset in words in the field holder | |
176 TosState field_type, // the (machine) field type | |
177 bool is_final, // the field is final | |
178 bool is_volatile // the field is volatile | |
179 ); | |
180 | |
181 void set_method( // sets entry to resolved method entry | |
182 Bytecodes::Code invoke_code, // the bytecode used for invoking the method | |
183 methodHandle method, // the method/prototype if any (NULL, otherwise) | |
184 int vtable_index // the vtable index if any, else negative | |
185 ); | |
186 | |
187 void set_interface_call( | |
188 methodHandle method, // Resolved method | |
189 int index // Method index into interface | |
190 ); | |
191 | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
192 void set_dynamic_call( |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2227
diff
changeset
|
193 Handle call_site, // Resolved java.lang.invoke.CallSite (f1) |
1507
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1059
diff
changeset
|
194 methodHandle signature_invoker // determines signature information |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
195 ); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
196 |
1660
083fde3b838e
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
1602
diff
changeset
|
197 // For JVM_CONSTANT_InvokeDynamic cache entries: |
083fde3b838e
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
1602
diff
changeset
|
198 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
|
199 int bootstrap_method_index_in_cache(); |
083fde3b838e
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
1602
diff
changeset
|
200 |
0 | 201 void set_parameter_size(int value) { |
202 assert(parameter_size() == 0 || parameter_size() == value, | |
203 "size must not change"); | |
204 // Setting the parameter size by itself is only safe if the | |
205 // current value of _flags is 0, otherwise another thread may have | |
206 // updated it and we don't want to overwrite that value. Don't | |
207 // bother trying to update it once it's nonzero but always make | |
208 // sure that the final parameter size agrees with what was passed. | |
209 if (_flags == 0) { | |
210 Atomic::cmpxchg_ptr((value & 0xFF), &_flags, 0); | |
211 } | |
212 guarantee(parameter_size() == value, "size must not change"); | |
213 } | |
214 | |
215 // Which bytecode number (1 or 2) in the index field is valid for this bytecode? | |
216 // Returns -1 if neither is valid. | |
217 static int bytecode_number(Bytecodes::Code code) { | |
218 switch (code) { | |
219 case Bytecodes::_getstatic : // fall through | |
220 case Bytecodes::_getfield : // fall through | |
221 case Bytecodes::_invokespecial : // fall through | |
222 case Bytecodes::_invokestatic : // fall through | |
1662
e0ba4e04c839
6969574: invokedynamic call sites deoptimize instead of executing
jrose
parents:
1660
diff
changeset
|
223 case Bytecodes::_invokedynamic : // fall through |
0 | 224 case Bytecodes::_invokeinterface : return 1; |
225 case Bytecodes::_putstatic : // fall through | |
226 case Bytecodes::_putfield : // fall through | |
227 case Bytecodes::_invokevirtual : return 2; | |
228 default : break; | |
229 } | |
230 return -1; | |
231 } | |
232 | |
233 // Has this bytecode been resolved? Only valid for invokes and get/put field/static. | |
234 bool is_resolved(Bytecodes::Code code) const { | |
235 switch (bytecode_number(code)) { | |
236 case 1: return (bytecode_1() == code); | |
237 case 2: return (bytecode_2() == code); | |
238 } | |
239 return false; // default: not resolved | |
240 } | |
241 | |
242 // Accessors | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
243 bool is_secondary_entry() const { return (_indices & 0xFFFF) == 0; } |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
244 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
|
245 return (_indices & 0xFFFF); } |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
246 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
|
247 return ((uintx)_indices >> 16); } |
0 | 248 Bytecodes::Code bytecode_1() const { return Bytecodes::cast((_indices >> 16) & 0xFF); } |
249 Bytecodes::Code bytecode_2() const { return Bytecodes::cast((_indices >> 24) & 0xFF); } | |
250 volatile oop f1() const { return _f1; } | |
1660
083fde3b838e
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
1602
diff
changeset
|
251 bool is_f1_null() const { return (oop)_f1 == NULL; } // classifies a CPC entry as unbound |
0 | 252 intx f2() const { return _f2; } |
253 int field_index() const; | |
254 int parameter_size() const { return _flags & 0xFF; } | |
255 bool is_vfinal() const { return ((_flags & (1 << vfinalMethod)) == (1 << vfinalMethod)); } | |
256 bool is_volatile() const { return ((_flags & (1 << volatileField)) == (1 << volatileField)); } | |
257 bool is_methodInterface() const { return ((_flags & (1 << methodInterface)) == (1 << methodInterface)); } | |
258 bool is_byte() const { return (((uintx) _flags >> tosBits) == btos); } | |
259 bool is_char() const { return (((uintx) _flags >> tosBits) == ctos); } | |
260 bool is_short() const { return (((uintx) _flags >> tosBits) == stos); } | |
261 bool is_int() const { return (((uintx) _flags >> tosBits) == itos); } | |
262 bool is_long() const { return (((uintx) _flags >> tosBits) == ltos); } | |
263 bool is_float() const { return (((uintx) _flags >> tosBits) == ftos); } | |
264 bool is_double() const { return (((uintx) _flags >> tosBits) == dtos); } | |
265 bool is_object() const { return (((uintx) _flags >> tosBits) == atos); } | |
266 TosState flag_state() const { assert( ( (_flags >> tosBits) & 0x0F ) < number_of_states, "Invalid state in as_flags"); | |
267 return (TosState)((_flags >> tosBits) & 0x0F); } | |
268 | |
269 // Code generation support | |
270 static WordSize size() { return in_WordSize(sizeof(ConstantPoolCacheEntry) / HeapWordSize); } | |
1059
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
271 static ByteSize size_in_bytes() { return in_ByteSize(sizeof(ConstantPoolCacheEntry)); } |
0 | 272 static ByteSize indices_offset() { return byte_offset_of(ConstantPoolCacheEntry, _indices); } |
273 static ByteSize f1_offset() { return byte_offset_of(ConstantPoolCacheEntry, _f1); } | |
274 static ByteSize f2_offset() { return byte_offset_of(ConstantPoolCacheEntry, _f2); } | |
275 static ByteSize flags_offset() { return byte_offset_of(ConstantPoolCacheEntry, _flags); } | |
276 | |
277 // GC Support | |
278 void oops_do(void f(oop*)); | |
279 void oop_iterate(OopClosure* blk); | |
280 void oop_iterate_m(OopClosure* blk, MemRegion mr); | |
281 void follow_contents(); | |
282 void adjust_pointers(); | |
283 | |
284 #ifndef SERIALGC | |
285 // Parallel Old | |
286 void follow_contents(ParCompactionManager* cm); | |
287 #endif // SERIALGC | |
288 | |
289 void update_pointers(); | |
290 | |
291 // RedefineClasses() API support: | |
292 // If this constantPoolCacheEntry refers to old_method then update it | |
293 // to refer to new_method. | |
294 // trace_name_printed is set to true if the current call has | |
295 // printed the klass name so that other routines in the adjust_* | |
296 // group don't print the klass name. | |
297 bool adjust_method_entry(methodOop old_method, methodOop new_method, | |
298 bool * trace_name_printed); | |
299 bool is_interesting_method_entry(klassOop k); | |
300 bool is_field_entry() const { return (_flags & (1 << hotSwapBit)) == 0; } | |
301 bool is_method_entry() const { return (_flags & (1 << hotSwapBit)) != 0; } | |
302 | |
303 // Debugging & Printing | |
304 void print (outputStream* st, int index) const; | |
305 void verify(outputStream* st) const; | |
306 | |
307 static void verify_tosBits() { | |
308 assert(tosBits == 28, "interpreter now assumes tosBits is 28"); | |
309 } | |
310 }; | |
311 | |
312 | |
313 // A constant pool cache is a runtime data structure set aside to a constant pool. The cache | |
314 // holds interpreter runtime information for all field access and invoke bytecodes. The cache | |
315 // is created and initialized before a class is actively used (i.e., initialized), the indivi- | |
316 // dual cache entries are filled at resolution (i.e., "link") time (see also: rewriter.*). | |
317 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
318 class constantPoolCacheOopDesc: public oopDesc { |
0 | 319 friend class VMStructs; |
320 private: | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
321 int _length; |
0 | 322 constantPoolOop _constant_pool; // the corresponding constant pool |
323 | |
324 // Sizing | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
325 debug_only(friend class ClassVerifier;) |
1913
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1903
diff
changeset
|
326 public: |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
327 int length() const { return _length; } |
1913
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1903
diff
changeset
|
328 private: |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
329 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
|
330 |
0 | 331 static int header_size() { return sizeof(constantPoolCacheOopDesc) / HeapWordSize; } |
332 static int object_size(int length) { return align_object_size(header_size() + length * in_words(ConstantPoolCacheEntry::size())); } | |
333 int object_size() { return object_size(length()); } | |
334 | |
335 // Helpers | |
336 constantPoolOop* constant_pool_addr() { return &_constant_pool; } | |
337 ConstantPoolCacheEntry* base() const { return (ConstantPoolCacheEntry*)((address)this + in_bytes(base_offset())); } | |
338 | |
339 friend class constantPoolCacheKlass; | |
1059
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
340 friend class ConstantPoolCacheEntry; |
0 | 341 |
342 public: | |
343 // Initialization | |
344 void initialize(intArray& inverse_index_map); | |
345 | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
346 // Secondary indexes. |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
347 // They must look completely different from normal indexes. |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
348 // 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
|
349 // 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
|
350 // 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
|
351 static bool is_secondary_index(int i) { return (i < 0); } |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
352 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
|
353 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
|
354 |
0 | 355 // Accessors |
356 void set_constant_pool(constantPoolOop pool) { oop_store_without_check((oop*)&_constant_pool, (oop)pool); } | |
357 constantPoolOop constant_pool() const { return _constant_pool; } | |
1059
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
358 // Fetches the entry at the given index. |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
359 // The entry may be either primary or secondary. |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
360 // 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
|
361 ConstantPoolCacheEntry* entry_at(int i) const { |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
362 assert(0 <= i && i < length(), "index out of bounds"); |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
363 return base() + 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 // Fetches the secondary entry referred to by index. |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
366 // 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
|
367 ConstantPoolCacheEntry* secondary_entry_at(int i) const { |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
368 int raw_index = i; |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
369 if (is_secondary_index(i)) { // correct these on the fly |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
370 raw_index = decode_secondary_index(i); |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
371 } |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
372 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
|
373 return entry_at(raw_index); |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
374 } |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
375 // 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
|
376 // 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
|
377 // The index must not be byte-swapped. |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
378 ConstantPoolCacheEntry* main_entry_at(int i) const { |
1059
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
379 int primary_index = i; |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
380 if (is_secondary_index(i)) { |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
381 // run through an extra level of indirection: |
1059
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
382 int raw_index = decode_secondary_index(i); |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
383 primary_index = entry_at(raw_index)->main_entry_index(); |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
384 } |
1059
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
385 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
|
386 return entry_at(primary_index); |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
387 } |
0 | 388 |
389 // Code generation | |
390 static ByteSize base_offset() { return in_ByteSize(sizeof(constantPoolCacheOopDesc)); } | |
1059
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
391 static ByteSize entry_offset(int raw_index) { |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
392 int index = raw_index; |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
393 if (is_secondary_index(raw_index)) |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
394 index = decode_secondary_index(raw_index); |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
395 return (base_offset() + ConstantPoolCacheEntry::size_in_bytes() * index); |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
396 } |
0 | 397 |
398 // RedefineClasses() API support: | |
399 // If any entry of this constantPoolCache points to any of | |
400 // old_methods, replace it with the corresponding new_method. | |
401 // trace_name_printed is set to true if the current call has | |
402 // printed the klass name so that other routines in the adjust_* | |
403 // group don't print the klass name. | |
404 void adjust_method_entries(methodOop* old_methods, methodOop* new_methods, | |
405 int methods_length, bool * trace_name_printed); | |
406 }; | |
1972 | 407 |
408 #endif // SHARE_VM_OOPS_CPCACHEOOP_HPP |