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