src/share/vm/gc_implementation/shared/gcTimer.hpp

Tue, 26 Nov 2013 14:35:38 +0100

author
sjohanss
date
Tue, 26 Nov 2013 14:35:38 +0100
changeset 6148
55a0da3d420b
parent 5237
f2110083203d
child 6131
86e6d691f2e1
permissions
-rw-r--r--

8027675: Full collections with Serial slower in JDK 8 compared to 7u40
Summary: Reduced the number of calls to follow_class_loader and instead marked and pushed the klass holder directly. Also removed unneeded calls to adjust_klass.
Reviewed-by: coleenp, jmasa, mgerdin, tschatzl

sla@5237 1 /*
sla@5237 2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
sla@5237 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
sla@5237 4 *
sla@5237 5 * This code is free software; you can redistribute it and/or modify it
sla@5237 6 * under the terms of the GNU General Public License version 2 only, as
sla@5237 7 * published by the Free Software Foundation.
sla@5237 8 *
sla@5237 9 * This code is distributed in the hope that it will be useful, but WITHOUT
sla@5237 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
sla@5237 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
sla@5237 12 * version 2 for more details (a copy is included in the LICENSE file that
sla@5237 13 * accompanied this code).
sla@5237 14 *
sla@5237 15 * You should have received a copy of the GNU General Public License version
sla@5237 16 * 2 along with this work; if not, write to the Free Software Foundation,
sla@5237 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
sla@5237 18 *
sla@5237 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
sla@5237 20 * or visit www.oracle.com if you need additional information or have any
sla@5237 21 * questions.
sla@5237 22 *
sla@5237 23 */
sla@5237 24
sla@5237 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_SHARED_GCTIMER_HPP
sla@5237 26 #define SHARE_VM_GC_IMPLEMENTATION_SHARED_GCTIMER_HPP
sla@5237 27
sla@5237 28 #include "memory/allocation.hpp"
sla@5237 29 #include "prims/jni_md.h"
sla@5237 30 #include "utilities/macros.hpp"
sla@5237 31
sla@5237 32 class ConcurrentPhase;
sla@5237 33 class GCPhase;
sla@5237 34 class PausePhase;
sla@5237 35
sla@5237 36 template <class E> class GrowableArray;
sla@5237 37
sla@5237 38 class PhaseVisitor {
sla@5237 39 public:
sla@5237 40 virtual void visit(GCPhase* phase) = 0;
sla@5237 41 virtual void visit(PausePhase* phase) { visit((GCPhase*)phase); }
sla@5237 42 virtual void visit(ConcurrentPhase* phase) { visit((GCPhase*)phase); }
sla@5237 43 };
sla@5237 44
sla@5237 45 class GCPhase {
sla@5237 46 const char* _name;
sla@5237 47 int _level;
sla@5237 48 jlong _start;
sla@5237 49 jlong _end;
sla@5237 50
sla@5237 51 public:
sla@5237 52 void set_name(const char* name) { _name = name; }
sla@5237 53 const char* name() { return _name; }
sla@5237 54
sla@5237 55 int level() { return _level; }
sla@5237 56 void set_level(int level) { _level = level; }
sla@5237 57
sla@5237 58 jlong start() { return _start; }
sla@5237 59 void set_start(jlong time) { _start = time; }
sla@5237 60
sla@5237 61 jlong end() { return _end; }
sla@5237 62 void set_end(jlong time) { _end = time; }
sla@5237 63
sla@5237 64 virtual void accept(PhaseVisitor* visitor) = 0;
sla@5237 65 };
sla@5237 66
sla@5237 67 class PausePhase : public GCPhase {
sla@5237 68 public:
sla@5237 69 void accept(PhaseVisitor* visitor) {
sla@5237 70 visitor->visit(this);
sla@5237 71 }
sla@5237 72 };
sla@5237 73
sla@5237 74 class ConcurrentPhase : public GCPhase {
sla@5237 75 void accept(PhaseVisitor* visitor) {
sla@5237 76 visitor->visit(this);
sla@5237 77 }
sla@5237 78 };
sla@5237 79
sla@5237 80 class PhasesStack {
sla@5237 81 public:
sla@5237 82 // FIXME: Temporary set to 5 (used to be 4), since Reference processing needs it.
sla@5237 83 static const int PHASE_LEVELS = 5;
sla@5237 84
sla@5237 85 private:
sla@5237 86 int _phase_indices[PHASE_LEVELS];
sla@5237 87 int _next_phase_level;
sla@5237 88
sla@5237 89 public:
sla@5237 90 PhasesStack() { clear(); }
sla@5237 91 void clear();
sla@5237 92
sla@5237 93 void push(int phase_index);
sla@5237 94 int pop();
sla@5237 95 int count() const;
sla@5237 96 };
sla@5237 97
sla@5237 98 class TimePartitions {
sla@5237 99 static const int INITIAL_CAPACITY = 10;
sla@5237 100
sla@5237 101 // Currently we only support pause phases.
sla@5237 102 GrowableArray<PausePhase>* _phases;
sla@5237 103 PhasesStack _active_phases;
sla@5237 104
sla@5237 105 jlong _sum_of_pauses;
sla@5237 106 jlong _longest_pause;
sla@5237 107
sla@5237 108 public:
sla@5237 109 TimePartitions();
sla@5237 110 ~TimePartitions();
sla@5237 111 void clear();
sla@5237 112
sla@5237 113 void report_gc_phase_start(const char* name, jlong time);
sla@5237 114 void report_gc_phase_end(jlong time);
sla@5237 115
sla@5237 116 int num_phases() const;
sla@5237 117 GCPhase* phase_at(int index) const;
sla@5237 118
sla@5237 119 jlong sum_of_pauses();
sla@5237 120 jlong longest_pause();
sla@5237 121
sla@5237 122 bool has_active_phases();
sla@5237 123 private:
sla@5237 124 void update_statistics(GCPhase* phase);
sla@5237 125 };
sla@5237 126
sla@5237 127 class PhasesIterator {
sla@5237 128 public:
sla@5237 129 virtual bool has_next() = 0;
sla@5237 130 virtual GCPhase* next() = 0;
sla@5237 131 };
sla@5237 132
sla@5237 133 class GCTimer : public ResourceObj {
sla@5237 134 NOT_PRODUCT(friend class GCTimerTest;)
sla@5237 135 protected:
sla@5237 136 jlong _gc_start;
sla@5237 137 jlong _gc_end;
sla@5237 138 TimePartitions _time_partitions;
sla@5237 139
sla@5237 140 public:
sla@5237 141 virtual void register_gc_start(jlong time);
sla@5237 142 virtual void register_gc_end(jlong time);
sla@5237 143
sla@5237 144 void register_gc_phase_start(const char* name, jlong time);
sla@5237 145 void register_gc_phase_end(jlong time);
sla@5237 146
sla@5237 147 jlong gc_start() { return _gc_start; }
sla@5237 148 jlong gc_end() { return _gc_end; }
sla@5237 149
sla@5237 150 TimePartitions* time_partitions() { return &_time_partitions; }
sla@5237 151
sla@5237 152 long longest_pause();
sla@5237 153 long sum_of_pauses();
sla@5237 154
sla@5237 155 protected:
sla@5237 156 void register_gc_pause_start(const char* name, jlong time);
sla@5237 157 void register_gc_pause_end(jlong time);
sla@5237 158 };
sla@5237 159
sla@5237 160 class STWGCTimer : public GCTimer {
sla@5237 161 public:
sla@5237 162 virtual void register_gc_start(jlong time);
sla@5237 163 virtual void register_gc_end(jlong time);
sla@5237 164 };
sla@5237 165
sla@5237 166 class ConcurrentGCTimer : public GCTimer {
sla@5237 167 public:
sla@5237 168 void register_gc_pause_start(const char* name, jlong time);
sla@5237 169 void register_gc_pause_end(jlong time);
sla@5237 170 };
sla@5237 171
sla@5237 172 class TimePartitionPhasesIterator {
sla@5237 173 TimePartitions* _time_partitions;
sla@5237 174 int _next;
sla@5237 175
sla@5237 176 public:
sla@5237 177 TimePartitionPhasesIterator(TimePartitions* time_partitions) : _time_partitions(time_partitions), _next(0) { }
sla@5237 178
sla@5237 179 virtual bool has_next();
sla@5237 180 virtual GCPhase* next();
sla@5237 181 };
sla@5237 182
sla@5237 183
sla@5237 184 /////////////// Unit tests ///////////////
sla@5237 185
sla@5237 186 #ifndef PRODUCT
sla@5237 187
sla@5237 188 class GCTimerAllTest {
sla@5237 189 public:
sla@5237 190 static void all();
sla@5237 191 };
sla@5237 192
sla@5237 193 #endif
sla@5237 194
sla@5237 195 #endif // SHARE_VM_GC_IMPLEMENTATION_SHARED_GCTIMER_HPP

mercurial