Mercurial > hg > truffle
annotate src/share/vm/oops/cpCacheOop.hpp @ 6290:01d274503562
canonicalize reads and writes on null objects to deopts
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Tue, 28 Aug 2012 12:15:10 +0200 |
parents | 1d7922586cf6 |
children |
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 // -------------------------------- | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
41 // _indices [ b2 | b1 | index ] index = constant_pool_index (!= 0, normal entries only) |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
42 // _indices [ index | 00000 ] index = main_entry_index (secondary entries only) |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
43 // _f1 [ entry specific ] method, klass, or oop (MethodType or CallSite) |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
44 // _f2 [ entry specific ] vtable index or vfinal method |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
45 // _flags [tos|0|00|00|00|f|v|f2|unused|field_index] (for field entries) |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
46 // bit length [ 4 |1|1 |1 | 1|1|1| 1|---5--|----16-----] |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
47 // _flags [tos|M|vf|fv|ea|f|0|f2|unused|00000|psize] (for method entries) |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
48 // bit length [ 4 |1|1 |1 | 1|1|1| 1|---5--|--8--|--8--] |
0 | 49 |
50 // -------------------------------- | |
51 // | |
52 // with: | |
53 // index = original constant pool index | |
54 // b1 = bytecode 1 | |
55 // b2 = bytecode 2 | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
56 // psize = parameters size (method entries only) |
0 | 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) | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
62 // f2 = virtual but final (method entries only: is_vfinal()) |
0 | 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: | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
68 // bit 27: 0 for fields, 1 for methods |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
69 // f flag true if field is marked final |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
70 // v flag true if field is volatile (only for fields) |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
71 // f2 flag true if f2 contains an oop (e.g., virtual final method) |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
72 // fv flag true if invokeinterface used for method in class Object |
0 | 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 | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
89 // _f1 = field holder (as a java.lang.Class, not a klassOop) |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
90 // _f2 = field offset in bytes |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
91 // _flags = field type information, original FieldInfo index in field holder |
0 | 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 | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
97 // _f1 = methodOop for non-virtual calls, unused by virtual calls. |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
98 // for interface calls, which are essentially virtual but need a klass, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
99 // contains klassOop for the corresponding interface. |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
100 // for invokedynamic, f1 contains a site-specific CallSite object (as an appendix) |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
101 // for invokehandle, f1 contains a site-specific MethodType object (as an appendix) |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
102 // (upcoming metadata changes will move the appendix to a separate array) |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
103 // _f2 = vtable/itable index (or final methodOop) for virtual calls only, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
104 // unused by non-virtual. The is_vfinal flag indicates this is a |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
105 // method pointer for a final method, not an index. |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
106 // _flags = method type info (t section), |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
107 // virtual final bit (vfinal), |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
108 // parameter size (psize section) |
0 | 109 // |
110 // Note: invokevirtual & invokespecial bytecodes can share the same constant | |
111 // pool entry and thus the same constant pool cache entry. All invoke | |
112 // bytecodes but invokevirtual use only _f1 and the corresponding b1 | |
113 // bytecode, while invokevirtual uses only _f2 and the corresponding | |
114 // b2 bytecode. The value of _flags is shared for both types of entries. | |
115 // | |
116 // The fields are volatile so that they are stored in the order written in the | |
117 // source code. The _indices field with the bytecode must be written last. | |
118 | |
119 class ConstantPoolCacheEntry VALUE_OBJ_CLASS_SPEC { | |
120 friend class VMStructs; | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
121 friend class constantPoolCacheKlass; |
1602 | 122 friend class constantPoolOopDesc; //resolve_constant_at_impl => set_f1 |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
123 |
0 | 124 private: |
125 volatile intx _indices; // constant pool index & rewrite bytecodes | |
126 volatile oop _f1; // entry specific oop field | |
127 volatile intx _f2; // entry specific int/oop field | |
128 volatile intx _flags; // flags | |
129 | |
130 | |
131 #ifdef ASSERT | |
132 bool same_methodOop(oop cur_f1, oop f1); | |
133 #endif | |
134 | |
135 void set_bytecode_1(Bytecodes::Code code); | |
136 void set_bytecode_2(Bytecodes::Code code); | |
137 void set_f1(oop f1) { | |
138 oop existing_f1 = _f1; // read once | |
139 assert(existing_f1 == NULL || existing_f1 == f1, "illegal field change"); | |
140 oop_store(&_f1, f1); | |
141 } | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
142 void release_set_f1(oop f1); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
143 void set_f2(intx f2) { assert(_f2 == 0 || _f2 == f2, "illegal field change"); _f2 = f2; } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
144 void set_f2_as_vfinal_method(methodOop f2) { assert(_f2 == 0 || _f2 == (intptr_t) f2, "illegal field change"); assert(is_vfinal(), "flags must be set"); _f2 = (intptr_t) f2; } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
145 int make_flags(TosState state, int option_bits, int field_index_or_method_params); |
0 | 146 void set_flags(intx flags) { _flags = flags; } |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
147 bool init_flags_atomic(intx flags); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
148 void set_field_flags(TosState field_type, int option_bits, int field_index) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
149 assert((field_index & field_index_mask) == field_index, "field_index in range"); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
150 set_flags(make_flags(field_type, option_bits | (1 << is_field_entry_shift), field_index)); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
151 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
152 void set_method_flags(TosState return_type, int option_bits, int method_params) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
153 assert((method_params & parameter_size_mask) == method_params, "method_params in range"); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
154 set_flags(make_flags(return_type, option_bits, method_params)); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
155 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
156 bool init_method_flags_atomic(TosState return_type, int option_bits, int method_params) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
157 assert((method_params & parameter_size_mask) == method_params, "method_params in range"); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
158 return init_flags_atomic(make_flags(return_type, option_bits, method_params)); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
159 } |
0 | 160 |
161 public: | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
162 // specific bit definitions for the flags field: |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
163 // (Note: the interpreter must use these definitions to access the CP cache.) |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
164 enum { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
165 // high order bits are the TosState corresponding to field type or method return type |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
166 tos_state_bits = 4, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
167 tos_state_mask = right_n_bits(tos_state_bits), |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
168 tos_state_shift = BitsPerInt - tos_state_bits, // see verify_tos_state_shift below |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
169 // misc. option bits; can be any bit position in [16..27] |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
170 is_vfinal_shift = 21, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
171 is_volatile_shift = 22, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
172 is_final_shift = 23, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
173 has_appendix_shift = 24, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
174 is_forced_virtual_shift = 25, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
175 is_field_entry_shift = 26, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
176 // low order bits give field index (for FieldInfo) or method parameter size: |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
177 field_index_bits = 16, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
178 field_index_mask = right_n_bits(field_index_bits), |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
179 parameter_size_bits = 8, // subset of field_index_mask, range is 0..255 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
180 parameter_size_mask = right_n_bits(parameter_size_bits), |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
181 option_bits_mask = ~(((-1) << tos_state_shift) | (field_index_mask | parameter_size_mask)) |
0 | 182 }; |
183 | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
184 // specific bit definitions for the indices field: |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
185 enum { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
186 main_cp_index_bits = 2*BitsPerByte, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
187 main_cp_index_mask = right_n_bits(main_cp_index_bits), |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
188 bytecode_1_shift = main_cp_index_bits, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
189 bytecode_1_mask = right_n_bits(BitsPerByte), // == (u1)0xFF |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
190 bytecode_2_shift = main_cp_index_bits + BitsPerByte, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
191 bytecode_2_mask = right_n_bits(BitsPerByte), // == (u1)0xFF |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
192 // the secondary cp index overlaps with bytecodes 1 and 2: |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
193 secondary_cp_index_shift = bytecode_1_shift, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
194 secondary_cp_index_bits = BitsPerInt - main_cp_index_bits |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
195 }; |
0 | 196 |
197 | |
198 // Initialization | |
1059
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
199 void initialize_entry(int original_index); // initialize primary entry |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
200 void initialize_secondary_entry(int main_index); // initialize secondary entry |
0 | 201 |
202 void set_field( // sets entry to resolved field state | |
203 Bytecodes::Code get_code, // the bytecode used for reading the field | |
204 Bytecodes::Code put_code, // the bytecode used for writing the field | |
205 KlassHandle field_holder, // the object/klass holding the field | |
206 int orig_field_index, // the original field index in the field holder | |
207 int field_offset, // the field offset in words in the field holder | |
208 TosState field_type, // the (machine) field type | |
209 bool is_final, // the field is final | |
210 bool is_volatile // the field is volatile | |
211 ); | |
212 | |
213 void set_method( // sets entry to resolved method entry | |
214 Bytecodes::Code invoke_code, // the bytecode used for invoking the method | |
215 methodHandle method, // the method/prototype if any (NULL, otherwise) | |
216 int vtable_index // the vtable index if any, else negative | |
217 ); | |
218 | |
219 void set_interface_call( | |
220 methodHandle method, // Resolved method | |
221 int index // Method index into interface | |
222 ); | |
223 | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
224 void set_method_handle( |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
225 methodHandle method, // adapter for invokeExact, etc. |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
226 Handle appendix // stored in f1; could be a java.lang.invoke.MethodType |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
227 ); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
228 |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
229 void set_dynamic_call( |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
230 methodHandle method, // adapter for this call site |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
231 Handle appendix // stored in f1; could be a java.lang.invoke.CallSite |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
232 ); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
233 |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
234 // Common code for invokedynamic and MH invocations. |
1660
083fde3b838e
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
1602
diff
changeset
|
235 |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
236 // The "appendix" is an optional call-site-specific parameter which is |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
237 // pushed by the JVM at the end of the argument list. This argument may |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
238 // be a MethodType for the MH.invokes and a CallSite for an invokedynamic |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
239 // instruction. However, its exact type and use depends on the Java upcall, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
240 // which simply returns a compiled LambdaForm along with any reference |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
241 // that LambdaForm needs to complete the call. If the upcall returns a |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
242 // null appendix, the argument is not passed at all. |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
243 // |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
244 // The appendix is *not* represented in the signature of the symbolic |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
245 // reference for the call site, but (if present) it *is* represented in |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
246 // the methodOop bound to the site. This means that static and dynamic |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
247 // resolution logic needs to make slightly different assessments about the |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
248 // number and types of arguments. |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
249 void set_method_handle_common( |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
250 Bytecodes::Code invoke_code, // _invokehandle or _invokedynamic |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
251 methodHandle adapter, // invoker method (f2) |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
252 Handle appendix // appendix such as CallSite, MethodType, etc. (f1) |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
253 ); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
254 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
255 methodOop method_if_resolved(constantPoolHandle cpool); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
256 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
257 void set_parameter_size(int value); |
0 | 258 |
259 // Which bytecode number (1 or 2) in the index field is valid for this bytecode? | |
260 // Returns -1 if neither is valid. | |
261 static int bytecode_number(Bytecodes::Code code) { | |
262 switch (code) { | |
263 case Bytecodes::_getstatic : // fall through | |
264 case Bytecodes::_getfield : // fall through | |
265 case Bytecodes::_invokespecial : // fall through | |
266 case Bytecodes::_invokestatic : // fall through | |
267 case Bytecodes::_invokeinterface : return 1; | |
268 case Bytecodes::_putstatic : // fall through | |
269 case Bytecodes::_putfield : // fall through | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
270 case Bytecodes::_invokehandle : // fall through |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
271 case Bytecodes::_invokedynamic : // fall through |
0 | 272 case Bytecodes::_invokevirtual : return 2; |
273 default : break; | |
274 } | |
275 return -1; | |
276 } | |
277 | |
278 // Has this bytecode been resolved? Only valid for invokes and get/put field/static. | |
279 bool is_resolved(Bytecodes::Code code) const { | |
280 switch (bytecode_number(code)) { | |
281 case 1: return (bytecode_1() == code); | |
282 case 2: return (bytecode_2() == code); | |
283 } | |
284 return false; // default: not resolved | |
285 } | |
286 | |
287 // Accessors | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
288 bool is_secondary_entry() const { return (_indices & main_cp_index_mask) == 0; } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
289 int main_entry_index() const { assert(is_secondary_entry(), "must be secondary entry"); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
290 return ((uintx)_indices >> secondary_cp_index_shift); } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
291 int primary_entry_indices() const { assert(!is_secondary_entry(), "must be main entry"); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
292 return _indices; } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
293 int constant_pool_index() const { return (primary_entry_indices() & main_cp_index_mask); } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
294 Bytecodes::Code bytecode_1() const { return Bytecodes::cast((primary_entry_indices() >> bytecode_1_shift) |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
295 & bytecode_1_mask); } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
296 Bytecodes::Code bytecode_2() const { return Bytecodes::cast((primary_entry_indices() >> bytecode_2_shift) |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
297 & bytecode_2_mask); } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
298 methodOop f1_as_method() const { oop f1 = _f1; assert(f1 == NULL || f1->is_method(), ""); return methodOop(f1); } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
299 klassOop f1_as_klass() const { oop f1 = _f1; assert(f1 == NULL || f1->is_klass(), ""); return klassOop(f1); } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
300 oop f1_as_klass_mirror() const { oop f1 = f1_as_instance(); return f1; } // i.e., return a java_mirror |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
301 oop f1_as_instance() const { oop f1 = _f1; assert(f1 == NULL || f1->is_instance() || f1->is_array(), ""); return f1; } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
302 oop f1_appendix() const { assert(has_appendix(), ""); return f1_as_instance(); } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
303 bool is_f1_null() const { oop f1 = _f1; return f1 == NULL; } // classifies a CPC entry as unbound |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
304 int f2_as_index() const { assert(!is_vfinal(), ""); return (int) _f2; } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
305 methodOop f2_as_vfinal_method() const { assert(is_vfinal(), ""); return methodOop(_f2); } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
306 int field_index() const { assert(is_field_entry(), ""); return (_flags & field_index_mask); } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
307 int parameter_size() const { assert(is_method_entry(), ""); return (_flags & parameter_size_mask); } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
308 bool is_volatile() const { return (_flags & (1 << is_volatile_shift)) != 0; } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
309 bool is_final() const { return (_flags & (1 << is_final_shift)) != 0; } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
310 bool has_appendix() const { return (_flags & (1 << has_appendix_shift)) != 0; } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
311 bool is_forced_virtual() const { return (_flags & (1 << is_forced_virtual_shift)) != 0; } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
312 bool is_vfinal() const { return (_flags & (1 << is_vfinal_shift)) != 0; } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
313 bool is_method_entry() const { return (_flags & (1 << is_field_entry_shift)) == 0; } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
314 bool is_field_entry() const { return (_flags & (1 << is_field_entry_shift)) != 0; } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
315 bool is_byte() const { return flag_state() == btos; } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
316 bool is_char() const { return flag_state() == ctos; } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
317 bool is_short() const { return flag_state() == stos; } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
318 bool is_int() const { return flag_state() == itos; } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
319 bool is_long() const { return flag_state() == ltos; } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
320 bool is_float() const { return flag_state() == ftos; } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
321 bool is_double() const { return flag_state() == dtos; } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
322 bool is_object() const { return flag_state() == atos; } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
323 TosState flag_state() const { assert((uint)number_of_states <= (uint)tos_state_mask+1, ""); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
324 return (TosState)((_flags >> tos_state_shift) & tos_state_mask); } |
0 | 325 |
326 // Code generation support | |
327 static WordSize size() { return in_WordSize(sizeof(ConstantPoolCacheEntry) / HeapWordSize); } | |
1059
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
328 static ByteSize size_in_bytes() { return in_ByteSize(sizeof(ConstantPoolCacheEntry)); } |
0 | 329 static ByteSize indices_offset() { return byte_offset_of(ConstantPoolCacheEntry, _indices); } |
330 static ByteSize f1_offset() { return byte_offset_of(ConstantPoolCacheEntry, _f1); } | |
331 static ByteSize f2_offset() { return byte_offset_of(ConstantPoolCacheEntry, _f2); } | |
332 static ByteSize flags_offset() { return byte_offset_of(ConstantPoolCacheEntry, _flags); } | |
333 | |
334 // GC Support | |
335 void oops_do(void f(oop*)); | |
336 void oop_iterate(OopClosure* blk); | |
337 void oop_iterate_m(OopClosure* blk, MemRegion mr); | |
338 void follow_contents(); | |
339 void adjust_pointers(); | |
340 | |
341 #ifndef SERIALGC | |
342 // Parallel Old | |
343 void follow_contents(ParCompactionManager* cm); | |
344 #endif // SERIALGC | |
345 | |
346 void update_pointers(); | |
347 | |
348 // RedefineClasses() API support: | |
349 // If this constantPoolCacheEntry refers to old_method then update it | |
350 // to refer to new_method. | |
351 // trace_name_printed is set to true if the current call has | |
352 // printed the klass name so that other routines in the adjust_* | |
353 // group don't print the klass name. | |
354 bool adjust_method_entry(methodOop old_method, methodOop new_method, | |
355 bool * trace_name_printed); | |
356 bool is_interesting_method_entry(klassOop k); | |
357 | |
358 // Debugging & Printing | |
359 void print (outputStream* st, int index) const; | |
360 void verify(outputStream* st) const; | |
361 | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
362 static void verify_tos_state_shift() { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
363 // When shifting flags as a 32-bit int, make sure we don't need an extra mask for tos_state: |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3785
diff
changeset
|
364 assert((((u4)-1 >> tos_state_shift) & ~tos_state_mask) == 0, "no need for tos_state mask"); |
0 | 365 } |
366 }; | |
367 | |
368 | |
369 // A constant pool cache is a runtime data structure set aside to a constant pool. The cache | |
370 // holds interpreter runtime information for all field access and invoke bytecodes. The cache | |
371 // is created and initialized before a class is actively used (i.e., initialized), the indivi- | |
372 // dual cache entries are filled at resolution (i.e., "link") time (see also: rewriter.*). | |
373 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
374 class constantPoolCacheOopDesc: public oopDesc { |
0 | 375 friend class VMStructs; |
376 private: | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
377 int _length; |
0 | 378 constantPoolOop _constant_pool; // the corresponding constant pool |
379 | |
380 // Sizing | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
381 debug_only(friend class ClassVerifier;) |
1913
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1903
diff
changeset
|
382 public: |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
383 int length() const { return _length; } |
1913
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1903
diff
changeset
|
384 private: |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
385 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
|
386 |
0 | 387 static int header_size() { return sizeof(constantPoolCacheOopDesc) / HeapWordSize; } |
388 static int object_size(int length) { return align_object_size(header_size() + length * in_words(ConstantPoolCacheEntry::size())); } | |
389 int object_size() { return object_size(length()); } | |
390 | |
391 // Helpers | |
392 constantPoolOop* constant_pool_addr() { return &_constant_pool; } | |
393 ConstantPoolCacheEntry* base() const { return (ConstantPoolCacheEntry*)((address)this + in_bytes(base_offset())); } | |
394 | |
395 friend class constantPoolCacheKlass; | |
1059
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
396 friend class ConstantPoolCacheEntry; |
0 | 397 |
398 public: | |
399 // Initialization | |
400 void initialize(intArray& inverse_index_map); | |
401 | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
402 // Secondary indexes. |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
403 // They must look completely different from normal indexes. |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
404 // 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
|
405 // 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
|
406 // 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
|
407 static bool is_secondary_index(int i) { return (i < 0); } |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
408 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
|
409 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
|
410 |
0 | 411 // Accessors |
412 void set_constant_pool(constantPoolOop pool) { oop_store_without_check((oop*)&_constant_pool, (oop)pool); } | |
413 constantPoolOop constant_pool() const { return _constant_pool; } | |
1059
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
414 // Fetches the entry at the given index. |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
415 // The entry may be either primary or secondary. |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
416 // 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
|
417 ConstantPoolCacheEntry* entry_at(int i) const { |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
418 assert(0 <= i && i < length(), "index out of bounds"); |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
419 return base() + i; |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
420 } |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
421 // Fetches the secondary entry referred to by index. |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
422 // 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
|
423 ConstantPoolCacheEntry* secondary_entry_at(int i) const { |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
424 int raw_index = i; |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
425 if (is_secondary_index(i)) { // correct these on the fly |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
426 raw_index = decode_secondary_index(i); |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
427 } |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
428 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
|
429 return entry_at(raw_index); |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
430 } |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
431 // 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
|
432 // 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
|
433 // The index must not be byte-swapped. |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
434 ConstantPoolCacheEntry* main_entry_at(int i) const { |
1059
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
435 int primary_index = i; |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
436 if (is_secondary_index(i)) { |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
437 // run through an extra level of indirection: |
1059
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
438 int raw_index = decode_secondary_index(i); |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
439 primary_index = entry_at(raw_index)->main_entry_index(); |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
440 } |
1059
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
441 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
|
442 return entry_at(primary_index); |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
443 } |
0 | 444 |
445 // Code generation | |
446 static ByteSize base_offset() { return in_ByteSize(sizeof(constantPoolCacheOopDesc)); } | |
1059
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
447 static ByteSize entry_offset(int raw_index) { |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
448 int index = raw_index; |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
449 if (is_secondary_index(raw_index)) |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
450 index = decode_secondary_index(raw_index); |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
451 return (base_offset() + ConstantPoolCacheEntry::size_in_bytes() * index); |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
452 } |
0 | 453 |
454 // RedefineClasses() API support: | |
455 // If any entry of this constantPoolCache points to any of | |
456 // old_methods, replace it with the corresponding new_method. | |
457 // trace_name_printed is set to true if the current call has | |
458 // printed the klass name so that other routines in the adjust_* | |
459 // group don't print the klass name. | |
460 void adjust_method_entries(methodOop* old_methods, methodOop* new_methods, | |
461 int methods_length, bool * trace_name_printed); | |
462 }; | |
1972 | 463 |
464 #endif // SHARE_VM_OOPS_CPCACHEOOP_HPP |