diff --git a/src/hotspot/share/compiler/compilationPolicy.hpp b/src/hotspot/share/compiler/compilationPolicy.hpp index 6ec0d70817c..75571674fe1 100644 --- a/src/hotspot/share/compiler/compilationPolicy.hpp +++ b/src/hotspot/share/compiler/compilationPolicy.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022, 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 @@ -251,7 +251,6 @@ class CompilationPolicy : AllStatic { static bool can_be_osr_compiled(const methodHandle& m, int comp_level = CompLevel_any); static bool is_compilation_enabled(); - static void do_safepoint_work() { } static CompileTask* select_task_helper(CompileQueue* compile_queue); // Return initial compile level to use with Xcomp (depends on compilation mode). static void reprofile(ScopeDesc* trap_scope, bool is_osr); diff --git a/src/hotspot/share/runtime/safepoint.cpp b/src/hotspot/share/runtime/safepoint.cpp index 3894a11bcbf..8cce80ddcbe 100644 --- a/src/hotspot/share/runtime/safepoint.cpp +++ b/src/hotspot/share/runtime/safepoint.cpp @@ -506,19 +506,9 @@ bool SafepointSynchronize::is_cleanup_needed() { return false; } -class ParallelSPCleanupThreadClosure : public ThreadClosure { -public: - void do_thread(Thread* thread) { - if (thread->is_Java_thread()) { - StackWatermarkSet::start_processing(thread->as_Java_thread(), StackWatermarkKind::gc); - } - } -}; - -class ParallelSPCleanupTask : public AbstractGangTask { +class ParallelCleanupTask : public AbstractGangTask { private: SubTasksDone _subtasks; - uint _num_workers; bool _do_lazy_roots; class Tracer { @@ -538,32 +528,14 @@ class ParallelSPCleanupTask : public AbstractGangTask { }; public: - ParallelSPCleanupTask(uint num_workers) : + ParallelCleanupTask() : AbstractGangTask("Parallel Safepoint Cleanup"), _subtasks(SafepointSynchronize::SAFEPOINT_CLEANUP_NUM_TASKS), - _num_workers(num_workers), _do_lazy_roots(!VMThread::vm_operation()->skip_thread_oop_barriers() && Universe::heap()->uses_stack_watermark_barrier()) {} void work(uint worker_id) { - if (_subtasks.try_claim_task(SafepointSynchronize::SAFEPOINT_CLEANUP_LAZY_ROOT_PROCESSING)) { - if (_do_lazy_roots) { - Tracer t("lazy partial thread root processing"); - ParallelSPCleanupThreadClosure cl; - Threads::threads_do(&cl); - } - } - - if (_subtasks.try_claim_task(SafepointSynchronize::SAFEPOINT_CLEANUP_UPDATE_INLINE_CACHES)) { - Tracer t("updating inline caches"); - InlineCacheBuffer::update_inline_caches(); - } - - if (_subtasks.try_claim_task(SafepointSynchronize::SAFEPOINT_CLEANUP_COMPILATION_POLICY)) { - Tracer t("compilation policy safepoint handler"); - CompilationPolicy::do_safepoint_work(); - } - + // These tasks are ordered by relative length of time to execute so that potentially longer tasks start first. if (_subtasks.try_claim_task(SafepointSynchronize::SAFEPOINT_CLEANUP_SYMBOL_TABLE_REHASH)) { if (SymbolTable::needs_rehashing()) { Tracer t("rehashing symbol table"); @@ -585,6 +557,25 @@ class ParallelSPCleanupTask : public AbstractGangTask { } } + if (_subtasks.try_claim_task(SafepointSynchronize::SAFEPOINT_CLEANUP_LAZY_ROOT_PROCESSING)) { + if (_do_lazy_roots) { + Tracer t("lazy partial thread root processing"); + class LazyRootClosure : public ThreadClosure { + public: + void do_thread(Thread* thread) { + StackWatermarkSet::start_processing(thread->as_Java_thread(), StackWatermarkKind::gc); + } + }; + LazyRootClosure cl; + Threads::java_threads_do(&cl); + } + } + + if (_subtasks.try_claim_task(SafepointSynchronize::SAFEPOINT_CLEANUP_UPDATE_INLINE_CACHES)) { + Tracer t("updating inline caches"); + InlineCacheBuffer::update_inline_caches(); + } + if (_subtasks.try_claim_task(SafepointSynchronize::SAFEPOINT_CLEANUP_REQUEST_OOPSTORAGE_CLEANUP)) { // Don't bother reporting event or time for this very short operation. // To have any utility we'd also want to report whether needed. @@ -602,15 +593,13 @@ void SafepointSynchronize::do_cleanup_tasks() { CollectedHeap* heap = Universe::heap(); assert(heap != NULL, "heap not initialized yet?"); + ParallelCleanupTask cleanup; WorkGang* cleanup_workers = heap->safepoint_workers(); if (cleanup_workers != NULL) { // Parallel cleanup using GC provided thread pool. - uint num_cleanup_workers = cleanup_workers->active_workers(); - ParallelSPCleanupTask cleanup(num_cleanup_workers); cleanup_workers->run_task(&cleanup); } else { // Serial cleanup using VMThread. - ParallelSPCleanupTask cleanup(1); cleanup.work(0); } diff --git a/src/hotspot/share/runtime/safepoint.hpp b/src/hotspot/share/runtime/safepoint.hpp index c986f540dc4..95d0e1fb18f 100644 --- a/src/hotspot/share/runtime/safepoint.hpp +++ b/src/hotspot/share/runtime/safepoint.hpp @@ -72,7 +72,6 @@ class SafepointSynchronize : AllStatic { enum SafepointCleanupTasks { SAFEPOINT_CLEANUP_LAZY_ROOT_PROCESSING, SAFEPOINT_CLEANUP_UPDATE_INLINE_CACHES, - SAFEPOINT_CLEANUP_COMPILATION_POLICY, SAFEPOINT_CLEANUP_SYMBOL_TABLE_REHASH, SAFEPOINT_CLEANUP_STRING_TABLE_REHASH, SAFEPOINT_CLEANUP_SYSTEM_DICTIONARY_RESIZE, diff --git a/src/hotspot/share/runtime/synchronizer.cpp b/src/hotspot/share/runtime/synchronizer.cpp index 0206c8f5b1b..869b5604c8f 100644 --- a/src/hotspot/share/runtime/synchronizer.cpp +++ b/src/hotspot/share/runtime/synchronizer.cpp @@ -1676,7 +1676,7 @@ void ObjectSynchronizer::do_final_audit_and_print_stats() { ; // empty } // The other audit_and_print_stats() call is done at the Debug - // level at a safepoint in ObjectSynchronizer::do_safepoint_work(). + // level at a safepoint in SafepointSynchronize::do_cleanup_tasks. ObjectSynchronizer::audit_and_print_stats(true /* on_exit */); } } diff --git a/test/hotspot/jtreg/runtime/logging/SafepointCleanupTest.java b/test/hotspot/jtreg/runtime/logging/SafepointCleanupTest.java index 9136953a5e9..3318b4d696f 100644 --- a/test/hotspot/jtreg/runtime/logging/SafepointCleanupTest.java +++ b/test/hotspot/jtreg/runtime/logging/SafepointCleanupTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2022, 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 @@ -40,7 +40,6 @@ static void analyzeOutputOn(ProcessBuilder pb) throws Exception { output.shouldContain("[safepoint,cleanup]"); output.shouldContain("safepoint cleanup tasks"); output.shouldContain("updating inline caches"); - output.shouldContain("compilation policy safepoint handler"); output.shouldHaveExitValue(0); }