annotate src/share/vm/oops/cpCacheOop.hpp @ 1552:c18cbe5936b8

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