src/share/vm/services/memTrackWorker.hpp

Fri, 12 Apr 2013 15:22:08 -0700

author
katleman
date
Fri, 12 Apr 2013 15:22:08 -0700
changeset 4916
b0301c02f38e
parent 4512
4102b59539ce
child 4927
35f8765422b9
permissions
-rw-r--r--

8012048: JDK8 b85 source with GPL header errors
Reviewed-by: iris, mduigou, jjg

zgu@3900 1 /*
zgu@3900 2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
zgu@3900 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
zgu@3900 4 *
zgu@3900 5 * This code is free software; you can redistribute it and/or modify it
zgu@3900 6 * under the terms of the GNU General Public License version 2 only, as
zgu@3900 7 * published by the Free Software Foundation.
zgu@3900 8 *
zgu@3900 9 * This code is distributed in the hope that it will be useful, but WITHOUT
zgu@3900 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
zgu@3900 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
zgu@3900 12 * version 2 for more details (a copy is included in the LICENSE file that
zgu@3900 13 * accompanied this code).
zgu@3900 14 *
zgu@3900 15 * You should have received a copy of the GNU General Public License version
zgu@3900 16 * 2 along with this work; if not, write to the Free Software Foundation,
zgu@3900 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
zgu@3900 18 *
zgu@3900 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
zgu@3900 20 * or visit www.oracle.com if you need additional information or have any
zgu@3900 21 * questions.
zgu@3900 22 *
zgu@3900 23 */
zgu@3900 24
zgu@3900 25 #ifndef SHARE_VM_SERVICES_MEM_TRACK_WORKER_HPP
zgu@3900 26 #define SHARE_VM_SERVICES_MEM_TRACK_WORKER_HPP
zgu@3900 27
zgu@3900 28 #include "memory/allocation.hpp"
zgu@3900 29 #include "runtime/thread.hpp"
zgu@3900 30 #include "services/memRecorder.hpp"
zgu@3900 31
zgu@3900 32 // Maximum MAX_GENERATIONS generation data can be tracked.
zgu@3900 33 #define MAX_GENERATIONS 512
zgu@3900 34
zgu@4400 35 class GenerationData : public _ValueObj {
zgu@4400 36 private:
zgu@4400 37 int _number_of_classes;
zgu@4400 38 MemRecorder* _recorder_list;
zgu@4400 39
zgu@4400 40 public:
zgu@4400 41 GenerationData(): _number_of_classes(0), _recorder_list(NULL) { }
zgu@4400 42
zgu@4400 43 inline int number_of_classes() const { return _number_of_classes; }
zgu@4400 44 inline void set_number_of_classes(long num) { _number_of_classes = num; }
zgu@4400 45
zgu@4400 46 inline MemRecorder* next_recorder() {
zgu@4400 47 if (_recorder_list == NULL) {
zgu@4400 48 return NULL;
zgu@4400 49 } else {
zgu@4400 50 MemRecorder* tmp = _recorder_list;
zgu@4400 51 _recorder_list = _recorder_list->next();
zgu@4400 52 return tmp;
zgu@4400 53 }
zgu@4400 54 }
zgu@4400 55
zgu@4400 56 inline bool has_more_recorder() const {
zgu@4400 57 return (_recorder_list != NULL);
zgu@4400 58 }
zgu@4400 59
zgu@4400 60 // add recorders to this generation
zgu@4400 61 void add_recorders(MemRecorder* head) {
zgu@4400 62 if (head != NULL) {
zgu@4400 63 if (_recorder_list == NULL) {
zgu@4400 64 _recorder_list = head;
zgu@4400 65 } else {
zgu@4400 66 MemRecorder* tmp = _recorder_list;
zgu@4400 67 for (; tmp->next() != NULL; tmp = tmp->next());
zgu@4400 68 tmp->set_next(head);
zgu@4400 69 }
zgu@4400 70 }
zgu@4400 71 }
zgu@4400 72
zgu@4400 73 void reset();
zgu@4400 74
zgu@4400 75 NOT_PRODUCT(MemRecorder* peek() const { return _recorder_list; })
zgu@4400 76 };
zgu@3900 77
zgu@3900 78 class MemTrackWorker : public NamedThread {
zgu@3900 79 private:
zgu@4400 80 // circular buffer. This buffer contains generation data to be merged into global
zgu@3900 81 // snaphsot.
zgu@4400 82 // Each slot holds a generation
zgu@4400 83 GenerationData _gen[MAX_GENERATIONS];
zgu@4400 84 int _head, _tail; // head and tail pointers to above circular buffer
zgu@3900 85
zgu@4400 86 bool _has_error;
zgu@3900 87
zgu@3900 88 public:
zgu@3900 89 MemTrackWorker();
zgu@3900 90 ~MemTrackWorker();
zgu@3900 91 _NOINLINE_ void* operator new(size_t size);
zgu@3900 92 _NOINLINE_ void* operator new(size_t size, const std::nothrow_t& nothrow_constant);
zgu@3900 93
zgu@3900 94 void start();
zgu@3900 95 void run();
zgu@3900 96
zgu@3900 97 inline bool has_error() const { return _has_error; }
zgu@3900 98
zgu@3900 99 // task at synchronization point
zgu@4400 100 void at_sync_point(MemRecorder* pending_recorders, int number_of_classes);
zgu@3900 101
zgu@3900 102 // for debugging purpose, they are not thread safe.
zgu@3900 103 NOT_PRODUCT(static int count_recorder(const MemRecorder* head);)
zgu@3900 104 NOT_PRODUCT(int count_pending_recorders() const;)
zgu@3900 105
zgu@3900 106 NOT_PRODUCT(int _sync_point_count;)
zgu@3900 107 NOT_PRODUCT(int _merge_count;)
zgu@3900 108 NOT_PRODUCT(int _last_gen_in_use;)
zgu@3900 109
ctornqvi@4512 110 // how many generations are queued
zgu@3900 111 inline int generations_in_use() const {
zgu@3935 112 return (_tail >= _head ? (_tail - _head + 1) : (MAX_GENERATIONS - (_head - _tail) + 1));
zgu@3900 113 }
zgu@3900 114 };
zgu@3900 115
zgu@3900 116 #endif // SHARE_VM_SERVICES_MEM_TRACK_WORKER_HPP

mercurial