--- old/src/share/vm/oops/instanceKlass.cpp 2016-11-03 14:16:43.000000000 -0700 +++ new/src/share/vm/oops/instanceKlass.cpp 2016-11-03 14:16:43.000000000 -0700 @@ -23,8 +23,10 @@ */ #include "precompiled.hpp" +#include "aot/aotLoader.hpp" #include "classfile/classFileParser.hpp" #include "classfile/classFileStream.hpp" +#include "classfile/classLoader.hpp" #include "classfile/javaClasses.hpp" #include "classfile/systemDictionary.hpp" #include "classfile/systemDictionaryShared.hpp" @@ -144,7 +146,8 @@ parser.itable_size(), nonstatic_oop_map_size(parser.total_oop_map_count()), parser.is_interface(), - parser.is_anonymous()); + parser.is_anonymous(), + should_store_fingerprint()); const Symbol* const class_name = parser.class_name(); assert(class_name != NULL, "invariant"); @@ -787,6 +790,9 @@ } + // Look for aot compiled methods for this klass, including class initializer. + AOTLoader::load_for_klass(this_k, THREAD); + // Step 8 { assert(THREAD->is_Java_thread(), "non-JavaThread in initialize_impl"); @@ -1950,6 +1956,73 @@ } } +bool InstanceKlass::supers_have_passed_fingerprint_checks() { + if (java_super() != NULL && !java_super()->has_passed_fingerprint_check()) { + ResourceMark rm; + log_trace(class, fingerprint)("%s : super %s not fingerprinted", external_name(), java_super()->external_name()); + return false; + } + + Array* local_interfaces = this->local_interfaces(); + if (local_interfaces != NULL) { + int length = local_interfaces->length(); + for (int i = 0; i < length; i++) { + InstanceKlass* intf = InstanceKlass::cast(local_interfaces->at(i)); + if (!intf->has_passed_fingerprint_check()) { + ResourceMark rm; + log_trace(class, fingerprint)("%s : interface %s not fingerprinted", external_name(), intf->external_name()); + return false; + } + } + } + + return true; +} + +bool InstanceKlass::should_store_fingerprint() { +#if INCLUDE_AOT + // We store the fingerprint into the InstanceKlass only in the following 2 cases: + if (EnableJVMCI && !UseJVMCICompiler) { + // (1) We are running AOT to generate a shared library. + return true; + } + if (DumpSharedSpaces) { + // (2) We are running -Xshare:dump to create a shared archive + return true; + } +#endif + + // In all other cases we might set the _misc_has_passed_fingerprint_check bit, + // but do not store the 64-bit fingerprint to save space. + return false; +} + +bool InstanceKlass::has_stored_fingerprint() const { +#if INCLUDE_AOT + return should_store_fingerprint() || is_shared(); +#else + return false; +#endif +} + +uint64_t InstanceKlass::get_stored_fingerprint() const { + if (has_stored_fingerprint()) { + address adr = adr_fingerprint(); + assert(adr != NULL, "sanity"); + return (uint64_t)Bytes::get_native_u8(adr); // adr may not be 64-bit aligned + } + return 0; +} + +void InstanceKlass::store_fingerprint(uint64_t fingerprint) { + assert(should_store_fingerprint(), "must be"); + address adr = adr_fingerprint(); + assert(adr != NULL, "sanity"); + Bytes::put_native_u8(adr, (u8)fingerprint); // adr may not be 64-bit aligned + + ResourceMark rm; + log_trace(class, fingerprint)("stored as " PTR64_FORMAT " for class %s", fingerprint, external_name()); +} static void remove_unshareable_in_class(Klass* k) { // remove klass's unshareable info