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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
2227
e5383553fd4e 7014851: Remove unused parallel compaction code
stefank
parents: 2226
diff changeset
2 * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 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
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1913
diff changeset
25 #ifndef SHARE_VM_OOPS_CPCACHEOOP_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1913
diff changeset
26 #define SHARE_VM_OOPS_CPCACHEOOP_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1913
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1913
diff changeset
28 #include "interpreter/bytecodes.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1913
diff changeset
29 #include "memory/allocation.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1913
diff changeset
30 #include "oops/arrayOop.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1913
diff changeset
31 #include "utilities/array.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1913
diff changeset
32
0
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // A ConstantPoolCacheEntry describes an individual entry of the constant
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // pool cache. There's 2 principal kinds of entries: field entries for in-
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // stance & static field access, and method entries for invokes. Some of
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // the entry layout is shared and looks as follows:
a61af66fc99e Initial load
duke
parents:
diff changeset
37 //
a61af66fc99e Initial load
duke
parents:
diff changeset
38 // bit number |31 0|
a61af66fc99e Initial load
duke
parents:
diff changeset
39 // bit length |-8--|-8--|---16----|
a61af66fc99e Initial load
duke
parents:
diff changeset
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
a61af66fc99e Initial load
duke
parents:
diff changeset
49
a61af66fc99e Initial load
duke
parents:
diff changeset
50 // --------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
51 //
a61af66fc99e Initial load
duke
parents:
diff changeset
52 // with:
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // index = original constant pool index
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // b1 = bytecode 1
a61af66fc99e Initial load
duke
parents:
diff changeset
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
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // field_index = index into field information in holder instanceKlass
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // The index max is 0xffff (max number of fields in constant pool)
a61af66fc99e Initial load
duke
parents:
diff changeset
59 // and is multiplied by (instanceKlass::next_offset) when accessing.
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // t = TosState (see below)
a61af66fc99e Initial load
duke
parents:
diff changeset
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
a61af66fc99e Initial load
duke
parents:
diff changeset
63 // v = field is volatile (see below)
a61af66fc99e Initial load
duke
parents:
diff changeset
64 // m = invokeinterface used for method in class Object (see below)
a61af66fc99e Initial load
duke
parents:
diff changeset
65 // h = RedefineClasses/Hotswap bit (see below)
a61af66fc99e Initial load
duke
parents:
diff changeset
66 //
a61af66fc99e Initial load
duke
parents:
diff changeset
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
a61af66fc99e Initial load
duke
parents:
diff changeset
73 //
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // The flags 31, 30, 29, 28 together build a 4 bit number 0 to 8 with the
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // following mapping to the TosState states:
a61af66fc99e Initial load
duke
parents:
diff changeset
76 //
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // btos: 0
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // ctos: 1
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // stos: 2
a61af66fc99e Initial load
duke
parents:
diff changeset
80 // itos: 3
a61af66fc99e Initial load
duke
parents:
diff changeset
81 // ltos: 4
a61af66fc99e Initial load
duke
parents:
diff changeset
82 // ftos: 5
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // dtos: 6
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // atos: 7
a61af66fc99e Initial load
duke
parents:
diff changeset
85 // vtos: 8
a61af66fc99e Initial load
duke
parents:
diff changeset
86 //
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // Entry specific: field entries:
a61af66fc99e Initial load
duke
parents:
diff changeset
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
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // (field_index section)
a61af66fc99e Initial load
duke
parents:
diff changeset
93 //
a61af66fc99e Initial load
duke
parents:
diff changeset
94 // Entry specific: method entries:
a61af66fc99e Initial load
duke
parents:
diff changeset
95 // _indices = invoke code for f1 (b1 section), invoke code for f2 (b2 section),
a61af66fc99e Initial load
duke
parents:
diff changeset
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
a61af66fc99e Initial load
duke
parents:
diff changeset
109 //
a61af66fc99e Initial load
duke
parents:
diff changeset
110 // Note: invokevirtual & invokespecial bytecodes can share the same constant
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // pool entry and thus the same constant pool cache entry. All invoke
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // bytecodes but invokevirtual use only _f1 and the corresponding b1
a61af66fc99e Initial load
duke
parents:
diff changeset
113 // bytecode, while invokevirtual uses only _f2 and the corresponding
a61af66fc99e Initial load
duke
parents:
diff changeset
114 // b2 bytecode. The value of _flags is shared for both types of entries.
a61af66fc99e Initial load
duke
parents:
diff changeset
115 //
a61af66fc99e Initial load
duke
parents:
diff changeset
116 // The fields are volatile so that they are stored in the order written in the
a61af66fc99e Initial load
duke
parents:
diff changeset
117 // source code. The _indices field with the bytecode must be written last.
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 class ConstantPoolCacheEntry VALUE_OBJ_CLASS_SPEC {
a61af66fc99e Initial load
duke
parents:
diff changeset
120 friend class VMStructs;
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
121 friend class constantPoolCacheKlass;
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
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
a61af66fc99e Initial load
duke
parents:
diff changeset
124 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
125 volatile intx _indices; // constant pool index & rewrite bytecodes
a61af66fc99e Initial load
duke
parents:
diff changeset
126 volatile oop _f1; // entry specific oop field
a61af66fc99e Initial load
duke
parents:
diff changeset
127 volatile intx _f2; // entry specific int/oop field
a61af66fc99e Initial load
duke
parents:
diff changeset
128 volatile intx _flags; // flags
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130
a61af66fc99e Initial load
duke
parents:
diff changeset
131 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
132 bool same_methodOop(oop cur_f1, oop f1);
a61af66fc99e Initial load
duke
parents:
diff changeset
133 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
134
a61af66fc99e Initial load
duke
parents:
diff changeset
135 void set_bytecode_1(Bytecodes::Code code);
a61af66fc99e Initial load
duke
parents:
diff changeset
136 void set_bytecode_2(Bytecodes::Code code);
a61af66fc99e Initial load
duke
parents:
diff changeset
137 void set_f1(oop f1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
138 oop existing_f1 = _f1; // read once
a61af66fc99e Initial load
duke
parents:
diff changeset
139 assert(existing_f1 == NULL || existing_f1 == f1, "illegal field change");
a61af66fc99e Initial load
duke
parents:
diff changeset
140 oop_store(&_f1, f1);
a61af66fc99e Initial load
duke
parents:
diff changeset
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
a61af66fc99e Initial load
duke
parents:
diff changeset
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
a61af66fc99e Initial load
duke
parents:
diff changeset
160
a61af66fc99e Initial load
duke
parents:
diff changeset
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
a61af66fc99e Initial load
duke
parents:
diff changeset
182 };
a61af66fc99e Initial load
duke
parents:
diff changeset
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
a61af66fc99e Initial load
duke
parents:
diff changeset
196
a61af66fc99e Initial load
duke
parents:
diff changeset
197
a61af66fc99e Initial load
duke
parents:
diff changeset
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
a61af66fc99e Initial load
duke
parents:
diff changeset
201
a61af66fc99e Initial load
duke
parents:
diff changeset
202 void set_field( // sets entry to resolved field state
a61af66fc99e Initial load
duke
parents:
diff changeset
203 Bytecodes::Code get_code, // the bytecode used for reading the field
a61af66fc99e Initial load
duke
parents:
diff changeset
204 Bytecodes::Code put_code, // the bytecode used for writing the field
a61af66fc99e Initial load
duke
parents:
diff changeset
205 KlassHandle field_holder, // the object/klass holding the field
a61af66fc99e Initial load
duke
parents:
diff changeset
206 int orig_field_index, // the original field index in the field holder
a61af66fc99e Initial load
duke
parents:
diff changeset
207 int field_offset, // the field offset in words in the field holder
a61af66fc99e Initial load
duke
parents:
diff changeset
208 TosState field_type, // the (machine) field type
a61af66fc99e Initial load
duke
parents:
diff changeset
209 bool is_final, // the field is final
a61af66fc99e Initial load
duke
parents:
diff changeset
210 bool is_volatile // the field is volatile
a61af66fc99e Initial load
duke
parents:
diff changeset
211 );
a61af66fc99e Initial load
duke
parents:
diff changeset
212
a61af66fc99e Initial load
duke
parents:
diff changeset
213 void set_method( // sets entry to resolved method entry
a61af66fc99e Initial load
duke
parents:
diff changeset
214 Bytecodes::Code invoke_code, // the bytecode used for invoking the method
a61af66fc99e Initial load
duke
parents:
diff changeset
215 methodHandle method, // the method/prototype if any (NULL, otherwise)
a61af66fc99e Initial load
duke
parents:
diff changeset
216 int vtable_index // the vtable index if any, else negative
a61af66fc99e Initial load
duke
parents:
diff changeset
217 );
a61af66fc99e Initial load
duke
parents:
diff changeset
218
a61af66fc99e Initial load
duke
parents:
diff changeset
219 void set_interface_call(
a61af66fc99e Initial load
duke
parents:
diff changeset
220 methodHandle method, // Resolved method
a61af66fc99e Initial load
duke
parents:
diff changeset
221 int index // Method index into interface
a61af66fc99e Initial load
duke
parents:
diff changeset
222 );
a61af66fc99e Initial load
duke
parents:
diff changeset
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
a61af66fc99e Initial load
duke
parents:
diff changeset
258
a61af66fc99e Initial load
duke
parents:
diff changeset
259 // Which bytecode number (1 or 2) in the index field is valid for this bytecode?
a61af66fc99e Initial load
duke
parents:
diff changeset
260 // Returns -1 if neither is valid.
a61af66fc99e Initial load
duke
parents:
diff changeset
261 static int bytecode_number(Bytecodes::Code code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
262 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
263 case Bytecodes::_getstatic : // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
264 case Bytecodes::_getfield : // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
265 case Bytecodes::_invokespecial : // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
266 case Bytecodes::_invokestatic : // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
267 case Bytecodes::_invokeinterface : return 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
268 case Bytecodes::_putstatic : // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
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
a61af66fc99e Initial load
duke
parents:
diff changeset
272 case Bytecodes::_invokevirtual : return 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
273 default : break;
a61af66fc99e Initial load
duke
parents:
diff changeset
274 }
a61af66fc99e Initial load
duke
parents:
diff changeset
275 return -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
276 }
a61af66fc99e Initial load
duke
parents:
diff changeset
277
a61af66fc99e Initial load
duke
parents:
diff changeset
278 // Has this bytecode been resolved? Only valid for invokes and get/put field/static.
a61af66fc99e Initial load
duke
parents:
diff changeset
279 bool is_resolved(Bytecodes::Code code) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
280 switch (bytecode_number(code)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
281 case 1: return (bytecode_1() == code);
a61af66fc99e Initial load
duke
parents:
diff changeset
282 case 2: return (bytecode_2() == code);
a61af66fc99e Initial load
duke
parents:
diff changeset
283 }
a61af66fc99e Initial load
duke
parents:
diff changeset
284 return false; // default: not resolved
a61af66fc99e Initial load
duke
parents:
diff changeset
285 }
a61af66fc99e Initial load
duke
parents:
diff changeset
286
a61af66fc99e Initial load
duke
parents:
diff changeset
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
a61af66fc99e Initial load
duke
parents:
diff changeset
325
a61af66fc99e Initial load
duke
parents:
diff changeset
326 // Code generation support
a61af66fc99e Initial load
duke
parents:
diff changeset
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
a61af66fc99e Initial load
duke
parents:
diff changeset
329 static ByteSize indices_offset() { return byte_offset_of(ConstantPoolCacheEntry, _indices); }
a61af66fc99e Initial load
duke
parents:
diff changeset
330 static ByteSize f1_offset() { return byte_offset_of(ConstantPoolCacheEntry, _f1); }
a61af66fc99e Initial load
duke
parents:
diff changeset
331 static ByteSize f2_offset() { return byte_offset_of(ConstantPoolCacheEntry, _f2); }
a61af66fc99e Initial load
duke
parents:
diff changeset
332 static ByteSize flags_offset() { return byte_offset_of(ConstantPoolCacheEntry, _flags); }
a61af66fc99e Initial load
duke
parents:
diff changeset
333
a61af66fc99e Initial load
duke
parents:
diff changeset
334 // GC Support
a61af66fc99e Initial load
duke
parents:
diff changeset
335 void oops_do(void f(oop*));
a61af66fc99e Initial load
duke
parents:
diff changeset
336 void oop_iterate(OopClosure* blk);
a61af66fc99e Initial load
duke
parents:
diff changeset
337 void oop_iterate_m(OopClosure* blk, MemRegion mr);
a61af66fc99e Initial load
duke
parents:
diff changeset
338 void follow_contents();
a61af66fc99e Initial load
duke
parents:
diff changeset
339 void adjust_pointers();
a61af66fc99e Initial load
duke
parents:
diff changeset
340
a61af66fc99e Initial load
duke
parents:
diff changeset
341 #ifndef SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
342 // Parallel Old
a61af66fc99e Initial load
duke
parents:
diff changeset
343 void follow_contents(ParCompactionManager* cm);
a61af66fc99e Initial load
duke
parents:
diff changeset
344 #endif // SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
345
a61af66fc99e Initial load
duke
parents:
diff changeset
346 void update_pointers();
a61af66fc99e Initial load
duke
parents:
diff changeset
347
a61af66fc99e Initial load
duke
parents:
diff changeset
348 // RedefineClasses() API support:
a61af66fc99e Initial load
duke
parents:
diff changeset
349 // If this constantPoolCacheEntry refers to old_method then update it
a61af66fc99e Initial load
duke
parents:
diff changeset
350 // to refer to new_method.
a61af66fc99e Initial load
duke
parents:
diff changeset
351 // trace_name_printed is set to true if the current call has
a61af66fc99e Initial load
duke
parents:
diff changeset
352 // printed the klass name so that other routines in the adjust_*
a61af66fc99e Initial load
duke
parents:
diff changeset
353 // group don't print the klass name.
a61af66fc99e Initial load
duke
parents:
diff changeset
354 bool adjust_method_entry(methodOop old_method, methodOop new_method,
a61af66fc99e Initial load
duke
parents:
diff changeset
355 bool * trace_name_printed);
a61af66fc99e Initial load
duke
parents:
diff changeset
356 bool is_interesting_method_entry(klassOop k);
a61af66fc99e Initial load
duke
parents:
diff changeset
357
a61af66fc99e Initial load
duke
parents:
diff changeset
358 // Debugging & Printing
a61af66fc99e Initial load
duke
parents:
diff changeset
359 void print (outputStream* st, int index) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
360 void verify(outputStream* st) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
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
a61af66fc99e Initial load
duke
parents:
diff changeset
365 }
a61af66fc99e Initial load
duke
parents:
diff changeset
366 };
a61af66fc99e Initial load
duke
parents:
diff changeset
367
a61af66fc99e Initial load
duke
parents:
diff changeset
368
a61af66fc99e Initial load
duke
parents:
diff changeset
369 // A constant pool cache is a runtime data structure set aside to a constant pool. The cache
a61af66fc99e Initial load
duke
parents:
diff changeset
370 // holds interpreter runtime information for all field access and invoke bytecodes. The cache
a61af66fc99e Initial load
duke
parents:
diff changeset
371 // is created and initialized before a class is actively used (i.e., initialized), the indivi-
a61af66fc99e Initial load
duke
parents:
diff changeset
372 // dual cache entries are filled at resolution (i.e., "link") time (see also: rewriter.*).
a61af66fc99e Initial load
duke
parents:
diff changeset
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
a61af66fc99e Initial load
duke
parents:
diff changeset
375 friend class VMStructs;
a61af66fc99e Initial load
duke
parents:
diff changeset
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
a61af66fc99e Initial load
duke
parents:
diff changeset
378 constantPoolOop _constant_pool; // the corresponding constant pool
a61af66fc99e Initial load
duke
parents:
diff changeset
379
a61af66fc99e Initial load
duke
parents:
diff changeset
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
a61af66fc99e Initial load
duke
parents:
diff changeset
387 static int header_size() { return sizeof(constantPoolCacheOopDesc) / HeapWordSize; }
a61af66fc99e Initial load
duke
parents:
diff changeset
388 static int object_size(int length) { return align_object_size(header_size() + length * in_words(ConstantPoolCacheEntry::size())); }
a61af66fc99e Initial load
duke
parents:
diff changeset
389 int object_size() { return object_size(length()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
390
a61af66fc99e Initial load
duke
parents:
diff changeset
391 // Helpers
a61af66fc99e Initial load
duke
parents:
diff changeset
392 constantPoolOop* constant_pool_addr() { return &_constant_pool; }
a61af66fc99e Initial load
duke
parents:
diff changeset
393 ConstantPoolCacheEntry* base() const { return (ConstantPoolCacheEntry*)((address)this + in_bytes(base_offset())); }
a61af66fc99e Initial load
duke
parents:
diff changeset
394
a61af66fc99e Initial load
duke
parents:
diff changeset
395 friend class constantPoolCacheKlass;
1059
389049f3f393 6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents: 726
diff changeset
396 friend class ConstantPoolCacheEntry;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
397
a61af66fc99e Initial load
duke
parents:
diff changeset
398 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
399 // Initialization
a61af66fc99e Initial load
duke
parents:
diff changeset
400 void initialize(intArray& inverse_index_map);
a61af66fc99e Initial load
duke
parents:
diff changeset
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
a61af66fc99e Initial load
duke
parents:
diff changeset
411 // Accessors
a61af66fc99e Initial load
duke
parents:
diff changeset
412 void set_constant_pool(constantPoolOop pool) { oop_store_without_check((oop*)&_constant_pool, (oop)pool); }
a61af66fc99e Initial load
duke
parents:
diff changeset
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
a61af66fc99e Initial load
duke
parents:
diff changeset
444
a61af66fc99e Initial load
duke
parents:
diff changeset
445 // Code generation
a61af66fc99e Initial load
duke
parents:
diff changeset
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
a61af66fc99e Initial load
duke
parents:
diff changeset
453
a61af66fc99e Initial load
duke
parents:
diff changeset
454 // RedefineClasses() API support:
a61af66fc99e Initial load
duke
parents:
diff changeset
455 // If any entry of this constantPoolCache points to any of
a61af66fc99e Initial load
duke
parents:
diff changeset
456 // old_methods, replace it with the corresponding new_method.
a61af66fc99e Initial load
duke
parents:
diff changeset
457 // trace_name_printed is set to true if the current call has
a61af66fc99e Initial load
duke
parents:
diff changeset
458 // printed the klass name so that other routines in the adjust_*
a61af66fc99e Initial load
duke
parents:
diff changeset
459 // group don't print the klass name.
a61af66fc99e Initial load
duke
parents:
diff changeset
460 void adjust_method_entries(methodOop* old_methods, methodOop* new_methods,
a61af66fc99e Initial load
duke
parents:
diff changeset
461 int methods_length, bool * trace_name_printed);
a61af66fc99e Initial load
duke
parents:
diff changeset
462 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1913
diff changeset
463
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1913
diff changeset
464 #endif // SHARE_VM_OOPS_CPCACHEOOP_HPP