src/share/vm/oops/methodCounters.hpp

Fri, 20 Sep 2013 09:30:02 -0400

author
coleenp
date
Fri, 20 Sep 2013 09:30:02 -0400
changeset 5749
4f9a42c33738
parent 0
f90c822e73f8
child 7171
631667807de7
permissions
-rw-r--r--

8022887: Assertion hit while using class and redefining it with RedefineClasses simultaneously
Summary: Need to refetch each method from InstanceKlass after all safepoints. Removed leaky PreviousVersionInfo code.
Reviewed-by: dcubed, sspitsyn

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #ifndef SHARE_VM_OOPS_METHODCOUNTERS_HPP
aoqi@0 26 #define SHARE_VM_OOPS_METHODCOUNTERS_HPP
aoqi@0 27
aoqi@0 28 #include "oops/metadata.hpp"
aoqi@0 29 #include "interpreter/invocationCounter.hpp"
aoqi@0 30
aoqi@0 31 class MethodCounters: public MetaspaceObj {
aoqi@0 32 friend class VMStructs;
aoqi@0 33 private:
aoqi@0 34 int _interpreter_invocation_count; // Count of times invoked (reused as prev_event_count in tiered)
aoqi@0 35 u2 _interpreter_throwout_count; // Count of times method was exited via exception while interpreting
aoqi@0 36 u2 _number_of_breakpoints; // fullspeed debugging support
aoqi@0 37 InvocationCounter _invocation_counter; // Incremented before each activation of the method - used to trigger frequency-based optimizations
aoqi@0 38 InvocationCounter _backedge_counter; // Incremented before each backedge taken - used to trigger frequencey-based optimizations
aoqi@0 39
aoqi@0 40 #ifdef TIERED
aoqi@0 41 float _rate; // Events (invocation and backedge counter increments) per millisecond
aoqi@0 42 jlong _prev_time; // Previous time the rate was acquired
aoqi@0 43 #endif
aoqi@0 44
aoqi@0 45 MethodCounters() : _interpreter_invocation_count(0),
aoqi@0 46 _interpreter_throwout_count(0),
aoqi@0 47 _number_of_breakpoints(0)
aoqi@0 48 #ifdef TIERED
aoqi@0 49 , _rate(0),
aoqi@0 50 _prev_time(0)
aoqi@0 51 #endif
aoqi@0 52 {
aoqi@0 53 invocation_counter()->init();
aoqi@0 54 backedge_counter()->init();
aoqi@0 55 }
aoqi@0 56
aoqi@0 57 public:
aoqi@0 58 static MethodCounters* allocate(ClassLoaderData* loader_data, TRAPS);
aoqi@0 59
aoqi@0 60 void deallocate_contents(ClassLoaderData* loader_data) {}
aoqi@0 61 DEBUG_ONLY(bool on_stack() { return false; }) // for template
aoqi@0 62
aoqi@0 63 static int size() { return sizeof(MethodCounters) / wordSize; }
aoqi@0 64
aoqi@0 65 bool is_klass() const { return false; }
aoqi@0 66
aoqi@0 67 void clear_counters();
aoqi@0 68
aoqi@0 69 int interpreter_invocation_count() {
aoqi@0 70 return _interpreter_invocation_count;
aoqi@0 71 }
aoqi@0 72 void set_interpreter_invocation_count(int count) {
aoqi@0 73 _interpreter_invocation_count = count;
aoqi@0 74 }
aoqi@0 75 int increment_interpreter_invocation_count() {
aoqi@0 76 return ++_interpreter_invocation_count;
aoqi@0 77 }
aoqi@0 78
aoqi@0 79 void interpreter_throwout_increment() {
aoqi@0 80 if (_interpreter_throwout_count < 65534) {
aoqi@0 81 _interpreter_throwout_count++;
aoqi@0 82 }
aoqi@0 83 }
aoqi@0 84 int interpreter_throwout_count() const {
aoqi@0 85 return _interpreter_throwout_count;
aoqi@0 86 }
aoqi@0 87 void set_interpreter_throwout_count(int count) {
aoqi@0 88 _interpreter_throwout_count = count;
aoqi@0 89 }
aoqi@0 90
aoqi@0 91 u2 number_of_breakpoints() const { return _number_of_breakpoints; }
aoqi@0 92 void incr_number_of_breakpoints() { ++_number_of_breakpoints; }
aoqi@0 93 void decr_number_of_breakpoints() { --_number_of_breakpoints; }
aoqi@0 94 void clear_number_of_breakpoints() { _number_of_breakpoints = 0; }
aoqi@0 95
aoqi@0 96 #ifdef TIERED
aoqi@0 97 jlong prev_time() const { return _prev_time; }
aoqi@0 98 void set_prev_time(jlong time) { _prev_time = time; }
aoqi@0 99 float rate() const { return _rate; }
aoqi@0 100 void set_rate(float rate) { _rate = rate; }
aoqi@0 101 #endif
aoqi@0 102
aoqi@0 103 // invocation counter
aoqi@0 104 InvocationCounter* invocation_counter() { return &_invocation_counter; }
aoqi@0 105 InvocationCounter* backedge_counter() { return &_backedge_counter; }
aoqi@0 106
aoqi@0 107 static ByteSize interpreter_invocation_counter_offset() {
aoqi@0 108 return byte_offset_of(MethodCounters, _interpreter_invocation_count);
aoqi@0 109 }
aoqi@0 110
aoqi@0 111 static ByteSize invocation_counter_offset() {
aoqi@0 112 return byte_offset_of(MethodCounters, _invocation_counter);
aoqi@0 113 }
aoqi@0 114
aoqi@0 115 static ByteSize backedge_counter_offset() {
aoqi@0 116 return byte_offset_of(MethodCounters, _backedge_counter);
aoqi@0 117 }
aoqi@0 118
aoqi@0 119 static int interpreter_invocation_counter_offset_in_bytes() {
aoqi@0 120 return offset_of(MethodCounters, _interpreter_invocation_count);
aoqi@0 121 }
aoqi@0 122
aoqi@0 123 };
aoqi@0 124 #endif //SHARE_VM_OOPS_METHODCOUNTERS_HPP

mercurial