aoqi@0: /* aoqi@0: * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: * aoqi@0: */ aoqi@0: aoqi@0: #ifndef SHARE_VM_OOPS_METHODCOUNTERS_HPP aoqi@0: #define SHARE_VM_OOPS_METHODCOUNTERS_HPP aoqi@0: aoqi@0: #include "oops/metadata.hpp" aoqi@0: #include "interpreter/invocationCounter.hpp" aoqi@0: aoqi@0: class MethodCounters: public MetaspaceObj { aoqi@0: friend class VMStructs; aoqi@0: private: aoqi@0: int _interpreter_invocation_count; // Count of times invoked (reused as prev_event_count in tiered) aoqi@0: u2 _interpreter_throwout_count; // Count of times method was exited via exception while interpreting aoqi@0: u2 _number_of_breakpoints; // fullspeed debugging support aoqi@0: InvocationCounter _invocation_counter; // Incremented before each activation of the method - used to trigger frequency-based optimizations aoqi@0: InvocationCounter _backedge_counter; // Incremented before each backedge taken - used to trigger frequencey-based optimizations aoqi@0: aoqi@0: #ifdef TIERED aoqi@0: float _rate; // Events (invocation and backedge counter increments) per millisecond aoqi@0: jlong _prev_time; // Previous time the rate was acquired aoqi@0: #endif aoqi@0: aoqi@0: MethodCounters() : _interpreter_invocation_count(0), aoqi@0: _interpreter_throwout_count(0), aoqi@0: _number_of_breakpoints(0) aoqi@0: #ifdef TIERED aoqi@0: , _rate(0), aoqi@0: _prev_time(0) aoqi@0: #endif aoqi@0: { aoqi@0: invocation_counter()->init(); aoqi@0: backedge_counter()->init(); aoqi@0: } aoqi@0: aoqi@0: public: aoqi@0: static MethodCounters* allocate(ClassLoaderData* loader_data, TRAPS); aoqi@0: aoqi@0: void deallocate_contents(ClassLoaderData* loader_data) {} aoqi@0: DEBUG_ONLY(bool on_stack() { return false; }) // for template aoqi@0: aoqi@0: static int size() { return sizeof(MethodCounters) / wordSize; } aoqi@0: aoqi@0: bool is_klass() const { return false; } aoqi@0: aoqi@0: void clear_counters(); aoqi@0: aoqi@0: int interpreter_invocation_count() { aoqi@0: return _interpreter_invocation_count; aoqi@0: } aoqi@0: void set_interpreter_invocation_count(int count) { aoqi@0: _interpreter_invocation_count = count; aoqi@0: } aoqi@0: int increment_interpreter_invocation_count() { aoqi@0: return ++_interpreter_invocation_count; aoqi@0: } aoqi@0: aoqi@0: void interpreter_throwout_increment() { aoqi@0: if (_interpreter_throwout_count < 65534) { aoqi@0: _interpreter_throwout_count++; aoqi@0: } aoqi@0: } aoqi@0: int interpreter_throwout_count() const { aoqi@0: return _interpreter_throwout_count; aoqi@0: } aoqi@0: void set_interpreter_throwout_count(int count) { aoqi@0: _interpreter_throwout_count = count; aoqi@0: } aoqi@0: aoqi@0: u2 number_of_breakpoints() const { return _number_of_breakpoints; } aoqi@0: void incr_number_of_breakpoints() { ++_number_of_breakpoints; } aoqi@0: void decr_number_of_breakpoints() { --_number_of_breakpoints; } aoqi@0: void clear_number_of_breakpoints() { _number_of_breakpoints = 0; } aoqi@0: aoqi@0: #ifdef TIERED aoqi@0: jlong prev_time() const { return _prev_time; } aoqi@0: void set_prev_time(jlong time) { _prev_time = time; } aoqi@0: float rate() const { return _rate; } aoqi@0: void set_rate(float rate) { _rate = rate; } aoqi@0: #endif aoqi@0: aoqi@0: // invocation counter aoqi@0: InvocationCounter* invocation_counter() { return &_invocation_counter; } aoqi@0: InvocationCounter* backedge_counter() { return &_backedge_counter; } aoqi@0: aoqi@0: static ByteSize interpreter_invocation_counter_offset() { aoqi@0: return byte_offset_of(MethodCounters, _interpreter_invocation_count); aoqi@0: } aoqi@0: aoqi@0: static ByteSize invocation_counter_offset() { aoqi@0: return byte_offset_of(MethodCounters, _invocation_counter); aoqi@0: } aoqi@0: aoqi@0: static ByteSize backedge_counter_offset() { aoqi@0: return byte_offset_of(MethodCounters, _backedge_counter); aoqi@0: } aoqi@0: aoqi@0: static int interpreter_invocation_counter_offset_in_bytes() { aoqi@0: return offset_of(MethodCounters, _interpreter_invocation_count); aoqi@0: } aoqi@0: aoqi@0: }; aoqi@0: #endif //SHARE_VM_OOPS_METHODCOUNTERS_HPP