Mercurial > hg > graal-jvmci-8
comparison src/share/vm/ci/ciStreams.cpp @ 1138:dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
Summary: C2 needs some additional optimizations to be able to handle MethodHandle invokes and invokedynamic instructions at the best performance.
Reviewed-by: kvn, never
author | twisti |
---|---|
date | Tue, 05 Jan 2010 15:21:25 +0100 |
parents | 97125851f396 |
children | c18cbe5936b8 ab102d5d923e |
comparison
equal
deleted
inserted
replaced
1137:97125851f396 | 1138:dd57230ba8fe |
---|---|
184 // ciBytecodeStream::get_klass | 184 // ciBytecodeStream::get_klass |
185 // | 185 // |
186 // If this bytecode is a new, newarray, multianewarray, instanceof, | 186 // If this bytecode is a new, newarray, multianewarray, instanceof, |
187 // or checkcast, get the referenced klass. | 187 // or checkcast, get the referenced klass. |
188 ciKlass* ciBytecodeStream::get_klass(bool& will_link) { | 188 ciKlass* ciBytecodeStream::get_klass(bool& will_link) { |
189 return CURRENT_ENV->get_klass_by_index(_holder, get_klass_index(), | 189 VM_ENTRY_MARK; |
190 will_link); | 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 // ciBytecodeStream::get_constant_index | 195 // ciBytecodeStream::get_constant_index |
195 // | 196 // |
211 // ciBytecodeStream::get_constant | 212 // ciBytecodeStream::get_constant |
212 // | 213 // |
213 // If this bytecode is one of the ldc variants, get the referenced | 214 // If this bytecode is one of the ldc variants, get the referenced |
214 // constant. | 215 // constant. |
215 ciConstant ciBytecodeStream::get_constant() { | 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 bool ciBytecodeStream::is_unresolved_string() const { | 223 bool ciBytecodeStream::is_unresolved_string() const { |
221 return CURRENT_ENV->is_unresolved_string(_holder, get_constant_index()); | 224 return CURRENT_ENV->is_unresolved_string(_holder, get_constant_index()); |
262 // bytecodes. | 265 // bytecodes. |
263 // | 266 // |
264 // There is no "will_link" result passed back. The user is responsible | 267 // There is no "will_link" result passed back. The user is responsible |
265 // for checking linkability when retrieving the associated field. | 268 // for checking linkability when retrieving the associated field. |
266 ciInstanceKlass* ciBytecodeStream::get_declared_field_holder() { | 269 ciInstanceKlass* ciBytecodeStream::get_declared_field_holder() { |
270 VM_ENTRY_MARK; | |
271 constantPoolHandle cpool(_method->get_methodOop()->constants()); | |
267 int holder_index = get_field_holder_index(); | 272 int holder_index = get_field_holder_index(); |
268 bool ignore; | 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 ->as_instance_klass(); | 275 ->as_instance_klass(); |
271 } | 276 } |
272 | 277 |
273 // ------------------------------------------------------------------ | 278 // ------------------------------------------------------------------ |
274 // ciBytecodeStream::get_field_holder_index | 279 // ciBytecodeStream::get_field_holder_index |
275 // | 280 // |
276 // Get the constant pool index of the declared holder of the field | 281 // Get the constant pool index of the declared holder of the field |
277 // referenced by the current bytecode. Used for generating | 282 // referenced by the current bytecode. Used for generating |
278 // deoptimization information. | 283 // deoptimization information. |
279 int ciBytecodeStream::get_field_holder_index() { | 284 int ciBytecodeStream::get_field_holder_index() { |
280 VM_ENTRY_MARK; | 285 GUARDED_VM_ENTRY( |
281 constantPoolOop cpool = _holder->get_instanceKlass()->constants(); | 286 constantPoolOop cpool = _holder->get_instanceKlass()->constants(); |
282 return cpool->klass_ref_index_at(get_field_index()); | 287 return cpool->klass_ref_index_at(get_field_index()); |
288 ) | |
283 } | 289 } |
284 | 290 |
285 // ------------------------------------------------------------------ | 291 // ------------------------------------------------------------------ |
286 // ciBytecodeStream::get_field_signature_index | 292 // ciBytecodeStream::get_field_signature_index |
287 // | 293 // |
319 // ------------------------------------------------------------------ | 325 // ------------------------------------------------------------------ |
320 // ciBytecodeStream::get_method | 326 // ciBytecodeStream::get_method |
321 // | 327 // |
322 // If this is a method invocation bytecode, get the invoked method. | 328 // If this is a method invocation bytecode, get the invoked method. |
323 ciMethod* ciBytecodeStream::get_method(bool& will_link) { | 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 will_link = m->is_loaded(); | 333 will_link = m->is_loaded(); |
326 return m; | 334 return m; |
327 } | 335 } |
328 | 336 |
329 // ------------------------------------------------------------------ | 337 // ------------------------------------------------------------------ |
336 // bytecodes. | 344 // bytecodes. |
337 // | 345 // |
338 // There is no "will_link" result passed back. The user is responsible | 346 // There is no "will_link" result passed back. The user is responsible |
339 // for checking linkability when retrieving the associated method. | 347 // for checking linkability when retrieving the associated method. |
340 ciKlass* ciBytecodeStream::get_declared_method_holder() { | 348 ciKlass* ciBytecodeStream::get_declared_method_holder() { |
349 VM_ENTRY_MARK; | |
350 constantPoolHandle cpool(_method->get_methodOop()->constants()); | |
341 bool ignore; | 351 bool ignore; |
342 // report as InvokeDynamic for invokedynamic, which is syntactically classless | 352 // report as InvokeDynamic for invokedynamic, which is syntactically classless |
343 if (cur_bc() == Bytecodes::_invokedynamic) | 353 if (cur_bc() == Bytecodes::_invokedynamic) |
344 return CURRENT_ENV->get_klass_by_name(_holder, ciSymbol::java_dyn_InvokeDynamic(), false); | 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 // ciBytecodeStream::get_method_holder_index | 359 // ciBytecodeStream::get_method_holder_index |
350 // | 360 // |
351 // Get the constant pool index of the declared holder of the method | 361 // Get the constant pool index of the declared holder of the method |
352 // referenced by the current bytecode. Used for generating | 362 // referenced by the current bytecode. Used for generating |
353 // deoptimization information. | 363 // deoptimization information. |
354 int ciBytecodeStream::get_method_holder_index() { | 364 int ciBytecodeStream::get_method_holder_index() { |
355 VM_ENTRY_MARK; | 365 constantPoolOop cpool = _method->get_methodOop()->constants(); |
356 constantPoolOop cpool = _holder->get_instanceKlass()->constants(); | |
357 return cpool->klass_ref_index_at(get_method_index()); | 366 return cpool->klass_ref_index_at(get_method_index()); |
358 } | 367 } |
359 | 368 |
360 // ------------------------------------------------------------------ | 369 // ------------------------------------------------------------------ |
361 // ciBytecodeStream::get_method_signature_index | 370 // ciBytecodeStream::get_method_signature_index |
379 constantPoolOop cpool = _holder->get_instanceKlass()->constants(); | 388 constantPoolOop cpool = _holder->get_instanceKlass()->constants(); |
380 constantPoolCacheOop cpcache = cpool->cache(); | 389 constantPoolCacheOop cpcache = cpool->cache(); |
381 | 390 |
382 return CURRENT_ENV->get_object(cpcache)->as_cpcache(); | 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 } |