annotate src/share/vm/interpreter/bytecodeHistogram.hpp @ 7212:291ffc492eb6

Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/
author Doug Simon <doug.simon@oracle.com>
date Fri, 14 Dec 2012 14:35:13 +0100
parents f95d63e2154a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #ifndef SHARE_VM_INTERPRETER_BYTECODEHISTOGRAM_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_INTERPRETER_BYTECODEHISTOGRAM_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "interpreter/bytecodes.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "memory/allocation.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30
0
a61af66fc99e Initial load
duke
parents:
diff changeset
31 // BytecodeCounter counts the number of bytecodes executed
a61af66fc99e Initial load
duke
parents:
diff changeset
32
a61af66fc99e Initial load
duke
parents:
diff changeset
33 class BytecodeCounter: AllStatic {
a61af66fc99e Initial load
duke
parents:
diff changeset
34 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
35 NOT_PRODUCT(static int _counter_value;)
a61af66fc99e Initial load
duke
parents:
diff changeset
36 NOT_PRODUCT(static jlong _reset_time;)
a61af66fc99e Initial load
duke
parents:
diff changeset
37
a61af66fc99e Initial load
duke
parents:
diff changeset
38 friend class TemplateInterpreterGenerator;
a61af66fc99e Initial load
duke
parents:
diff changeset
39 friend class BytecodeInterpreter;
a61af66fc99e Initial load
duke
parents:
diff changeset
40
a61af66fc99e Initial load
duke
parents:
diff changeset
41 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
42 // Initialization
a61af66fc99e Initial load
duke
parents:
diff changeset
43 static void reset() PRODUCT_RETURN;
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 // Counter info (all info since last reset)
a61af66fc99e Initial load
duke
parents:
diff changeset
46 static int counter_value() PRODUCT_RETURN0 NOT_PRODUCT({ return _counter_value; });
a61af66fc99e Initial load
duke
parents:
diff changeset
47 static double elapsed_time() PRODUCT_RETURN0; // in seconds
a61af66fc99e Initial load
duke
parents:
diff changeset
48 static double frequency() PRODUCT_RETURN0; // bytecodes/seconds
a61af66fc99e Initial load
duke
parents:
diff changeset
49
a61af66fc99e Initial load
duke
parents:
diff changeset
50 // Counter printing
a61af66fc99e Initial load
duke
parents:
diff changeset
51 static void print() PRODUCT_RETURN;
a61af66fc99e Initial load
duke
parents:
diff changeset
52 };
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // BytecodeHistogram collects number of executions of bytecodes
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57 class BytecodeHistogram: AllStatic {
a61af66fc99e Initial load
duke
parents:
diff changeset
58 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
59 NOT_PRODUCT(static int _counters[Bytecodes::number_of_codes];) // a counter for each bytecode
a61af66fc99e Initial load
duke
parents:
diff changeset
60
a61af66fc99e Initial load
duke
parents:
diff changeset
61 friend class TemplateInterpreterGenerator;
a61af66fc99e Initial load
duke
parents:
diff changeset
62 friend class InterpreterGenerator;
a61af66fc99e Initial load
duke
parents:
diff changeset
63 friend class BytecodeInterpreter;
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // Initialization
a61af66fc99e Initial load
duke
parents:
diff changeset
67 static void reset() PRODUCT_RETURN; // reset counters
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // Profile printing
a61af66fc99e Initial load
duke
parents:
diff changeset
70 static void print(float cutoff = 0.01F) PRODUCT_RETURN; // cutoff in percent
a61af66fc99e Initial load
duke
parents:
diff changeset
71 };
a61af66fc99e Initial load
duke
parents:
diff changeset
72
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // BytecodePairHistogram collects number of executions of bytecode pairs.
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // A bytecode pair is any sequence of two consequtive bytecodes.
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 class BytecodePairHistogram: AllStatic {
a61af66fc99e Initial load
duke
parents:
diff changeset
78 public: // for SparcWorks
a61af66fc99e Initial load
duke
parents:
diff changeset
79 enum Constants {
a61af66fc99e Initial load
duke
parents:
diff changeset
80 log2_number_of_codes = 8, // use a power of 2 for faster addressing
a61af66fc99e Initial load
duke
parents:
diff changeset
81 number_of_codes = 1 << log2_number_of_codes, // must be no less than Bytecodes::number_of_codes
a61af66fc99e Initial load
duke
parents:
diff changeset
82 number_of_pairs = number_of_codes * number_of_codes
a61af66fc99e Initial load
duke
parents:
diff changeset
83 };
a61af66fc99e Initial load
duke
parents:
diff changeset
84
a61af66fc99e Initial load
duke
parents:
diff changeset
85 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
86 NOT_PRODUCT(static int _index;) // new bytecode is shifted in - used to index into _counters
a61af66fc99e Initial load
duke
parents:
diff changeset
87 NOT_PRODUCT(static int _counters[number_of_pairs];) // a counter for each pair
a61af66fc99e Initial load
duke
parents:
diff changeset
88
a61af66fc99e Initial load
duke
parents:
diff changeset
89 friend class TemplateInterpreterGenerator;
a61af66fc99e Initial load
duke
parents:
diff changeset
90 friend class InterpreterGenerator;
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
93 // Initialization
a61af66fc99e Initial load
duke
parents:
diff changeset
94 static void reset() PRODUCT_RETURN; // reset counters
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96 // Profile printing
a61af66fc99e Initial load
duke
parents:
diff changeset
97 static void print(float cutoff = 0.01F) PRODUCT_RETURN; // cutoff in percent
a61af66fc99e Initial load
duke
parents:
diff changeset
98 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
99
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
100 #endif // SHARE_VM_INTERPRETER_BYTECODEHISTOGRAM_HPP