Mercurial > hg > graal-jvmci-8
diff src/share/vm/prims/unsafe.cpp @ 20415:47e3110c47e8
6642881: Improve performance of Class.getClassLoader()
Summary: Add classLoader to java/lang/Class instance for fast access
Reviewed-by: alanb, lfoltan, rriggs, vlivanov, twisti, jfranck
author | coleenp |
---|---|
date | Fri, 05 Sep 2014 16:01:29 -0400 |
parents | c49dcaf78a65 |
children | 7848fc12602b f46871c6c063 |
line wrap: on
line diff
--- a/src/share/vm/prims/unsafe.cpp Fri Sep 05 00:28:43 2014 +0200 +++ b/src/share/vm/prims/unsafe.cpp Fri Sep 05 16:01:29 2014 -0400 @@ -953,6 +953,14 @@ } UNSAFE_END +static jobject get_class_loader(JNIEnv* env, jclass cls) { + if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(cls))) { + return NULL; + } + Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); + oop loader = k->class_loader(); + return JNIHandles::make_local(env, loader); +} UNSAFE_ENTRY(jclass, Unsafe_DefineClass0(JNIEnv *env, jobject unsafe, jstring name, jbyteArray data, int offset, int length)) UnsafeWrapper("Unsafe_DefineClass"); @@ -961,7 +969,7 @@ int depthFromDefineClass0 = 1; jclass caller = JVM_GetCallerClass(env, depthFromDefineClass0); - jobject loader = (caller == NULL) ? NULL : JVM_GetClassLoader(env, caller); + jobject loader = (caller == NULL) ? NULL : get_class_loader(env, caller); jobject pd = (caller == NULL) ? NULL : JVM_GetProtectionDomain(env, caller); return Unsafe_DefineClass_impl(env, name, data, offset, length, loader, pd);