8203381: Replace InstanceKlass::allocate_instance_handle with JavaCalls::construct_new_instance
Reviewed-by: lfoltan, dholmes, coleenp, minqi
This commit is contained in:
parent
f0e6200376
commit
1ae12b4328
@ -3249,17 +3249,9 @@ int java_lang_Module::_module_entry_offset = -1;
|
||||
|
||||
Handle java_lang_Module::create(Handle loader, Handle module_name, TRAPS) {
|
||||
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
||||
|
||||
Symbol* name = vmSymbols::java_lang_Module();
|
||||
Klass* k = SystemDictionary::resolve_or_fail(name, true, CHECK_NH);
|
||||
InstanceKlass* ik = InstanceKlass::cast(k);
|
||||
Handle jlmh = ik->allocate_instance_handle(CHECK_NH);
|
||||
JavaValue result(T_VOID);
|
||||
JavaCalls::call_special(&result, jlmh, ik,
|
||||
vmSymbols::object_initializer_name(),
|
||||
return JavaCalls::construct_new_instance(SystemDictionary::Module_klass(),
|
||||
vmSymbols::java_lang_module_init_signature(),
|
||||
loader, module_name, CHECK_NH);
|
||||
return jlmh;
|
||||
}
|
||||
|
||||
#define MODULE_FIELDS_DO(macro) \
|
||||
|
@ -728,24 +728,14 @@ void CompileBroker::compilation_init_phase2() {
|
||||
}
|
||||
|
||||
Handle CompileBroker::create_thread_oop(const char* name, TRAPS) {
|
||||
Klass* k = SystemDictionary::find(vmSymbols::java_lang_Thread(), Handle(), Handle(), CHECK_NH);
|
||||
assert(k != NULL, "must be initialized");
|
||||
InstanceKlass* klass = InstanceKlass::cast(k);
|
||||
instanceHandle thread_handle = klass->allocate_instance_handle(CHECK_NH);
|
||||
Handle string = java_lang_String::create_from_str(name, CHECK_NH);
|
||||
|
||||
// Initialize thread_oop to put it into the system threadGroup
|
||||
Handle thread_group(THREAD, Universe::system_thread_group());
|
||||
JavaValue result(T_VOID);
|
||||
JavaCalls::call_special(&result, thread_handle,
|
||||
klass,
|
||||
vmSymbols::object_initializer_name(),
|
||||
return JavaCalls::construct_new_instance(
|
||||
SystemDictionary::Thread_klass(),
|
||||
vmSymbols::threadgroup_string_void_signature(),
|
||||
thread_group,
|
||||
string,
|
||||
CHECK_NH);
|
||||
|
||||
return thread_handle;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1200,11 +1200,8 @@ static bool is_authorized(Handle context, InstanceKlass* klass, TRAPS) {
|
||||
// and null permissions - which gives no permissions.
|
||||
oop create_dummy_access_control_context(TRAPS) {
|
||||
InstanceKlass* pd_klass = SystemDictionary::ProtectionDomain_klass();
|
||||
Handle obj = pd_klass->allocate_instance_handle(CHECK_NULL);
|
||||
// Call constructor ProtectionDomain(null, null);
|
||||
JavaValue result(T_VOID);
|
||||
JavaCalls::call_special(&result, obj, pd_klass,
|
||||
vmSymbols::object_initializer_name(),
|
||||
Handle obj = JavaCalls::construct_new_instance(pd_klass,
|
||||
vmSymbols::codesource_permissioncollection_signature(),
|
||||
Handle(), Handle(), CHECK_NULL);
|
||||
|
||||
|
@ -446,31 +446,25 @@ void os::init_before_ergo() {
|
||||
void os::initialize_jdk_signal_support(TRAPS) {
|
||||
if (!ReduceSignalUsage) {
|
||||
// Setup JavaThread for processing signals
|
||||
Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), true, CHECK);
|
||||
InstanceKlass* ik = InstanceKlass::cast(k);
|
||||
instanceHandle thread_oop = ik->allocate_instance_handle(CHECK);
|
||||
|
||||
const char thread_name[] = "Signal Dispatcher";
|
||||
Handle string = java_lang_String::create_from_str(thread_name, CHECK);
|
||||
|
||||
// Initialize thread_oop to put it into the system threadGroup
|
||||
Handle thread_group (THREAD, Universe::system_thread_group());
|
||||
JavaValue result(T_VOID);
|
||||
JavaCalls::call_special(&result, thread_oop,
|
||||
ik,
|
||||
vmSymbols::object_initializer_name(),
|
||||
Handle thread_oop = JavaCalls::construct_new_instance(SystemDictionary::Thread_klass(),
|
||||
vmSymbols::threadgroup_string_void_signature(),
|
||||
thread_group,
|
||||
string,
|
||||
CHECK);
|
||||
|
||||
Klass* group = SystemDictionary::ThreadGroup_klass();
|
||||
JavaValue result(T_VOID);
|
||||
JavaCalls::call_special(&result,
|
||||
thread_group,
|
||||
group,
|
||||
vmSymbols::add_method_name(),
|
||||
vmSymbols::thread_void_signature(),
|
||||
thread_oop, // ARG 1
|
||||
thread_oop,
|
||||
CHECK);
|
||||
|
||||
{ MutexLocker mu(Threads_lock);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -39,19 +39,13 @@ ServiceThread* ServiceThread::_instance = NULL;
|
||||
void ServiceThread::initialize() {
|
||||
EXCEPTION_MARK;
|
||||
|
||||
InstanceKlass* klass = SystemDictionary::Thread_klass();
|
||||
instanceHandle thread_oop = klass->allocate_instance_handle(CHECK);
|
||||
|
||||
const char* name = "Service Thread";
|
||||
|
||||
Handle string = java_lang_String::create_from_str(name, CHECK);
|
||||
|
||||
// Initialize thread_oop to put it into the system threadGroup
|
||||
Handle thread_group (THREAD, Universe::system_thread_group());
|
||||
JavaValue result(T_VOID);
|
||||
JavaCalls::call_special(&result, thread_oop,
|
||||
klass,
|
||||
vmSymbols::object_initializer_name(),
|
||||
Handle thread_oop = JavaCalls::construct_new_instance(
|
||||
SystemDictionary::Thread_klass(),
|
||||
vmSymbols::threadgroup_string_void_signature(),
|
||||
thread_group,
|
||||
string,
|
||||
|
@ -1025,44 +1025,32 @@ static void initialize_class(Symbol* class_name, TRAPS) {
|
||||
|
||||
// Creates the initial ThreadGroup
|
||||
static Handle create_initial_thread_group(TRAPS) {
|
||||
Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_ThreadGroup(), true, CHECK_NH);
|
||||
InstanceKlass* ik = InstanceKlass::cast(k);
|
||||
|
||||
Handle system_instance = ik->allocate_instance_handle(CHECK_NH);
|
||||
{
|
||||
JavaValue result(T_VOID);
|
||||
JavaCalls::call_special(&result,
|
||||
system_instance,
|
||||
ik,
|
||||
vmSymbols::object_initializer_name(),
|
||||
Handle system_instance = JavaCalls::construct_new_instance(
|
||||
SystemDictionary::ThreadGroup_klass(),
|
||||
vmSymbols::void_method_signature(),
|
||||
CHECK_NH);
|
||||
}
|
||||
Universe::set_system_thread_group(system_instance());
|
||||
|
||||
Handle main_instance = ik->allocate_instance_handle(CHECK_NH);
|
||||
{
|
||||
JavaValue result(T_VOID);
|
||||
Handle string = java_lang_String::create_from_str("main", CHECK_NH);
|
||||
JavaCalls::call_special(&result,
|
||||
main_instance,
|
||||
ik,
|
||||
vmSymbols::object_initializer_name(),
|
||||
Handle main_instance = JavaCalls::construct_new_instance(
|
||||
SystemDictionary::ThreadGroup_klass(),
|
||||
vmSymbols::threadgroup_string_void_signature(),
|
||||
system_instance,
|
||||
string,
|
||||
CHECK_NH);
|
||||
}
|
||||
return main_instance;
|
||||
}
|
||||
|
||||
// Creates the initial Thread
|
||||
static oop create_initial_thread(Handle thread_group, JavaThread* thread,
|
||||
TRAPS) {
|
||||
Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), true, CHECK_NULL);
|
||||
InstanceKlass* ik = InstanceKlass::cast(k);
|
||||
InstanceKlass* ik = SystemDictionary::Thread_klass();
|
||||
assert(ik->is_initialized(), "must be");
|
||||
instanceHandle thread_oop = ik->allocate_instance_handle(CHECK_NULL);
|
||||
|
||||
// Cannot use JavaCalls::construct_new_instance because the java.lang.Thread
|
||||
// constructor calls Thread.current(), which must be set here for the
|
||||
// initial thread.
|
||||
java_lang_Thread::set_thread(thread_oop(), thread);
|
||||
java_lang_Thread::set_priority(thread_oop(), NormPriority);
|
||||
thread->set_threadObj(thread_oop());
|
||||
@ -1170,10 +1158,13 @@ void JavaThread::allocate_threadObj(Handle thread_group, const char* thread_name
|
||||
assert(thread_group.not_null(), "thread group should be specified");
|
||||
assert(threadObj() == NULL, "should only create Java thread object once");
|
||||
|
||||
Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), true, CHECK);
|
||||
InstanceKlass* ik = InstanceKlass::cast(k);
|
||||
InstanceKlass* ik = SystemDictionary::Thread_klass();
|
||||
assert(ik->is_initialized(), "must be");
|
||||
instanceHandle thread_oop = ik->allocate_instance_handle(CHECK);
|
||||
|
||||
// We are called from jni_AttachCurrentThread/jni_AttachCurrentThreadAsDaemon.
|
||||
// We cannot use JavaCalls::construct_new_instance because the java.lang.Thread
|
||||
// constructor calls Thread.current(), which must be set here.
|
||||
java_lang_Thread::set_thread(thread_oop(), this);
|
||||
java_lang_Thread::set_priority(thread_oop(), NormPriority);
|
||||
set_threadObj(thread_oop());
|
||||
@ -1187,8 +1178,8 @@ void JavaThread::allocate_threadObj(Handle thread_group, const char* thread_name
|
||||
ik,
|
||||
vmSymbols::object_initializer_name(),
|
||||
vmSymbols::threadgroup_string_void_signature(),
|
||||
thread_group, // Argument 1
|
||||
name, // Argument 2
|
||||
thread_group,
|
||||
name,
|
||||
THREAD);
|
||||
} else {
|
||||
// Thread gets assigned name "Thread-nnn" and null target
|
||||
@ -1198,8 +1189,8 @@ void JavaThread::allocate_threadObj(Handle thread_group, const char* thread_name
|
||||
ik,
|
||||
vmSymbols::object_initializer_name(),
|
||||
vmSymbols::threadgroup_runnable_void_signature(),
|
||||
thread_group, // Argument 1
|
||||
Handle(), // Argument 2
|
||||
thread_group,
|
||||
Handle(),
|
||||
THREAD);
|
||||
}
|
||||
|
||||
|
@ -409,16 +409,6 @@ bool AttachListener::has_init_error(TRAPS) {
|
||||
// Starts the Attach Listener thread
|
||||
void AttachListener::init() {
|
||||
EXCEPTION_MARK;
|
||||
Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), true, THREAD);
|
||||
if (has_init_error(THREAD)) {
|
||||
return;
|
||||
}
|
||||
|
||||
InstanceKlass* klass = InstanceKlass::cast(k);
|
||||
instanceHandle thread_oop = klass->allocate_instance_handle(THREAD);
|
||||
if (has_init_error(THREAD)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const char thread_name[] = "Attach Listener";
|
||||
Handle string = java_lang_String::create_from_str(thread_name, THREAD);
|
||||
@ -428,26 +418,23 @@ void AttachListener::init() {
|
||||
|
||||
// Initialize thread_oop to put it into the system threadGroup
|
||||
Handle thread_group (THREAD, Universe::system_thread_group());
|
||||
JavaValue result(T_VOID);
|
||||
JavaCalls::call_special(&result, thread_oop,
|
||||
klass,
|
||||
vmSymbols::object_initializer_name(),
|
||||
Handle thread_oop = JavaCalls::construct_new_instance(SystemDictionary::Thread_klass(),
|
||||
vmSymbols::threadgroup_string_void_signature(),
|
||||
thread_group,
|
||||
string,
|
||||
THREAD);
|
||||
|
||||
if (has_init_error(THREAD)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Klass* group = SystemDictionary::ThreadGroup_klass();
|
||||
JavaValue result(T_VOID);
|
||||
JavaCalls::call_special(&result,
|
||||
thread_group,
|
||||
group,
|
||||
vmSymbols::add_method_name(),
|
||||
vmSymbols::thread_void_signature(),
|
||||
thread_oop, // ARG 1
|
||||
thread_oop,
|
||||
THREAD);
|
||||
if (has_init_error(THREAD)) {
|
||||
return;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -133,32 +133,20 @@ static Handle createGcInfo(GCMemoryManager *gcManager, GCStatInfo *gcStatInfo,TR
|
||||
// The type is 'I'
|
||||
objArrayOop extra_args_array = oopFactory::new_objArray(SystemDictionary::Integer_klass(), 1, CHECK_NH);
|
||||
objArrayHandle extra_array (THREAD, extra_args_array);
|
||||
InstanceKlass* intK = SystemDictionary::Integer_klass();
|
||||
|
||||
instanceHandle extra_arg_val = intK->allocate_instance_handle(CHECK_NH);
|
||||
|
||||
{
|
||||
JavaValue res(T_VOID);
|
||||
JavaCallArguments argsInt;
|
||||
argsInt.push_oop(extra_arg_val);
|
||||
argsInt.push_int(gcManager->num_gc_threads());
|
||||
|
||||
JavaCalls::call_special(&res,
|
||||
intK,
|
||||
vmSymbols::object_initializer_name(),
|
||||
Handle extra_arg_val = JavaCalls::construct_new_instance(
|
||||
SystemDictionary::Integer_klass(),
|
||||
vmSymbols::int_void_signature(),
|
||||
&argsInt,
|
||||
CHECK_NH);
|
||||
}
|
||||
|
||||
extra_array->obj_at_put(0,extra_arg_val());
|
||||
|
||||
InstanceKlass* gcInfoklass = Management::com_sun_management_GcInfo_klass(CHECK_NH);
|
||||
|
||||
Handle gcInfo_instance = gcInfoklass->allocate_instance_handle(CHECK_NH);
|
||||
|
||||
JavaValue constructor_result(T_VOID);
|
||||
JavaCallArguments constructor_args(16);
|
||||
constructor_args.push_oop(gcInfo_instance);
|
||||
constructor_args.push_oop(getGcInfoBuilder(gcManager,THREAD));
|
||||
constructor_args.push_long(gcStatInfo->gc_index());
|
||||
constructor_args.push_long(Management::ticks_to_ms(gcStatInfo->start_time()));
|
||||
@ -167,14 +155,11 @@ static Handle createGcInfo(GCMemoryManager *gcManager, GCStatInfo *gcStatInfo,TR
|
||||
constructor_args.push_oop(usage_after_gc_ah);
|
||||
constructor_args.push_oop(extra_array);
|
||||
|
||||
JavaCalls::call_special(&constructor_result,
|
||||
return JavaCalls::construct_new_instance(
|
||||
gcInfoklass,
|
||||
vmSymbols::object_initializer_name(),
|
||||
vmSymbols::com_sun_management_GcInfo_constructor_signature(),
|
||||
&constructor_args,
|
||||
CHECK_NH);
|
||||
|
||||
return Handle(THREAD, gcInfo_instance());
|
||||
}
|
||||
|
||||
void GCNotifier::sendNotification(TRAPS) {
|
||||
|
@ -337,26 +337,17 @@ static void initialize_ThreadInfo_constructor_arguments(JavaCallArguments* args,
|
||||
// Helper function to construct a ThreadInfo object
|
||||
instanceOop Management::create_thread_info_instance(ThreadSnapshot* snapshot, TRAPS) {
|
||||
InstanceKlass* ik = Management::java_lang_management_ThreadInfo_klass(CHECK_NULL);
|
||||
|
||||
JavaValue result(T_VOID);
|
||||
JavaCallArguments args(14);
|
||||
|
||||
// First allocate a ThreadObj object and
|
||||
// push the receiver as the first argument
|
||||
Handle element = ik->allocate_instance_handle(CHECK_NULL);
|
||||
args.push_oop(element);
|
||||
|
||||
// initialize the arguments for the ThreadInfo constructor
|
||||
initialize_ThreadInfo_constructor_arguments(&args, snapshot, CHECK_NULL);
|
||||
|
||||
// Call ThreadInfo constructor with no locked monitors and synchronizers
|
||||
JavaCalls::call_special(&result,
|
||||
Handle element = JavaCalls::construct_new_instance(
|
||||
ik,
|
||||
vmSymbols::object_initializer_name(),
|
||||
vmSymbols::java_lang_management_ThreadInfo_constructor_signature(),
|
||||
&args,
|
||||
CHECK_NULL);
|
||||
|
||||
return (instanceOop) element();
|
||||
}
|
||||
|
||||
@ -366,15 +357,8 @@ instanceOop Management::create_thread_info_instance(ThreadSnapshot* snapshot,
|
||||
objArrayHandle synchronizers_array,
|
||||
TRAPS) {
|
||||
InstanceKlass* ik = Management::java_lang_management_ThreadInfo_klass(CHECK_NULL);
|
||||
|
||||
JavaValue result(T_VOID);
|
||||
JavaCallArguments args(17);
|
||||
|
||||
// First allocate a ThreadObj object and
|
||||
// push the receiver as the first argument
|
||||
Handle element = ik->allocate_instance_handle(CHECK_NULL);
|
||||
args.push_oop(element);
|
||||
|
||||
// initialize the arguments for the ThreadInfo constructor
|
||||
initialize_ThreadInfo_constructor_arguments(&args, snapshot, CHECK_NULL);
|
||||
|
||||
@ -384,13 +368,11 @@ instanceOop Management::create_thread_info_instance(ThreadSnapshot* snapshot,
|
||||
args.push_oop(synchronizers_array);
|
||||
|
||||
// Call ThreadInfo constructor with locked monitors and synchronizers
|
||||
JavaCalls::call_special(&result,
|
||||
Handle element = JavaCalls::construct_new_instance(
|
||||
ik,
|
||||
vmSymbols::object_initializer_name(),
|
||||
vmSymbols::java_lang_management_ThreadInfo_with_locks_constructor_signature(),
|
||||
&args,
|
||||
CHECK_NULL);
|
||||
|
||||
return (instanceOop) element();
|
||||
}
|
||||
|
||||
|
@ -217,23 +217,17 @@ bool MemoryService::set_verbose(bool verbose) {
|
||||
Handle MemoryService::create_MemoryUsage_obj(MemoryUsage usage, TRAPS) {
|
||||
InstanceKlass* ik = Management::java_lang_management_MemoryUsage_klass(CHECK_NH);
|
||||
|
||||
instanceHandle obj = ik->allocate_instance_handle(CHECK_NH);
|
||||
|
||||
JavaValue result(T_VOID);
|
||||
JavaCallArguments args(10);
|
||||
args.push_oop(obj); // receiver
|
||||
args.push_long(usage.init_size_as_jlong()); // Argument 1
|
||||
args.push_long(usage.used_as_jlong()); // Argument 2
|
||||
args.push_long(usage.committed_as_jlong()); // Argument 3
|
||||
args.push_long(usage.max_size_as_jlong()); // Argument 4
|
||||
args.push_long(usage.init_size_as_jlong());
|
||||
args.push_long(usage.used_as_jlong());
|
||||
args.push_long(usage.committed_as_jlong());
|
||||
args.push_long(usage.max_size_as_jlong());
|
||||
|
||||
JavaCalls::call_special(&result,
|
||||
return JavaCalls::construct_new_instance(
|
||||
ik,
|
||||
vmSymbols::object_initializer_name(),
|
||||
vmSymbols::long_long_long_long_void_signature(),
|
||||
&args,
|
||||
CHECK_NH);
|
||||
return obj;
|
||||
}
|
||||
|
||||
TraceMemoryManagerStats::TraceMemoryManagerStats(GCMemoryManager* gc_memory_manager,
|
||||
|
@ -264,24 +264,11 @@ Handle Exceptions::new_exception(Thread *thread, Symbol* name,
|
||||
|
||||
if (!thread->has_pending_exception()) {
|
||||
assert(klass != NULL, "klass must exist");
|
||||
// We are about to create an instance - so make sure that klass is initialized
|
||||
InstanceKlass* ik = InstanceKlass::cast(klass);
|
||||
ik->initialize(thread);
|
||||
if (!thread->has_pending_exception()) {
|
||||
// Allocate new exception
|
||||
h_exception = ik->allocate_instance_handle(thread);
|
||||
if (!thread->has_pending_exception()) {
|
||||
JavaValue result(T_VOID);
|
||||
args->set_receiver(h_exception);
|
||||
// Call constructor
|
||||
JavaCalls::call_special(&result, ik,
|
||||
vmSymbols::object_initializer_name(),
|
||||
h_exception = JavaCalls::construct_new_instance(InstanceKlass::cast(klass),
|
||||
signature,
|
||||
args,
|
||||
thread);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if another exception was thrown in the process, if so rethrow that one
|
||||
if (thread->has_pending_exception()) {
|
||||
|
Loading…
Reference in New Issue
Block a user