0N/A/*
2273N/A * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PCTASKS_HPP
1879N/A#define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PCTASKS_HPP
1879N/A
1879N/A#include "gc_implementation/parallelScavenge/gcTaskManager.hpp"
1879N/A#include "gc_implementation/parallelScavenge/psParallelCompact.hpp"
1879N/A#include "gc_implementation/parallelScavenge/psTasks.hpp"
1879N/A
0N/A
0N/A// Tasks for parallel compaction of the old generation
0N/A//
0N/A// Tasks are created and enqueued on a task queue. The
0N/A// tasks for parallel old collector for marking objects
0N/A// are MarkFromRootsTask and ThreadRootsMarkingTask.
0N/A//
0N/A// MarkFromRootsTask's are created
0N/A// with a root group (e.g., jni_handles) and when the do_it()
0N/A// method of a MarkFromRootsTask is executed, it starts marking
0N/A// form it's root group.
0N/A//
0N/A// ThreadRootsMarkingTask's are created for each Java thread. When
0N/A// the do_it() method of a ThreadRootsMarkingTask is executed, it
0N/A// starts marking from the thread's roots.
0N/A//
0N/A// The enqueuing of the MarkFromRootsTask and ThreadRootsMarkingTask
0N/A// do little more than create the task and put it on a queue. The
0N/A// queue is a GCTaskQueue and threads steal tasks from this GCTaskQueue.
0N/A//
0N/A// In addition to the MarkFromRootsTask and ThreadRootsMarkingTask
0N/A// tasks there are StealMarkingTask tasks. The StealMarkingTask's
0N/A// steal a reference from the marking stack of another
0N/A// thread and transitively marks the object of the reference
0N/A// and internal references. After successfully stealing a reference
0N/A// and marking it, the StealMarkingTask drains its marking stack
0N/A// stack before attempting another steal.
0N/A//
0N/A// ThreadRootsMarkingTask
0N/A//
0N/A// This task marks from the roots of a single thread. This task
0N/A// enables marking of thread roots in parallel.
0N/A//
0N/A
0N/Aclass ParallelTaskTerminator;
0N/A
0N/Aclass ThreadRootsMarkingTask : public GCTask {
0N/A private:
0N/A JavaThread* _java_thread;
0N/A VMThread* _vm_thread;
0N/A public:
0N/A ThreadRootsMarkingTask(JavaThread* root) : _java_thread(root), _vm_thread(NULL) {}
0N/A ThreadRootsMarkingTask(VMThread* root) : _java_thread(NULL), _vm_thread(root) {}
0N/A
0N/A char* name() { return (char *)"thread-roots-marking-task"; }
0N/A
0N/A virtual void do_it(GCTaskManager* manager, uint which);
0N/A};
0N/A
0N/A
0N/A//
0N/A// MarkFromRootsTask
0N/A//
0N/A// This task marks from all the roots to all live
0N/A// objects.
0N/A//
0N/A//
0N/A
0N/Aclass MarkFromRootsTask : public GCTask {
0N/A public:
0N/A enum RootType {
0N/A universe = 1,
0N/A jni_handles = 2,
0N/A threads = 3,
0N/A object_synchronizer = 4,
0N/A flat_profiler = 5,
0N/A management = 6,
0N/A jvmti = 7,
0N/A system_dictionary = 8,
2749N/A code_cache = 9
0N/A };
0N/A private:
0N/A RootType _root_type;
0N/A public:
0N/A MarkFromRootsTask(RootType value) : _root_type(value) {}
0N/A
0N/A char* name() { return (char *)"mark-from-roots-task"; }
0N/A
0N/A virtual void do_it(GCTaskManager* manager, uint which);
0N/A};
0N/A
0N/A//
0N/A// RefProcTaskProxy
0N/A//
0N/A// This task is used as a proxy to parallel reference processing tasks .
0N/A//
0N/A
0N/Aclass RefProcTaskProxy : public GCTask {
0N/A typedef AbstractRefProcTaskExecutor::ProcessTask ProcessTask;
0N/A ProcessTask & _rp_task;
0N/A uint _work_id;
0N/Apublic:
0N/A RefProcTaskProxy(ProcessTask & rp_task, uint work_id)
0N/A : _rp_task(rp_task),
0N/A _work_id(work_id)
0N/A { }
0N/A
0N/Aprivate:
0N/A virtual char* name() { return (char *)"Process referents by policy in parallel"; }
0N/A
0N/A virtual void do_it(GCTaskManager* manager, uint which);
0N/A};
0N/A
0N/A
0N/A
0N/A//
0N/A// RefEnqueueTaskProxy
0N/A//
0N/A// This task is used as a proxy to parallel reference processing tasks .
0N/A//
0N/A
0N/Aclass RefEnqueueTaskProxy: public GCTask {
0N/A typedef AbstractRefProcTaskExecutor::EnqueueTask EnqueueTask;
0N/A EnqueueTask& _enq_task;
0N/A uint _work_id;
0N/A
0N/Apublic:
0N/A RefEnqueueTaskProxy(EnqueueTask& enq_task, uint work_id)
0N/A : _enq_task(enq_task),
0N/A _work_id(work_id)
0N/A { }
0N/A
0N/A virtual char* name() { return (char *)"Enqueue reference objects in parallel"; }
0N/A virtual void do_it(GCTaskManager* manager, uint which)
0N/A {
0N/A _enq_task.work(_work_id);
0N/A }
0N/A};
0N/A
0N/A
0N/A//
0N/A// RefProcTaskExecutor
0N/A//
0N/A// Task executor is an interface for the reference processor to run
0N/A// tasks using GCTaskManager.
0N/A//
0N/A
0N/Aclass RefProcTaskExecutor: public AbstractRefProcTaskExecutor {
0N/A virtual void execute(ProcessTask& task);
0N/A virtual void execute(EnqueueTask& task);
0N/A};
0N/A
0N/A
0N/A//
0N/A// StealMarkingTask
0N/A//
0N/A// This task is used to distribute work to idle threads.
0N/A//
0N/A
0N/Aclass StealMarkingTask : public GCTask {
0N/A private:
0N/A ParallelTaskTerminator* const _terminator;
0N/A private:
0N/A
0N/A public:
0N/A char* name() { return (char *)"steal-marking-task"; }
0N/A
0N/A StealMarkingTask(ParallelTaskTerminator* t);
0N/A
0N/A ParallelTaskTerminator* terminator() { return _terminator; }
0N/A
0N/A virtual void do_it(GCTaskManager* manager, uint which);
0N/A};
0N/A
0N/A//
375N/A// StealRegionCompactionTask
0N/A//
0N/A// This task is used to distribute work to idle threads.
0N/A//
0N/A
375N/Aclass StealRegionCompactionTask : public GCTask {
0N/A private:
0N/A ParallelTaskTerminator* const _terminator;
0N/A public:
375N/A StealRegionCompactionTask(ParallelTaskTerminator* t);
0N/A
375N/A char* name() { return (char *)"steal-region-task"; }
0N/A ParallelTaskTerminator* terminator() { return _terminator; }
0N/A
0N/A virtual void do_it(GCTaskManager* manager, uint which);
0N/A};
0N/A
0N/A//
0N/A// UpdateDensePrefixTask
0N/A//
0N/A// This task is used to update the dense prefix
0N/A// of a space.
0N/A//
0N/A
0N/Aclass UpdateDensePrefixTask : public GCTask {
0N/A private:
0N/A PSParallelCompact::SpaceId _space_id;
375N/A size_t _region_index_start;
375N/A size_t _region_index_end;
0N/A
0N/A public:
0N/A char* name() { return (char *)"update-dense_prefix-task"; }
0N/A
0N/A UpdateDensePrefixTask(PSParallelCompact::SpaceId space_id,
375N/A size_t region_index_start,
375N/A size_t region_index_end);
0N/A
0N/A virtual void do_it(GCTaskManager* manager, uint which);
0N/A};
0N/A
0N/A//
0N/A// DrainStacksCompactionTask
0N/A//
375N/A// This task processes regions that have been added to the stacks of each
0N/A// compaction manager.
0N/A//
0N/A// Trying to use one draining thread does not work because there are no
0N/A// guarantees about which task will be picked up by which thread. For example,
375N/A// if thread A gets all the preloaded regions, thread A may not get a draining
0N/A// task (they may all be done by other threads).
0N/A//
0N/A
0N/Aclass DrainStacksCompactionTask : public GCTask {
1753N/A uint _stack_index;
1753N/A uint stack_index() { return _stack_index; }
0N/A public:
1753N/A DrainStacksCompactionTask(uint stack_index) : GCTask(),
1753N/A _stack_index(stack_index) {};
375N/A char* name() { return (char *)"drain-region-task"; }
0N/A virtual void do_it(GCTaskManager* manager, uint which);
0N/A};
1879N/A
1879N/A#endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PCTASKS_HPP