Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/oops/methodCounters.hpp
32285 views
/*1* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_VM_OOPS_METHODCOUNTERS_HPP25#define SHARE_VM_OOPS_METHODCOUNTERS_HPP2627#include "oops/metadata.hpp"28#include "interpreter/invocationCounter.hpp"2930class MethodCounters: public MetaspaceObj {31friend class VMStructs;32private:33int _interpreter_invocation_count; // Count of times invoked (reused as prev_event_count in tiered)34u2 _interpreter_throwout_count; // Count of times method was exited via exception while interpreting35u2 _number_of_breakpoints; // fullspeed debugging support36InvocationCounter _invocation_counter; // Incremented before each activation of the method - used to trigger frequency-based optimizations37InvocationCounter _backedge_counter; // Incremented before each backedge taken - used to trigger frequencey-based optimizations3839#ifdef TIERED40float _rate; // Events (invocation and backedge counter increments) per millisecond41u1 _highest_comp_level; // Highest compile level this method has ever seen.42u1 _highest_osr_comp_level; // Same for OSR level43jlong _prev_time; // Previous time the rate was acquired44#endif4546MethodCounters() : _interpreter_invocation_count(0),47_interpreter_throwout_count(0),48_number_of_breakpoints(0)49#ifdef TIERED50, _rate(0),51_highest_comp_level(0),52_highest_osr_comp_level(0),53_prev_time(0)54#endif55{56invocation_counter()->init();57backedge_counter()->init();58}5960public:61static MethodCounters* allocate(ClassLoaderData* loader_data, TRAPS);6263void deallocate_contents(ClassLoaderData* loader_data) {}64DEBUG_ONLY(bool on_stack() { return false; }) // for template6566static int size() { return sizeof(MethodCounters) / wordSize; }6768bool is_klass() const { return false; }6970void clear_counters();7172int interpreter_invocation_count() {73return _interpreter_invocation_count;74}75void set_interpreter_invocation_count(int count) {76_interpreter_invocation_count = count;77}78int increment_interpreter_invocation_count() {79return ++_interpreter_invocation_count;80}8182void interpreter_throwout_increment() {83if (_interpreter_throwout_count < 65534) {84_interpreter_throwout_count++;85}86}87int interpreter_throwout_count() const {88return _interpreter_throwout_count;89}90void set_interpreter_throwout_count(int count) {91_interpreter_throwout_count = count;92}9394u2 number_of_breakpoints() const { return _number_of_breakpoints; }95void incr_number_of_breakpoints() { ++_number_of_breakpoints; }96void decr_number_of_breakpoints() { --_number_of_breakpoints; }97void clear_number_of_breakpoints() { _number_of_breakpoints = 0; }9899#ifdef TIERED100jlong prev_time() const { return _prev_time; }101void set_prev_time(jlong time) { _prev_time = time; }102float rate() const { return _rate; }103void set_rate(float rate) { _rate = rate; }104#endif105106int highest_comp_level() const;107void set_highest_comp_level(int level);108int highest_osr_comp_level() const;109void set_highest_osr_comp_level(int level);110111// invocation counter112InvocationCounter* invocation_counter() { return &_invocation_counter; }113InvocationCounter* backedge_counter() { return &_backedge_counter; }114115static ByteSize interpreter_invocation_counter_offset() {116return byte_offset_of(MethodCounters, _interpreter_invocation_count);117}118119static ByteSize invocation_counter_offset() {120return byte_offset_of(MethodCounters, _invocation_counter);121}122123static ByteSize backedge_counter_offset() {124return byte_offset_of(MethodCounters, _backedge_counter);125}126127static int interpreter_invocation_counter_offset_in_bytes() {128return offset_of(MethodCounters, _interpreter_invocation_count);129}130131};132#endif //SHARE_VM_OOPS_METHODCOUNTERS_HPP133134135