1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/runtime/rframe.hpp Sat Dec 01 00:00:00 2007 +0000 1.3 @@ -0,0 +1,117 @@ 1.4 +/* 1.5 + * Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.24 + * have any questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +// rframes ("recompiler frames") decorate stack frames with some extra information 1.29 +// needed by the recompiler. The recompiler views the stack (at the time of recompilation) 1.30 +// as a list of rframes. 1.31 + 1.32 +class RFrame : public ResourceObj { 1.33 + protected: 1.34 + const frame _fr; // my frame 1.35 + JavaThread* const _thread; // thread where frame resides. 1.36 + RFrame* _caller; // caller / callee rframes (or NULL) 1.37 + RFrame*const _callee; 1.38 + const int _num; // stack frame number (0 = most recent) 1.39 + int _invocations; // current invocation estimate (for this frame) 1.40 + // (i.e., how often was this frame called) 1.41 + int _distance; // recompilation search "distance" (measured in # of interpreted frames) 1.42 + 1.43 + RFrame(frame fr, JavaThread* thread, RFrame*const callee); 1.44 + virtual void init() = 0; // compute invocations, loopDepth, etc. 1.45 + void print(const char* name); 1.46 + 1.47 + public: 1.48 + 1.49 + static RFrame* new_RFrame(frame fr, JavaThread* thread, RFrame*const callee); 1.50 + 1.51 + virtual bool is_interpreted() const { return false; } 1.52 + virtual bool is_compiled() const { return false; } 1.53 + int distance() const { return _distance; } 1.54 + void set_distance(int d); 1.55 + int invocations() const { return _invocations; } 1.56 + int num() const { return _num; } 1.57 + frame fr() const { return _fr; } 1.58 + JavaThread* thread() const { return _thread; } 1.59 + virtual int cost() const = 0; // estimated inlining cost (size) 1.60 + virtual methodHandle top_method() const = 0; 1.61 + virtual javaVFrame* top_vframe() const = 0; 1.62 + virtual nmethod* nm() const { ShouldNotCallThis(); return NULL; } 1.63 + 1.64 + RFrame* caller(); 1.65 + RFrame* callee() const { return _callee; } 1.66 + RFrame* parent() const; // rframe containing lexical scope (if any) 1.67 + virtual void print() = 0; 1.68 + 1.69 + static int computeSends(methodOop m); 1.70 + static int computeSends(nmethod* nm); 1.71 + static int computeCumulSends(methodOop m); 1.72 + static int computeCumulSends(nmethod* nm); 1.73 +}; 1.74 + 1.75 +class CompiledRFrame : public RFrame { // frame containing a compiled method 1.76 + protected: 1.77 + nmethod* _nm; 1.78 + javaVFrame* _vf; // top vframe; may be NULL (for most recent frame) 1.79 + methodHandle _method; // top method 1.80 + 1.81 + CompiledRFrame(frame fr, JavaThread* thread, RFrame*const callee); 1.82 + void init(); 1.83 + friend class RFrame; 1.84 + 1.85 + public: 1.86 + CompiledRFrame(frame fr, JavaThread* thread); // for nmethod triggering its counter (callee == NULL) 1.87 + bool is_compiled() const { return true; } 1.88 + methodHandle top_method() const { return _method; } 1.89 + javaVFrame* top_vframe() const { return _vf; } 1.90 + nmethod* nm() const { return _nm; } 1.91 + int cost() const; 1.92 + void print(); 1.93 +}; 1.94 + 1.95 +class InterpretedRFrame : public RFrame { // interpreter frame 1.96 + protected: 1.97 + javaVFrame* _vf; // may be NULL (for most recent frame) 1.98 + methodHandle _method; 1.99 + 1.100 + InterpretedRFrame(frame fr, JavaThread* thread, RFrame*const callee); 1.101 + void init(); 1.102 + friend class RFrame; 1.103 + 1.104 + public: 1.105 + InterpretedRFrame(frame fr, JavaThread* thread, methodHandle m); // constructor for method triggering its invocation counter 1.106 + bool is_interpreted() const { return true; } 1.107 + methodHandle top_method() const { return _method; } 1.108 + javaVFrame* top_vframe() const { return _vf; } 1.109 + int cost() const; 1.110 + void print(); 1.111 +}; 1.112 + 1.113 +// treat deoptimized frames as interpreted 1.114 +class DeoptimizedRFrame : public InterpretedRFrame { 1.115 + protected: 1.116 + DeoptimizedRFrame(frame fr, JavaThread* thread, RFrame*const callee); 1.117 + friend class RFrame; 1.118 + public: 1.119 + void print(); 1.120 +};