comparison src/share/vm/ci/ciMethod.cpp @ 2007:5ddfcf4b079e

7003554: (tiered) assert(is_null_object() || handle() != NULL) failed: cannot embed null pointer Summary: C1 with profiling doesn't check whether the MDO has been really allocated, which can silently fail if the perm gen is full. The solution is to check if the allocation failed and bailout out of inlining or compilation. Reviewed-by: kvn, never
author iveresov
date Thu, 02 Dec 2010 17:21:12 -0800
parents f95d63e2154a
children 3582bf76420e
comparison
equal deleted inserted replaced
2006:bbefa3ca1543 2007:5ddfcf4b079e
795 return CURRENT_THREAD_ENV->get_object(mtype)->as_instance(); 795 return CURRENT_THREAD_ENV->get_object(mtype)->as_instance();
796 } 796 }
797 797
798 798
799 // ------------------------------------------------------------------ 799 // ------------------------------------------------------------------
800 // ciMethod::build_method_data 800 // ciMethod::ensure_method_data
801 // 801 //
802 // Generate new methodDataOop objects at compile time. 802 // Generate new methodDataOop objects at compile time.
803 void ciMethod::build_method_data(methodHandle h_m) { 803 // Return true if allocation was successful or no MDO is required.
804 bool ciMethod::ensure_method_data(methodHandle h_m) {
804 EXCEPTION_CONTEXT; 805 EXCEPTION_CONTEXT;
805 if (is_native() || is_abstract() || h_m()->is_accessor()) return; 806 if (is_native() || is_abstract() || h_m()->is_accessor()) return true;
806 if (h_m()->method_data() == NULL) { 807 if (h_m()->method_data() == NULL) {
807 methodOopDesc::build_interpreter_method_data(h_m, THREAD); 808 methodOopDesc::build_interpreter_method_data(h_m, THREAD);
808 if (HAS_PENDING_EXCEPTION) { 809 if (HAS_PENDING_EXCEPTION) {
809 CLEAR_PENDING_EXCEPTION; 810 CLEAR_PENDING_EXCEPTION;
810 } 811 }
811 } 812 }
813 if (h_m()->method_data() != NULL) {
814 _method_data = CURRENT_ENV->get_object(h_m()->method_data())->as_method_data();
815 _method_data->load_data();
816 return true;
817 } else {
818 _method_data = CURRENT_ENV->get_empty_methodData();
819 return false;
820 }
821 }
822
823 // public, retroactive version
824 bool ciMethod::ensure_method_data() {
825 bool result = true;
826 if (_method_data == NULL || _method_data->is_empty()) {
827 GUARDED_VM_ENTRY({
828 result = ensure_method_data(get_methodOop());
829 });
830 }
831 return result;
832 }
833
834
835 // ------------------------------------------------------------------
836 // ciMethod::method_data
837 //
838 ciMethodData* ciMethod::method_data() {
839 if (_method_data != NULL) {
840 return _method_data;
841 }
842 VM_ENTRY_MARK;
843 ciEnv* env = CURRENT_ENV;
844 Thread* my_thread = JavaThread::current();
845 methodHandle h_m(my_thread, get_methodOop());
846
812 if (h_m()->method_data() != NULL) { 847 if (h_m()->method_data() != NULL) {
813 _method_data = CURRENT_ENV->get_object(h_m()->method_data())->as_method_data(); 848 _method_data = CURRENT_ENV->get_object(h_m()->method_data())->as_method_data();
814 _method_data->load_data(); 849 _method_data->load_data();
815 } else { 850 } else {
816 _method_data = CURRENT_ENV->get_empty_methodData(); 851 _method_data = CURRENT_ENV->get_empty_methodData();
817 } 852 }
818 }
819
820 // public, retroactive version
821 void ciMethod::build_method_data() {
822 if (_method_data == NULL || _method_data->is_empty()) {
823 GUARDED_VM_ENTRY({
824 build_method_data(get_methodOop());
825 });
826 }
827 }
828
829
830 // ------------------------------------------------------------------
831 // ciMethod::method_data
832 //
833 ciMethodData* ciMethod::method_data() {
834 if (_method_data != NULL) {
835 return _method_data;
836 }
837 VM_ENTRY_MARK;
838 ciEnv* env = CURRENT_ENV;
839 Thread* my_thread = JavaThread::current();
840 methodHandle h_m(my_thread, get_methodOop());
841
842 // Create an MDO for the inlinee
843 if (TieredCompilation && is_c1_compile(env->comp_level())) {
844 build_method_data(h_m);
845 }
846
847 if (h_m()->method_data() != NULL) {
848 _method_data = CURRENT_ENV->get_object(h_m()->method_data())->as_method_data();
849 _method_data->load_data();
850 } else {
851 _method_data = CURRENT_ENV->get_empty_methodData();
852 }
853 return _method_data; 853 return _method_data;
854 854
855 } 855 }
856 856
857 // ------------------------------------------------------------------
858 // ciMethod::method_data_or_null
859 // Returns a pointer to ciMethodData if MDO exists on the VM side,
860 // NULL otherwise.
861 ciMethodData* ciMethod::method_data_or_null() {
862 ciMethodData *md = method_data();
863 if (md->is_empty()) return NULL;
864 return md;
865 }
857 866
858 // ------------------------------------------------------------------ 867 // ------------------------------------------------------------------
859 // ciMethod::will_link 868 // ciMethod::will_link
860 // 869 //
861 // Will this method link in a specific calling context? 870 // Will this method link in a specific calling context?