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

src/share/vm/ci/ciEnv.cpp

Print this page
rev 1082 : [mq]: indy.compiler.patch


  24 
  25 #include "incls/_precompiled.incl"
  26 #include "incls/_ciEnv.cpp.incl"
  27 
  28 // ciEnv
  29 //
  30 // This class is the top level broker for requests from the compiler
  31 // to the VM.
  32 
  33 ciObject*              ciEnv::_null_object_instance;
  34 ciMethodKlass*         ciEnv::_method_klass_instance;
  35 ciSymbolKlass*         ciEnv::_symbol_klass_instance;
  36 ciKlassKlass*          ciEnv::_klass_klass_instance;
  37 ciInstanceKlassKlass*  ciEnv::_instance_klass_klass_instance;
  38 ciTypeArrayKlassKlass* ciEnv::_type_array_klass_klass_instance;
  39 ciObjArrayKlassKlass*  ciEnv::_obj_array_klass_klass_instance;
  40 
  41 ciInstanceKlass* ciEnv::_ArrayStoreException;
  42 ciInstanceKlass* ciEnv::_Class;
  43 ciInstanceKlass* ciEnv::_ClassCastException;

  44 ciInstanceKlass* ciEnv::_Object;
  45 ciInstanceKlass* ciEnv::_Throwable;
  46 ciInstanceKlass* ciEnv::_Thread;
  47 ciInstanceKlass* ciEnv::_OutOfMemoryError;
  48 ciInstanceKlass* ciEnv::_String;
  49 ciInstanceKlass* ciEnv::_StringBuffer;
  50 ciInstanceKlass* ciEnv::_StringBuilder;
  51 ciInstanceKlass* ciEnv::_Integer;
  52 
  53 ciSymbol*        ciEnv::_unloaded_cisymbol = NULL;
  54 ciInstanceKlass* ciEnv::_unloaded_ciinstance_klass = NULL;
  55 ciObjArrayKlass* ciEnv::_unloaded_ciobjarrayklass = NULL;
  56 
  57 jobject ciEnv::_ArrayIndexOutOfBoundsException_handle = NULL;
  58 jobject ciEnv::_ArrayStoreException_handle = NULL;
  59 jobject ciEnv::_ClassCastException_handle = NULL;
  60 
  61 #ifndef PRODUCT
  62 static bool firstEnv = true;
  63 #endif /* PRODUCT */


 719   if (holder_is_accessible) { // Our declared holder is loaded.
 720     instanceKlass* lookup = declared_holder->get_instanceKlass();
 721     methodOop m = lookup_method(accessor->get_instanceKlass(), lookup, name_sym, sig_sym, bc);
 722     if (m != NULL) {
 723       // We found the method.
 724       return get_object(m)->as_method();
 725     }
 726   }
 727 
 728   // Either the declared holder was not loaded, or the method could
 729   // not be found.  Create a dummy ciMethod to represent the failed
 730   // lookup.
 731 
 732   return get_unloaded_method(declared_holder,
 733                              get_object(name_sym)->as_symbol(),
 734                              get_object(sig_sym)->as_symbol());
 735 }
 736 
 737 
 738 // ------------------------------------------------------------------





























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



 766   GUARDED_VM_ENTRY(return get_method_by_index_impl(accessor, index, bc);)

 767 }
 768 

 769 // ------------------------------------------------------------------
 770 // ciEnv::name_buffer
 771 char *ciEnv::name_buffer(int req_len) {
 772   if (_name_buffer_len < req_len) {
 773     if (_name_buffer == NULL) {
 774       _name_buffer = (char*)arena()->Amalloc(sizeof(char)*req_len);
 775       _name_buffer_len = req_len;
 776     } else {
 777       _name_buffer =
 778         (char*)arena()->Arealloc(_name_buffer, _name_buffer_len, req_len);
 779       _name_buffer_len = req_len;
 780     }
 781   }
 782   return _name_buffer;
 783 }
 784 
 785 // ------------------------------------------------------------------
 786 // ciEnv::is_in_vm
 787 bool ciEnv::is_in_vm() {
 788   return JavaThread::current()->thread_state() == _thread_in_vm;




  24 
  25 #include "incls/_precompiled.incl"
  26 #include "incls/_ciEnv.cpp.incl"
  27 
  28 // ciEnv
  29 //
  30 // This class is the top level broker for requests from the compiler
  31 // to the VM.
  32 
  33 ciObject*              ciEnv::_null_object_instance;
  34 ciMethodKlass*         ciEnv::_method_klass_instance;
  35 ciSymbolKlass*         ciEnv::_symbol_klass_instance;
  36 ciKlassKlass*          ciEnv::_klass_klass_instance;
  37 ciInstanceKlassKlass*  ciEnv::_instance_klass_klass_instance;
  38 ciTypeArrayKlassKlass* ciEnv::_type_array_klass_klass_instance;
  39 ciObjArrayKlassKlass*  ciEnv::_obj_array_klass_klass_instance;
  40 
  41 ciInstanceKlass* ciEnv::_ArrayStoreException;
  42 ciInstanceKlass* ciEnv::_Class;
  43 ciInstanceKlass* ciEnv::_ClassCastException;
  44 ciInstanceKlass* ciEnv::_InvokeDynamic;
  45 ciInstanceKlass* ciEnv::_Object;
  46 ciInstanceKlass* ciEnv::_Throwable;
  47 ciInstanceKlass* ciEnv::_Thread;
  48 ciInstanceKlass* ciEnv::_OutOfMemoryError;
  49 ciInstanceKlass* ciEnv::_String;
  50 ciInstanceKlass* ciEnv::_StringBuffer;
  51 ciInstanceKlass* ciEnv::_StringBuilder;
  52 ciInstanceKlass* ciEnv::_Integer;
  53 
  54 ciSymbol*        ciEnv::_unloaded_cisymbol = NULL;
  55 ciInstanceKlass* ciEnv::_unloaded_ciinstance_klass = NULL;
  56 ciObjArrayKlass* ciEnv::_unloaded_ciobjarrayklass = NULL;
  57 
  58 jobject ciEnv::_ArrayIndexOutOfBoundsException_handle = NULL;
  59 jobject ciEnv::_ArrayStoreException_handle = NULL;
  60 jobject ciEnv::_ClassCastException_handle = NULL;
  61 
  62 #ifndef PRODUCT
  63 static bool firstEnv = true;
  64 #endif /* PRODUCT */


 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 }
 766 
 767 
 768 // ------------------------------------------------------------------
 769 // ciEnv::get_instance_klass_for_declared_method_holder
 770 ciInstanceKlass* ciEnv::get_instance_klass_for_declared_method_holder(ciKlass* method_holder) {
 771   // For the case of <array>.clone(), the method holder can be a ciArrayKlass
 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 
 818 // ------------------------------------------------------------------
 819 // ciEnv::is_in_vm
 820 bool ciEnv::is_in_vm() {
 821   return JavaThread::current()->thread_state() == _thread_in_vm;


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