8244550: Unsafe::allocateInstance does redundant transitions
Reviewed-by: coleenp, mchung, dholmes
This commit is contained in:
parent
62bf2d07e7
commit
c2780c9556
src/hotspot/share
c1
classfile
jfr
leakprofiler
recorder/checkpoint/types/traceid
jvmci
oops
prims
runtime
@ -30,6 +30,7 @@
|
||||
#include "c1/c1_LIRAssembler.hpp"
|
||||
#include "c1/c1_MacroAssembler.hpp"
|
||||
#include "c1/c1_Runtime1.hpp"
|
||||
#include "classfile/javaClasses.inline.hpp"
|
||||
#include "classfile/systemDictionary.hpp"
|
||||
#include "classfile/vmSymbols.hpp"
|
||||
#include "code/codeBlob.hpp"
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "jimage.hpp"
|
||||
#include "classfile/classListParser.hpp"
|
||||
#include "classfile/classLoaderExt.hpp"
|
||||
#include "classfile/javaClasses.inline.hpp"
|
||||
#include "classfile/symbolTable.hpp"
|
||||
#include "classfile/systemDictionary.hpp"
|
||||
#include "classfile/systemDictionaryShared.hpp"
|
||||
|
@ -1495,14 +1495,6 @@ oop java_lang_Class::create_basic_type_mirror(const char* basic_type_name, Basic
|
||||
}
|
||||
|
||||
|
||||
Klass* java_lang_Class::as_Klass(oop java_class) {
|
||||
//%note memory_2
|
||||
assert(java_lang_Class::is_instance(java_class), "must be a Class object");
|
||||
Klass* k = ((Klass*)java_class->metadata_field(_klass_offset));
|
||||
assert(k == NULL || k->is_klass(), "type check");
|
||||
return k;
|
||||
}
|
||||
|
||||
Klass* java_lang_Class::as_Klass_raw(oop java_class) {
|
||||
//%note memory_2
|
||||
assert(java_lang_Class::is_instance(java_class), "must be a Class object");
|
||||
|
@ -211,6 +211,14 @@ inline bool java_lang_Class::is_instance(oop obj) {
|
||||
return obj != NULL && obj->klass() == SystemDictionary::Class_klass();
|
||||
}
|
||||
|
||||
inline Klass* java_lang_Class::as_Klass(oop java_class) {
|
||||
//%note memory_2
|
||||
assert(java_lang_Class::is_instance(java_class), "must be a Class object");
|
||||
Klass* k = ((Klass*)java_class->metadata_field(_klass_offset));
|
||||
assert(k == NULL || k->is_klass(), "type check");
|
||||
return k;
|
||||
}
|
||||
|
||||
inline bool java_lang_Class::is_primitive(oop java_class) {
|
||||
// should assert:
|
||||
//assert(java_lang_Class::is_instance(java_class), "must be a Class object");
|
||||
|
@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
#include "precompiled.hpp"
|
||||
#include "classfile/javaClasses.hpp"
|
||||
#include "classfile/javaClasses.inline.hpp"
|
||||
#include "jfr/leakprofiler/chains/edge.hpp"
|
||||
#include "jfr/leakprofiler/chains/edgeStore.hpp"
|
||||
#include "jfr/leakprofiler/chains/edgeUtils.hpp"
|
||||
|
@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
#include "precompiled.hpp"
|
||||
#include "classfile/javaClasses.hpp"
|
||||
#include "classfile/javaClasses.inline.hpp"
|
||||
#include "classfile/symbolTable.hpp"
|
||||
#include "classfile/systemDictionary.hpp"
|
||||
#include "jfr/leakprofiler/checkpoint/objectSampleDescription.hpp"
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include "precompiled.hpp"
|
||||
#include "classfile/classLoaderData.inline.hpp"
|
||||
#include "classfile/javaClasses.inline.hpp"
|
||||
#include "classfile/symbolTable.hpp"
|
||||
#include "jfr/recorder/checkpoint/types/traceid/jfrTraceId.inline.hpp"
|
||||
#include "jfr/utilities/jfrTypes.hpp"
|
||||
|
@ -22,6 +22,7 @@
|
||||
*/
|
||||
|
||||
#include "precompiled.hpp"
|
||||
#include "classfile/javaClasses.inline.hpp"
|
||||
#include "code/compiledIC.hpp"
|
||||
#include "compiler/compileBroker.hpp"
|
||||
#include "jvmci/jvmciCodeInstaller.hpp"
|
||||
|
@ -22,6 +22,7 @@
|
||||
*/
|
||||
|
||||
#include "precompiled.hpp"
|
||||
#include "classfile/javaClasses.inline.hpp"
|
||||
#include "classfile/symbolTable.hpp"
|
||||
#include "compiler/compileBroker.hpp"
|
||||
#include "jvmci/jniAccessMark.inline.hpp"
|
||||
|
@ -958,6 +958,7 @@ public:
|
||||
}
|
||||
// allocation
|
||||
instanceOop allocate_instance(TRAPS);
|
||||
static instanceOop allocate_instance(oop cls, TRAPS);
|
||||
|
||||
// additional member function to return a handle
|
||||
instanceHandle allocate_instance_handle(TRAPS);
|
||||
|
@ -157,4 +157,16 @@ ALWAYSINLINE void InstanceKlass::oop_oop_iterate_bounded(oop obj, OopClosureType
|
||||
oop_oop_iterate_oop_maps_bounded<T>(obj, closure, mr);
|
||||
}
|
||||
|
||||
inline instanceOop InstanceKlass::allocate_instance(oop java_class, TRAPS) {
|
||||
Klass* k = java_lang_Class::as_Klass(java_class);
|
||||
if (k == NULL) {
|
||||
ResourceMark rm(THREAD);
|
||||
THROW_(vmSymbols::java_lang_InstantiationException(), NULL);
|
||||
}
|
||||
InstanceKlass* ik = cast(k);
|
||||
ik->check_valid_for_instantiation(false, CHECK_NULL);
|
||||
ik->initialize(CHECK_NULL);
|
||||
return ik->allocate_instance(THREAD);
|
||||
}
|
||||
|
||||
#endif // SHARE_OOPS_INSTANCEKLASS_INLINE_HPP
|
||||
|
@ -49,7 +49,7 @@
|
||||
#include "memory/universe.hpp"
|
||||
#include "oops/access.inline.hpp"
|
||||
#include "oops/arrayOop.inline.hpp"
|
||||
#include "oops/instanceKlass.hpp"
|
||||
#include "oops/instanceKlass.inline.hpp"
|
||||
#include "oops/instanceOop.hpp"
|
||||
#include "oops/markWord.hpp"
|
||||
#include "oops/method.hpp"
|
||||
@ -1064,19 +1064,6 @@ static void jni_invoke_nonstatic(JNIEnv *env, JavaValue* result, jobject receive
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static instanceOop alloc_object(jclass clazz, TRAPS) {
|
||||
Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz));
|
||||
if (k == NULL) {
|
||||
ResourceMark rm(THREAD);
|
||||
THROW_(vmSymbols::java_lang_InstantiationException(), NULL);
|
||||
}
|
||||
k->check_valid_for_instantiation(false, CHECK_NULL);
|
||||
k->initialize(CHECK_NULL);
|
||||
instanceOop ih = InstanceKlass::cast(k)->allocate_instance(THREAD);
|
||||
return ih;
|
||||
}
|
||||
|
||||
DT_RETURN_MARK_DECL(AllocObject, jobject
|
||||
, HOTSPOT_JNI_ALLOCOBJECT_RETURN(_ret_ref));
|
||||
|
||||
@ -1088,7 +1075,7 @@ JNI_ENTRY(jobject, jni_AllocObject(JNIEnv *env, jclass clazz))
|
||||
jobject ret = NULL;
|
||||
DT_RETURN_MARK(AllocObject, jobject, (const jobject&)ret);
|
||||
|
||||
instanceOop i = alloc_object(clazz, CHECK_NULL);
|
||||
instanceOop i = InstanceKlass::allocate_instance(JNIHandles::resolve_non_null(clazz), CHECK_NULL);
|
||||
ret = JNIHandles::make_local(env, i);
|
||||
return ret;
|
||||
JNI_END
|
||||
@ -1104,7 +1091,7 @@ JNI_ENTRY(jobject, jni_NewObjectA(JNIEnv *env, jclass clazz, jmethodID methodID,
|
||||
jobject obj = NULL;
|
||||
DT_RETURN_MARK(NewObjectA, jobject, (const jobject)obj);
|
||||
|
||||
instanceOop i = alloc_object(clazz, CHECK_NULL);
|
||||
instanceOop i = InstanceKlass::allocate_instance(JNIHandles::resolve_non_null(clazz), CHECK_NULL);
|
||||
obj = JNIHandles::make_local(env, i);
|
||||
JavaValue jvalue(T_VOID);
|
||||
JNI_ArgumentPusherArray ap(methodID, args);
|
||||
@ -1124,7 +1111,7 @@ JNI_ENTRY(jobject, jni_NewObjectV(JNIEnv *env, jclass clazz, jmethodID methodID,
|
||||
jobject obj = NULL;
|
||||
DT_RETURN_MARK(NewObjectV, jobject, (const jobject&)obj);
|
||||
|
||||
instanceOop i = alloc_object(clazz, CHECK_NULL);
|
||||
instanceOop i = InstanceKlass::allocate_instance(JNIHandles::resolve_non_null(clazz), CHECK_NULL);
|
||||
obj = JNIHandles::make_local(env, i);
|
||||
JavaValue jvalue(T_VOID);
|
||||
JNI_ArgumentPusherVaArg ap(methodID, args);
|
||||
@ -1144,7 +1131,7 @@ JNI_ENTRY(jobject, jni_NewObject(JNIEnv *env, jclass clazz, jmethodID methodID,
|
||||
jobject obj = NULL;
|
||||
DT_RETURN_MARK(NewObject, jobject, (const jobject&)obj);
|
||||
|
||||
instanceOop i = alloc_object(clazz, CHECK_NULL);
|
||||
instanceOop i = InstanceKlass::allocate_instance(JNIHandles::resolve_non_null(clazz), CHECK_NULL);
|
||||
obj = JNIHandles::make_local(env, i);
|
||||
va_list args;
|
||||
va_start(args, methodID);
|
||||
|
@ -27,12 +27,14 @@
|
||||
#include "jvm.h"
|
||||
#include "classfile/classFileStream.hpp"
|
||||
#include "classfile/classLoader.hpp"
|
||||
#include "classfile/javaClasses.inline.hpp"
|
||||
#include "classfile/vmSymbols.hpp"
|
||||
#include "jfr/jfrEvents.hpp"
|
||||
#include "memory/allocation.inline.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
#include "oops/access.inline.hpp"
|
||||
#include "oops/fieldStreams.inline.hpp"
|
||||
#include "oops/instanceKlass.inline.hpp"
|
||||
#include "oops/objArrayOop.inline.hpp"
|
||||
#include "oops/oop.inline.hpp"
|
||||
#include "oops/typeArrayOop.inline.hpp"
|
||||
@ -353,8 +355,8 @@ UNSAFE_LEAF(void, Unsafe_FullFence(JNIEnv *env, jobject unsafe)) {
|
||||
////// Allocation requests
|
||||
|
||||
UNSAFE_ENTRY(jobject, Unsafe_AllocateInstance(JNIEnv *env, jobject unsafe, jclass cls)) {
|
||||
ThreadToNativeFromVM ttnfv(thread);
|
||||
return env->AllocObject(cls);
|
||||
instanceOop i = InstanceKlass::allocate_instance(JNIHandles::resolve_non_null(cls), CHECK_NULL);
|
||||
return JNIHandles::make_local(env, i);
|
||||
} UNSAFE_END
|
||||
|
||||
UNSAFE_ENTRY(jlong, Unsafe_AllocateMemory0(JNIEnv *env, jobject unsafe, jlong size)) {
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <new>
|
||||
|
||||
#include "classfile/classLoaderDataGraph.hpp"
|
||||
#include "classfile/javaClasses.inline.hpp"
|
||||
#include "classfile/modules.hpp"
|
||||
#include "classfile/protectionDomainCache.hpp"
|
||||
#include "classfile/stringTable.hpp"
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
#include "precompiled.hpp"
|
||||
#include "jvm.h"
|
||||
#include "classfile/javaClasses.inline.hpp"
|
||||
#include "classfile/symbolTable.hpp"
|
||||
#include "classfile/systemDictionary.hpp"
|
||||
#include "code/codeCache.hpp"
|
||||
|
@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
#include "precompiled.hpp"
|
||||
#include "classfile/javaClasses.hpp"
|
||||
#include "classfile/javaClasses.inline.hpp"
|
||||
#include "classfile/systemDictionary.hpp"
|
||||
#include "classfile/vmSymbols.hpp"
|
||||
#include "code/codeCache.hpp"
|
||||
|
Loading…
x
Reference in New Issue
Block a user