2013-06-10 11:30:51 +02:00
|
|
|
/*
|
2015-05-13 15:16:06 +02:00
|
|
|
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
|
2013-06-10 11:30:51 +02:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2015-05-13 15:16:06 +02:00
|
|
|
#ifndef SHARE_VM_GC_SHARED_GCTIMER_HPP
|
|
|
|
#define SHARE_VM_GC_SHARED_GCTIMER_HPP
|
2013-06-10 11:30:51 +02:00
|
|
|
|
|
|
|
#include "memory/allocation.hpp"
|
|
|
|
#include "prims/jni_md.h"
|
|
|
|
#include "utilities/macros.hpp"
|
2013-11-23 12:25:13 +01:00
|
|
|
#include "utilities/ticks.hpp"
|
2013-06-10 11:30:51 +02:00
|
|
|
|
|
|
|
class ConcurrentPhase;
|
|
|
|
class GCPhase;
|
|
|
|
class PausePhase;
|
|
|
|
|
|
|
|
template <class E> class GrowableArray;
|
|
|
|
|
|
|
|
class PhaseVisitor {
|
|
|
|
public:
|
|
|
|
virtual void visit(GCPhase* phase) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
class GCPhase {
|
2015-12-18 08:17:30 -08:00
|
|
|
public:
|
|
|
|
enum PhaseType {
|
|
|
|
PausePhaseType = 0,
|
|
|
|
ConcurrentPhaseType = 1
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
2013-06-10 11:30:51 +02:00
|
|
|
const char* _name;
|
|
|
|
int _level;
|
2013-11-23 12:25:13 +01:00
|
|
|
Ticks _start;
|
|
|
|
Ticks _end;
|
2015-12-18 08:17:30 -08:00
|
|
|
PhaseType _type;
|
2013-06-10 11:30:51 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
void set_name(const char* name) { _name = name; }
|
2013-11-23 12:25:13 +01:00
|
|
|
const char* name() const { return _name; }
|
2013-06-10 11:30:51 +02:00
|
|
|
|
2013-11-23 12:25:13 +01:00
|
|
|
int level() const { return _level; }
|
2013-06-10 11:30:51 +02:00
|
|
|
void set_level(int level) { _level = level; }
|
|
|
|
|
2013-11-23 12:25:13 +01:00
|
|
|
const Ticks start() const { return _start; }
|
|
|
|
void set_start(const Ticks& time) { _start = time; }
|
2013-06-10 11:30:51 +02:00
|
|
|
|
2013-11-23 12:25:13 +01:00
|
|
|
const Ticks end() const { return _end; }
|
|
|
|
void set_end(const Ticks& time) { _end = time; }
|
2013-06-10 11:30:51 +02:00
|
|
|
|
2015-12-18 08:17:30 -08:00
|
|
|
PhaseType type() const { return _type; }
|
|
|
|
void set_type(PhaseType type) { _type = type; }
|
2013-06-10 11:30:51 +02:00
|
|
|
|
|
|
|
void accept(PhaseVisitor* visitor) {
|
|
|
|
visitor->visit(this);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class PhasesStack {
|
|
|
|
public:
|
2015-12-18 08:17:30 -08:00
|
|
|
// Set to 5, since Reference processing needs it.
|
2013-06-10 11:30:51 +02:00
|
|
|
static const int PHASE_LEVELS = 5;
|
|
|
|
|
|
|
|
private:
|
|
|
|
int _phase_indices[PHASE_LEVELS];
|
|
|
|
int _next_phase_level;
|
|
|
|
|
|
|
|
public:
|
|
|
|
PhasesStack() { clear(); }
|
|
|
|
void clear();
|
|
|
|
|
|
|
|
void push(int phase_index);
|
|
|
|
int pop();
|
|
|
|
int count() const;
|
|
|
|
};
|
|
|
|
|
|
|
|
class TimePartitions {
|
|
|
|
static const int INITIAL_CAPACITY = 10;
|
|
|
|
|
2015-12-18 08:17:30 -08:00
|
|
|
GrowableArray<GCPhase>* _phases;
|
2013-06-10 11:30:51 +02:00
|
|
|
PhasesStack _active_phases;
|
|
|
|
|
2013-11-23 12:25:13 +01:00
|
|
|
Tickspan _sum_of_pauses;
|
|
|
|
Tickspan _longest_pause;
|
2013-06-10 11:30:51 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
TimePartitions();
|
|
|
|
~TimePartitions();
|
|
|
|
void clear();
|
|
|
|
|
2015-12-18 08:17:30 -08:00
|
|
|
void report_gc_phase_start(const char* name, const Ticks& time, GCPhase::PhaseType type=GCPhase::PausePhaseType);
|
|
|
|
void report_gc_phase_end(const Ticks& time, GCPhase::PhaseType type=GCPhase::PausePhaseType);
|
2013-06-10 11:30:51 +02:00
|
|
|
|
|
|
|
int num_phases() const;
|
|
|
|
GCPhase* phase_at(int index) const;
|
|
|
|
|
2013-11-23 12:25:13 +01:00
|
|
|
const Tickspan sum_of_pauses() const { return _sum_of_pauses; }
|
|
|
|
const Tickspan longest_pause() const { return _longest_pause; }
|
2013-06-10 11:30:51 +02:00
|
|
|
|
|
|
|
bool has_active_phases();
|
2015-12-18 08:17:30 -08:00
|
|
|
|
2013-06-10 11:30:51 +02:00
|
|
|
private:
|
|
|
|
void update_statistics(GCPhase* phase);
|
|
|
|
};
|
|
|
|
|
|
|
|
class PhasesIterator {
|
|
|
|
public:
|
|
|
|
virtual bool has_next() = 0;
|
|
|
|
virtual GCPhase* next() = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
class GCTimer : public ResourceObj {
|
|
|
|
NOT_PRODUCT(friend class GCTimerTest;)
|
|
|
|
protected:
|
2013-11-23 12:25:13 +01:00
|
|
|
Ticks _gc_start;
|
|
|
|
Ticks _gc_end;
|
2013-06-10 11:30:51 +02:00
|
|
|
TimePartitions _time_partitions;
|
|
|
|
|
|
|
|
public:
|
2013-11-23 12:25:13 +01:00
|
|
|
virtual void register_gc_start(const Ticks& time = Ticks::now());
|
|
|
|
virtual void register_gc_end(const Ticks& time = Ticks::now());
|
2013-06-10 11:30:51 +02:00
|
|
|
|
2013-11-23 12:25:13 +01:00
|
|
|
void register_gc_phase_start(const char* name, const Ticks& time);
|
|
|
|
void register_gc_phase_end(const Ticks& time);
|
2013-06-10 11:30:51 +02:00
|
|
|
|
2013-11-23 12:25:13 +01:00
|
|
|
const Ticks gc_start() const { return _gc_start; }
|
|
|
|
const Ticks gc_end() const { return _gc_end; }
|
2013-06-10 11:30:51 +02:00
|
|
|
|
|
|
|
TimePartitions* time_partitions() { return &_time_partitions; }
|
|
|
|
|
|
|
|
protected:
|
2013-11-23 12:25:13 +01:00
|
|
|
void register_gc_pause_start(const char* name, const Ticks& time = Ticks::now());
|
|
|
|
void register_gc_pause_end(const Ticks& time = Ticks::now());
|
2013-06-10 11:30:51 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class STWGCTimer : public GCTimer {
|
|
|
|
public:
|
2013-11-23 12:25:13 +01:00
|
|
|
virtual void register_gc_start(const Ticks& time = Ticks::now());
|
|
|
|
virtual void register_gc_end(const Ticks& time = Ticks::now());
|
2013-06-10 11:30:51 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class ConcurrentGCTimer : public GCTimer {
|
2015-12-18 08:17:30 -08:00
|
|
|
// ConcurrentGCTimer can't be used if there is an overlap between a pause phase and a concurrent phase.
|
|
|
|
// _is_concurrent_phase_active is used to find above case.
|
|
|
|
bool _is_concurrent_phase_active;
|
|
|
|
|
2013-06-10 11:30:51 +02:00
|
|
|
public:
|
2015-12-18 08:17:30 -08:00
|
|
|
ConcurrentGCTimer(): GCTimer(), _is_concurrent_phase_active(false) {};
|
|
|
|
|
2013-11-23 12:25:13 +01:00
|
|
|
void register_gc_pause_start(const char* name);
|
|
|
|
void register_gc_pause_end();
|
2015-12-18 08:17:30 -08:00
|
|
|
|
|
|
|
void register_gc_concurrent_start(const char* name, const Ticks& time = Ticks::now());
|
|
|
|
void register_gc_concurrent_end(const Ticks& time = Ticks::now());
|
2013-06-10 11:30:51 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class TimePartitionPhasesIterator {
|
|
|
|
TimePartitions* _time_partitions;
|
|
|
|
int _next;
|
|
|
|
|
|
|
|
public:
|
|
|
|
TimePartitionPhasesIterator(TimePartitions* time_partitions) : _time_partitions(time_partitions), _next(0) { }
|
|
|
|
|
|
|
|
virtual bool has_next();
|
|
|
|
virtual GCPhase* next();
|
|
|
|
};
|
|
|
|
|
2015-05-13 15:16:06 +02:00
|
|
|
#endif // SHARE_VM_GC_SHARED_GCTIMER_HPP
|