|
1 /* |
|
2 * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. |
|
8 * |
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
|
13 * accompanied this code). |
|
14 * |
|
15 * You should have received a copy of the GNU General Public License version |
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 * |
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 * or visit www.oracle.com if you need additional information or have any |
|
21 * questions. |
|
22 * |
|
23 */ |
|
24 #include "precompiled.hpp" |
|
25 #include "memory/metaspaceClosure.hpp" |
|
26 #include "oops/methodCounters.hpp" |
|
27 #include "runtime/handles.inline.hpp" |
|
28 |
|
29 MethodCounters* MethodCounters::allocate(const methodHandle& mh, TRAPS) { |
|
30 ClassLoaderData* loader_data = mh->method_holder()->class_loader_data(); |
|
31 return new(loader_data, method_counters_size(), MetaspaceObj::MethodCountersType, THREAD) MethodCounters(mh); |
|
32 } |
|
33 |
|
34 void MethodCounters::clear_counters() { |
|
35 invocation_counter()->reset(); |
|
36 backedge_counter()->reset(); |
|
37 set_interpreter_throwout_count(0); |
|
38 set_interpreter_invocation_count(0); |
|
39 set_nmethod_age(INT_MAX); |
|
40 #ifdef TIERED |
|
41 set_prev_time(0); |
|
42 set_rate(0); |
|
43 set_highest_comp_level(0); |
|
44 set_highest_osr_comp_level(0); |
|
45 #endif |
|
46 } |
|
47 |
|
48 |
|
49 int MethodCounters::highest_comp_level() const { |
|
50 #ifdef TIERED |
|
51 return _highest_comp_level; |
|
52 #else |
|
53 return CompLevel_none; |
|
54 #endif |
|
55 } |
|
56 |
|
57 void MethodCounters::set_highest_comp_level(int level) { |
|
58 #ifdef TIERED |
|
59 _highest_comp_level = level; |
|
60 #endif |
|
61 } |
|
62 |
|
63 int MethodCounters::highest_osr_comp_level() const { |
|
64 #ifdef TIERED |
|
65 return _highest_osr_comp_level; |
|
66 #else |
|
67 return CompLevel_none; |
|
68 #endif |
|
69 } |
|
70 |
|
71 void MethodCounters::set_highest_osr_comp_level(int level) { |
|
72 #ifdef TIERED |
|
73 _highest_osr_comp_level = level; |
|
74 #endif |
|
75 } |
|
76 |
|
77 void MethodCounters::metaspace_pointers_do(MetaspaceClosure* it) { |
|
78 log_trace(cds)("Iter(MethodCounters): %p", this); |
|
79 #if INCLUDE_AOT |
|
80 it->push(&_method); |
|
81 #endif |
|
82 } |
|
83 |
|
84 void MethodCounters::print_value_on(outputStream* st) const { |
|
85 assert(is_methodCounters(), "must be methodCounters"); |
|
86 st->print("method counters"); |
|
87 print_address_on(st); |
|
88 } |
|
89 |
|
90 |