src/share/vm/oops/instanceKlass.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/oops

src/share/vm/oops/instanceKlass.cpp

Print this page
rev 29186 : Review changes 2


   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"

  26 #include "classfile/classFileParser.hpp"
  27 #include "classfile/classFileStream.hpp"
  28 #include "classfile/classLoader.hpp"
  29 #include "classfile/javaClasses.hpp"
  30 #include "classfile/systemDictionary.hpp"
  31 #include "classfile/systemDictionaryShared.hpp"
  32 #include "classfile/verifier.hpp"
  33 #include "classfile/vmSymbols.hpp"
  34 #include "code/dependencyContext.hpp"
  35 #include "compiler/compileBroker.hpp"
  36 #include "gc/shared/collectedHeap.inline.hpp"
  37 #include "gc/shared/specialized_oop_closures.hpp"
  38 #include "interpreter/oopMapCache.hpp"
  39 #include "interpreter/rewriter.hpp"
  40 #include "jvmtifiles/jvmti.h"
  41 #include "logging/log.hpp"
  42 #include "memory/heapInspection.hpp"
  43 #include "memory/iterator.inline.hpp"
  44 #include "memory/metadataFactory.hpp"
  45 #include "memory/metaspaceShared.hpp"
  46 #include "memory/oopFactory.hpp"
  47 #include "memory/resourceArea.hpp"
  48 #include "oops/fieldStreams.hpp"
  49 #include "oops/instanceClassLoaderKlass.hpp"
  50 #include "oops/instanceKlass.inline.hpp"
  51 #include "oops/instanceMirrorKlass.hpp"
  52 #include "oops/instanceOop.hpp"
  53 #include "oops/klass.inline.hpp"
  54 #include "oops/method.hpp"
  55 #include "oops/oop.inline.hpp"
  56 #include "oops/symbol.hpp"
  57 #include "prims/jvmtiExport.hpp"
  58 #include "prims/jvmtiRedefineClasses.hpp"
  59 #include "prims/jvmtiThreadState.hpp"
  60 #include "prims/methodComparator.hpp"
  61 #include "aot/aotLoader.hpp"
  62 #include "runtime/atomic.hpp"
  63 #include "runtime/fieldDescriptor.hpp"
  64 #include "runtime/handles.inline.hpp"
  65 #include "runtime/javaCalls.hpp"
  66 #include "runtime/mutexLocker.hpp"
  67 #include "runtime/orderAccess.inline.hpp"
  68 #include "runtime/thread.inline.hpp"
  69 #include "services/classLoadingService.hpp"
  70 #include "services/threadService.hpp"
  71 #include "utilities/dtrace.hpp"
  72 #include "utilities/macros.hpp"
  73 #include "utilities/stringUtils.hpp"
  74 #include "logging/log.hpp"
  75 #ifdef COMPILER1
  76 #include "c1/c1_Compiler.hpp"
  77 #endif
  78 
  79 #ifdef DTRACE_ENABLED
  80 
  81 


 773     if (!HAS_PENDING_EXCEPTION && this_k->has_nonstatic_concrete_methods()) {
 774       this_k->initialize_super_interfaces(this_k, THREAD);
 775     }
 776 
 777     // If any exceptions, complete abruptly, throwing the same exception as above.
 778     if (HAS_PENDING_EXCEPTION) {
 779       Handle e(THREAD, PENDING_EXCEPTION);
 780       CLEAR_PENDING_EXCEPTION;
 781       {
 782         EXCEPTION_MARK;
 783         // Locks object, set state, and notify all waiting threads
 784         this_k->set_initialization_state_and_notify(initialization_error, THREAD);
 785         CLEAR_PENDING_EXCEPTION;
 786       }
 787       DTRACE_CLASSINIT_PROBE_WAIT(super__failed, this_k(), -1,wait);
 788       THROW_OOP(e());
 789     }
 790   }
 791 
 792 
 793   if (UseAOT) {
 794     // Look for aot compiled methods for this klass, including class initializer.
 795     AOTLoader::load_for_klass(this_k, THREAD);
 796   }
 797 
 798   // Step 8
 799   {
 800     assert(THREAD->is_Java_thread(), "non-JavaThread in initialize_impl");
 801     JavaThread* jt = (JavaThread*)THREAD;
 802     DTRACE_CLASSINIT_PROBE_WAIT(clinit, this_k(), -1,wait);
 803     // Timer includes any side effects of class initialization (resolution,
 804     // etc), but not recursive entry into call_class_initializer().
 805     PerfClassTraceTime timer(ClassLoader::perf_class_init_time(),
 806                              ClassLoader::perf_class_init_selftime(),
 807                              ClassLoader::perf_classes_inited(),
 808                              jt->get_thread_stat()->perf_recursion_counts_addr(),
 809                              jt->get_thread_stat()->perf_timers_addr(),
 810                              PerfClassTraceTime::CLASS_CLINIT);
 811     this_k->call_class_initializer(THREAD);
 812   }
 813 
 814   // Step 9
 815   if (!HAS_PENDING_EXCEPTION) {
 816     this_k->set_initialization_state_and_notify(fully_initialized, CHECK);


1944             *klass = NULL;
1945           }
1946         }
1947       }
1948     }
1949   }
1950 }
1951 
1952 void InstanceKlass::clean_method_data(BoolObjectClosure* is_alive) {
1953   for (int m = 0; m < methods()->length(); m++) {
1954     MethodData* mdo = methods()->at(m)->method_data();
1955     if (mdo != NULL) {
1956       mdo->clean_method_data(is_alive);
1957     }
1958   }
1959 }
1960 
1961 bool InstanceKlass::supers_have_passed_fingerprint_checks() {
1962   if (java_super() != NULL && !java_super()->has_passed_fingerprint_check()) {
1963     ResourceMark rm;
1964     log_trace(classfingerprint)("%s : super %s not fingerprinted", external_name(), java_super()->external_name());
1965     return false;
1966   }
1967 
1968   Array<Klass*>* local_interfaces = this->local_interfaces();
1969   if (local_interfaces != NULL) {
1970     int length = local_interfaces->length();
1971     for (int i = 0; i < length; i++) {
1972       InstanceKlass* intf = InstanceKlass::cast(local_interfaces->at(i));
1973       if (!intf->has_passed_fingerprint_check()) {
1974         ResourceMark rm;
1975         log_trace(classfingerprint)("%s : interface %s not fingerprinted", external_name(), intf->external_name());
1976         return false;
1977       }
1978     }
1979   }
1980 
1981   return true;
1982 }
1983 
1984 bool InstanceKlass::should_store_fingerprint() {
1985 #if INCLUDE_AOT
1986   // We store the fingerprint into the InstanceKlass only in the following 2 cases:
1987   if (EnableJVMCI && !UseJVMCICompiler) {
1988     // (1) We are running AOT to generate a shared library.
1989     return true;
1990   }
1991   if (DumpSharedSpaces) {
1992     // (2) We are running -Xshare:dump to create a shared archive
1993     return true;
1994   }
1995 #endif


2006   return false;
2007 #endif
2008 }
2009 
2010 uint64_t InstanceKlass::get_stored_fingerprint() const {
2011   if (has_stored_fingerprint()) {
2012     address adr = adr_fingerprint();
2013     assert(adr != NULL, "sanity");
2014     return (uint64_t)Bytes::get_native_u8(adr); // adr may not be 64-bit aligned
2015   }
2016   return 0;
2017 }
2018 
2019 void InstanceKlass::store_fingerprint(uint64_t fingerprint) {
2020   assert(should_store_fingerprint(), "must be");
2021   address adr = adr_fingerprint();
2022   assert(adr != NULL, "sanity");
2023   Bytes::put_native_u8(adr, (u8)fingerprint); // adr may not be 64-bit aligned
2024 
2025   ResourceMark rm;
2026   log_trace(classfingerprint)("stored as " PTR64_FORMAT " for class %s", fingerprint, external_name());
2027 }
2028 
2029 static void remove_unshareable_in_class(Klass* k) {
2030   // remove klass's unshareable info
2031   k->remove_unshareable_info();
2032 }
2033 
2034 void InstanceKlass::remove_unshareable_info() {
2035   Klass::remove_unshareable_info();
2036   // Unlink the class
2037   if (is_linked()) {
2038     unlink_class();
2039   }
2040   init_implementor();
2041 
2042   constants()->remove_unshareable_info();
2043 
2044   assert(_dep_context == DependencyContext::EMPTY, "dependency context is not shareable");
2045 
2046   for (int i = 0; i < methods()->length(); i++) {




   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "aot/aotLoader.hpp"
  27 #include "classfile/classFileParser.hpp"
  28 #include "classfile/classFileStream.hpp"
  29 #include "classfile/classLoader.hpp"
  30 #include "classfile/javaClasses.hpp"
  31 #include "classfile/systemDictionary.hpp"
  32 #include "classfile/systemDictionaryShared.hpp"
  33 #include "classfile/verifier.hpp"
  34 #include "classfile/vmSymbols.hpp"
  35 #include "code/dependencyContext.hpp"
  36 #include "compiler/compileBroker.hpp"
  37 #include "gc/shared/collectedHeap.inline.hpp"
  38 #include "gc/shared/specialized_oop_closures.hpp"
  39 #include "interpreter/oopMapCache.hpp"
  40 #include "interpreter/rewriter.hpp"
  41 #include "jvmtifiles/jvmti.h"
  42 #include "logging/log.hpp"
  43 #include "memory/heapInspection.hpp"
  44 #include "memory/iterator.inline.hpp"
  45 #include "memory/metadataFactory.hpp"
  46 #include "memory/metaspaceShared.hpp"
  47 #include "memory/oopFactory.hpp"
  48 #include "memory/resourceArea.hpp"
  49 #include "oops/fieldStreams.hpp"
  50 #include "oops/instanceClassLoaderKlass.hpp"
  51 #include "oops/instanceKlass.inline.hpp"
  52 #include "oops/instanceMirrorKlass.hpp"
  53 #include "oops/instanceOop.hpp"
  54 #include "oops/klass.inline.hpp"
  55 #include "oops/method.hpp"
  56 #include "oops/oop.inline.hpp"
  57 #include "oops/symbol.hpp"
  58 #include "prims/jvmtiExport.hpp"
  59 #include "prims/jvmtiRedefineClasses.hpp"
  60 #include "prims/jvmtiThreadState.hpp"
  61 #include "prims/methodComparator.hpp"

  62 #include "runtime/atomic.hpp"
  63 #include "runtime/fieldDescriptor.hpp"
  64 #include "runtime/handles.inline.hpp"
  65 #include "runtime/javaCalls.hpp"
  66 #include "runtime/mutexLocker.hpp"
  67 #include "runtime/orderAccess.inline.hpp"
  68 #include "runtime/thread.inline.hpp"
  69 #include "services/classLoadingService.hpp"
  70 #include "services/threadService.hpp"
  71 #include "utilities/dtrace.hpp"
  72 #include "utilities/macros.hpp"
  73 #include "utilities/stringUtils.hpp"
  74 #include "logging/log.hpp"
  75 #ifdef COMPILER1
  76 #include "c1/c1_Compiler.hpp"
  77 #endif
  78 
  79 #ifdef DTRACE_ENABLED
  80 
  81 


 773     if (!HAS_PENDING_EXCEPTION && this_k->has_nonstatic_concrete_methods()) {
 774       this_k->initialize_super_interfaces(this_k, THREAD);
 775     }
 776 
 777     // If any exceptions, complete abruptly, throwing the same exception as above.
 778     if (HAS_PENDING_EXCEPTION) {
 779       Handle e(THREAD, PENDING_EXCEPTION);
 780       CLEAR_PENDING_EXCEPTION;
 781       {
 782         EXCEPTION_MARK;
 783         // Locks object, set state, and notify all waiting threads
 784         this_k->set_initialization_state_and_notify(initialization_error, THREAD);
 785         CLEAR_PENDING_EXCEPTION;
 786       }
 787       DTRACE_CLASSINIT_PROBE_WAIT(super__failed, this_k(), -1,wait);
 788       THROW_OOP(e());
 789     }
 790   }
 791 
 792 

 793   // Look for aot compiled methods for this klass, including class initializer.
 794   AOTLoader::load_for_klass(this_k, THREAD);

 795 
 796   // Step 8
 797   {
 798     assert(THREAD->is_Java_thread(), "non-JavaThread in initialize_impl");
 799     JavaThread* jt = (JavaThread*)THREAD;
 800     DTRACE_CLASSINIT_PROBE_WAIT(clinit, this_k(), -1,wait);
 801     // Timer includes any side effects of class initialization (resolution,
 802     // etc), but not recursive entry into call_class_initializer().
 803     PerfClassTraceTime timer(ClassLoader::perf_class_init_time(),
 804                              ClassLoader::perf_class_init_selftime(),
 805                              ClassLoader::perf_classes_inited(),
 806                              jt->get_thread_stat()->perf_recursion_counts_addr(),
 807                              jt->get_thread_stat()->perf_timers_addr(),
 808                              PerfClassTraceTime::CLASS_CLINIT);
 809     this_k->call_class_initializer(THREAD);
 810   }
 811 
 812   // Step 9
 813   if (!HAS_PENDING_EXCEPTION) {
 814     this_k->set_initialization_state_and_notify(fully_initialized, CHECK);


1942             *klass = NULL;
1943           }
1944         }
1945       }
1946     }
1947   }
1948 }
1949 
1950 void InstanceKlass::clean_method_data(BoolObjectClosure* is_alive) {
1951   for (int m = 0; m < methods()->length(); m++) {
1952     MethodData* mdo = methods()->at(m)->method_data();
1953     if (mdo != NULL) {
1954       mdo->clean_method_data(is_alive);
1955     }
1956   }
1957 }
1958 
1959 bool InstanceKlass::supers_have_passed_fingerprint_checks() {
1960   if (java_super() != NULL && !java_super()->has_passed_fingerprint_check()) {
1961     ResourceMark rm;
1962     log_trace(class, fingerprint)("%s : super %s not fingerprinted", external_name(), java_super()->external_name());
1963     return false;
1964   }
1965 
1966   Array<Klass*>* local_interfaces = this->local_interfaces();
1967   if (local_interfaces != NULL) {
1968     int length = local_interfaces->length();
1969     for (int i = 0; i < length; i++) {
1970       InstanceKlass* intf = InstanceKlass::cast(local_interfaces->at(i));
1971       if (!intf->has_passed_fingerprint_check()) {
1972         ResourceMark rm;
1973         log_trace(class, fingerprint)("%s : interface %s not fingerprinted", external_name(), intf->external_name());
1974         return false;
1975       }
1976     }
1977   }
1978 
1979   return true;
1980 }
1981 
1982 bool InstanceKlass::should_store_fingerprint() {
1983 #if INCLUDE_AOT
1984   // We store the fingerprint into the InstanceKlass only in the following 2 cases:
1985   if (EnableJVMCI && !UseJVMCICompiler) {
1986     // (1) We are running AOT to generate a shared library.
1987     return true;
1988   }
1989   if (DumpSharedSpaces) {
1990     // (2) We are running -Xshare:dump to create a shared archive
1991     return true;
1992   }
1993 #endif


2004   return false;
2005 #endif
2006 }
2007 
2008 uint64_t InstanceKlass::get_stored_fingerprint() const {
2009   if (has_stored_fingerprint()) {
2010     address adr = adr_fingerprint();
2011     assert(adr != NULL, "sanity");
2012     return (uint64_t)Bytes::get_native_u8(adr); // adr may not be 64-bit aligned
2013   }
2014   return 0;
2015 }
2016 
2017 void InstanceKlass::store_fingerprint(uint64_t fingerprint) {
2018   assert(should_store_fingerprint(), "must be");
2019   address adr = adr_fingerprint();
2020   assert(adr != NULL, "sanity");
2021   Bytes::put_native_u8(adr, (u8)fingerprint); // adr may not be 64-bit aligned
2022 
2023   ResourceMark rm;
2024   log_trace(class, fingerprint)("stored as " PTR64_FORMAT " for class %s", fingerprint, external_name());
2025 }
2026 
2027 static void remove_unshareable_in_class(Klass* k) {
2028   // remove klass's unshareable info
2029   k->remove_unshareable_info();
2030 }
2031 
2032 void InstanceKlass::remove_unshareable_info() {
2033   Klass::remove_unshareable_info();
2034   // Unlink the class
2035   if (is_linked()) {
2036     unlink_class();
2037   }
2038   init_implementor();
2039 
2040   constants()->remove_unshareable_info();
2041 
2042   assert(_dep_context == DependencyContext::EMPTY, "dependency context is not shareable");
2043 
2044   for (int i = 0; i < methods()->length(); i++) {


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