1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/gcTaskThread.hpp Wed Apr 27 01:25:04 2016 +0800 1.3 @@ -0,0 +1,110 @@ 1.4 +/* 1.5 + * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 + * or visit www.oracle.com if you need additional information or have any 1.24 + * questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +#ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_GCTASKTHREAD_HPP 1.29 +#define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_GCTASKTHREAD_HPP 1.30 + 1.31 +#include "runtime/thread.hpp" 1.32 + 1.33 +// Forward declarations of classes defined here. 1.34 +class GCTaskThread; 1.35 +class GCTaskTimeStamp; 1.36 + 1.37 +// Declarations of classes referenced in this file via pointer. 1.38 +class GCTaskManager; 1.39 + 1.40 +class GCTaskThread : public WorkerThread { 1.41 + friend class GCTaskManager; 1.42 +private: 1.43 + // Instance state. 1.44 + GCTaskManager* _manager; // Manager for worker. 1.45 + const uint _processor_id; // Which processor the worker is on. 1.46 + 1.47 + GCTaskTimeStamp* _time_stamps; 1.48 + uint _time_stamp_index; 1.49 + 1.50 + GCTaskTimeStamp* time_stamp_at(uint index); 1.51 + 1.52 + bool _is_working; // True if participating in GC tasks 1.53 + 1.54 + public: 1.55 + // Factory create and destroy methods. 1.56 + static GCTaskThread* create(GCTaskManager* manager, 1.57 + uint which, 1.58 + uint processor_id) { 1.59 + return new GCTaskThread(manager, which, processor_id); 1.60 + } 1.61 + static void destroy(GCTaskThread* manager) { 1.62 + if (manager != NULL) { 1.63 + delete manager; 1.64 + } 1.65 + } 1.66 + // Methods from Thread. 1.67 + bool is_GC_task_thread() const { 1.68 + return true; 1.69 + } 1.70 + virtual void run(); 1.71 + // Methods. 1.72 + void start(); 1.73 + 1.74 + void print_task_time_stamps(); 1.75 + void print_on(outputStream* st) const; 1.76 + void print() const { print_on(tty); } 1.77 + 1.78 +protected: 1.79 + // Constructor. Clients use factory, but there could be subclasses. 1.80 + GCTaskThread(GCTaskManager* manager, uint which, uint processor_id); 1.81 + // Destructor: virtual destructor because of virtual methods. 1.82 + virtual ~GCTaskThread(); 1.83 + // Accessors. 1.84 + GCTaskManager* manager() const { 1.85 + return _manager; 1.86 + } 1.87 + uint which() const { 1.88 + return id(); 1.89 + } 1.90 + uint processor_id() const { 1.91 + return _processor_id; 1.92 + } 1.93 + void set_is_working(bool v) { _is_working = v; } 1.94 +}; 1.95 + 1.96 +class GCTaskTimeStamp : public CHeapObj<mtGC> 1.97 +{ 1.98 + private: 1.99 + jlong _entry_time; 1.100 + jlong _exit_time; 1.101 + char* _name; 1.102 + 1.103 + public: 1.104 + jlong entry_time() { return _entry_time; } 1.105 + jlong exit_time() { return _exit_time; } 1.106 + const char* name() const { return (const char*)_name; } 1.107 + 1.108 + void set_entry_time(jlong time) { _entry_time = time; } 1.109 + void set_exit_time(jlong time) { _exit_time = time; } 1.110 + void set_name(char* name) { _name = name; } 1.111 +}; 1.112 + 1.113 +#endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_GCTASKTHREAD_HPP