8252656: Replace RegisterArrayForGC mechanism with plain Handles

Reviewed-by: coleenp, tschatzl, dholmes
This commit is contained in:
Stefan Karlsson 2020-09-02 11:13:11 +02:00
parent 7282d0deb5
commit 4c73e045ce
3 changed files with 3 additions and 35 deletions

View File

@ -1376,27 +1376,12 @@ JVM_ENTRY(jobject, JVM_GetInheritedAccessControlContext(JNIEnv *env, jclass cls)
return JNIHandles::make_local(THREAD, result);
JVM_END
class RegisterArrayForGC {
private:
JavaThread *_thread;
public:
RegisterArrayForGC(JavaThread *thread, GrowableArray<oop>* array) {
_thread = thread;
_thread->register_array_for_gc(array);
}
~RegisterArrayForGC() {
_thread->register_array_for_gc(NULL);
}
};
JVM_ENTRY(jobject, JVM_GetStackAccessControlContext(JNIEnv *env, jclass cls))
JVMWrapper("JVM_GetStackAccessControlContext");
if (!UsePrivilegedStack) return NULL;
ResourceMark rm(THREAD);
GrowableArray<oop>* local_array = new GrowableArray<oop>(12);
GrowableArray<Handle>* local_array = new GrowableArray<Handle>(12);
JvmtiVMObjectAllocEventCollector oam;
// count the protection domains on the execution stack. We collapse
@ -1438,7 +1423,7 @@ JVM_ENTRY(jobject, JVM_GetStackAccessControlContext(JNIEnv *env, jclass cls))
}
if ((previous_protection_domain != protection_domain) && (protection_domain != NULL)) {
local_array->push(protection_domain);
local_array->push(Handle(thread, protection_domain));
previous_protection_domain = protection_domain;
}
@ -1455,13 +1440,11 @@ JVM_ENTRY(jobject, JVM_GetStackAccessControlContext(JNIEnv *env, jclass cls))
return JNIHandles::make_local(THREAD, result);
}
// the resource area must be registered in case of a gc
RegisterArrayForGC ragc(thread, local_array);
objArrayOop context = oopFactory::new_objArray(SystemDictionary::ProtectionDomain_klass(),
local_array->length(), CHECK_NULL);
objArrayHandle h_context(thread, context);
for (int index = 0; index < local_array->length(); index++) {
h_context->obj_at_put(index, local_array->at(index));
h_context->obj_at_put(index, local_array->at(index)());
}
oop result = java_security_AccessControlContext::create(h_context, is_privileged, privileged_context, CHECK_NULL);

View File

@ -1691,7 +1691,6 @@ void JavaThread::initialize() {
_on_thread_list = false;
_thread_state = _thread_new;
_terminated = _not_terminated;
_array_for_gc = NULL;
_suspend_equivalent = false;
_in_deopt_handler = 0;
_doing_unsafe_access = false;
@ -3010,13 +3009,6 @@ void JavaThread::oops_do(OopClosure* f, CodeBlobClosure* cf) {
// Record JavaThread to GC thread
RememberProcessedThread rpt(this);
// traverse the registered growable array
if (_array_for_gc != NULL) {
for (int index = 0; index < _array_for_gc->length(); index++) {
f->do_oop(_array_for_gc->adr_at(index));
}
}
// Traverse the monitor chunks
for (MonitorChunk* chunk = monitor_chunks(); chunk != NULL; chunk = chunk->next()) {
chunk->oops_do(f);

View File

@ -1960,13 +1960,6 @@ class JavaThread: public Thread {
void thread_main_inner();
virtual void post_run();
private:
GrowableArray<oop>* _array_for_gc;
public:
void register_array_for_gc(GrowableArray<oop>* array) { _array_for_gc = array; }
public:
// Thread local information maintained by JVMTI.
void set_jvmti_thread_state(JvmtiThreadState *value) { _jvmti_thread_state = value; }