1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/interpreter/bytecodeHistogram.hpp Sat Dec 01 00:00:00 2007 +0000 1.3 @@ -0,0 +1,92 @@ 1.4 +/* 1.5 + * Copyright 1997-2004 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.24 + * have any questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +// BytecodeCounter counts the number of bytecodes executed 1.29 + 1.30 +class BytecodeCounter: AllStatic { 1.31 + private: 1.32 + NOT_PRODUCT(static int _counter_value;) 1.33 + NOT_PRODUCT(static jlong _reset_time;) 1.34 + 1.35 + friend class TemplateInterpreterGenerator; 1.36 + friend class BytecodeInterpreter; 1.37 + 1.38 + public: 1.39 + // Initialization 1.40 + static void reset() PRODUCT_RETURN; 1.41 + 1.42 + // Counter info (all info since last reset) 1.43 + static int counter_value() PRODUCT_RETURN0 NOT_PRODUCT({ return _counter_value; }); 1.44 + static double elapsed_time() PRODUCT_RETURN0; // in seconds 1.45 + static double frequency() PRODUCT_RETURN0; // bytecodes/seconds 1.46 + 1.47 + // Counter printing 1.48 + static void print() PRODUCT_RETURN; 1.49 +}; 1.50 + 1.51 + 1.52 +// BytecodeHistogram collects number of executions of bytecodes 1.53 + 1.54 +class BytecodeHistogram: AllStatic { 1.55 + private: 1.56 + NOT_PRODUCT(static int _counters[Bytecodes::number_of_codes];) // a counter for each bytecode 1.57 + 1.58 + friend class TemplateInterpreterGenerator; 1.59 + friend class InterpreterGenerator; 1.60 + friend class BytecodeInterpreter; 1.61 + 1.62 + public: 1.63 + // Initialization 1.64 + static void reset() PRODUCT_RETURN; // reset counters 1.65 + 1.66 + // Profile printing 1.67 + static void print(float cutoff = 0.01F) PRODUCT_RETURN; // cutoff in percent 1.68 +}; 1.69 + 1.70 + 1.71 +// BytecodePairHistogram collects number of executions of bytecode pairs. 1.72 +// A bytecode pair is any sequence of two consequtive bytecodes. 1.73 + 1.74 +class BytecodePairHistogram: AllStatic { 1.75 + public: // for SparcWorks 1.76 + enum Constants { 1.77 + log2_number_of_codes = 8, // use a power of 2 for faster addressing 1.78 + number_of_codes = 1 << log2_number_of_codes, // must be no less than Bytecodes::number_of_codes 1.79 + number_of_pairs = number_of_codes * number_of_codes 1.80 + }; 1.81 + 1.82 + private: 1.83 + NOT_PRODUCT(static int _index;) // new bytecode is shifted in - used to index into _counters 1.84 + NOT_PRODUCT(static int _counters[number_of_pairs];) // a counter for each pair 1.85 + 1.86 + friend class TemplateInterpreterGenerator; 1.87 + friend class InterpreterGenerator; 1.88 + 1.89 + public: 1.90 + // Initialization 1.91 + static void reset() PRODUCT_RETURN; // reset counters 1.92 + 1.93 + // Profile printing 1.94 + static void print(float cutoff = 0.01F) PRODUCT_RETURN; // cutoff in percent 1.95 +};