Thu, 11 Sep 2014 12:18:26 -0700
8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
Summary: Tiered policy requires highest compilation levels always available
Reviewed-by: kvn, vlivanov
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 |
iveresov@7171 | 42 | u1 _highest_comp_level; // Highest compile level this method has ever seen. |
iveresov@7171 | 43 | u1 _highest_osr_comp_level; // Same for OSR level |
aoqi@0 | 44 | jlong _prev_time; // Previous time the rate was acquired |
aoqi@0 | 45 | #endif |
aoqi@0 | 46 | |
aoqi@0 | 47 | MethodCounters() : _interpreter_invocation_count(0), |
aoqi@0 | 48 | _interpreter_throwout_count(0), |
aoqi@0 | 49 | _number_of_breakpoints(0) |
aoqi@0 | 50 | #ifdef TIERED |
aoqi@0 | 51 | , _rate(0), |
iveresov@7171 | 52 | _highest_comp_level(0), |
iveresov@7171 | 53 | _highest_osr_comp_level(0), |
aoqi@0 | 54 | _prev_time(0) |
aoqi@0 | 55 | #endif |
aoqi@0 | 56 | { |
aoqi@0 | 57 | invocation_counter()->init(); |
aoqi@0 | 58 | backedge_counter()->init(); |
aoqi@0 | 59 | } |
aoqi@0 | 60 | |
aoqi@0 | 61 | public: |
aoqi@0 | 62 | static MethodCounters* allocate(ClassLoaderData* loader_data, TRAPS); |
aoqi@0 | 63 | |
aoqi@0 | 64 | void deallocate_contents(ClassLoaderData* loader_data) {} |
aoqi@0 | 65 | DEBUG_ONLY(bool on_stack() { return false; }) // for template |
aoqi@0 | 66 | |
aoqi@0 | 67 | static int size() { return sizeof(MethodCounters) / wordSize; } |
aoqi@0 | 68 | |
aoqi@0 | 69 | bool is_klass() const { return false; } |
aoqi@0 | 70 | |
aoqi@0 | 71 | void clear_counters(); |
aoqi@0 | 72 | |
aoqi@0 | 73 | int interpreter_invocation_count() { |
aoqi@0 | 74 | return _interpreter_invocation_count; |
aoqi@0 | 75 | } |
aoqi@0 | 76 | void set_interpreter_invocation_count(int count) { |
aoqi@0 | 77 | _interpreter_invocation_count = count; |
aoqi@0 | 78 | } |
aoqi@0 | 79 | int increment_interpreter_invocation_count() { |
aoqi@0 | 80 | return ++_interpreter_invocation_count; |
aoqi@0 | 81 | } |
aoqi@0 | 82 | |
aoqi@0 | 83 | void interpreter_throwout_increment() { |
aoqi@0 | 84 | if (_interpreter_throwout_count < 65534) { |
aoqi@0 | 85 | _interpreter_throwout_count++; |
aoqi@0 | 86 | } |
aoqi@0 | 87 | } |
aoqi@0 | 88 | int interpreter_throwout_count() const { |
aoqi@0 | 89 | return _interpreter_throwout_count; |
aoqi@0 | 90 | } |
aoqi@0 | 91 | void set_interpreter_throwout_count(int count) { |
aoqi@0 | 92 | _interpreter_throwout_count = count; |
aoqi@0 | 93 | } |
aoqi@0 | 94 | |
aoqi@0 | 95 | u2 number_of_breakpoints() const { return _number_of_breakpoints; } |
aoqi@0 | 96 | void incr_number_of_breakpoints() { ++_number_of_breakpoints; } |
aoqi@0 | 97 | void decr_number_of_breakpoints() { --_number_of_breakpoints; } |
aoqi@0 | 98 | void clear_number_of_breakpoints() { _number_of_breakpoints = 0; } |
aoqi@0 | 99 | |
aoqi@0 | 100 | #ifdef TIERED |
aoqi@0 | 101 | jlong prev_time() const { return _prev_time; } |
aoqi@0 | 102 | void set_prev_time(jlong time) { _prev_time = time; } |
aoqi@0 | 103 | float rate() const { return _rate; } |
aoqi@0 | 104 | void set_rate(float rate) { _rate = rate; } |
aoqi@0 | 105 | #endif |
aoqi@0 | 106 | |
iveresov@7171 | 107 | int highest_comp_level() const; |
iveresov@7171 | 108 | void set_highest_comp_level(int level); |
iveresov@7171 | 109 | int highest_osr_comp_level() const; |
iveresov@7171 | 110 | void set_highest_osr_comp_level(int level); |
iveresov@7171 | 111 | |
aoqi@0 | 112 | // invocation counter |
aoqi@0 | 113 | InvocationCounter* invocation_counter() { return &_invocation_counter; } |
aoqi@0 | 114 | InvocationCounter* backedge_counter() { return &_backedge_counter; } |
aoqi@0 | 115 | |
aoqi@0 | 116 | static ByteSize interpreter_invocation_counter_offset() { |
aoqi@0 | 117 | return byte_offset_of(MethodCounters, _interpreter_invocation_count); |
aoqi@0 | 118 | } |
aoqi@0 | 119 | |
aoqi@0 | 120 | static ByteSize invocation_counter_offset() { |
aoqi@0 | 121 | return byte_offset_of(MethodCounters, _invocation_counter); |
aoqi@0 | 122 | } |
aoqi@0 | 123 | |
aoqi@0 | 124 | static ByteSize backedge_counter_offset() { |
aoqi@0 | 125 | return byte_offset_of(MethodCounters, _backedge_counter); |
aoqi@0 | 126 | } |
aoqi@0 | 127 | |
aoqi@0 | 128 | static int interpreter_invocation_counter_offset_in_bytes() { |
aoqi@0 | 129 | return offset_of(MethodCounters, _interpreter_invocation_count); |
aoqi@0 | 130 | } |
aoqi@0 | 131 | |
aoqi@0 | 132 | }; |
aoqi@0 | 133 | #endif //SHARE_VM_OOPS_METHODCOUNTERS_HPP |