aoqi@0: /* aoqi@0: * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: * aoqi@0: */ aoqi@0: aoqi@0: #ifndef SHARE_VM_RUNTIME_RFRAME_HPP aoqi@0: #define SHARE_VM_RUNTIME_RFRAME_HPP aoqi@0: aoqi@0: #include "memory/allocation.hpp" aoqi@0: #include "runtime/frame.inline.hpp" aoqi@0: aoqi@0: // rframes ("recompiler frames") decorate stack frames with some extra information aoqi@0: // needed by the recompiler. The recompiler views the stack (at the time of recompilation) aoqi@0: // as a list of rframes. aoqi@0: aoqi@0: class RFrame : public ResourceObj { aoqi@0: protected: aoqi@0: const frame _fr; // my frame aoqi@0: JavaThread* const _thread; // thread where frame resides. aoqi@0: RFrame* _caller; // caller / callee rframes (or NULL) aoqi@0: RFrame*const _callee; aoqi@0: const int _num; // stack frame number (0 = most recent) aoqi@0: int _invocations; // current invocation estimate (for this frame) aoqi@0: // (i.e., how often was this frame called) aoqi@0: int _distance; // recompilation search "distance" (measured in # of interpreted frames) aoqi@0: aoqi@0: RFrame(frame fr, JavaThread* thread, RFrame*const callee); aoqi@0: virtual void init() = 0; // compute invocations, loopDepth, etc. aoqi@0: void print(const char* name); aoqi@0: aoqi@0: public: aoqi@0: aoqi@0: static RFrame* new_RFrame(frame fr, JavaThread* thread, RFrame*const callee); aoqi@0: aoqi@0: virtual bool is_interpreted() const { return false; } aoqi@0: virtual bool is_compiled() const { return false; } aoqi@0: int distance() const { return _distance; } aoqi@0: void set_distance(int d); aoqi@0: int invocations() const { return _invocations; } aoqi@0: int num() const { return _num; } aoqi@0: frame fr() const { return _fr; } aoqi@0: JavaThread* thread() const { return _thread; } aoqi@0: virtual int cost() const = 0; // estimated inlining cost (size) aoqi@0: virtual methodHandle top_method() const = 0; aoqi@0: virtual javaVFrame* top_vframe() const = 0; aoqi@0: virtual nmethod* nm() const { ShouldNotCallThis(); return NULL; } aoqi@0: aoqi@0: RFrame* caller(); aoqi@0: RFrame* callee() const { return _callee; } aoqi@0: RFrame* parent() const; // rframe containing lexical scope (if any) aoqi@0: virtual void print() = 0; aoqi@0: aoqi@0: static int computeSends(Method* m); aoqi@0: static int computeSends(nmethod* nm); aoqi@0: static int computeCumulSends(Method* m); aoqi@0: static int computeCumulSends(nmethod* nm); aoqi@0: }; aoqi@0: aoqi@0: class CompiledRFrame : public RFrame { // frame containing a compiled method aoqi@0: protected: aoqi@0: nmethod* _nm; aoqi@0: javaVFrame* _vf; // top vframe; may be NULL (for most recent frame) aoqi@0: methodHandle _method; // top method aoqi@0: aoqi@0: CompiledRFrame(frame fr, JavaThread* thread, RFrame*const callee); aoqi@0: void init(); aoqi@0: friend class RFrame; aoqi@0: aoqi@0: public: aoqi@0: CompiledRFrame(frame fr, JavaThread* thread); // for nmethod triggering its counter (callee == NULL) aoqi@0: bool is_compiled() const { return true; } aoqi@0: methodHandle top_method() const { return _method; } aoqi@0: javaVFrame* top_vframe() const { return _vf; } aoqi@0: nmethod* nm() const { return _nm; } aoqi@0: int cost() const; aoqi@0: void print(); aoqi@0: }; aoqi@0: aoqi@0: class InterpretedRFrame : public RFrame { // interpreter frame aoqi@0: protected: aoqi@0: javaVFrame* _vf; // may be NULL (for most recent frame) aoqi@0: methodHandle _method; aoqi@0: aoqi@0: InterpretedRFrame(frame fr, JavaThread* thread, RFrame*const callee); aoqi@0: void init(); aoqi@0: friend class RFrame; aoqi@0: aoqi@0: public: aoqi@0: InterpretedRFrame(frame fr, JavaThread* thread, methodHandle m); // constructor for method triggering its invocation counter aoqi@0: bool is_interpreted() const { return true; } aoqi@0: methodHandle top_method() const { return _method; } aoqi@0: javaVFrame* top_vframe() const { return _vf; } aoqi@0: int cost() const; aoqi@0: void print(); aoqi@0: }; aoqi@0: aoqi@0: // treat deoptimized frames as interpreted aoqi@0: class DeoptimizedRFrame : public InterpretedRFrame { aoqi@0: protected: aoqi@0: DeoptimizedRFrame(frame fr, JavaThread* thread, RFrame*const callee); aoqi@0: friend class RFrame; aoqi@0: public: aoqi@0: void print(); aoqi@0: }; aoqi@0: aoqi@0: #endif // SHARE_VM_RUNTIME_RFRAME_HPP