annotate src/share/vm/ci/ciStreams.cpp @ 844:bd02caa94611

6862919: Update copyright year Summary: Update copyright for files that have been modified in 2009, up to 07/09 Reviewed-by: tbell, ohair
author xdono
date Tue, 28 Jul 2009 12:12:40 -0700
parents be93aad57795
children e66fd840cb6b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
844
bd02caa94611 6862919: Update copyright year
xdono
parents: 726
diff changeset
2 * Copyright 1999-2009 Sun Microsystems, Inc. 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 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
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 #include "incls/_precompiled.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
26 #include "incls/_ciStreams.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 // ciExceptionHandlerStream
a61af66fc99e Initial load
duke
parents:
diff changeset
29 //
a61af66fc99e Initial load
duke
parents:
diff changeset
30 // Walk over some selected set of a methods exception handlers.
a61af66fc99e Initial load
duke
parents:
diff changeset
31
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // ciExceptionHandlerStream::count
a61af66fc99e Initial load
duke
parents:
diff changeset
34 //
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // How many exception handlers are there in this stream?
a61af66fc99e Initial load
duke
parents:
diff changeset
36 //
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // Implementation note: Compiler2 needs this functionality, so I had
a61af66fc99e Initial load
duke
parents:
diff changeset
38 int ciExceptionHandlerStream::count() {
a61af66fc99e Initial load
duke
parents:
diff changeset
39 int save_pos = _pos;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 int save_end = _end;
a61af66fc99e Initial load
duke
parents:
diff changeset
41
a61af66fc99e Initial load
duke
parents:
diff changeset
42 int count = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44 _pos = -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
45 _end = _method->_handler_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47
a61af66fc99e Initial load
duke
parents:
diff changeset
48 next();
a61af66fc99e Initial load
duke
parents:
diff changeset
49 while (!is_done()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
50 count++;
a61af66fc99e Initial load
duke
parents:
diff changeset
51 next();
a61af66fc99e Initial load
duke
parents:
diff changeset
52 }
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 _pos = save_pos;
a61af66fc99e Initial load
duke
parents:
diff changeset
55 _end = save_end;
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57 return count;
a61af66fc99e Initial load
duke
parents:
diff changeset
58 }
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 int ciExceptionHandlerStream::count_remaining() {
a61af66fc99e Initial load
duke
parents:
diff changeset
61 int save_pos = _pos;
a61af66fc99e Initial load
duke
parents:
diff changeset
62 int save_end = _end;
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64 int count = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 while (!is_done()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
67 count++;
a61af66fc99e Initial load
duke
parents:
diff changeset
68 next();
a61af66fc99e Initial load
duke
parents:
diff changeset
69 }
a61af66fc99e Initial load
duke
parents:
diff changeset
70
a61af66fc99e Initial load
duke
parents:
diff changeset
71 _pos = save_pos;
a61af66fc99e Initial load
duke
parents:
diff changeset
72 _end = save_end;
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74 return count;
a61af66fc99e Initial load
duke
parents:
diff changeset
75 }
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // ciBytecodeStream
a61af66fc99e Initial load
duke
parents:
diff changeset
78 //
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // The class is used to iterate over the bytecodes of a method.
a61af66fc99e Initial load
duke
parents:
diff changeset
80 // It hides the details of constant pool structure/access by
a61af66fc99e Initial load
duke
parents:
diff changeset
81 // providing accessors for constant pool items.
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // ciBytecodeStream::wide
a61af66fc99e Initial load
duke
parents:
diff changeset
85 //
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // Special handling for the wide bytcode
a61af66fc99e Initial load
duke
parents:
diff changeset
87 Bytecodes::Code ciBytecodeStream::wide()
a61af66fc99e Initial load
duke
parents:
diff changeset
88 {
a61af66fc99e Initial load
duke
parents:
diff changeset
89 // Get following bytecode; do not return wide
a61af66fc99e Initial load
duke
parents:
diff changeset
90 Bytecodes::Code bc = (Bytecodes::Code)_pc[1];
a61af66fc99e Initial load
duke
parents:
diff changeset
91 _pc += 2; // Skip both bytecodes
a61af66fc99e Initial load
duke
parents:
diff changeset
92 _pc += 2; // Skip index always
a61af66fc99e Initial load
duke
parents:
diff changeset
93 if( bc == Bytecodes::_iinc )
a61af66fc99e Initial load
duke
parents:
diff changeset
94 _pc += 2; // Skip optional constant
a61af66fc99e Initial load
duke
parents:
diff changeset
95 _was_wide = _pc; // Flag last wide bytecode found
a61af66fc99e Initial load
duke
parents:
diff changeset
96 return bc;
a61af66fc99e Initial load
duke
parents:
diff changeset
97 }
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
100 // ciBytecodeStream::table
a61af66fc99e Initial load
duke
parents:
diff changeset
101 //
a61af66fc99e Initial load
duke
parents:
diff changeset
102 // Special handling for switch ops
a61af66fc99e Initial load
duke
parents:
diff changeset
103 Bytecodes::Code ciBytecodeStream::table( Bytecodes::Code bc ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
104 switch( bc ) { // Check for special bytecode handling
a61af66fc99e Initial load
duke
parents:
diff changeset
105
a61af66fc99e Initial load
duke
parents:
diff changeset
106 case Bytecodes::_lookupswitch:
a61af66fc99e Initial load
duke
parents:
diff changeset
107 _pc++; // Skip wide bytecode
a61af66fc99e Initial load
duke
parents:
diff changeset
108 _pc += (_start-_pc)&3; // Word align
a61af66fc99e Initial load
duke
parents:
diff changeset
109 _table_base = (jint*)_pc; // Capture for later usage
a61af66fc99e Initial load
duke
parents:
diff changeset
110 // table_base[0] is default far_dest
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // Table has 2 lead elements (default, length), then pairs of u4 values.
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // So load table length, and compute address at end of table
a61af66fc99e Initial load
duke
parents:
diff changeset
113 _pc = (address)&_table_base[2+ 2*Bytes::get_Java_u4((address)&_table_base[1])];
a61af66fc99e Initial load
duke
parents:
diff changeset
114 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 case Bytecodes::_tableswitch: {
a61af66fc99e Initial load
duke
parents:
diff changeset
117 _pc++; // Skip wide bytecode
a61af66fc99e Initial load
duke
parents:
diff changeset
118 _pc += (_start-_pc)&3; // Word align
a61af66fc99e Initial load
duke
parents:
diff changeset
119 _table_base = (jint*)_pc; // Capture for later usage
a61af66fc99e Initial load
duke
parents:
diff changeset
120 // table_base[0] is default far_dest
a61af66fc99e Initial load
duke
parents:
diff changeset
121 int lo = Bytes::get_Java_u4((address)&_table_base[1]);// Low bound
a61af66fc99e Initial load
duke
parents:
diff changeset
122 int hi = Bytes::get_Java_u4((address)&_table_base[2]);// High bound
a61af66fc99e Initial load
duke
parents:
diff changeset
123 int len = hi - lo + 1; // Dense table size
a61af66fc99e Initial load
duke
parents:
diff changeset
124 _pc = (address)&_table_base[3+len]; // Skip past table
a61af66fc99e Initial load
duke
parents:
diff changeset
125 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
126 }
a61af66fc99e Initial load
duke
parents:
diff changeset
127
a61af66fc99e Initial load
duke
parents:
diff changeset
128 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
129 fatal("unhandled bytecode");
a61af66fc99e Initial load
duke
parents:
diff changeset
130 }
a61af66fc99e Initial load
duke
parents:
diff changeset
131 return bc;
a61af66fc99e Initial load
duke
parents:
diff changeset
132 }
a61af66fc99e Initial load
duke
parents:
diff changeset
133
a61af66fc99e Initial load
duke
parents:
diff changeset
134 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
135 // ciBytecodeStream::reset_to_bci
a61af66fc99e Initial load
duke
parents:
diff changeset
136 void ciBytecodeStream::reset_to_bci( int bci ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
137 _bc_start=_was_wide=0;
a61af66fc99e Initial load
duke
parents:
diff changeset
138 _pc = _start+bci;
a61af66fc99e Initial load
duke
parents:
diff changeset
139 }
a61af66fc99e Initial load
duke
parents:
diff changeset
140
a61af66fc99e Initial load
duke
parents:
diff changeset
141 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
142 // ciBytecodeStream::force_bci
a61af66fc99e Initial load
duke
parents:
diff changeset
143 void ciBytecodeStream::force_bci(int bci) {
a61af66fc99e Initial load
duke
parents:
diff changeset
144 if (bci < 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
145 reset_to_bci(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
146 _bc_start = _start + bci;
a61af66fc99e Initial load
duke
parents:
diff changeset
147 _bc = EOBC();
a61af66fc99e Initial load
duke
parents:
diff changeset
148 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
149 reset_to_bci(bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
150 next();
a61af66fc99e Initial load
duke
parents:
diff changeset
151 }
a61af66fc99e Initial load
duke
parents:
diff changeset
152 }
a61af66fc99e Initial load
duke
parents:
diff changeset
153
a61af66fc99e Initial load
duke
parents:
diff changeset
154
a61af66fc99e Initial load
duke
parents:
diff changeset
155 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
156 // Constant pool access
a61af66fc99e Initial load
duke
parents:
diff changeset
157 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
158
a61af66fc99e Initial load
duke
parents:
diff changeset
159 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
160 // ciBytecodeStream::get_klass_index
a61af66fc99e Initial load
duke
parents:
diff changeset
161 //
a61af66fc99e Initial load
duke
parents:
diff changeset
162 // If this bytecodes references a klass, return the index of the
a61af66fc99e Initial load
duke
parents:
diff changeset
163 // referenced klass.
a61af66fc99e Initial load
duke
parents:
diff changeset
164 int ciBytecodeStream::get_klass_index() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
165 switch(cur_bc()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
166 case Bytecodes::_ldc:
a61af66fc99e Initial load
duke
parents:
diff changeset
167 return get_index();
a61af66fc99e Initial load
duke
parents:
diff changeset
168 case Bytecodes::_ldc_w:
a61af66fc99e Initial load
duke
parents:
diff changeset
169 case Bytecodes::_ldc2_w:
a61af66fc99e Initial load
duke
parents:
diff changeset
170 case Bytecodes::_checkcast:
a61af66fc99e Initial load
duke
parents:
diff changeset
171 case Bytecodes::_instanceof:
a61af66fc99e Initial load
duke
parents:
diff changeset
172 case Bytecodes::_anewarray:
a61af66fc99e Initial load
duke
parents:
diff changeset
173 case Bytecodes::_multianewarray:
a61af66fc99e Initial load
duke
parents:
diff changeset
174 case Bytecodes::_new:
a61af66fc99e Initial load
duke
parents:
diff changeset
175 case Bytecodes::_newarray:
a61af66fc99e Initial load
duke
parents:
diff changeset
176 return get_index_big();
a61af66fc99e Initial load
duke
parents:
diff changeset
177 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
178 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
179 return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
180 }
a61af66fc99e Initial load
duke
parents:
diff changeset
181 }
a61af66fc99e Initial load
duke
parents:
diff changeset
182
a61af66fc99e Initial load
duke
parents:
diff changeset
183 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
184 // ciBytecodeStream::get_klass
a61af66fc99e Initial load
duke
parents:
diff changeset
185 //
a61af66fc99e Initial load
duke
parents:
diff changeset
186 // If this bytecode is a new, newarray, multianewarray, instanceof,
a61af66fc99e Initial load
duke
parents:
diff changeset
187 // or checkcast, get the referenced klass.
a61af66fc99e Initial load
duke
parents:
diff changeset
188 ciKlass* ciBytecodeStream::get_klass(bool& will_link) {
a61af66fc99e Initial load
duke
parents:
diff changeset
189 return CURRENT_ENV->get_klass_by_index(_holder, get_klass_index(),
a61af66fc99e Initial load
duke
parents:
diff changeset
190 will_link);
a61af66fc99e Initial load
duke
parents:
diff changeset
191 }
a61af66fc99e Initial load
duke
parents:
diff changeset
192
a61af66fc99e Initial load
duke
parents:
diff changeset
193 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
194 // ciBytecodeStream::get_constant_index
a61af66fc99e Initial load
duke
parents:
diff changeset
195 //
a61af66fc99e Initial load
duke
parents:
diff changeset
196 // If this bytecode is one of the ldc variants, get the index of the
a61af66fc99e Initial load
duke
parents:
diff changeset
197 // referenced constant.
a61af66fc99e Initial load
duke
parents:
diff changeset
198 int ciBytecodeStream::get_constant_index() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
199 switch(cur_bc()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
200 case Bytecodes::_ldc:
a61af66fc99e Initial load
duke
parents:
diff changeset
201 return get_index();
a61af66fc99e Initial load
duke
parents:
diff changeset
202 case Bytecodes::_ldc_w:
a61af66fc99e Initial load
duke
parents:
diff changeset
203 case Bytecodes::_ldc2_w:
a61af66fc99e Initial load
duke
parents:
diff changeset
204 return get_index_big();
a61af66fc99e Initial load
duke
parents:
diff changeset
205 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
206 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
207 return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
208 }
a61af66fc99e Initial load
duke
parents:
diff changeset
209 }
a61af66fc99e Initial load
duke
parents:
diff changeset
210 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
211 // ciBytecodeStream::get_constant
a61af66fc99e Initial load
duke
parents:
diff changeset
212 //
a61af66fc99e Initial load
duke
parents:
diff changeset
213 // If this bytecode is one of the ldc variants, get the referenced
a61af66fc99e Initial load
duke
parents:
diff changeset
214 // constant.
a61af66fc99e Initial load
duke
parents:
diff changeset
215 ciConstant ciBytecodeStream::get_constant() {
a61af66fc99e Initial load
duke
parents:
diff changeset
216 return CURRENT_ENV->get_constant_by_index(_holder, get_constant_index());
a61af66fc99e Initial load
duke
parents:
diff changeset
217 }
a61af66fc99e Initial load
duke
parents:
diff changeset
218
a61af66fc99e Initial load
duke
parents:
diff changeset
219 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
220 bool ciBytecodeStream::is_unresolved_string() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
221 return CURRENT_ENV->is_unresolved_string(_holder, get_constant_index());
a61af66fc99e Initial load
duke
parents:
diff changeset
222 }
a61af66fc99e Initial load
duke
parents:
diff changeset
223
a61af66fc99e Initial load
duke
parents:
diff changeset
224 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
225 bool ciBytecodeStream::is_unresolved_klass() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
226 return CURRENT_ENV->is_unresolved_klass(_holder, get_klass_index());
a61af66fc99e Initial load
duke
parents:
diff changeset
227 }
a61af66fc99e Initial load
duke
parents:
diff changeset
228
a61af66fc99e Initial load
duke
parents:
diff changeset
229 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
230 // ciBytecodeStream::get_field_index
a61af66fc99e Initial load
duke
parents:
diff changeset
231 //
a61af66fc99e Initial load
duke
parents:
diff changeset
232 // If this is a field access bytecode, get the constant pool
a61af66fc99e Initial load
duke
parents:
diff changeset
233 // index of the referenced field.
a61af66fc99e Initial load
duke
parents:
diff changeset
234 int ciBytecodeStream::get_field_index() {
a61af66fc99e Initial load
duke
parents:
diff changeset
235 assert(cur_bc() == Bytecodes::_getfield ||
a61af66fc99e Initial load
duke
parents:
diff changeset
236 cur_bc() == Bytecodes::_putfield ||
a61af66fc99e Initial load
duke
parents:
diff changeset
237 cur_bc() == Bytecodes::_getstatic ||
a61af66fc99e Initial load
duke
parents:
diff changeset
238 cur_bc() == Bytecodes::_putstatic, "wrong bc");
a61af66fc99e Initial load
duke
parents:
diff changeset
239 return get_index_big();
a61af66fc99e Initial load
duke
parents:
diff changeset
240 }
a61af66fc99e Initial load
duke
parents:
diff changeset
241
a61af66fc99e Initial load
duke
parents:
diff changeset
242
a61af66fc99e Initial load
duke
parents:
diff changeset
243 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
244 // ciBytecodeStream::get_field
a61af66fc99e Initial load
duke
parents:
diff changeset
245 //
a61af66fc99e Initial load
duke
parents:
diff changeset
246 // If this bytecode is one of get_field, get_static, put_field,
a61af66fc99e Initial load
duke
parents:
diff changeset
247 // or put_static, get the referenced field.
a61af66fc99e Initial load
duke
parents:
diff changeset
248 ciField* ciBytecodeStream::get_field(bool& will_link) {
a61af66fc99e Initial load
duke
parents:
diff changeset
249 ciField* f = CURRENT_ENV->get_field_by_index(_holder, get_field_index());
a61af66fc99e Initial load
duke
parents:
diff changeset
250 will_link = f->will_link(_holder, _bc);
a61af66fc99e Initial load
duke
parents:
diff changeset
251 return f;
a61af66fc99e Initial load
duke
parents:
diff changeset
252 }
a61af66fc99e Initial load
duke
parents:
diff changeset
253
a61af66fc99e Initial load
duke
parents:
diff changeset
254
a61af66fc99e Initial load
duke
parents:
diff changeset
255 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
256 // ciBytecodeStream::get_declared_field_holder
a61af66fc99e Initial load
duke
parents:
diff changeset
257 //
a61af66fc99e Initial load
duke
parents:
diff changeset
258 // Get the declared holder of the currently referenced field.
a61af66fc99e Initial load
duke
parents:
diff changeset
259 //
a61af66fc99e Initial load
duke
parents:
diff changeset
260 // Usage note: the holder() of a ciField class returns the canonical
a61af66fc99e Initial load
duke
parents:
diff changeset
261 // holder of the field, rather than the holder declared in the
a61af66fc99e Initial load
duke
parents:
diff changeset
262 // bytecodes.
a61af66fc99e Initial load
duke
parents:
diff changeset
263 //
a61af66fc99e Initial load
duke
parents:
diff changeset
264 // There is no "will_link" result passed back. The user is responsible
a61af66fc99e Initial load
duke
parents:
diff changeset
265 // for checking linkability when retrieving the associated field.
a61af66fc99e Initial load
duke
parents:
diff changeset
266 ciInstanceKlass* ciBytecodeStream::get_declared_field_holder() {
a61af66fc99e Initial load
duke
parents:
diff changeset
267 int holder_index = get_field_holder_index();
a61af66fc99e Initial load
duke
parents:
diff changeset
268 bool ignore;
a61af66fc99e Initial load
duke
parents:
diff changeset
269 return CURRENT_ENV->get_klass_by_index(_holder, holder_index, ignore)
a61af66fc99e Initial load
duke
parents:
diff changeset
270 ->as_instance_klass();
a61af66fc99e Initial load
duke
parents:
diff changeset
271 }
a61af66fc99e Initial load
duke
parents:
diff changeset
272
a61af66fc99e Initial load
duke
parents:
diff changeset
273 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
274 // ciBytecodeStream::get_field_holder_index
a61af66fc99e Initial load
duke
parents:
diff changeset
275 //
a61af66fc99e Initial load
duke
parents:
diff changeset
276 // Get the constant pool index of the declared holder of the field
a61af66fc99e Initial load
duke
parents:
diff changeset
277 // referenced by the current bytecode. Used for generating
a61af66fc99e Initial load
duke
parents:
diff changeset
278 // deoptimization information.
a61af66fc99e Initial load
duke
parents:
diff changeset
279 int ciBytecodeStream::get_field_holder_index() {
a61af66fc99e Initial load
duke
parents:
diff changeset
280 VM_ENTRY_MARK;
a61af66fc99e Initial load
duke
parents:
diff changeset
281 constantPoolOop cpool = _holder->get_instanceKlass()->constants();
a61af66fc99e Initial load
duke
parents:
diff changeset
282 return cpool->klass_ref_index_at(get_field_index());
a61af66fc99e Initial load
duke
parents:
diff changeset
283 }
a61af66fc99e Initial load
duke
parents:
diff changeset
284
a61af66fc99e Initial load
duke
parents:
diff changeset
285 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
286 // ciBytecodeStream::get_field_signature_index
a61af66fc99e Initial load
duke
parents:
diff changeset
287 //
a61af66fc99e Initial load
duke
parents:
diff changeset
288 // Get the constant pool index of the signature of the field
a61af66fc99e Initial load
duke
parents:
diff changeset
289 // referenced by the current bytecode. Used for generating
a61af66fc99e Initial load
duke
parents:
diff changeset
290 // deoptimization information.
a61af66fc99e Initial load
duke
parents:
diff changeset
291 int ciBytecodeStream::get_field_signature_index() {
a61af66fc99e Initial load
duke
parents:
diff changeset
292 VM_ENTRY_MARK;
a61af66fc99e Initial load
duke
parents:
diff changeset
293 constantPoolOop cpool = _holder->get_instanceKlass()->constants();
a61af66fc99e Initial load
duke
parents:
diff changeset
294 int nt_index = cpool->name_and_type_ref_index_at(get_field_index());
a61af66fc99e Initial load
duke
parents:
diff changeset
295 return cpool->signature_ref_index_at(nt_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
296 }
a61af66fc99e Initial load
duke
parents:
diff changeset
297
a61af66fc99e Initial load
duke
parents:
diff changeset
298 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
299 // ciBytecodeStream::get_method_index
a61af66fc99e Initial load
duke
parents:
diff changeset
300 //
a61af66fc99e Initial load
duke
parents:
diff changeset
301 // If this is a method invocation bytecode, get the constant pool
a61af66fc99e Initial load
duke
parents:
diff changeset
302 // index of the invoked method.
a61af66fc99e Initial load
duke
parents:
diff changeset
303 int ciBytecodeStream::get_method_index() {
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
304 #ifdef ASSERT
0
a61af66fc99e Initial load
duke
parents:
diff changeset
305 switch (cur_bc()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
306 case Bytecodes::_invokeinterface:
a61af66fc99e Initial load
duke
parents:
diff changeset
307 case Bytecodes::_invokevirtual:
a61af66fc99e Initial load
duke
parents:
diff changeset
308 case Bytecodes::_invokespecial:
a61af66fc99e Initial load
duke
parents:
diff changeset
309 case Bytecodes::_invokestatic:
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
310 case Bytecodes::_invokedynamic:
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
311 break;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
312 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
313 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
314 }
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
315 #endif
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
316 return get_index_int();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
317 }
a61af66fc99e Initial load
duke
parents:
diff changeset
318
a61af66fc99e Initial load
duke
parents:
diff changeset
319 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
320 // ciBytecodeStream::get_method
a61af66fc99e Initial load
duke
parents:
diff changeset
321 //
a61af66fc99e Initial load
duke
parents:
diff changeset
322 // If this is a method invocation bytecode, get the invoked method.
a61af66fc99e Initial load
duke
parents:
diff changeset
323 ciMethod* ciBytecodeStream::get_method(bool& will_link) {
a61af66fc99e Initial load
duke
parents:
diff changeset
324 ciMethod* m = CURRENT_ENV->get_method_by_index(_holder, get_method_index(),cur_bc());
a61af66fc99e Initial load
duke
parents:
diff changeset
325 will_link = m->is_loaded();
a61af66fc99e Initial load
duke
parents:
diff changeset
326 return m;
a61af66fc99e Initial load
duke
parents:
diff changeset
327 }
a61af66fc99e Initial load
duke
parents:
diff changeset
328
a61af66fc99e Initial load
duke
parents:
diff changeset
329 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
330 // ciBytecodeStream::get_declared_method_holder
a61af66fc99e Initial load
duke
parents:
diff changeset
331 //
a61af66fc99e Initial load
duke
parents:
diff changeset
332 // Get the declared holder of the currently referenced method.
a61af66fc99e Initial load
duke
parents:
diff changeset
333 //
a61af66fc99e Initial load
duke
parents:
diff changeset
334 // Usage note: the holder() of a ciMethod class returns the canonical
a61af66fc99e Initial load
duke
parents:
diff changeset
335 // holder of the method, rather than the holder declared in the
a61af66fc99e Initial load
duke
parents:
diff changeset
336 // bytecodes.
a61af66fc99e Initial load
duke
parents:
diff changeset
337 //
a61af66fc99e Initial load
duke
parents:
diff changeset
338 // There is no "will_link" result passed back. The user is responsible
a61af66fc99e Initial load
duke
parents:
diff changeset
339 // for checking linkability when retrieving the associated method.
a61af66fc99e Initial load
duke
parents:
diff changeset
340 ciKlass* ciBytecodeStream::get_declared_method_holder() {
a61af66fc99e Initial load
duke
parents:
diff changeset
341 bool ignore;
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
342 // report as Dynamic for invokedynamic, which is syntactically classless
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
343 if (cur_bc() == Bytecodes::_invokedynamic)
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
344 return CURRENT_ENV->get_klass_by_name(_holder, ciSymbol::java_dyn_Dynamic(), false);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
345 return CURRENT_ENV->get_klass_by_index(_holder, get_method_holder_index(), ignore);
a61af66fc99e Initial load
duke
parents:
diff changeset
346 }
a61af66fc99e Initial load
duke
parents:
diff changeset
347
a61af66fc99e Initial load
duke
parents:
diff changeset
348 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
349 // ciBytecodeStream::get_method_holder_index
a61af66fc99e Initial load
duke
parents:
diff changeset
350 //
a61af66fc99e Initial load
duke
parents:
diff changeset
351 // Get the constant pool index of the declared holder of the method
a61af66fc99e Initial load
duke
parents:
diff changeset
352 // referenced by the current bytecode. Used for generating
a61af66fc99e Initial load
duke
parents:
diff changeset
353 // deoptimization information.
a61af66fc99e Initial load
duke
parents:
diff changeset
354 int ciBytecodeStream::get_method_holder_index() {
a61af66fc99e Initial load
duke
parents:
diff changeset
355 VM_ENTRY_MARK;
a61af66fc99e Initial load
duke
parents:
diff changeset
356 constantPoolOop cpool = _holder->get_instanceKlass()->constants();
a61af66fc99e Initial load
duke
parents:
diff changeset
357 return cpool->klass_ref_index_at(get_method_index());
a61af66fc99e Initial load
duke
parents:
diff changeset
358 }
a61af66fc99e Initial load
duke
parents:
diff changeset
359
a61af66fc99e Initial load
duke
parents:
diff changeset
360 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
361 // ciBytecodeStream::get_method_signature_index
a61af66fc99e Initial load
duke
parents:
diff changeset
362 //
a61af66fc99e Initial load
duke
parents:
diff changeset
363 // Get the constant pool index of the signature of the method
a61af66fc99e Initial load
duke
parents:
diff changeset
364 // referenced by the current bytecode. Used for generating
a61af66fc99e Initial load
duke
parents:
diff changeset
365 // deoptimization information.
a61af66fc99e Initial load
duke
parents:
diff changeset
366 int ciBytecodeStream::get_method_signature_index() {
a61af66fc99e Initial load
duke
parents:
diff changeset
367 VM_ENTRY_MARK;
a61af66fc99e Initial load
duke
parents:
diff changeset
368 constantPoolOop cpool = _holder->get_instanceKlass()->constants();
a61af66fc99e Initial load
duke
parents:
diff changeset
369 int method_index = get_method_index();
a61af66fc99e Initial load
duke
parents:
diff changeset
370 int name_and_type_index = cpool->name_and_type_ref_index_at(method_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
371 return cpool->signature_ref_index_at(name_and_type_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
372 }