From aff3b72c1a0882f988ad92ccdea79964aef48ee2 Mon Sep 17 00:00:00 2001 From: Zhai Mo Date: Mon, 17 Jul 2023 16:42:10 +0800 Subject: [PATCH] [Wisp] Remove useless list of coroutine_stack and coroutine_stack_cache. (port to jdk17) Summary: Remove useless code Test Plan: all wisp tests Reviewed-by: yulei Issue: https://github.com/dragonwell-project/dragonwell17/issues/90 --- src/hotspot/share/prims/unsafe.cpp | 29 ++++++--------------------- src/hotspot/share/runtime/globals.hpp | 3 --- src/hotspot/share/runtime/thread.cpp | 12 +---------- src/hotspot/share/runtime/thread.hpp | 6 ------ 4 files changed, 7 insertions(+), 43 deletions(-) diff --git a/src/hotspot/share/prims/unsafe.cpp b/src/hotspot/share/prims/unsafe.cpp index 9aedf93f9f6..dddaacf60ae 100644 --- a/src/hotspot/share/prims/unsafe.cpp +++ b/src/hotspot/share/prims/unsafe.cpp @@ -897,14 +897,7 @@ JVM_ENTRY(void, CoroutineSupport_switchToAndTerminate(JNIEnv* env, jclass klass, java_dyn_CoroutineBase::set_native_coroutine(old_oop, 0); - CoroutineStack* stack = coro->stack(); - stack->remove_from_list(thread->coroutine_stack_list()); - if (thread->coroutine_stack_cache_size() < MaxFreeCoroutinesCacheSize) { - stack->insert_into_list(thread->coroutine_stack_cache()); - thread->coroutine_stack_cache_size() ++; - } else { - CoroutineStack::free_stack(stack, thread); - } + CoroutineStack::free_stack(coro->stack(), thread); delete coro; JVM_END @@ -922,19 +915,11 @@ JVM_ENTRY(jlong, CoroutineSupport_createCoroutine(JNIEnv* env, jclass klass, job if (stack_size == 0 || stack_size < -1) { THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "invalid stack size"); } - CoroutineStack* stack = NULL; - if (stack_size <= 0 && thread->coroutine_stack_cache_size() > 0) { - stack = thread->coroutine_stack_cache(); - stack->remove_from_list(thread->coroutine_stack_cache()); - thread->coroutine_stack_cache_size() --; - DEBUG_CORO_ONLY(tty->print("reused coroutine stack at %08x\n", stack->_stack_base)); - } else { - stack = CoroutineStack::create_stack(thread, stack_size); - if (stack == NULL) { - THROW_0(vmSymbols::java_lang_OutOfMemoryError()); - } + + CoroutineStack* stack = CoroutineStack::create_stack(thread, stack_size); + if (stack == NULL) { + THROW_0(vmSymbols::java_lang_OutOfMemoryError()); } - stack->insert_into_list(thread->coroutine_stack_list()); Coroutine* coro = Coroutine::create_coroutine(thread, stack, JNIHandles::resolve(coroutine)); if (coro == NULL) { @@ -952,9 +937,7 @@ JVM_ENTRY(jboolean, CoroutineSupport_testDisposableAndTryReleaseStack(JNIEnv* en jboolean is_disposable = coro->is_disposable(); if (is_disposable) { - CoroutineStack* stack = coro->stack(); - stack->remove_from_list(thread->coroutine_stack_list()); - CoroutineStack::free_stack(stack, thread); + CoroutineStack::free_stack(coro->stack(), thread); delete coro; } return is_disposable; diff --git a/src/hotspot/share/runtime/globals.hpp b/src/hotspot/share/runtime/globals.hpp index fab9c84fb4d..9101d9307ea 100644 --- a/src/hotspot/share/runtime/globals.hpp +++ b/src/hotspot/share/runtime/globals.hpp @@ -2095,9 +2095,6 @@ const intx ObjectAlignmentInBytes = 8; product(uintx, DefaultCoroutineStackSize, 128*K, \ "Default size of stack that is associated with new coroutine") \ \ - product(uintx, MaxFreeCoroutinesCacheSize, 20, \ - "The max number of free coroutine stacks a thread can keep") \ - \ product(bool, UseWispMonitor, false, \ "yields to next coroutine when ObjectMonitor is contended") \ \ diff --git a/src/hotspot/share/runtime/thread.cpp b/src/hotspot/share/runtime/thread.cpp index bd0c1b326d8..d2db42c8885 100644 --- a/src/hotspot/share/runtime/thread.cpp +++ b/src/hotspot/share/runtime/thread.cpp @@ -1098,9 +1098,6 @@ JavaThread::JavaThread() : _frames_to_pop_failed_realloc(0), // coroutine support - _coroutine_stack_cache(nullptr), - _coroutine_stack_cache_size(0), - _coroutine_stack_list(nullptr), _coroutine_list(nullptr), _current_coroutine(nullptr), _wisp_preempted(false), @@ -1262,12 +1259,6 @@ JavaThread::JavaThread(ThreadFunction entry_point, size_t stack_sz) : JavaThread } JavaThread::~JavaThread() { - while (EnableCoroutine && coroutine_stack_cache() != NULL) { - CoroutineStack* stack = coroutine_stack_cache(); - stack->remove_from_list(coroutine_stack_cache()); - CoroutineStack::free_stack(stack, this); - } - while (EnableCoroutine && coroutine_list() != NULL) { CoroutineStack::free_stack(coroutine_list()->stack(), this); delete coroutine_list(); @@ -4150,8 +4141,7 @@ void Threads::verify() { void JavaThread::initialize_coroutine_support() { assert(EnableCoroutine, "EnableCoroutine isn't enable"); - CoroutineStack::create_thread_stack(this)->insert_into_list(_coroutine_stack_list); - Coroutine::create_thread_coroutine(this, _coroutine_stack_list)->insert_into_list(_coroutine_list); + Coroutine::create_thread_coroutine(this, CoroutineStack::create_thread_stack(this))->insert_into_list(_coroutine_list); } #ifndef PRODUCT diff --git a/src/hotspot/share/runtime/thread.hpp b/src/hotspot/share/runtime/thread.hpp index 4e2e6770c99..2f9306c4b78 100644 --- a/src/hotspot/share/runtime/thread.hpp +++ b/src/hotspot/share/runtime/thread.hpp @@ -1038,9 +1038,6 @@ class JavaThread: public Thread { int _frames_to_pop_failed_realloc; // coroutine support - CoroutineStack* _coroutine_stack_cache; - uintx _coroutine_stack_cache_size; - CoroutineStack* _coroutine_stack_list; Coroutine* _coroutine_list; Coroutine* _current_coroutine; bool _wisp_preempted; @@ -1048,9 +1045,6 @@ class JavaThread: public Thread { intptr_t _coroutine_temp; public: - CoroutineStack*& coroutine_stack_cache() { return _coroutine_stack_cache; } - uintx& coroutine_stack_cache_size() { return _coroutine_stack_cache_size; } - CoroutineStack*& coroutine_stack_list() { return _coroutine_stack_list; } Coroutine*& coroutine_list() { return _coroutine_list; } Coroutine* current_coroutine() { return _current_coroutine; } void set_current_coroutine(Coroutine *coro) { _current_coroutine = coro; }