Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/gc_implementation/parallelScavenge/pcTasks.hpp
38920 views
/*1* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PCTASKS_HPP25#define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PCTASKS_HPP2627#include "gc_implementation/parallelScavenge/gcTaskManager.hpp"28#include "gc_implementation/parallelScavenge/psParallelCompact.hpp"29#include "gc_implementation/parallelScavenge/psTasks.hpp"303132// Tasks for parallel compaction of the old generation33//34// Tasks are created and enqueued on a task queue. The35// tasks for parallel old collector for marking objects36// are MarkFromRootsTask and ThreadRootsMarkingTask.37//38// MarkFromRootsTask's are created39// with a root group (e.g., jni_handles) and when the do_it()40// method of a MarkFromRootsTask is executed, it starts marking41// form it's root group.42//43// ThreadRootsMarkingTask's are created for each Java thread. When44// the do_it() method of a ThreadRootsMarkingTask is executed, it45// starts marking from the thread's roots.46//47// The enqueuing of the MarkFromRootsTask and ThreadRootsMarkingTask48// do little more than create the task and put it on a queue. The49// queue is a GCTaskQueue and threads steal tasks from this GCTaskQueue.50//51// In addition to the MarkFromRootsTask and ThreadRootsMarkingTask52// tasks there are StealMarkingTask tasks. The StealMarkingTask's53// steal a reference from the marking stack of another54// thread and transitively marks the object of the reference55// and internal references. After successfully stealing a reference56// and marking it, the StealMarkingTask drains its marking stack57// stack before attempting another steal.58//59// ThreadRootsMarkingTask60//61// This task marks from the roots of a single thread. This task62// enables marking of thread roots in parallel.63//6465class ParallelTaskTerminator;6667class ThreadRootsMarkingTask : public GCTask {68private:69JavaThread* _java_thread;70VMThread* _vm_thread;71public:72ThreadRootsMarkingTask(JavaThread* root) : _java_thread(root), _vm_thread(NULL) {}73ThreadRootsMarkingTask(VMThread* root) : _java_thread(NULL), _vm_thread(root) {}7475char* name() { return (char *)"thread-roots-marking-task"; }7677virtual void do_it(GCTaskManager* manager, uint which);78};798081//82// MarkFromRootsTask83//84// This task marks from all the roots to all live85// objects.86//87//8889class MarkFromRootsTask : public GCTask {90public:91enum RootType {92universe = 1,93jni_handles = 2,94threads = 3,95object_synchronizer = 4,96flat_profiler = 5,97management = 6,98jvmti = 7,99system_dictionary = 8,100class_loader_data = 9,101code_cache = 10102};103private:104RootType _root_type;105public:106MarkFromRootsTask(RootType value) : _root_type(value) {}107108char* name() { return (char *)"mark-from-roots-task"; }109110virtual void do_it(GCTaskManager* manager, uint which);111};112113//114// RefProcTaskProxy115//116// This task is used as a proxy to parallel reference processing tasks .117//118119class RefProcTaskProxy : public GCTask {120typedef AbstractRefProcTaskExecutor::ProcessTask ProcessTask;121ProcessTask & _rp_task;122uint _work_id;123public:124RefProcTaskProxy(ProcessTask & rp_task, uint work_id)125: _rp_task(rp_task),126_work_id(work_id)127{ }128129private:130virtual char* name() { return (char *)"Process referents by policy in parallel"; }131132virtual void do_it(GCTaskManager* manager, uint which);133};134135136137//138// RefEnqueueTaskProxy139//140// This task is used as a proxy to parallel reference processing tasks .141//142143class RefEnqueueTaskProxy: public GCTask {144typedef AbstractRefProcTaskExecutor::EnqueueTask EnqueueTask;145EnqueueTask& _enq_task;146uint _work_id;147148public:149RefEnqueueTaskProxy(EnqueueTask& enq_task, uint work_id)150: _enq_task(enq_task),151_work_id(work_id)152{ }153154virtual char* name() { return (char *)"Enqueue reference objects in parallel"; }155virtual void do_it(GCTaskManager* manager, uint which)156{157_enq_task.work(_work_id);158}159};160161162//163// RefProcTaskExecutor164//165// Task executor is an interface for the reference processor to run166// tasks using GCTaskManager.167//168169class RefProcTaskExecutor: public AbstractRefProcTaskExecutor {170virtual void execute(ProcessTask& task);171virtual void execute(EnqueueTask& task);172};173174175//176// StealMarkingTask177//178// This task is used to distribute work to idle threads.179//180181class StealMarkingTask : public GCTask {182private:183ParallelTaskTerminator* const _terminator;184private:185186public:187char* name() { return (char *)"steal-marking-task"; }188189StealMarkingTask(ParallelTaskTerminator* t);190191ParallelTaskTerminator* terminator() { return _terminator; }192193virtual void do_it(GCTaskManager* manager, uint which);194};195196//197// StealRegionCompactionTask198//199// This task is used to distribute work to idle threads.200//201202class StealRegionCompactionTask : public GCTask {203private:204ParallelTaskTerminator* const _terminator;205public:206StealRegionCompactionTask(ParallelTaskTerminator* t);207208char* name() { return (char *)"steal-region-task"; }209ParallelTaskTerminator* terminator() { return _terminator; }210211virtual void do_it(GCTaskManager* manager, uint which);212};213214//215// UpdateDensePrefixTask216//217// This task is used to update the dense prefix218// of a space.219//220221class UpdateDensePrefixTask : public GCTask {222private:223PSParallelCompact::SpaceId _space_id;224size_t _region_index_start;225size_t _region_index_end;226227public:228char* name() { return (char *)"update-dense_prefix-task"; }229230UpdateDensePrefixTask(PSParallelCompact::SpaceId space_id,231size_t region_index_start,232size_t region_index_end);233234virtual void do_it(GCTaskManager* manager, uint which);235};236237//238// DrainStacksCompactionTask239//240// This task processes regions that have been added to the stacks of each241// compaction manager.242//243// Trying to use one draining thread does not work because there are no244// guarantees about which task will be picked up by which thread. For example,245// if thread A gets all the preloaded regions, thread A may not get a draining246// task (they may all be done by other threads).247//248249class DrainStacksCompactionTask : public GCTask {250uint _stack_index;251uint stack_index() { return _stack_index; }252public:253DrainStacksCompactionTask(uint stack_index) : GCTask(),254_stack_index(stack_index) {};255char* name() { return (char *)"drain-region-task"; }256virtual void do_it(GCTaskManager* manager, uint which);257};258259#endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PCTASKS_HPP260261262