rframe.hpp

Go to the documentation of this file.
00001 /* Copyright 1994, 1995 LongView Technologies L.L.C. $Revision: 1.14 $ */
00002 /* Copyright (c) 2006, Sun Microsystems, Inc.
00003 All rights reserved.
00004 
00005 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 
00006 following conditions are met:
00007 
00008     * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
00009     * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following 
00010           disclaimer in the documentation and/or other materials provided with the distribution.
00011     * Neither the name of Sun Microsystems nor the names of its contributors may be used to endorse or promote products derived 
00012           from this software without specific prior written permission.
00013 
00014 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT 
00015 NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 
00016 THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
00017 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
00018 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
00019 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
00020 
00021 
00022 */
00023 
00024 
00025 // rframes ("recompiler frames") decorate stack frames with some extra information
00026 // needed by the recompiler.  The recompiler views the stack (at the time of recompilation) 
00027 // as a list of rframes.
00028 
00029 #ifdef DELTA_COMPILER
00030 
00031 class RFrame : public PrintableResourceObj {
00032  protected:
00033   frame _fr;                    // my frame
00034   RFrame* _caller, *_callee;    // caller / callee rframes (or NULL)
00035   int _num;                     // stack frame number (0 = most recent)
00036   int _distance;                // recompilation search "distance" (measured in # of interpreted frames)
00037   int _invocations;             // current invocation estimate (for this frame)
00038                                 // (i.e., how often was thus frame called)
00039   int _ncallers;                // number of callers
00040   int _sends;                   // sends caused by this frame
00041   int _cumulSends;              // sends including sends from nested blocks
00042   int _loopDepth;               // loop depth of callee
00043 
00044   RFrame(frame fr, const RFrame* callee);
00045   virtual void init() = 0;      // compute invocations, loopDepth, etc.
00046   void print(const char* name);
00047 
00048  public:
00049 
00050   static RFrame* new_RFrame(frame fr, const RFrame* callee);
00051 
00052   virtual bool is_interpreted() const   { return false; }
00053   virtual bool is_compiled() const      { return false; }
00054   bool is_super() const;                // invoked by super send?
00055   int invocations() const               { return _invocations; }
00056   int sends() const                     { return _sends; }
00057   int cumulSends() const                { return _cumulSends; }
00058   int loopDepth() const                 { return _loopDepth; }
00059   int num() const                       { return _num; }
00060   int distance() const                  { return _distance; }
00061   void set_distance(int d);
00062   int nCallers() const                  { return _ncallers; }
00063   bool is_blockMethod() const;
00064   frame fr() const                      { return _fr; }
00065   virtual LookupKey* key() const        = 0;    // lookup key or NULL (for block invoc.)
00066   virtual int cost() const              = 0;    // estimated inlining cost (size)
00067   virtual methodOop top_method() const  = 0;
00068   virtual deltaVFrame* top_vframe() const = 0;
00069   virtual void cleanupStaleInlineCaches() = 0;
00070   virtual nmethod* nm() const           { ShouldNotCallThis(); return NULL; }
00071   bool hasBlockArgs() const;            // does top method receive block arguments?
00072   GrowableArray<blockClosureOop>* blockArgs() const;  // return list of all block args
00073 
00074   RFrame* caller();
00075   RFrame* callee() const                { return _callee; }
00076   RFrame* parent() const;               // rframe containing lexical scope (if any)
00077   void print()                          = 0;
00078 
00079   static int computeSends(methodOop m);
00080   static int computeSends(nmethod* nm);
00081   static int computeCumulSends(methodOop m);
00082   static int computeCumulSends(nmethod* nm);
00083 };
00084 
00085 class CompiledRFrame : public RFrame {          // frame containing a compiled method
00086  protected:
00087   nmethod* _nm;
00088   deltaVFrame* _vf;             // top vframe; may be NULL (for most recent frame)
00089 
00090   CompiledRFrame(frame fr, const RFrame* callee);
00091   void init();
00092   friend class RFrame;
00093 
00094  public:
00095   CompiledRFrame(frame fr);     // for nmethod triggering its counter (callee == NULL)
00096   bool is_compiled() const              { return true; }
00097   methodOop top_method() const;
00098   deltaVFrame* top_vframe() const       { return _vf; }
00099   nmethod* nm() const                   { return _nm; }
00100   LookupKey* key() const;
00101   int cost() const;
00102   void cleanupStaleInlineCaches();
00103   void print();
00104 };
00105 
00106 class InterpretedRFrame : public RFrame {       // interpreter frame
00107  protected:
00108   methodOop _method;
00109   int _bci;                     // current bci
00110   klassOop _receiverKlass;
00111   deltaVFrame* _vf;             // may be NULL (for most recent frame)
00112   LookupKey* _key;              // cached value of key()
00113  
00114   InterpretedRFrame(frame fr, const RFrame* callee);
00115   void init();
00116   friend class RFrame;
00117 
00118  public:
00119   InterpretedRFrame(frame fr, methodOop m, klassOop rcvrKlass); // for method triggering its invocation counter
00120   bool is_interpreted() const           { return true; }
00121   methodOop top_method() const          { return _method; }
00122   deltaVFrame* top_vframe() const       { return _vf; }
00123   LookupKey* key() const;
00124   int cost() const;
00125   void cleanupStaleInlineCaches();
00126   void print();
00127 };
00128 
00129 #endif

Generated on Mon Oct 9 13:37:26 2006 for Strongtalk VM by  doxygen 1.4.7