src/share/vm/runtime/rframe.hpp

Wed, 09 Apr 2008 15:10:22 -0700

author
rasbold
date
Wed, 09 Apr 2008 15:10:22 -0700
changeset 544
9f4457a14b58
parent 435
a61af66fc99e
child 1907
c18cbe5936b8
permissions
-rw-r--r--

Merge

duke@435 1 /*
duke@435 2 * Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 // rframes ("recompiler frames") decorate stack frames with some extra information
duke@435 26 // needed by the recompiler. The recompiler views the stack (at the time of recompilation)
duke@435 27 // as a list of rframes.
duke@435 28
duke@435 29 class RFrame : public ResourceObj {
duke@435 30 protected:
duke@435 31 const frame _fr; // my frame
duke@435 32 JavaThread* const _thread; // thread where frame resides.
duke@435 33 RFrame* _caller; // caller / callee rframes (or NULL)
duke@435 34 RFrame*const _callee;
duke@435 35 const int _num; // stack frame number (0 = most recent)
duke@435 36 int _invocations; // current invocation estimate (for this frame)
duke@435 37 // (i.e., how often was this frame called)
duke@435 38 int _distance; // recompilation search "distance" (measured in # of interpreted frames)
duke@435 39
duke@435 40 RFrame(frame fr, JavaThread* thread, RFrame*const callee);
duke@435 41 virtual void init() = 0; // compute invocations, loopDepth, etc.
duke@435 42 void print(const char* name);
duke@435 43
duke@435 44 public:
duke@435 45
duke@435 46 static RFrame* new_RFrame(frame fr, JavaThread* thread, RFrame*const callee);
duke@435 47
duke@435 48 virtual bool is_interpreted() const { return false; }
duke@435 49 virtual bool is_compiled() const { return false; }
duke@435 50 int distance() const { return _distance; }
duke@435 51 void set_distance(int d);
duke@435 52 int invocations() const { return _invocations; }
duke@435 53 int num() const { return _num; }
duke@435 54 frame fr() const { return _fr; }
duke@435 55 JavaThread* thread() const { return _thread; }
duke@435 56 virtual int cost() const = 0; // estimated inlining cost (size)
duke@435 57 virtual methodHandle top_method() const = 0;
duke@435 58 virtual javaVFrame* top_vframe() const = 0;
duke@435 59 virtual nmethod* nm() const { ShouldNotCallThis(); return NULL; }
duke@435 60
duke@435 61 RFrame* caller();
duke@435 62 RFrame* callee() const { return _callee; }
duke@435 63 RFrame* parent() const; // rframe containing lexical scope (if any)
duke@435 64 virtual void print() = 0;
duke@435 65
duke@435 66 static int computeSends(methodOop m);
duke@435 67 static int computeSends(nmethod* nm);
duke@435 68 static int computeCumulSends(methodOop m);
duke@435 69 static int computeCumulSends(nmethod* nm);
duke@435 70 };
duke@435 71
duke@435 72 class CompiledRFrame : public RFrame { // frame containing a compiled method
duke@435 73 protected:
duke@435 74 nmethod* _nm;
duke@435 75 javaVFrame* _vf; // top vframe; may be NULL (for most recent frame)
duke@435 76 methodHandle _method; // top method
duke@435 77
duke@435 78 CompiledRFrame(frame fr, JavaThread* thread, RFrame*const callee);
duke@435 79 void init();
duke@435 80 friend class RFrame;
duke@435 81
duke@435 82 public:
duke@435 83 CompiledRFrame(frame fr, JavaThread* thread); // for nmethod triggering its counter (callee == NULL)
duke@435 84 bool is_compiled() const { return true; }
duke@435 85 methodHandle top_method() const { return _method; }
duke@435 86 javaVFrame* top_vframe() const { return _vf; }
duke@435 87 nmethod* nm() const { return _nm; }
duke@435 88 int cost() const;
duke@435 89 void print();
duke@435 90 };
duke@435 91
duke@435 92 class InterpretedRFrame : public RFrame { // interpreter frame
duke@435 93 protected:
duke@435 94 javaVFrame* _vf; // may be NULL (for most recent frame)
duke@435 95 methodHandle _method;
duke@435 96
duke@435 97 InterpretedRFrame(frame fr, JavaThread* thread, RFrame*const callee);
duke@435 98 void init();
duke@435 99 friend class RFrame;
duke@435 100
duke@435 101 public:
duke@435 102 InterpretedRFrame(frame fr, JavaThread* thread, methodHandle m); // constructor for method triggering its invocation counter
duke@435 103 bool is_interpreted() const { return true; }
duke@435 104 methodHandle top_method() const { return _method; }
duke@435 105 javaVFrame* top_vframe() const { return _vf; }
duke@435 106 int cost() const;
duke@435 107 void print();
duke@435 108 };
duke@435 109
duke@435 110 // treat deoptimized frames as interpreted
duke@435 111 class DeoptimizedRFrame : public InterpretedRFrame {
duke@435 112 protected:
duke@435 113 DeoptimizedRFrame(frame fr, JavaThread* thread, RFrame*const callee);
duke@435 114 friend class RFrame;
duke@435 115 public:
duke@435 116 void print();
duke@435 117 };

mercurial