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 1082 : imported patch indy.compiler.patch
rev 1083 : [mq]: indy.compiler.inline.patch


 426   if (require_local)  return NULL;
 427   // Not yet loaded into the VM, or not governed by loader constraints.
 428   // Make a CI representative for it.
 429   return get_unloaded_klass(accessing_klass, name);
 430 }
 431 
 432 // ------------------------------------------------------------------
 433 // ciEnv::get_klass_by_name
 434 ciKlass* ciEnv::get_klass_by_name(ciKlass* accessing_klass,
 435                                   ciSymbol* klass_name,
 436                                   bool require_local) {
 437   GUARDED_VM_ENTRY(return get_klass_by_name_impl(accessing_klass,
 438                                                  klass_name,
 439                                                  require_local);)
 440 }
 441 
 442 // ------------------------------------------------------------------
 443 // ciEnv::get_klass_by_index_impl
 444 //
 445 // Implementation of get_klass_by_index.
 446 ciKlass* ciEnv::get_klass_by_index_impl(ciInstanceKlass* accessor,
 447                                         int index,
 448                                         bool& is_accessible) {
 449   assert(accessor->get_instanceKlass()->is_linked(), "must be linked before accessing constant pool");
 450   EXCEPTION_CONTEXT;
 451   constantPoolHandle cpool(THREAD, accessor->get_instanceKlass()->constants());
 452   KlassHandle klass (THREAD, constantPoolOopDesc::klass_at_if_loaded(cpool, index));
 453   symbolHandle klass_name;
 454   if (klass.is_null()) {
 455     // The klass has not been inserted into the constant pool.
 456     // Try to look it up by name.
 457     {
 458       // We have to lock the cpool to keep the oop from being resolved
 459       // while we are accessing it.
 460       ObjectLocker ol(cpool, THREAD);
 461 
 462       constantTag tag = cpool->tag_at(index);
 463       if (tag.is_klass()) {
 464         // The klass has been inserted into the constant pool
 465         // very recently.
 466         klass = KlassHandle(THREAD, cpool->resolved_klass_at(index));
 467       } else if (tag.is_symbol()) {
 468         klass_name = symbolHandle(THREAD, cpool->symbol_at(index));
 469       } else {
 470         assert(cpool->tag_at(index).is_unresolved_klass(), "wrong tag");
 471         klass_name = symbolHandle(THREAD, cpool->unresolved_klass_at(index));


 493   }
 494 
 495   // Check for prior unloaded klass.  The SystemDictionary's answers
 496   // can vary over time but the compiler needs consistency.
 497   ciSymbol* name = get_object(klass()->klass_part()->name())->as_symbol();
 498   ciKlass* unloaded_klass = check_get_unloaded_klass(accessor, name);
 499   if (unloaded_klass != NULL) {
 500     is_accessible = false;
 501     return unloaded_klass;
 502   }
 503 
 504   // It is known to be accessible, since it was found in the constant pool.
 505   is_accessible = true;
 506   return get_object(klass())->as_klass();
 507 }
 508 
 509 // ------------------------------------------------------------------
 510 // ciEnv::get_klass_by_index
 511 //
 512 // Get a klass from the constant pool.
 513 ciKlass* ciEnv::get_klass_by_index(ciInstanceKlass* accessor,
 514                                    int index,
 515                                    bool& is_accessible) {
 516   GUARDED_VM_ENTRY(return get_klass_by_index_impl(accessor, index, is_accessible);)

 517 }
 518 
 519 // ------------------------------------------------------------------
 520 // ciEnv::get_constant_by_index_impl
 521 //
 522 // Implementation of get_constant_by_index().
 523 ciConstant ciEnv::get_constant_by_index_impl(ciInstanceKlass* accessor,
 524                                              int index) {

 525   EXCEPTION_CONTEXT;
 526   instanceKlass* ik_accessor = accessor->get_instanceKlass();
 527   assert(ik_accessor->is_linked(), "must be linked before accessing constant pool");
 528   constantPoolOop cpool = ik_accessor->constants();
 529   constantTag tag = cpool->tag_at(index);
 530   if (tag.is_int()) {
 531     return ciConstant(T_INT, (jint)cpool->int_at(index));
 532   } else if (tag.is_long()) {
 533     return ciConstant((jlong)cpool->long_at(index));
 534   } else if (tag.is_float()) {
 535     return ciConstant((jfloat)cpool->float_at(index));
 536   } else if (tag.is_double()) {
 537     return ciConstant((jdouble)cpool->double_at(index));
 538   } else if (tag.is_string() || tag.is_unresolved_string()) {
 539     oop string = NULL;
 540     if (cpool->is_pseudo_string_at(index)) {
 541       string = cpool->pseudo_string_at(index);
 542     } else {
 543       string = cpool->string_at(index, THREAD);
 544       if (HAS_PENDING_EXCEPTION) {
 545         CLEAR_PENDING_EXCEPTION;
 546         record_out_of_memory_failure();
 547         return ciConstant();
 548       }
 549     }
 550     ciObject* constant = get_object(string);
 551     assert (constant->is_instance(), "must be an instance, or not? ");
 552     return ciConstant(T_OBJECT, constant);
 553   } else if (tag.is_klass() || tag.is_unresolved_klass()) {
 554     // 4881222: allow ldc to take a class type
 555     bool ignore;
 556     ciKlass* klass = get_klass_by_index_impl(accessor, index, ignore);
 557     if (HAS_PENDING_EXCEPTION) {
 558       CLEAR_PENDING_EXCEPTION;
 559       record_out_of_memory_failure();
 560       return ciConstant();
 561     }
 562     assert (klass->is_instance_klass() || klass->is_array_klass(),
 563             "must be an instance or array klass ");
 564     return ciConstant(T_OBJECT, klass);





 565   } else {
 566     ShouldNotReachHere();
 567     return ciConstant();
 568   }
 569 }
 570 
 571 // ------------------------------------------------------------------
 572 // ciEnv::is_unresolved_string_impl
 573 //
 574 // Implementation of is_unresolved_string().
 575 bool ciEnv::is_unresolved_string_impl(instanceKlass* accessor, int index) const {
 576   EXCEPTION_CONTEXT;
 577   assert(accessor->is_linked(), "must be linked before accessing constant pool");
 578   constantPoolOop cpool = accessor->constants();
 579   constantTag tag = cpool->tag_at(index);
 580   return tag.is_unresolved_string();
 581 }
 582 
 583 // ------------------------------------------------------------------
 584 // ciEnv::is_unresolved_klass_impl
 585 //
 586 // Implementation of is_unresolved_klass().
 587 bool ciEnv::is_unresolved_klass_impl(instanceKlass* accessor, int index) const {
 588   EXCEPTION_CONTEXT;
 589   assert(accessor->is_linked(), "must be linked before accessing constant pool");
 590   constantPoolOop cpool = accessor->constants();
 591   constantTag tag = cpool->tag_at(index);
 592   return tag.is_unresolved_klass();
 593 }
 594 
 595 // ------------------------------------------------------------------
 596 // ciEnv::get_constant_by_index
 597 //
 598 // Pull a constant out of the constant pool.  How appropriate.
 599 //
 600 // Implementation note: this query is currently in no way cached.
 601 ciConstant ciEnv::get_constant_by_index(ciInstanceKlass* accessor,
 602                                         int index) {
 603   GUARDED_VM_ENTRY(return get_constant_by_index_impl(accessor, index); )

 604 }
 605 
 606 // ------------------------------------------------------------------
 607 // ciEnv::is_unresolved_string
 608 //
 609 // Check constant pool
 610 //
 611 // Implementation note: this query is currently in no way cached.
 612 bool ciEnv::is_unresolved_string(ciInstanceKlass* accessor,
 613                                         int index) const {
 614   GUARDED_VM_ENTRY(return is_unresolved_string_impl(accessor->get_instanceKlass(), index); )
 615 }
 616 
 617 // ------------------------------------------------------------------
 618 // ciEnv::is_unresolved_klass
 619 //
 620 // Check constant pool
 621 //
 622 // Implementation note: this query is currently in no way cached.
 623 bool ciEnv::is_unresolved_klass(ciInstanceKlass* accessor,


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


 772   // instead of a ciInstanceKlass.  For that case simply pretend that the
 773   // declared holder is Object.clone since that's where the call will bottom out.
 774   // A more correct fix would trickle out through many interfaces in CI,
 775   // requiring ciInstanceKlass* to become ciKlass* and many more places would
 776   // require checks to make sure the expected type was found.  Given that this
 777   // only occurs for clone() the more extensive fix seems like overkill so
 778   // instead we simply smear the array type into Object.
 779   if (method_holder->is_instance_klass()) {
 780     return method_holder->as_instance_klass();
 781   } else if (method_holder->is_array_klass()) {
 782     return current()->Object_klass();
 783   } else {
 784     ShouldNotReachHere();
 785   }
 786   return NULL;
 787 }
 788 
 789 
 790 // ------------------------------------------------------------------
 791 // ciEnv::get_method_by_index
 792 ciMethod* ciEnv::get_method_by_index(ciInstanceKlass* accessor,
 793                                      int index, Bytecodes::Code bc) {

 794   if (bc == Bytecodes::_invokedynamic) {
 795     GUARDED_VM_ENTRY(return get_fake_invokedynamic_method_impl(accessor, index, bc);)
 796   } else {
 797     GUARDED_VM_ENTRY(return get_method_by_index_impl(accessor, index, bc);)
 798   }
 799 }
 800 
 801 
 802 // ------------------------------------------------------------------
 803 // ciEnv::name_buffer
 804 char *ciEnv::name_buffer(int req_len) {
 805   if (_name_buffer_len < req_len) {
 806     if (_name_buffer == NULL) {
 807       _name_buffer = (char*)arena()->Amalloc(sizeof(char)*req_len);
 808       _name_buffer_len = req_len;
 809     } else {
 810       _name_buffer =
 811         (char*)arena()->Arealloc(_name_buffer, _name_buffer_len, req_len);
 812       _name_buffer_len = req_len;
 813     }
 814   }
 815   return _name_buffer;
 816 }
 817 




 426   if (require_local)  return NULL;
 427   // Not yet loaded into the VM, or not governed by loader constraints.
 428   // Make a CI representative for it.
 429   return get_unloaded_klass(accessing_klass, name);
 430 }
 431 
 432 // ------------------------------------------------------------------
 433 // ciEnv::get_klass_by_name
 434 ciKlass* ciEnv::get_klass_by_name(ciKlass* accessing_klass,
 435                                   ciSymbol* klass_name,
 436                                   bool require_local) {
 437   GUARDED_VM_ENTRY(return get_klass_by_name_impl(accessing_klass,
 438                                                  klass_name,
 439                                                  require_local);)
 440 }
 441 
 442 // ------------------------------------------------------------------
 443 // ciEnv::get_klass_by_index_impl
 444 //
 445 // Implementation of get_klass_by_index.
 446 ciKlass* ciEnv::get_klass_by_index_impl(constantPoolHandle cpool,
 447                                         int index,
 448                                         bool& is_accessible,
 449                                         ciInstanceKlass* accessor) {
 450   EXCEPTION_CONTEXT;

 451   KlassHandle klass (THREAD, constantPoolOopDesc::klass_at_if_loaded(cpool, index));
 452   symbolHandle klass_name;
 453   if (klass.is_null()) {
 454     // The klass has not been inserted into the constant pool.
 455     // Try to look it up by name.
 456     {
 457       // We have to lock the cpool to keep the oop from being resolved
 458       // while we are accessing it.
 459       ObjectLocker ol(cpool, THREAD);
 460 
 461       constantTag tag = cpool->tag_at(index);
 462       if (tag.is_klass()) {
 463         // The klass has been inserted into the constant pool
 464         // very recently.
 465         klass = KlassHandle(THREAD, cpool->resolved_klass_at(index));
 466       } else if (tag.is_symbol()) {
 467         klass_name = symbolHandle(THREAD, cpool->symbol_at(index));
 468       } else {
 469         assert(cpool->tag_at(index).is_unresolved_klass(), "wrong tag");
 470         klass_name = symbolHandle(THREAD, cpool->unresolved_klass_at(index));


 492   }
 493 
 494   // Check for prior unloaded klass.  The SystemDictionary's answers
 495   // can vary over time but the compiler needs consistency.
 496   ciSymbol* name = get_object(klass()->klass_part()->name())->as_symbol();
 497   ciKlass* unloaded_klass = check_get_unloaded_klass(accessor, name);
 498   if (unloaded_klass != NULL) {
 499     is_accessible = false;
 500     return unloaded_klass;
 501   }
 502 
 503   // It is known to be accessible, since it was found in the constant pool.
 504   is_accessible = true;
 505   return get_object(klass())->as_klass();
 506 }
 507 
 508 // ------------------------------------------------------------------
 509 // ciEnv::get_klass_by_index
 510 //
 511 // Get a klass from the constant pool.
 512 ciKlass* ciEnv::get_klass_by_index(constantPoolHandle cpool,
 513                                    int index,
 514                                    bool& is_accessible,
 515                                    ciInstanceKlass* accessor) {
 516   GUARDED_VM_ENTRY(return get_klass_by_index_impl(cpool, index, is_accessible, accessor);)
 517 }
 518 
 519 // ------------------------------------------------------------------
 520 // ciEnv::get_constant_by_index_impl
 521 //
 522 // Implementation of get_constant_by_index().
 523 ciConstant ciEnv::get_constant_by_index_impl(constantPoolHandle cpool,
 524                                              int index,
 525                                              ciInstanceKlass* accessor) {
 526   EXCEPTION_CONTEXT;



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


 689     break;
 690   case Bytecodes::_invokeinterface:
 691     dest_method =
 692       LinkResolver::linktime_resolve_interface_method_or_null(h_holder, h_name, h_sig,
 693                                                               h_accessor, true);
 694     break;
 695   case Bytecodes::_invokevirtual:
 696     dest_method =
 697       LinkResolver::linktime_resolve_virtual_method_or_null(h_holder, h_name, h_sig,
 698                                                             h_accessor, true);
 699     break;
 700   default: ShouldNotReachHere();
 701   }
 702 
 703   return dest_method();
 704 }
 705 
 706 
 707 // ------------------------------------------------------------------
 708 // ciEnv::get_method_by_index_impl
 709 ciMethod* ciEnv::get_method_by_index_impl(constantPoolHandle cpool,
 710                                           int index, Bytecodes::Code bc,
 711                                           ciInstanceKlass* accessor) {



 712   int holder_index = cpool->klass_ref_index_at(index);
 713   bool holder_is_accessible;
 714   ciKlass* holder = get_klass_by_index_impl(cpool, holder_index, holder_is_accessible, accessor);
 715   ciInstanceKlass* declared_holder = get_instance_klass_for_declared_method_holder(holder);
 716 
 717   // Get the method's name and signature.
 718   symbolOop name_sym = cpool->name_ref_at(index);
 719   symbolOop sig_sym  = cpool->signature_ref_at(index);
 720 
 721   if (holder_is_accessible) { // Our declared holder is loaded.
 722     instanceKlass* lookup = declared_holder->get_instanceKlass();
 723     methodOop m = lookup_method(accessor->get_instanceKlass(), lookup, name_sym, sig_sym, bc);
 724     if (m != NULL) {
 725       // We found the method.
 726       return get_object(m)->as_method();
 727     }
 728   }
 729 
 730   // Either the declared holder was not loaded, or the method could
 731   // not be found.  Create a dummy ciMethod to represent the failed
 732   // lookup.
 733 
 734   return get_unloaded_method(declared_holder,
 735                              get_object(name_sym)->as_symbol(),
 736                              get_object(sig_sym)->as_symbol());
 737 }
 738 
 739 
 740 // ------------------------------------------------------------------
 741 // ciEnv::get_fake_invokedynamic_method_impl
 742 ciMethod* ciEnv::get_fake_invokedynamic_method_impl(constantPoolHandle cpool,
 743                                                     int index, Bytecodes::Code bc) {
 744   assert(bc == Bytecodes::_invokedynamic, "must be invokedynamic");


 745 
 746   // Get the CallSite from the constant pool cache.
 747   ConstantPoolCacheEntry* cpc_entry = cpool->cache()->secondary_entry_at(index);
 748   assert(cpc_entry != NULL && cpc_entry->is_secondary_entry(), "sanity");
 749   Handle call_site = cpc_entry->f1();
 750 
 751   // Call site might not be linked yet.
 752   if (call_site.is_null()) {
 753     ciInstanceKlass* mh_klass = get_object(SystemDictionary::MethodHandle_klass())->as_instance_klass();
 754     ciSymbol*       sig_sym   = get_object(cpool->signature_ref_at(index))->as_symbol();
 755     return get_unloaded_method(mh_klass, ciSymbol::invoke_name(), sig_sym);
 756   }
 757 
 758   // Get the methodOop from the CallSite.
 759   methodOop method_oop = (methodOop) java_dyn_CallSite::vmmethod(call_site());
 760   assert(method_oop != NULL, "sanity");
 761   assert(method_oop->is_method_handle_invoke(), "consistent");
 762 
 763   return get_object(method_oop)->as_method();
 764 }


 771   // instead of a ciInstanceKlass.  For that case simply pretend that the
 772   // declared holder is Object.clone since that's where the call will bottom out.
 773   // A more correct fix would trickle out through many interfaces in CI,
 774   // requiring ciInstanceKlass* to become ciKlass* and many more places would
 775   // require checks to make sure the expected type was found.  Given that this
 776   // only occurs for clone() the more extensive fix seems like overkill so
 777   // instead we simply smear the array type into Object.
 778   if (method_holder->is_instance_klass()) {
 779     return method_holder->as_instance_klass();
 780   } else if (method_holder->is_array_klass()) {
 781     return current()->Object_klass();
 782   } else {
 783     ShouldNotReachHere();
 784   }
 785   return NULL;
 786 }
 787 
 788 
 789 // ------------------------------------------------------------------
 790 // ciEnv::get_method_by_index
 791 ciMethod* ciEnv::get_method_by_index(constantPoolHandle cpool,
 792                                      int index, Bytecodes::Code bc,
 793                                      ciInstanceKlass* accessor) {
 794   if (bc == Bytecodes::_invokedynamic) {
 795     GUARDED_VM_ENTRY(return get_fake_invokedynamic_method_impl(cpool, index, bc);)
 796   } else {
 797     GUARDED_VM_ENTRY(return get_method_by_index_impl(cpool, index, bc, accessor);)
 798   }
 799 }
 800 
 801 
 802 // ------------------------------------------------------------------
 803 // ciEnv::name_buffer
 804 char *ciEnv::name_buffer(int req_len) {
 805   if (_name_buffer_len < req_len) {
 806     if (_name_buffer == NULL) {
 807       _name_buffer = (char*)arena()->Amalloc(sizeof(char)*req_len);
 808       _name_buffer_len = req_len;
 809     } else {
 810       _name_buffer =
 811         (char*)arena()->Arealloc(_name_buffer, _name_buffer_len, req_len);
 812       _name_buffer_len = req_len;
 813     }
 814   }
 815   return _name_buffer;
 816 }
 817 


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