Print this page
rev 1081 : imported patch indy-cleanup-6893081.patch
rev 1082 : imported patch indy.compiler.patch
rev 1083 : [mq]: indy.compiler.inline.patch
Split |
Close |
Expand all |
Collapse all |
--- old/src/share/vm/ci/ciStreams.cpp
+++ new/src/share/vm/ci/ciStreams.cpp
1 1 /*
2 2 * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation.
8 8 *
9 9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 12 * version 2 for more details (a copy is included in the LICENSE file that
13 13 * accompanied this code).
14 14 *
15 15 * You should have received a copy of the GNU General Public License version
16 16 * 2 along with this work; if not, write to the Free Software Foundation,
17 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 18 *
19 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 21 * have any questions.
22 22 *
23 23 */
24 24
25 25 #include "incls/_precompiled.incl"
26 26 #include "incls/_ciStreams.cpp.incl"
27 27
28 28 // ciExceptionHandlerStream
29 29 //
30 30 // Walk over some selected set of a methods exception handlers.
31 31
32 32 // ------------------------------------------------------------------
33 33 // ciExceptionHandlerStream::count
34 34 //
35 35 // How many exception handlers are there in this stream?
36 36 //
37 37 // Implementation note: Compiler2 needs this functionality, so I had
38 38 int ciExceptionHandlerStream::count() {
39 39 int save_pos = _pos;
40 40 int save_end = _end;
41 41
42 42 int count = 0;
43 43
44 44 _pos = -1;
45 45 _end = _method->_handler_count;
46 46
47 47
48 48 next();
49 49 while (!is_done()) {
50 50 count++;
51 51 next();
52 52 }
53 53
54 54 _pos = save_pos;
55 55 _end = save_end;
56 56
57 57 return count;
58 58 }
59 59
60 60 int ciExceptionHandlerStream::count_remaining() {
61 61 int save_pos = _pos;
62 62 int save_end = _end;
63 63
64 64 int count = 0;
65 65
66 66 while (!is_done()) {
67 67 count++;
68 68 next();
69 69 }
70 70
71 71 _pos = save_pos;
72 72 _end = save_end;
73 73
74 74 return count;
75 75 }
76 76
77 77 // ciBytecodeStream
78 78 //
79 79 // The class is used to iterate over the bytecodes of a method.
80 80 // It hides the details of constant pool structure/access by
81 81 // providing accessors for constant pool items.
82 82
83 83 // ------------------------------------------------------------------
84 84 // ciBytecodeStream::wide
85 85 //
86 86 // Special handling for the wide bytcode
87 87 Bytecodes::Code ciBytecodeStream::wide()
88 88 {
89 89 // Get following bytecode; do not return wide
90 90 Bytecodes::Code bc = (Bytecodes::Code)_pc[1];
91 91 _pc += 2; // Skip both bytecodes
92 92 _pc += 2; // Skip index always
93 93 if( bc == Bytecodes::_iinc )
94 94 _pc += 2; // Skip optional constant
95 95 _was_wide = _pc; // Flag last wide bytecode found
96 96 return bc;
97 97 }
98 98
99 99 // ------------------------------------------------------------------
100 100 // ciBytecodeStream::table
101 101 //
102 102 // Special handling for switch ops
103 103 Bytecodes::Code ciBytecodeStream::table( Bytecodes::Code bc ) {
104 104 switch( bc ) { // Check for special bytecode handling
105 105
106 106 case Bytecodes::_lookupswitch:
107 107 _pc++; // Skip wide bytecode
108 108 _pc += (_start-_pc)&3; // Word align
109 109 _table_base = (jint*)_pc; // Capture for later usage
110 110 // table_base[0] is default far_dest
111 111 // Table has 2 lead elements (default, length), then pairs of u4 values.
112 112 // So load table length, and compute address at end of table
113 113 _pc = (address)&_table_base[2+ 2*Bytes::get_Java_u4((address)&_table_base[1])];
114 114 break;
115 115
116 116 case Bytecodes::_tableswitch: {
117 117 _pc++; // Skip wide bytecode
118 118 _pc += (_start-_pc)&3; // Word align
119 119 _table_base = (jint*)_pc; // Capture for later usage
120 120 // table_base[0] is default far_dest
121 121 int lo = Bytes::get_Java_u4((address)&_table_base[1]);// Low bound
122 122 int hi = Bytes::get_Java_u4((address)&_table_base[2]);// High bound
123 123 int len = hi - lo + 1; // Dense table size
124 124 _pc = (address)&_table_base[3+len]; // Skip past table
125 125 break;
126 126 }
127 127
128 128 default:
129 129 fatal("unhandled bytecode");
130 130 }
131 131 return bc;
132 132 }
133 133
134 134 // ------------------------------------------------------------------
135 135 // ciBytecodeStream::reset_to_bci
136 136 void ciBytecodeStream::reset_to_bci( int bci ) {
137 137 _bc_start=_was_wide=0;
138 138 _pc = _start+bci;
139 139 }
140 140
141 141 // ------------------------------------------------------------------
142 142 // ciBytecodeStream::force_bci
143 143 void ciBytecodeStream::force_bci(int bci) {
144 144 if (bci < 0) {
145 145 reset_to_bci(0);
146 146 _bc_start = _start + bci;
147 147 _bc = EOBC();
148 148 } else {
149 149 reset_to_bci(bci);
150 150 next();
151 151 }
152 152 }
153 153
154 154
155 155 // ------------------------------------------------------------------
156 156 // Constant pool access
157 157 // ------------------------------------------------------------------
158 158
159 159 // ------------------------------------------------------------------
160 160 // ciBytecodeStream::get_klass_index
161 161 //
162 162 // If this bytecodes references a klass, return the index of the
163 163 // referenced klass.
164 164 int ciBytecodeStream::get_klass_index() const {
165 165 switch(cur_bc()) {
166 166 case Bytecodes::_ldc:
167 167 return get_index();
168 168 case Bytecodes::_ldc_w:
169 169 case Bytecodes::_ldc2_w:
170 170 case Bytecodes::_checkcast:
171 171 case Bytecodes::_instanceof:
172 172 case Bytecodes::_anewarray:
173 173 case Bytecodes::_multianewarray:
174 174 case Bytecodes::_new:
175 175 case Bytecodes::_newarray:
176 176 return get_index_big();
177 177 default:
178 178 ShouldNotReachHere();
↓ open down ↓ |
178 lines elided |
↑ open up ↑ |
179 179 return 0;
180 180 }
181 181 }
182 182
183 183 // ------------------------------------------------------------------
184 184 // ciBytecodeStream::get_klass
185 185 //
186 186 // If this bytecode is a new, newarray, multianewarray, instanceof,
187 187 // or checkcast, get the referenced klass.
188 188 ciKlass* ciBytecodeStream::get_klass(bool& will_link) {
189 - return CURRENT_ENV->get_klass_by_index(_holder, get_klass_index(),
190 - will_link);
189 + VM_ENTRY_MARK;
190 + constantPoolHandle cpool(_method->get_methodOop()->constants());
191 + return CURRENT_ENV->get_klass_by_index(cpool, get_klass_index(), will_link, _holder);
191 192 }
192 193
193 194 // ------------------------------------------------------------------
194 195 // ciBytecodeStream::get_constant_index
195 196 //
196 197 // If this bytecode is one of the ldc variants, get the index of the
197 198 // referenced constant.
198 199 int ciBytecodeStream::get_constant_index() const {
199 200 switch(cur_bc()) {
200 201 case Bytecodes::_ldc:
201 202 return get_index();
202 203 case Bytecodes::_ldc_w:
203 204 case Bytecodes::_ldc2_w:
204 205 return get_index_big();
205 206 default:
↓ open down ↓ |
5 lines elided |
↑ open up ↑ |
206 207 ShouldNotReachHere();
207 208 return 0;
208 209 }
209 210 }
210 211 // ------------------------------------------------------------------
211 212 // ciBytecodeStream::get_constant
212 213 //
213 214 // If this bytecode is one of the ldc variants, get the referenced
214 215 // constant.
215 216 ciConstant ciBytecodeStream::get_constant() {
216 - return CURRENT_ENV->get_constant_by_index(_holder, get_constant_index());
217 + VM_ENTRY_MARK;
218 + constantPoolHandle cpool(_method->get_methodOop()->constants());
219 + return CURRENT_ENV->get_constant_by_index(cpool, get_constant_index(), _holder);
217 220 }
218 221
219 222 // ------------------------------------------------------------------
220 223 bool ciBytecodeStream::is_unresolved_string() const {
221 224 return CURRENT_ENV->is_unresolved_string(_holder, get_constant_index());
222 225 }
223 226
224 227 // ------------------------------------------------------------------
225 228 bool ciBytecodeStream::is_unresolved_klass() const {
226 229 return CURRENT_ENV->is_unresolved_klass(_holder, get_klass_index());
227 230 }
228 231
229 232 // ------------------------------------------------------------------
230 233 // ciBytecodeStream::get_field_index
231 234 //
232 235 // If this is a field access bytecode, get the constant pool
233 236 // index of the referenced field.
234 237 int ciBytecodeStream::get_field_index() {
235 238 assert(cur_bc() == Bytecodes::_getfield ||
236 239 cur_bc() == Bytecodes::_putfield ||
237 240 cur_bc() == Bytecodes::_getstatic ||
238 241 cur_bc() == Bytecodes::_putstatic, "wrong bc");
239 242 return get_index_big();
240 243 }
241 244
242 245
243 246 // ------------------------------------------------------------------
244 247 // ciBytecodeStream::get_field
245 248 //
246 249 // If this bytecode is one of get_field, get_static, put_field,
247 250 // or put_static, get the referenced field.
248 251 ciField* ciBytecodeStream::get_field(bool& will_link) {
249 252 ciField* f = CURRENT_ENV->get_field_by_index(_holder, get_field_index());
250 253 will_link = f->will_link(_holder, _bc);
251 254 return f;
252 255 }
253 256
254 257
255 258 // ------------------------------------------------------------------
256 259 // ciBytecodeStream::get_declared_field_holder
↓ open down ↓ |
30 lines elided |
↑ open up ↑ |
257 260 //
258 261 // Get the declared holder of the currently referenced field.
259 262 //
260 263 // Usage note: the holder() of a ciField class returns the canonical
261 264 // holder of the field, rather than the holder declared in the
262 265 // bytecodes.
263 266 //
264 267 // There is no "will_link" result passed back. The user is responsible
265 268 // for checking linkability when retrieving the associated field.
266 269 ciInstanceKlass* ciBytecodeStream::get_declared_field_holder() {
270 + VM_ENTRY_MARK;
271 + constantPoolHandle cpool(_method->get_methodOop()->constants());
267 272 int holder_index = get_field_holder_index();
268 273 bool ignore;
269 - return CURRENT_ENV->get_klass_by_index(_holder, holder_index, ignore)
274 + return CURRENT_ENV->get_klass_by_index(cpool, holder_index, ignore, _holder)
270 275 ->as_instance_klass();
271 276 }
272 277
273 278 // ------------------------------------------------------------------
274 279 // ciBytecodeStream::get_field_holder_index
275 280 //
276 281 // Get the constant pool index of the declared holder of the field
277 282 // referenced by the current bytecode. Used for generating
278 283 // deoptimization information.
279 284 int ciBytecodeStream::get_field_holder_index() {
280 - VM_ENTRY_MARK;
281 - constantPoolOop cpool = _holder->get_instanceKlass()->constants();
282 - return cpool->klass_ref_index_at(get_field_index());
285 + GUARDED_VM_ENTRY(
286 + constantPoolOop cpool = _holder->get_instanceKlass()->constants();
287 + return cpool->klass_ref_index_at(get_field_index());
288 + )
283 289 }
284 290
285 291 // ------------------------------------------------------------------
286 292 // ciBytecodeStream::get_field_signature_index
287 293 //
288 294 // Get the constant pool index of the signature of the field
289 295 // referenced by the current bytecode. Used for generating
290 296 // deoptimization information.
291 297 int ciBytecodeStream::get_field_signature_index() {
292 298 VM_ENTRY_MARK;
293 299 constantPoolOop cpool = _holder->get_instanceKlass()->constants();
294 300 int nt_index = cpool->name_and_type_ref_index_at(get_field_index());
295 301 return cpool->signature_ref_index_at(nt_index);
296 302 }
297 303
298 304 // ------------------------------------------------------------------
299 305 // ciBytecodeStream::get_method_index
300 306 //
301 307 // If this is a method invocation bytecode, get the constant pool
302 308 // index of the invoked method.
303 309 int ciBytecodeStream::get_method_index() {
304 310 #ifdef ASSERT
305 311 switch (cur_bc()) {
306 312 case Bytecodes::_invokeinterface:
307 313 case Bytecodes::_invokevirtual:
308 314 case Bytecodes::_invokespecial:
309 315 case Bytecodes::_invokestatic:
310 316 case Bytecodes::_invokedynamic:
311 317 break;
312 318 default:
313 319 ShouldNotReachHere();
↓ open down ↓ |
21 lines elided |
↑ open up ↑ |
314 320 }
315 321 #endif
316 322 return get_index_int();
317 323 }
318 324
319 325 // ------------------------------------------------------------------
320 326 // ciBytecodeStream::get_method
321 327 //
322 328 // If this is a method invocation bytecode, get the invoked method.
323 329 ciMethod* ciBytecodeStream::get_method(bool& will_link) {
324 - ciMethod* m = CURRENT_ENV->get_method_by_index(_holder, get_method_index(), cur_bc());
330 + VM_ENTRY_MARK;
331 + constantPoolHandle cpool(_method->get_methodOop()->constants());
332 + ciMethod* m = CURRENT_ENV->get_method_by_index(cpool, get_method_index(), cur_bc(), _holder);
325 333 will_link = m->is_loaded();
326 334 return m;
327 335 }
328 336
329 337 // ------------------------------------------------------------------
330 338 // ciBytecodeStream::get_declared_method_holder
331 339 //
332 340 // Get the declared holder of the currently referenced method.
333 341 //
334 342 // Usage note: the holder() of a ciMethod class returns the canonical
335 343 // holder of the method, rather than the holder declared in the
336 344 // bytecodes.
337 345 //
338 346 // There is no "will_link" result passed back. The user is responsible
339 347 // for checking linkability when retrieving the associated method.
340 348 ciKlass* ciBytecodeStream::get_declared_method_holder() {
349 + VM_ENTRY_MARK;
350 + constantPoolHandle cpool(_method->get_methodOop()->constants());
341 351 bool ignore;
342 352 // report as InvokeDynamic for invokedynamic, which is syntactically classless
343 353 if (cur_bc() == Bytecodes::_invokedynamic)
344 354 return CURRENT_ENV->get_klass_by_name(_holder, ciSymbol::java_dyn_InvokeDynamic(), false);
345 - return CURRENT_ENV->get_klass_by_index(_holder, get_method_holder_index(), ignore);
355 + return CURRENT_ENV->get_klass_by_index(cpool, get_method_holder_index(), ignore, _holder);
346 356 }
347 357
348 358 // ------------------------------------------------------------------
349 359 // ciBytecodeStream::get_method_holder_index
350 360 //
351 361 // Get the constant pool index of the declared holder of the method
352 362 // referenced by the current bytecode. Used for generating
353 363 // deoptimization information.
354 364 int ciBytecodeStream::get_method_holder_index() {
355 - VM_ENTRY_MARK;
356 - constantPoolOop cpool = _holder->get_instanceKlass()->constants();
365 + constantPoolOop cpool = _method->get_methodOop()->constants();
357 366 return cpool->klass_ref_index_at(get_method_index());
358 367 }
359 368
360 369 // ------------------------------------------------------------------
361 370 // ciBytecodeStream::get_method_signature_index
362 371 //
363 372 // Get the constant pool index of the signature of the method
364 373 // referenced by the current bytecode. Used for generating
365 374 // deoptimization information.
366 375 int ciBytecodeStream::get_method_signature_index() {
367 376 VM_ENTRY_MARK;
368 377 constantPoolOop cpool = _holder->get_instanceKlass()->constants();
369 378 int method_index = get_method_index();
370 379 int name_and_type_index = cpool->name_and_type_ref_index_at(method_index);
371 380 return cpool->signature_ref_index_at(name_and_type_index);
372 381 }
373 382
↓ open down ↓ |
7 lines elided |
↑ open up ↑ |
374 383 // ------------------------------------------------------------------
375 384 // ciBytecodeStream::get_cpcache
376 385 ciCPCache* ciBytecodeStream::get_cpcache() {
377 386 VM_ENTRY_MARK;
378 387 // Get the constant pool.
379 388 constantPoolOop cpool = _holder->get_instanceKlass()->constants();
380 389 constantPoolCacheOop cpcache = cpool->cache();
381 390
382 391 return CURRENT_ENV->get_object(cpcache)->as_cpcache();
383 392 }
393 +
394 +// ------------------------------------------------------------------
395 +// ciBytecodeStream::get_call_site
396 +ciCallSite* ciBytecodeStream::get_call_site() {
397 + VM_ENTRY_MARK;
398 + // Get the constant pool.
399 + constantPoolOop cpool = _holder->get_instanceKlass()->constants();
400 + constantPoolCacheOop cpcache = cpool->cache();
401 +
402 + // Get the CallSite from the constant pool cache.
403 + int method_index = get_method_index();
404 + ConstantPoolCacheEntry* cpcache_entry = cpcache->secondary_entry_at(method_index);
405 + oop call_site_oop = cpcache_entry->f1();
406 +
407 + // Create a CallSite object and return it.
408 + return CURRENT_ENV->get_object(call_site_oop)->as_call_site();
409 +}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX