src/share/vm/ci/ciEnv.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 6893268 Sdiff src/share/vm/ci

src/share/vm/ci/ciEnv.cpp

Print this page
rev 1021 : 6858164: invokedynamic code needs some cleanup (post-6655638)
Note: The bug ID for this change set was erroneously used to call for review of 6815692.
Summary: Fix several crashers, remove needless paths for boxed-style bootstrap method call, refactor & simplify APIs for rewriter constantPoolOop, remove sun.dyn.CallSiteImpl
Reviewed-by: ?
rev 1025 : imported patch indy.compiler.patch
rev 1026 : imported patch indy.compiler.inline.patch


 403   if (require_local)  return NULL;
 404   // Not yet loaded into the VM, or not governed by loader constraints.
 405   // Make a CI representative for it.
 406   return get_unloaded_klass(accessing_klass, name);
 407 }
 408 
 409 // ------------------------------------------------------------------
 410 // ciEnv::get_klass_by_name
 411 ciKlass* ciEnv::get_klass_by_name(ciKlass* accessing_klass,
 412                                   ciSymbol* klass_name,
 413                                   bool require_local) {
 414   GUARDED_VM_ENTRY(return get_klass_by_name_impl(accessing_klass,
 415                                                  klass_name,
 416                                                  require_local);)
 417 }
 418 
 419 // ------------------------------------------------------------------
 420 // ciEnv::get_klass_by_index_impl
 421 //
 422 // Implementation of get_klass_by_index.
 423 ciKlass* ciEnv::get_klass_by_index_impl(ciInstanceKlass* accessor,
 424                                         int index,
 425                                         bool& is_accessible) {
 426   assert(accessor->get_instanceKlass()->is_linked(), "must be linked before accessing constant pool");
 427   EXCEPTION_CONTEXT;
 428   constantPoolHandle cpool(THREAD, accessor->get_instanceKlass()->constants());
 429   KlassHandle klass (THREAD, constantPoolOopDesc::klass_at_if_loaded(cpool, index));
 430   symbolHandle klass_name;
 431   if (klass.is_null()) {
 432     // The klass has not been inserted into the constant pool.
 433     // Try to look it up by name.
 434     {
 435       // We have to lock the cpool to keep the oop from being resolved
 436       // while we are accessing it.
 437       ObjectLocker ol(cpool, THREAD);
 438 
 439       constantTag tag = cpool->tag_at(index);
 440       if (tag.is_klass()) {
 441         // The klass has been inserted into the constant pool
 442         // very recently.
 443         klass = KlassHandle(THREAD, cpool->resolved_klass_at(index));
 444       } else if (tag.is_symbol()) {
 445         klass_name = symbolHandle(THREAD, cpool->symbol_at(index));
 446       } else {
 447         assert(cpool->tag_at(index).is_unresolved_klass(), "wrong tag");
 448         klass_name = symbolHandle(THREAD, cpool->unresolved_klass_at(index));


 470   }
 471 
 472   // Check for prior unloaded klass.  The SystemDictionary's answers
 473   // can vary over time but the compiler needs consistency.
 474   ciSymbol* name = get_object(klass()->klass_part()->name())->as_symbol();
 475   ciKlass* unloaded_klass = check_get_unloaded_klass(accessor, name);
 476   if (unloaded_klass != NULL) {
 477     is_accessible = false;
 478     return unloaded_klass;
 479   }
 480 
 481   // It is known to be accessible, since it was found in the constant pool.
 482   is_accessible = true;
 483   return get_object(klass())->as_klass();
 484 }
 485 
 486 // ------------------------------------------------------------------
 487 // ciEnv::get_klass_by_index
 488 //
 489 // Get a klass from the constant pool.
 490 ciKlass* ciEnv::get_klass_by_index(ciInstanceKlass* accessor,
 491                                    int index,
 492                                    bool& is_accessible) {
 493   GUARDED_VM_ENTRY(return get_klass_by_index_impl(accessor, index, is_accessible);)

 494 }
 495 
 496 // ------------------------------------------------------------------
 497 // ciEnv::get_constant_by_index_impl
 498 //
 499 // Implementation of get_constant_by_index().
 500 ciConstant ciEnv::get_constant_by_index_impl(ciInstanceKlass* accessor,
 501                                              int index) {

 502   EXCEPTION_CONTEXT;
 503   instanceKlass* ik_accessor = accessor->get_instanceKlass();
 504   assert(ik_accessor->is_linked(), "must be linked before accessing constant pool");
 505   constantPoolOop cpool = ik_accessor->constants();
 506   constantTag tag = cpool->tag_at(index);
 507   if (tag.is_int()) {
 508     return ciConstant(T_INT, (jint)cpool->int_at(index));
 509   } else if (tag.is_long()) {
 510     return ciConstant((jlong)cpool->long_at(index));
 511   } else if (tag.is_float()) {
 512     return ciConstant((jfloat)cpool->float_at(index));
 513   } else if (tag.is_double()) {
 514     return ciConstant((jdouble)cpool->double_at(index));
 515   } else if (tag.is_string() || tag.is_unresolved_string()) {
 516     oop string = NULL;
 517     if (cpool->is_pseudo_string_at(index)) {
 518       string = cpool->pseudo_string_at(index);
 519     } else {
 520       string = cpool->string_at(index, THREAD);
 521       if (HAS_PENDING_EXCEPTION) {
 522         CLEAR_PENDING_EXCEPTION;
 523         record_out_of_memory_failure();
 524         return ciConstant();
 525       }
 526     }
 527     ciObject* constant = get_object(string);
 528     assert (constant->is_instance(), "must be an instance, or not? ");
 529     return ciConstant(T_OBJECT, constant);
 530   } else if (tag.is_klass() || tag.is_unresolved_klass()) {
 531     // 4881222: allow ldc to take a class type
 532     bool ignore;
 533     ciKlass* klass = get_klass_by_index_impl(accessor, index, ignore);
 534     if (HAS_PENDING_EXCEPTION) {
 535       CLEAR_PENDING_EXCEPTION;
 536       record_out_of_memory_failure();
 537       return ciConstant();
 538     }
 539     assert (klass->is_instance_klass() || klass->is_array_klass(),
 540             "must be an instance or array klass ");
 541     return ciConstant(T_OBJECT, klass);





 542   } else {
 543     ShouldNotReachHere();
 544     return ciConstant();
 545   }
 546 }
 547 
 548 // ------------------------------------------------------------------
 549 // ciEnv::is_unresolved_string_impl
 550 //
 551 // Implementation of is_unresolved_string().
 552 bool ciEnv::is_unresolved_string_impl(instanceKlass* accessor, int index) const {
 553   EXCEPTION_CONTEXT;
 554   assert(accessor->is_linked(), "must be linked before accessing constant pool");
 555   constantPoolOop cpool = accessor->constants();
 556   constantTag tag = cpool->tag_at(index);
 557   return tag.is_unresolved_string();
 558 }
 559 
 560 // ------------------------------------------------------------------
 561 // ciEnv::is_unresolved_klass_impl
 562 //
 563 // Implementation of is_unresolved_klass().
 564 bool ciEnv::is_unresolved_klass_impl(instanceKlass* accessor, int index) const {
 565   EXCEPTION_CONTEXT;
 566   assert(accessor->is_linked(), "must be linked before accessing constant pool");
 567   constantPoolOop cpool = accessor->constants();
 568   constantTag tag = cpool->tag_at(index);
 569   return tag.is_unresolved_klass();
 570 }
 571 
 572 // ------------------------------------------------------------------
 573 // ciEnv::get_constant_by_index
 574 //
 575 // Pull a constant out of the constant pool.  How appropriate.
 576 //
 577 // Implementation note: this query is currently in no way cached.
 578 ciConstant ciEnv::get_constant_by_index(ciInstanceKlass* accessor,
 579                                         int index) {
 580   GUARDED_VM_ENTRY(return get_constant_by_index_impl(accessor, index); )

 581 }
 582 
 583 // ------------------------------------------------------------------
 584 // ciEnv::is_unresolved_string
 585 //
 586 // Check constant pool
 587 //
 588 // Implementation note: this query is currently in no way cached.
 589 bool ciEnv::is_unresolved_string(ciInstanceKlass* accessor,
 590                                         int index) const {
 591   GUARDED_VM_ENTRY(return is_unresolved_string_impl(accessor->get_instanceKlass(), index); )
 592 }
 593 
 594 // ------------------------------------------------------------------
 595 // ciEnv::is_unresolved_klass
 596 //
 597 // Check constant pool
 598 //
 599 // Implementation note: this query is currently in no way cached.
 600 bool ciEnv::is_unresolved_klass(ciInstanceKlass* accessor,


 662     break;
 663   case Bytecodes::_invokeinterface:
 664     dest_method =
 665       LinkResolver::linktime_resolve_interface_method_or_null(h_holder, h_name, h_sig,
 666                                                               h_accessor, true);
 667     break;
 668   case Bytecodes::_invokevirtual:
 669     dest_method =
 670       LinkResolver::linktime_resolve_virtual_method_or_null(h_holder, h_name, h_sig,
 671                                                             h_accessor, true);
 672     break;
 673   default: ShouldNotReachHere();
 674   }
 675 
 676   return dest_method();
 677 }
 678 
 679 
 680 // ------------------------------------------------------------------
 681 // ciEnv::get_method_by_index_impl
 682 ciMethod* ciEnv::get_method_by_index_impl(ciInstanceKlass* accessor,
 683                                      int index, Bytecodes::Code bc) {
 684   // Get the method's declared holder.
 685 
 686   assert(accessor->get_instanceKlass()->is_linked(), "must be linked before accessing constant pool");
 687   constantPoolHandle cpool = accessor->get_instanceKlass()->constants();
 688   int holder_index = cpool->klass_ref_index_at(index);
 689   bool holder_is_accessible;
 690   ciKlass* holder = get_klass_by_index_impl(accessor, holder_index, holder_is_accessible);
 691   ciInstanceKlass* declared_holder = get_instance_klass_for_declared_method_holder(holder);
 692 
 693   // Get the method's name and signature.
 694   symbolOop name_sym = cpool->name_ref_at(index);
 695   symbolOop sig_sym  = cpool->signature_ref_at(index);
 696 
 697   if (holder_is_accessible) { // Our declared holder is loaded.
 698     instanceKlass* lookup = declared_holder->get_instanceKlass();
 699     methodOop m = lookup_method(accessor->get_instanceKlass(), lookup, name_sym, sig_sym, bc);
 700     if (m != NULL) {
 701       // We found the method.
 702       return get_object(m)->as_method();
 703     }
 704   }
 705 
 706   // Either the declared holder was not loaded, or the method could
 707   // not be found.  Create a dummy ciMethod to represent the failed
 708   // lookup.
 709 
 710   return get_unloaded_method(declared_holder,
 711                              get_object(name_sym)->as_symbol(),
 712                              get_object(sig_sym)->as_symbol());
 713 }
 714 
 715 
 716 // ------------------------------------------------------------------
 717 // ciEnv::get_fake_invokedynamic_method_impl
 718 ciMethod* ciEnv::get_fake_invokedynamic_method_impl(ciInstanceKlass* accessor,
 719                                                     int index, Bytecodes::Code bc) {
 720   assert(bc == Bytecodes::_invokedynamic, "must be invokedynamic");
 721   assert(accessor->get_instanceKlass()->is_linked(), "must be linked before accessing constant pool");
 722   constantPoolHandle cpool = accessor->get_instanceKlass()->constants();
 723 
 724   // Get the CallSite from the constant pool cache.
 725   ConstantPoolCacheEntry* cpc_entry = cpool->cache()->secondary_entry_at(index);
 726   assert(cpc_entry != NULL && cpc_entry->is_secondary_entry(), "sanity");
 727   Handle call_site = cpc_entry->f1();
 728 
 729   // Call site might not be linked yet.
 730   if (call_site.is_null()) {
 731     ciInstanceKlass* mh_klass = get_object(SystemDictionary::MethodHandle_klass())->as_instance_klass();
 732     ciSymbol*       sig_sym   = get_object(cpool->signature_ref_at(index))->as_symbol();
 733     return get_unloaded_method(mh_klass, ciSymbol::invoke_name(), sig_sym);
 734   }
 735 
 736   // Get the methodOop from the CallSite.
 737   methodOop method_oop = (methodOop) java_dyn_CallSite::vmmethod(call_site());
 738   assert(method_oop != NULL, "sanity");
 739   assert(method_oop->is_method_handle_invoke(), "consistent");
 740 
 741   return get_object(method_oop)->as_method();
 742 }


 749   // instead of a ciInstanceKlass.  For that case simply pretend that the
 750   // declared holder is Object.clone since that's where the call will bottom out.
 751   // A more correct fix would trickle out through many interfaces in CI,
 752   // requiring ciInstanceKlass* to become ciKlass* and many more places would
 753   // require checks to make sure the expected type was found.  Given that this
 754   // only occurs for clone() the more extensive fix seems like overkill so
 755   // instead we simply smear the array type into Object.
 756   if (method_holder->is_instance_klass()) {
 757     return method_holder->as_instance_klass();
 758   } else if (method_holder->is_array_klass()) {
 759     return current()->Object_klass();
 760   } else {
 761     ShouldNotReachHere();
 762   }
 763   return NULL;
 764 }
 765 
 766 
 767 // ------------------------------------------------------------------
 768 // ciEnv::get_method_by_index
 769 ciMethod* ciEnv::get_method_by_index(ciInstanceKlass* accessor,
 770                                      int index, Bytecodes::Code bc) {

 771   if (bc == Bytecodes::_invokedynamic) {
 772     GUARDED_VM_ENTRY(return get_fake_invokedynamic_method_impl(accessor, index, bc);)
 773   } else {
 774     GUARDED_VM_ENTRY(return get_method_by_index_impl(accessor, index, bc);)
 775   }
 776 }
 777 
 778 
 779 // ------------------------------------------------------------------
 780 // ciEnv::name_buffer
 781 char *ciEnv::name_buffer(int req_len) {
 782   if (_name_buffer_len < req_len) {
 783     if (_name_buffer == NULL) {
 784       _name_buffer = (char*)arena()->Amalloc(sizeof(char)*req_len);
 785       _name_buffer_len = req_len;
 786     } else {
 787       _name_buffer =
 788         (char*)arena()->Arealloc(_name_buffer, _name_buffer_len, req_len);
 789       _name_buffer_len = req_len;
 790     }
 791   }
 792   return _name_buffer;
 793 }
 794 




 403   if (require_local)  return NULL;
 404   // Not yet loaded into the VM, or not governed by loader constraints.
 405   // Make a CI representative for it.
 406   return get_unloaded_klass(accessing_klass, name);
 407 }
 408 
 409 // ------------------------------------------------------------------
 410 // ciEnv::get_klass_by_name
 411 ciKlass* ciEnv::get_klass_by_name(ciKlass* accessing_klass,
 412                                   ciSymbol* klass_name,
 413                                   bool require_local) {
 414   GUARDED_VM_ENTRY(return get_klass_by_name_impl(accessing_klass,
 415                                                  klass_name,
 416                                                  require_local);)
 417 }
 418 
 419 // ------------------------------------------------------------------
 420 // ciEnv::get_klass_by_index_impl
 421 //
 422 // Implementation of get_klass_by_index.
 423 ciKlass* ciEnv::get_klass_by_index_impl(constantPoolHandle cpool,
 424                                         int index,
 425                                         bool& is_accessible,
 426                                         ciInstanceKlass* accessor) {
 427   EXCEPTION_CONTEXT;

 428   KlassHandle klass (THREAD, constantPoolOopDesc::klass_at_if_loaded(cpool, index));
 429   symbolHandle klass_name;
 430   if (klass.is_null()) {
 431     // The klass has not been inserted into the constant pool.
 432     // Try to look it up by name.
 433     {
 434       // We have to lock the cpool to keep the oop from being resolved
 435       // while we are accessing it.
 436       ObjectLocker ol(cpool, THREAD);
 437 
 438       constantTag tag = cpool->tag_at(index);
 439       if (tag.is_klass()) {
 440         // The klass has been inserted into the constant pool
 441         // very recently.
 442         klass = KlassHandle(THREAD, cpool->resolved_klass_at(index));
 443       } else if (tag.is_symbol()) {
 444         klass_name = symbolHandle(THREAD, cpool->symbol_at(index));
 445       } else {
 446         assert(cpool->tag_at(index).is_unresolved_klass(), "wrong tag");
 447         klass_name = symbolHandle(THREAD, cpool->unresolved_klass_at(index));


 469   }
 470 
 471   // Check for prior unloaded klass.  The SystemDictionary's answers
 472   // can vary over time but the compiler needs consistency.
 473   ciSymbol* name = get_object(klass()->klass_part()->name())->as_symbol();
 474   ciKlass* unloaded_klass = check_get_unloaded_klass(accessor, name);
 475   if (unloaded_klass != NULL) {
 476     is_accessible = false;
 477     return unloaded_klass;
 478   }
 479 
 480   // It is known to be accessible, since it was found in the constant pool.
 481   is_accessible = true;
 482   return get_object(klass())->as_klass();
 483 }
 484 
 485 // ------------------------------------------------------------------
 486 // ciEnv::get_klass_by_index
 487 //
 488 // Get a klass from the constant pool.
 489 ciKlass* ciEnv::get_klass_by_index(constantPoolHandle cpool,
 490                                    int index,
 491                                    bool& is_accessible,
 492                                    ciInstanceKlass* accessor) {
 493   GUARDED_VM_ENTRY(return get_klass_by_index_impl(cpool, index, is_accessible, accessor);)
 494 }
 495 
 496 // ------------------------------------------------------------------
 497 // ciEnv::get_constant_by_index_impl
 498 //
 499 // Implementation of get_constant_by_index().
 500 ciConstant ciEnv::get_constant_by_index_impl(constantPoolHandle cpool,
 501                                              int index,
 502                                              ciInstanceKlass* accessor) {
 503   EXCEPTION_CONTEXT;



 504   constantTag tag = cpool->tag_at(index);
 505   if (tag.is_int()) {
 506     return ciConstant(T_INT, (jint)cpool->int_at(index));
 507   } else if (tag.is_long()) {
 508     return ciConstant((jlong)cpool->long_at(index));
 509   } else if (tag.is_float()) {
 510     return ciConstant((jfloat)cpool->float_at(index));
 511   } else if (tag.is_double()) {
 512     return ciConstant((jdouble)cpool->double_at(index));
 513   } else if (tag.is_string() || tag.is_unresolved_string()) {
 514     oop string = NULL;
 515     if (cpool->is_pseudo_string_at(index)) {
 516       string = cpool->pseudo_string_at(index);
 517     } else {
 518       string = cpool->string_at(index, THREAD);
 519       if (HAS_PENDING_EXCEPTION) {
 520         CLEAR_PENDING_EXCEPTION;
 521         record_out_of_memory_failure();
 522         return ciConstant();
 523       }
 524     }
 525     ciObject* constant = get_object(string);
 526     assert (constant->is_instance(), "must be an instance, or not? ");
 527     return ciConstant(T_OBJECT, constant);
 528   } else if (tag.is_klass() || tag.is_unresolved_klass()) {
 529     // 4881222: allow ldc to take a class type
 530     bool ignore;
 531     ciKlass* klass = get_klass_by_index_impl(cpool, index, ignore, accessor);
 532     if (HAS_PENDING_EXCEPTION) {
 533       CLEAR_PENDING_EXCEPTION;
 534       record_out_of_memory_failure();
 535       return ciConstant();
 536     }
 537     assert (klass->is_instance_klass() || klass->is_array_klass(),
 538             "must be an instance or array klass ");
 539     return ciConstant(T_OBJECT, klass);
 540   } else if (tag.is_object()) {
 541     oop obj = cpool->object_at(index);
 542     assert(obj->is_instance(), "must be an instance");
 543     ciObject* ciobj = get_object(obj);
 544     return ciConstant(T_OBJECT, ciobj);
 545   } else {
 546     ShouldNotReachHere();
 547     return ciConstant();
 548   }
 549 }
 550 
 551 // ------------------------------------------------------------------
 552 // ciEnv::is_unresolved_string_impl
 553 //
 554 // Implementation of is_unresolved_string().
 555 bool ciEnv::is_unresolved_string_impl(instanceKlass* accessor, int index) const {
 556   EXCEPTION_CONTEXT;
 557   assert(accessor->is_linked(), "must be linked before accessing constant pool");
 558   constantPoolOop cpool = accessor->constants();
 559   constantTag tag = cpool->tag_at(index);
 560   return tag.is_unresolved_string();
 561 }
 562 
 563 // ------------------------------------------------------------------
 564 // ciEnv::is_unresolved_klass_impl
 565 //
 566 // Implementation of is_unresolved_klass().
 567 bool ciEnv::is_unresolved_klass_impl(instanceKlass* accessor, int index) const {
 568   EXCEPTION_CONTEXT;
 569   assert(accessor->is_linked(), "must be linked before accessing constant pool");
 570   constantPoolOop cpool = accessor->constants();
 571   constantTag tag = cpool->tag_at(index);
 572   return tag.is_unresolved_klass();
 573 }
 574 
 575 // ------------------------------------------------------------------
 576 // ciEnv::get_constant_by_index
 577 //
 578 // Pull a constant out of the constant pool.  How appropriate.
 579 //
 580 // Implementation note: this query is currently in no way cached.
 581 ciConstant ciEnv::get_constant_by_index(constantPoolHandle cpool,
 582                                         int index,
 583                                         ciInstanceKlass* accessor) {
 584   GUARDED_VM_ENTRY(return get_constant_by_index_impl(cpool, index, accessor);)
 585 }
 586 
 587 // ------------------------------------------------------------------
 588 // ciEnv::is_unresolved_string
 589 //
 590 // Check constant pool
 591 //
 592 // Implementation note: this query is currently in no way cached.
 593 bool ciEnv::is_unresolved_string(ciInstanceKlass* accessor,
 594                                  int index) const {
 595   GUARDED_VM_ENTRY(return is_unresolved_string_impl(accessor->get_instanceKlass(), index); )
 596 }
 597 
 598 // ------------------------------------------------------------------
 599 // ciEnv::is_unresolved_klass
 600 //
 601 // Check constant pool
 602 //
 603 // Implementation note: this query is currently in no way cached.
 604 bool ciEnv::is_unresolved_klass(ciInstanceKlass* accessor,


 666     break;
 667   case Bytecodes::_invokeinterface:
 668     dest_method =
 669       LinkResolver::linktime_resolve_interface_method_or_null(h_holder, h_name, h_sig,
 670                                                               h_accessor, true);
 671     break;
 672   case Bytecodes::_invokevirtual:
 673     dest_method =
 674       LinkResolver::linktime_resolve_virtual_method_or_null(h_holder, h_name, h_sig,
 675                                                             h_accessor, true);
 676     break;
 677   default: ShouldNotReachHere();
 678   }
 679 
 680   return dest_method();
 681 }
 682 
 683 
 684 // ------------------------------------------------------------------
 685 // ciEnv::get_method_by_index_impl
 686 ciMethod* ciEnv::get_method_by_index_impl(constantPoolHandle cpool,
 687                                           int index, Bytecodes::Code bc,
 688                                           ciInstanceKlass* accessor) {



 689   int holder_index = cpool->klass_ref_index_at(index);
 690   bool holder_is_accessible;
 691   ciKlass* holder = get_klass_by_index_impl(cpool, holder_index, holder_is_accessible, accessor);
 692   ciInstanceKlass* declared_holder = get_instance_klass_for_declared_method_holder(holder);
 693 
 694   // Get the method's name and signature.
 695   symbolOop name_sym = cpool->name_ref_at(index);
 696   symbolOop sig_sym  = cpool->signature_ref_at(index);
 697 
 698   if (holder_is_accessible) { // Our declared holder is loaded.
 699     instanceKlass* lookup = declared_holder->get_instanceKlass();
 700     methodOop m = lookup_method(accessor->get_instanceKlass(), lookup, name_sym, sig_sym, bc);
 701     if (m != NULL) {
 702       // We found the method.
 703       return get_object(m)->as_method();
 704     }
 705   }
 706 
 707   // Either the declared holder was not loaded, or the method could
 708   // not be found.  Create a dummy ciMethod to represent the failed
 709   // lookup.
 710 
 711   return get_unloaded_method(declared_holder,
 712                              get_object(name_sym)->as_symbol(),
 713                              get_object(sig_sym)->as_symbol());
 714 }
 715 
 716 
 717 // ------------------------------------------------------------------
 718 // ciEnv::get_fake_invokedynamic_method_impl
 719 ciMethod* ciEnv::get_fake_invokedynamic_method_impl(constantPoolHandle cpool,
 720                                                     int index, Bytecodes::Code bc) {
 721   assert(bc == Bytecodes::_invokedynamic, "must be invokedynamic");


 722 
 723   // Get the CallSite from the constant pool cache.
 724   ConstantPoolCacheEntry* cpc_entry = cpool->cache()->secondary_entry_at(index);
 725   assert(cpc_entry != NULL && cpc_entry->is_secondary_entry(), "sanity");
 726   Handle call_site = cpc_entry->f1();
 727 
 728   // Call site might not be linked yet.
 729   if (call_site.is_null()) {
 730     ciInstanceKlass* mh_klass = get_object(SystemDictionary::MethodHandle_klass())->as_instance_klass();
 731     ciSymbol*       sig_sym   = get_object(cpool->signature_ref_at(index))->as_symbol();
 732     return get_unloaded_method(mh_klass, ciSymbol::invoke_name(), sig_sym);
 733   }
 734 
 735   // Get the methodOop from the CallSite.
 736   methodOop method_oop = (methodOop) java_dyn_CallSite::vmmethod(call_site());
 737   assert(method_oop != NULL, "sanity");
 738   assert(method_oop->is_method_handle_invoke(), "consistent");
 739 
 740   return get_object(method_oop)->as_method();
 741 }


 748   // instead of a ciInstanceKlass.  For that case simply pretend that the
 749   // declared holder is Object.clone since that's where the call will bottom out.
 750   // A more correct fix would trickle out through many interfaces in CI,
 751   // requiring ciInstanceKlass* to become ciKlass* and many more places would
 752   // require checks to make sure the expected type was found.  Given that this
 753   // only occurs for clone() the more extensive fix seems like overkill so
 754   // instead we simply smear the array type into Object.
 755   if (method_holder->is_instance_klass()) {
 756     return method_holder->as_instance_klass();
 757   } else if (method_holder->is_array_klass()) {
 758     return current()->Object_klass();
 759   } else {
 760     ShouldNotReachHere();
 761   }
 762   return NULL;
 763 }
 764 
 765 
 766 // ------------------------------------------------------------------
 767 // ciEnv::get_method_by_index
 768 ciMethod* ciEnv::get_method_by_index(constantPoolHandle cpool,
 769                                      int index, Bytecodes::Code bc,
 770                                      ciInstanceKlass* accessor) {
 771   if (bc == Bytecodes::_invokedynamic) {
 772     GUARDED_VM_ENTRY(return get_fake_invokedynamic_method_impl(cpool, index, bc);)
 773   } else {
 774     GUARDED_VM_ENTRY(return get_method_by_index_impl(cpool, index, bc, accessor);)
 775   }
 776 }
 777 
 778 
 779 // ------------------------------------------------------------------
 780 // ciEnv::name_buffer
 781 char *ciEnv::name_buffer(int req_len) {
 782   if (_name_buffer_len < req_len) {
 783     if (_name_buffer == NULL) {
 784       _name_buffer = (char*)arena()->Amalloc(sizeof(char)*req_len);
 785       _name_buffer_len = req_len;
 786     } else {
 787       _name_buffer =
 788         (char*)arena()->Arealloc(_name_buffer, _name_buffer_len, req_len);
 789       _name_buffer_len = req_len;
 790     }
 791   }
 792   return _name_buffer;
 793 }
 794 


src/share/vm/ci/ciEnv.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File