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