1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/oops/methodCounters.hpp Wed Apr 27 01:25:04 2016 +0800 1.3 @@ -0,0 +1,124 @@ 1.4 +/* 1.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 + * or visit www.oracle.com if you need additional information or have any 1.24 + * questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +#ifndef SHARE_VM_OOPS_METHODCOUNTERS_HPP 1.29 +#define SHARE_VM_OOPS_METHODCOUNTERS_HPP 1.30 + 1.31 +#include "oops/metadata.hpp" 1.32 +#include "interpreter/invocationCounter.hpp" 1.33 + 1.34 +class MethodCounters: public MetaspaceObj { 1.35 + friend class VMStructs; 1.36 + private: 1.37 + int _interpreter_invocation_count; // Count of times invoked (reused as prev_event_count in tiered) 1.38 + u2 _interpreter_throwout_count; // Count of times method was exited via exception while interpreting 1.39 + u2 _number_of_breakpoints; // fullspeed debugging support 1.40 + InvocationCounter _invocation_counter; // Incremented before each activation of the method - used to trigger frequency-based optimizations 1.41 + InvocationCounter _backedge_counter; // Incremented before each backedge taken - used to trigger frequencey-based optimizations 1.42 + 1.43 +#ifdef TIERED 1.44 + float _rate; // Events (invocation and backedge counter increments) per millisecond 1.45 + jlong _prev_time; // Previous time the rate was acquired 1.46 +#endif 1.47 + 1.48 + MethodCounters() : _interpreter_invocation_count(0), 1.49 + _interpreter_throwout_count(0), 1.50 + _number_of_breakpoints(0) 1.51 +#ifdef TIERED 1.52 + , _rate(0), 1.53 + _prev_time(0) 1.54 +#endif 1.55 + { 1.56 + invocation_counter()->init(); 1.57 + backedge_counter()->init(); 1.58 + } 1.59 + 1.60 + public: 1.61 + static MethodCounters* allocate(ClassLoaderData* loader_data, TRAPS); 1.62 + 1.63 + void deallocate_contents(ClassLoaderData* loader_data) {} 1.64 + DEBUG_ONLY(bool on_stack() { return false; }) // for template 1.65 + 1.66 + static int size() { return sizeof(MethodCounters) / wordSize; } 1.67 + 1.68 + bool is_klass() const { return false; } 1.69 + 1.70 + void clear_counters(); 1.71 + 1.72 + int interpreter_invocation_count() { 1.73 + return _interpreter_invocation_count; 1.74 + } 1.75 + void set_interpreter_invocation_count(int count) { 1.76 + _interpreter_invocation_count = count; 1.77 + } 1.78 + int increment_interpreter_invocation_count() { 1.79 + return ++_interpreter_invocation_count; 1.80 + } 1.81 + 1.82 + void interpreter_throwout_increment() { 1.83 + if (_interpreter_throwout_count < 65534) { 1.84 + _interpreter_throwout_count++; 1.85 + } 1.86 + } 1.87 + int interpreter_throwout_count() const { 1.88 + return _interpreter_throwout_count; 1.89 + } 1.90 + void set_interpreter_throwout_count(int count) { 1.91 + _interpreter_throwout_count = count; 1.92 + } 1.93 + 1.94 + u2 number_of_breakpoints() const { return _number_of_breakpoints; } 1.95 + void incr_number_of_breakpoints() { ++_number_of_breakpoints; } 1.96 + void decr_number_of_breakpoints() { --_number_of_breakpoints; } 1.97 + void clear_number_of_breakpoints() { _number_of_breakpoints = 0; } 1.98 + 1.99 +#ifdef TIERED 1.100 + jlong prev_time() const { return _prev_time; } 1.101 + void set_prev_time(jlong time) { _prev_time = time; } 1.102 + float rate() const { return _rate; } 1.103 + void set_rate(float rate) { _rate = rate; } 1.104 +#endif 1.105 + 1.106 + // invocation counter 1.107 + InvocationCounter* invocation_counter() { return &_invocation_counter; } 1.108 + InvocationCounter* backedge_counter() { return &_backedge_counter; } 1.109 + 1.110 + static ByteSize interpreter_invocation_counter_offset() { 1.111 + return byte_offset_of(MethodCounters, _interpreter_invocation_count); 1.112 + } 1.113 + 1.114 + static ByteSize invocation_counter_offset() { 1.115 + return byte_offset_of(MethodCounters, _invocation_counter); 1.116 + } 1.117 + 1.118 + static ByteSize backedge_counter_offset() { 1.119 + return byte_offset_of(MethodCounters, _backedge_counter); 1.120 + } 1.121 + 1.122 + static int interpreter_invocation_counter_offset_in_bytes() { 1.123 + return offset_of(MethodCounters, _interpreter_invocation_count); 1.124 + } 1.125 + 1.126 +}; 1.127 +#endif //SHARE_VM_OOPS_METHODCOUNTERS_HPP