src/share/vm/interpreter/bytecodeHistogram.hpp

changeset 0
f90c822e73f8
child 6876
710a3c8b516e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/interpreter/bytecodeHistogram.hpp	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,100 @@
     1.4 +/*
     1.5 + * Copyright (c) 1997, 2010, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#ifndef SHARE_VM_INTERPRETER_BYTECODEHISTOGRAM_HPP
    1.29 +#define SHARE_VM_INTERPRETER_BYTECODEHISTOGRAM_HPP
    1.30 +
    1.31 +#include "interpreter/bytecodes.hpp"
    1.32 +#include "memory/allocation.hpp"
    1.33 +
    1.34 +// BytecodeCounter counts the number of bytecodes executed
    1.35 +
    1.36 +class BytecodeCounter: AllStatic {
    1.37 + private:
    1.38 +  NOT_PRODUCT(static int   _counter_value;)
    1.39 +  NOT_PRODUCT(static jlong _reset_time;)
    1.40 +
    1.41 +  friend class TemplateInterpreterGenerator;
    1.42 +  friend class         BytecodeInterpreter;
    1.43 +
    1.44 + public:
    1.45 +  // Initialization
    1.46 +  static void reset()                      PRODUCT_RETURN;
    1.47 +
    1.48 +  // Counter info (all info since last reset)
    1.49 +  static int    counter_value()            PRODUCT_RETURN0 NOT_PRODUCT({ return _counter_value; });
    1.50 +  static double elapsed_time()             PRODUCT_RETURN0; // in seconds
    1.51 +  static double frequency()                PRODUCT_RETURN0; // bytecodes/seconds
    1.52 +
    1.53 +  // Counter printing
    1.54 +  static void   print()                    PRODUCT_RETURN;
    1.55 +};
    1.56 +
    1.57 +
    1.58 +// BytecodeHistogram collects number of executions of bytecodes
    1.59 +
    1.60 +class BytecodeHistogram: AllStatic {
    1.61 + private:
    1.62 +  NOT_PRODUCT(static int _counters[Bytecodes::number_of_codes];)   // a counter for each bytecode
    1.63 +
    1.64 +  friend class TemplateInterpreterGenerator;
    1.65 +  friend class         InterpreterGenerator;
    1.66 +  friend class         BytecodeInterpreter;
    1.67 +
    1.68 + public:
    1.69 +  // Initialization
    1.70 +  static void reset()                       PRODUCT_RETURN; // reset counters
    1.71 +
    1.72 +  // Profile printing
    1.73 +  static void print(float cutoff = 0.01F)   PRODUCT_RETURN; // cutoff in percent
    1.74 +};
    1.75 +
    1.76 +
    1.77 +// BytecodePairHistogram collects number of executions of bytecode pairs.
    1.78 +// A bytecode pair is any sequence of two consequtive bytecodes.
    1.79 +
    1.80 +class BytecodePairHistogram: AllStatic {
    1.81 + public: // for SparcWorks
    1.82 +  enum Constants {
    1.83 +    log2_number_of_codes = 8,                         // use a power of 2 for faster addressing
    1.84 +    number_of_codes      = 1 << log2_number_of_codes, // must be no less than Bytecodes::number_of_codes
    1.85 +    number_of_pairs      = number_of_codes * number_of_codes
    1.86 +  };
    1.87 +
    1.88 + private:
    1.89 +  NOT_PRODUCT(static int  _index;)                      // new bytecode is shifted in - used to index into _counters
    1.90 +  NOT_PRODUCT(static int  _counters[number_of_pairs];)  // a counter for each pair
    1.91 +
    1.92 +  friend class TemplateInterpreterGenerator;
    1.93 +  friend class         InterpreterGenerator;
    1.94 +
    1.95 + public:
    1.96 +  // Initialization
    1.97 +  static void reset()                       PRODUCT_RETURN;   // reset counters
    1.98 +
    1.99 +  // Profile printing
   1.100 +  static void print(float cutoff = 0.01F)   PRODUCT_RETURN;   // cutoff in percent
   1.101 +};
   1.102 +
   1.103 +#endif // SHARE_VM_INTERPRETER_BYTECODEHISTOGRAM_HPP

mercurial