bytecodeTracer.hpp revision 1879:f95d63e2154a
1130803Smarcel/* 2130803Smarcel * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 3130803Smarcel * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4130803Smarcel * 5130803Smarcel * This code is free software; you can redistribute it and/or modify it 6130803Smarcel * under the terms of the GNU General Public License version 2 only, as 7130803Smarcel * published by the Free Software Foundation. 8130803Smarcel * 9130803Smarcel * This code is distributed in the hope that it will be useful, but WITHOUT 10130803Smarcel * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11130803Smarcel * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12130803Smarcel * version 2 for more details (a copy is included in the LICENSE file that 13130803Smarcel * accompanied this code). 14130803Smarcel * 15130803Smarcel * You should have received a copy of the GNU General Public License version 16130803Smarcel * 2 along with this work; if not, write to the Free Software Foundation, 17130803Smarcel * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18130803Smarcel * 19130803Smarcel * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20130803Smarcel * or visit www.oracle.com if you need additional information or have any 21130803Smarcel * questions. 22130803Smarcel * 23130803Smarcel */ 24130803Smarcel 25130803Smarcel#ifndef SHARE_VM_INTERPRETER_BYTECODETRACER_HPP 26130803Smarcel#define SHARE_VM_INTERPRETER_BYTECODETRACER_HPP 27130803Smarcel 28130803Smarcel#include "memory/allocation.hpp" 29130803Smarcel 30130803Smarcel// The BytecodeTracer is a helper class used by the interpreter for run-time 31130803Smarcel// bytecode tracing. If bytecode tracing is turned on, trace() will be called 32130803Smarcel// for each bytecode. 33130803Smarcel// 34130803Smarcel// By specialising the BytecodeClosure, all kinds of bytecode traces can 35130803Smarcel// be done. 36130803Smarcel 37130803Smarcel#ifndef PRODUCT 38130803Smarcel// class BytecodeTracer is only used by TraceBytecodes option 39130803Smarcel 40130803Smarcelclass BytecodeClosure; 41130803Smarcelclass BytecodeTracer: AllStatic { 42130803Smarcel private: 43130803Smarcel static BytecodeClosure* _closure; 44130803Smarcel 45130803Smarcel public: 46130803Smarcel static BytecodeClosure* std_closure(); // a printing closure 47130803Smarcel static BytecodeClosure* closure() { return _closure; } 48130803Smarcel static void set_closure(BytecodeClosure* closure) { _closure = closure; } 49130803Smarcel 50130803Smarcel static void trace(methodHandle method, address bcp, uintptr_t tos, uintptr_t tos2, outputStream* st = tty); 51130803Smarcel static void trace(methodHandle method, address bcp, outputStream* st = tty); 52130803Smarcel}; 53130803Smarcel 54130803Smarcel 55130803Smarcel// For each bytecode, a BytecodeClosure's trace() routine will be called. 56130803Smarcel 57130803Smarcelclass BytecodeClosure { 58130803Smarcel public: 59130803Smarcel virtual void trace(methodHandle method, address bcp, uintptr_t tos, uintptr_t tos2, outputStream* st) = 0; 60130803Smarcel virtual void trace(methodHandle method, address bcp, outputStream* st) = 0; 61130803Smarcel}; 62130803Smarcel 63130803Smarcel#endif // !PRODUCT 64130803Smarcel 65130803Smarcel#endif // SHARE_VM_INTERPRETER_BYTECODETRACER_HPP 66130803Smarcel