fprofiler.hpp revision 4170
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* 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.
*
*/
#ifndef SHARE_VM_RUNTIME_FPROFILER_HPP
#define SHARE_VM_RUNTIME_FPROFILER_HPP
#ifdef TARGET_OS_FAMILY_linux
# include "thread_linux.inline.hpp"
#endif
#ifdef TARGET_OS_FAMILY_solaris
# include "thread_solaris.inline.hpp"
#endif
#ifdef TARGET_OS_FAMILY_windows
# include "thread_windows.inline.hpp"
#endif
#ifdef TARGET_OS_FAMILY_bsd
# include "thread_bsd.inline.hpp"
#endif
// a simple flat profiler for Java
// Forward declaration of classes defined in this header file
class ThreadProfiler;
class ThreadProfilerMark;
class FlatProfiler;
class IntervalData;
// Declarations of classes defined only in the implementation.
class ProfilerNode;
class FlatProfilerTask;
enum TickPosition {
};
// One of these guys is constructed as we enter interesting regions
// and destructed as we exit the region. While we are in the region
// ticks are allotted to the region.
class ThreadProfilerMark: public StackObj {
public:
// For now, the only thread-specific region is the class loader.
private:
};
class IntervalData VALUE_OBJ_CLASS_SPEC {
// Just to keep these things all together
private:
int _interpreted;
int _compiled;
int _native;
int _compiling;
public:
int interpreted() {
return _interpreted;
}
int compiled() {
return _compiled;
}
int native() {
return _native;
}
int compiling() {
return _compiling;
}
int total() {
}
void inc_interpreted() {
_interpreted += 1;
}
void inc_compiled() {
_compiled += 1;
}
void inc_native() {
_native += 1;
}
void inc_compiling() {
_compiling += 1;
}
void reset() {
_interpreted = 0;
_compiled = 0;
_native = 0;
_compiling = 0;
}
};
public:
~ThreadProfiler();
// Resets the profiler
void reset();
// Activates the profiler for a certain thread
void engage();
// Deactivates the profiler
void disengage();
// Prints the collected profiling information
void print(const char* thread_name);
// Garbage Collection Support
void oops_do(OopClosure* f);
private:
// for recording ticks.
friend class ProfilerNode;
char* area_bottom; // preallocated area for pnodes
char* area_top;
char* area_limit;
static int table_size;
private:
void initialize();
private:
friend class FlatProfiler;
bool engaged;
// so we can do percentages for this thread, and quick checks for activity
int thread_ticks;
int compiler_ticks;
int interpreter_ticks;
public:
private:
friend class ThreadProfilerMark;
// counters for thread-specific regions
int class_loader_ticks;
int extra_ticks;
private:
// other thread-specific regions
int blocked_ticks;
enum UnknownTickSites {
};
int unknown_ticks_array[ut_end];
int unknown_ticks() {
int result = 0;
}
return result;
}
// For interval timing
private:
return _interval_data;
}
return &_interval_data;
}
};
class FlatProfiler: AllStatic {
public:
static void reset() ;
static void disengage() ;
static bool is_active();
// This is NULL if each thread has its own thread profiler,
// else this is the single thread profiler used by all threads.
// In particular it makes a difference during garbage collection,
// where you only want to traverse each thread profiler once.
static ThreadProfiler* get_thread_profiler();
// Garbage Collection Support
static void oops_do(OopClosure* f) ;
// Support for disassembler to inspect the PCRecorder
// Returns the start address for a given pc
// NULL is returned if the PCRecorder is inactive
// Returns the number of ticks recorded for the bucket
// pc belongs to.
private:
static bool full_profile() {
return full_profile_flag;
}
friend class ThreadProfiler;
// the following group of ticks cover everything that's not attributed to individual Java methods
static int received_gc_ticks; // ticks during which gc was active
static int vm_operation_ticks; // total ticks in vm_operations other than GC
static int threads_lock_ticks; // the number of times we couldn't get the Threads_lock without blocking
static int blocked_ticks; // ticks when the thread was blocked.
static int class_loader_ticks; // total ticks in class loader
static int extra_ticks; // total ticks an extra temporary measuring
static int compiler_ticks; // total ticks in compilation
static int interpreter_ticks; // ticks in unknown interpreted method
static int deopt_ticks; // ticks in deoptimization
static int unknown_ticks; // ticks that cannot be categorized
static int received_ticks; // ticks that were received by task
static int delivered_ticks; // ticks that were delivered by task
static int non_method_ticks() {
return
+ unknown_ticks );
}
static elapsedTimer timer;
// Counts of each of the byte codes
static int* bytecode_ticks;
static int* bytecode_ticks_stub;
static void print_byte_code_statistics();
// the ticks below are for continuous profiling (to adjust recompilation, etc.)
static int all_ticks; // total count of ticks received so far
static int all_int_ticks; // ticks in interpreter
static int all_comp_ticks; // ticks in compiled code (+ native)
static bool full_profile_flag; // collecting full profile?
// to accumulate thread-specific data
// if we aren't profiling individual threads.
static ThreadProfiler* thread_profiler;
static ThreadProfiler* vm_thread_profiler;
static void allocate_table();
// The task that periodically interrupts things.
friend class FlatProfilerTask;
static FlatProfilerTask* task;
static void record_vm_operation();
static void record_vm_tick();
static void record_thread_ticks();
// For interval analysis
private:
static int interval_ticks_previous; // delivered_ticks from the last interval
static void interval_print(); // print interval data.
static void interval_reset(); // reset interval data.
enum {interval_print_size = 10};
static IntervalData* interval_data;
};
#endif // SHARE_VM_RUNTIME_FPROFILER_HPP