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 "jvm.h"
27 #include "classfile/classFileStream.hpp"
28 #include "classfile/classLoader.hpp"
29 #include "classfile/classLoaderData.inline.hpp"
30 #include "classfile/javaAssertions.hpp"
31 #include "classfile/javaClasses.inline.hpp"
32 #include "classfile/moduleEntry.hpp"
33 #include "classfile/modules.hpp"
34 #include "classfile/packageEntry.hpp"
35 #include "classfile/stringTable.hpp"
36 #include "classfile/symbolTable.hpp"
37 #include "classfile/systemDictionary.hpp"
38 #include "classfile/vmSymbols.hpp"
39 #include "gc/shared/collectedHeap.inline.hpp"
40 #include "interpreter/bytecode.hpp"
41 #include "interpreter/bytecodeUtils.hpp"
42 #include "jfr/jfrEvents.hpp"
43 #include "logging/log.hpp"
44 #include "memory/heapShared.hpp"
45 #include "memory/oopFactory.hpp"
46 #include "memory/referenceType.hpp"
47 #include "memory/resourceArea.hpp"
48 #include "memory/universe.hpp"
49 #include "oops/access.inline.hpp"
50 #include "oops/constantPool.hpp"
51 #include "oops/fieldStreams.inline.hpp"
52 #include "oops/instanceKlass.hpp"
53 #include "oops/method.hpp"
54 #include "oops/recordComponent.hpp"
55 #include "oops/objArrayKlass.hpp"
56 #include "oops/objArrayOop.inline.hpp"
57 #include "oops/oop.inline.hpp"
58 #include "prims/jvm_misc.hpp"
59 #include "prims/jvmtiExport.hpp"
60 #include "prims/jvmtiThreadState.hpp"
61 #include "prims/nativeLookup.hpp"
62 #include "prims/stackwalk.hpp"
63 #include "runtime/arguments.hpp"
3673 oop result = Reflection::invoke_constructor(constructor_mirror, args, CHECK_NULL);
3674 jobject res = JNIHandles::make_local(env, result);
3675 if (JvmtiExport::should_post_vm_object_alloc()) {
3676 JvmtiExport::post_vm_object_alloc(JavaThread::current(), result);
3677 }
3678 return res;
3679 JVM_END
3680
3681 // Atomic ///////////////////////////////////////////////////////////////////////////////////////////
3682
3683 JVM_LEAF(jboolean, JVM_SupportsCX8())
3684 JVMWrapper("JVM_SupportsCX8");
3685 return VM_Version::supports_cx8();
3686 JVM_END
3687
3688 JVM_ENTRY(void, JVM_InitializeFromArchive(JNIEnv* env, jclass cls))
3689 JVMWrapper("JVM_InitializeFromArchive");
3690 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve(cls));
3691 assert(k->is_klass(), "just checking");
3692 HeapShared::initialize_from_archived_subgraph(k);
3693 JVM_END
3694
3695 JVM_ENTRY_NO_ENV(jlong, JVM_GetRandomSeedForCDSDump())
3696 JVMWrapper("JVM_GetRandomSeedForCDSDump");
3697 if (DumpSharedSpaces) {
3698 const char* release = Abstract_VM_Version::vm_release();
3699 const char* dbg_level = Abstract_VM_Version::jdk_debug_level();
3700 const char* version = VM_Version::internal_vm_info_string();
3701 jlong seed = (jlong)(java_lang_String::hash_code((const jbyte*)release, (int)strlen(release)) ^
3702 java_lang_String::hash_code((const jbyte*)dbg_level, (int)strlen(dbg_level)) ^
3703 java_lang_String::hash_code((const jbyte*)version, (int)strlen(version)));
3704 seed += (jlong)Abstract_VM_Version::vm_major_version();
3705 seed += (jlong)Abstract_VM_Version::vm_minor_version();
3706 seed += (jlong)Abstract_VM_Version::vm_security_version();
3707 seed += (jlong)Abstract_VM_Version::vm_patch_version();
3708 if (seed == 0) { // don't let this ever be zero.
3709 seed = 0x87654321;
3710 }
3711 log_debug(cds)("JVM_GetRandomSeedForCDSDump() = " JLONG_FORMAT, seed);
3712 return seed;
|
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 "jvm.h"
27 #include "classfile/classFileStream.hpp"
28 #include "classfile/classLoader.hpp"
29 #include "classfile/classLoaderData.hpp"
30 #include "classfile/classLoaderData.inline.hpp"
31 #include "classfile/javaAssertions.hpp"
32 #include "classfile/javaClasses.inline.hpp"
33 #include "classfile/moduleEntry.hpp"
34 #include "classfile/modules.hpp"
35 #include "classfile/packageEntry.hpp"
36 #include "classfile/stringTable.hpp"
37 #include "classfile/symbolTable.hpp"
38 #include "classfile/systemDictionary.hpp"
39 #include "classfile/vmSymbols.hpp"
40 #include "gc/shared/collectedHeap.inline.hpp"
41 #include "interpreter/bytecode.hpp"
42 #include "interpreter/bytecodeUtils.hpp"
43 #include "jfr/jfrEvents.hpp"
44 #include "logging/log.hpp"
45 #include "memory/dynamicArchive.hpp"
46 #include "memory/heapShared.hpp"
47 #include "memory/oopFactory.hpp"
48 #include "memory/referenceType.hpp"
49 #include "memory/resourceArea.hpp"
50 #include "memory/universe.hpp"
51 #include "oops/access.inline.hpp"
52 #include "oops/constantPool.hpp"
53 #include "oops/fieldStreams.inline.hpp"
54 #include "oops/instanceKlass.hpp"
55 #include "oops/method.hpp"
56 #include "oops/recordComponent.hpp"
57 #include "oops/objArrayKlass.hpp"
58 #include "oops/objArrayOop.inline.hpp"
59 #include "oops/oop.inline.hpp"
60 #include "prims/jvm_misc.hpp"
61 #include "prims/jvmtiExport.hpp"
62 #include "prims/jvmtiThreadState.hpp"
63 #include "prims/nativeLookup.hpp"
64 #include "prims/stackwalk.hpp"
65 #include "runtime/arguments.hpp"
3675 oop result = Reflection::invoke_constructor(constructor_mirror, args, CHECK_NULL);
3676 jobject res = JNIHandles::make_local(env, result);
3677 if (JvmtiExport::should_post_vm_object_alloc()) {
3678 JvmtiExport::post_vm_object_alloc(JavaThread::current(), result);
3679 }
3680 return res;
3681 JVM_END
3682
3683 // Atomic ///////////////////////////////////////////////////////////////////////////////////////////
3684
3685 JVM_LEAF(jboolean, JVM_SupportsCX8())
3686 JVMWrapper("JVM_SupportsCX8");
3687 return VM_Version::supports_cx8();
3688 JVM_END
3689
3690 JVM_ENTRY(void, JVM_InitializeFromArchive(JNIEnv* env, jclass cls))
3691 JVMWrapper("JVM_InitializeFromArchive");
3692 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve(cls));
3693 assert(k->is_klass(), "just checking");
3694 HeapShared::initialize_from_archived_subgraph(k);
3695 JVM_END
3696
3697 JVM_ENTRY(void, JVM_RegisterLambdaProxyClassForArchiving(JNIEnv* env,
3698 jclass caller,
3699 jstring invokedName,
3700 jobject invokedType,
3701 jobject methodType,
3702 jobject implMethodMember,
3703 jobject instantiatedMethodType,
3704 jclass lambdaProxyClass))
3705 JVMWrapper("JVM_RegisterLambdaProxyClassForArchiving");
3706 if (!DynamicDumpSharedSpaces) {
3707 return;
3708 }
3709
3710 Klass* caller_k = java_lang_Class::as_Klass(JNIHandles::resolve(caller));
3711 InstanceKlass* caller_ik = InstanceKlass::cast(caller_k);
3712 Klass* lambda_k = java_lang_Class::as_Klass(JNIHandles::resolve(lambdaProxyClass));
3713 InstanceKlass* lambda_ik = InstanceKlass::cast(lambda_k);
3714
3715 Symbol* invoked_name = NULL;
3716 if (invokedName != NULL) {
3717 invoked_name = java_lang_String::as_symbol_or_null(JNIHandles::resolve_non_null(invokedName));
3718 }
3719 Handle invoked_type_oop(THREAD, JNIHandles::resolve_non_null(invokedType));
3720 Symbol* invoked_type = java_lang_invoke_MethodType::as_signature(invoked_type_oop(), false);
3721
3722 Handle method_type_oop(THREAD, JNIHandles::resolve_non_null(methodType));
3723 Symbol* method_type = java_lang_invoke_MethodType::as_signature(method_type_oop(), false);
3724
3725 Handle impl_method_member_oop(THREAD, JNIHandles::resolve_non_null(implMethodMember));
3726 assert(java_lang_invoke_MemberName::is_method(impl_method_member_oop()), "must be");
3727 Method* m = java_lang_invoke_MemberName::vmtarget(impl_method_member_oop());
3728
3729 Handle instantiated_method_type_oop(THREAD, JNIHandles::resolve_non_null(instantiatedMethodType));
3730 Symbol* instantiated_method_type = java_lang_invoke_MethodType::as_signature(instantiated_method_type_oop(), false);
3731
3732 SystemDictionaryShared::add_lambda_proxy_class(caller_ik, lambda_ik, invoked_name, invoked_type,
3733 method_type, m, instantiated_method_type);
3734
3735 JVM_END
3736
3737 JVM_ENTRY(jclass, JVM_LookupLambdaProxyClassFromArchive(JNIEnv* env,
3738 jclass caller,
3739 jstring invokedName,
3740 jobject invokedType,
3741 jobject methodType,
3742 jobject implMethodMember,
3743 jobject instantiatedMethodType))
3744 JVMWrapper("JVM_LookupLambdaProxyClassFromArchive");
3745 if (!DynamicArchive::is_mapped()) {
3746 return NULL;
3747 }
3748
3749 Klass* caller_k = java_lang_Class::as_Klass(JNIHandles::resolve(caller));
3750 InstanceKlass* caller_ik = InstanceKlass::cast(caller_k);
3751 if (!caller_ik->is_shared()) {
3752 // there won't be a shared lambda class if the caller_ik is not in the shared archive.
3753 return NULL;
3754 }
3755
3756 Symbol* invoked_name = NULL;
3757 if (invokedName != NULL) {
3758 invoked_name = java_lang_String::as_symbol_or_null(JNIHandles::resolve_non_null(invokedName));
3759 }
3760 Handle invoked_type_oop(THREAD, JNIHandles::resolve_non_null(invokedType));
3761 Symbol* invoked_type = java_lang_invoke_MethodType::as_signature(invoked_type_oop(), false);
3762
3763 Handle method_type_oop(THREAD, JNIHandles::resolve_non_null(methodType));
3764 Symbol* method_type = java_lang_invoke_MethodType::as_signature(method_type_oop(), false);
3765
3766 Handle impl_method_member_oop(THREAD, JNIHandles::resolve_non_null(implMethodMember));
3767 assert(java_lang_invoke_MemberName::is_method(impl_method_member_oop()), "must be");
3768 Method* m = java_lang_invoke_MemberName::vmtarget(impl_method_member_oop());
3769
3770 Handle instantiated_method_type_oop(THREAD, JNIHandles::resolve_non_null(instantiatedMethodType));
3771 Symbol* instantiated_method_type = java_lang_invoke_MethodType::as_signature(instantiated_method_type_oop(), false);
3772
3773 InstanceKlass* lambda_ik = SystemDictionaryShared::get_shared_lambda_proxy_class(caller_ik, invoked_name, invoked_type,
3774 method_type, m, instantiated_method_type);
3775 jclass jcls = NULL;
3776 if (lambda_ik != NULL) {
3777 InstanceKlass* loaded_lambda = SystemDictionaryShared::load_shared_lambda_proxy_class(lambda_ik, caller_ik, THREAD);
3778 jcls = loaded_lambda == NULL ? NULL : (jclass) JNIHandles::make_local(env, loaded_lambda->java_mirror());
3779 }
3780 return jcls;
3781 JVM_END
3782
3783 JVM_ENTRY(jboolean, JVM_IsCDSDumpingEnabled(JNIEnv* env))
3784 JVMWrapper("JVM_IsCDSDumpingEnable");
3785 return DynamicDumpSharedSpaces;
3786 JVM_END
3787
3788 JVM_ENTRY(jboolean, JVM_IsCDSSharingEnabled(JNIEnv* env))
3789 JVMWrapper("JVM_IsCDSSharingEnable");
3790 return UseSharedSpaces;
3791 JVM_END
3792
3793 JVM_ENTRY_NO_ENV(jlong, JVM_GetRandomSeedForCDSDump())
3794 JVMWrapper("JVM_GetRandomSeedForCDSDump");
3795 if (DumpSharedSpaces) {
3796 const char* release = Abstract_VM_Version::vm_release();
3797 const char* dbg_level = Abstract_VM_Version::jdk_debug_level();
3798 const char* version = VM_Version::internal_vm_info_string();
3799 jlong seed = (jlong)(java_lang_String::hash_code((const jbyte*)release, (int)strlen(release)) ^
3800 java_lang_String::hash_code((const jbyte*)dbg_level, (int)strlen(dbg_level)) ^
3801 java_lang_String::hash_code((const jbyte*)version, (int)strlen(version)));
3802 seed += (jlong)Abstract_VM_Version::vm_major_version();
3803 seed += (jlong)Abstract_VM_Version::vm_minor_version();
3804 seed += (jlong)Abstract_VM_Version::vm_security_version();
3805 seed += (jlong)Abstract_VM_Version::vm_patch_version();
3806 if (seed == 0) { // don't let this ever be zero.
3807 seed = 0x87654321;
3808 }
3809 log_debug(cds)("JVM_GetRandomSeedForCDSDump() = " JLONG_FORMAT, seed);
3810 return seed;
|