src/share/vm/runtime/rframe.hpp

changeset 0
f90c822e73f8
child 6876
710a3c8b516e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/runtime/rframe.hpp	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,125 @@
     1.4 +/*
     1.5 + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#ifndef SHARE_VM_RUNTIME_RFRAME_HPP
    1.29 +#define SHARE_VM_RUNTIME_RFRAME_HPP
    1.30 +
    1.31 +#include "memory/allocation.hpp"
    1.32 +#include "runtime/frame.inline.hpp"
    1.33 +
    1.34 +// rframes ("recompiler frames") decorate stack frames with some extra information
    1.35 +// needed by the recompiler.  The recompiler views the stack (at the time of recompilation)
    1.36 +// as a list of rframes.
    1.37 +
    1.38 +class RFrame : public ResourceObj {
    1.39 + protected:
    1.40 +  const frame _fr;                  // my frame
    1.41 +  JavaThread* const _thread;        // thread where frame resides.
    1.42 +  RFrame* _caller;                  // caller / callee rframes (or NULL)
    1.43 +  RFrame*const _callee;
    1.44 +  const int _num;                   // stack frame number (0 = most recent)
    1.45 +  int _invocations;                 // current invocation estimate (for this frame)
    1.46 +                                    // (i.e., how often was this frame called)
    1.47 +  int _distance;                    // recompilation search "distance" (measured in # of interpreted frames)
    1.48 +
    1.49 +  RFrame(frame fr, JavaThread* thread, RFrame*const callee);
    1.50 +  virtual void init() = 0;          // compute invocations, loopDepth, etc.
    1.51 +  void print(const char* name);
    1.52 +
    1.53 + public:
    1.54 +
    1.55 +  static RFrame* new_RFrame(frame fr, JavaThread* thread, RFrame*const callee);
    1.56 +
    1.57 +  virtual bool is_interpreted() const     { return false; }
    1.58 +  virtual bool is_compiled() const        { return false; }
    1.59 +  int distance() const                    { return _distance; }
    1.60 +  void set_distance(int d);
    1.61 +  int invocations() const                 { return _invocations; }
    1.62 +  int num() const                         { return _num; }
    1.63 +  frame fr() const                        { return _fr; }
    1.64 +  JavaThread* thread() const              { return _thread; }
    1.65 +  virtual int cost() const = 0;           // estimated inlining cost (size)
    1.66 +  virtual methodHandle top_method() const  = 0;
    1.67 +  virtual javaVFrame* top_vframe() const = 0;
    1.68 +  virtual nmethod* nm() const             { ShouldNotCallThis(); return NULL; }
    1.69 +
    1.70 +  RFrame* caller();
    1.71 +  RFrame* callee() const                  { return _callee; }
    1.72 +  RFrame* parent() const;                 // rframe containing lexical scope (if any)
    1.73 +  virtual void print()                    = 0;
    1.74 +
    1.75 +  static int computeSends(Method* m);
    1.76 +  static int computeSends(nmethod* nm);
    1.77 +  static int computeCumulSends(Method* m);
    1.78 +  static int computeCumulSends(nmethod* nm);
    1.79 +};
    1.80 +
    1.81 +class CompiledRFrame : public RFrame {    // frame containing a compiled method
    1.82 + protected:
    1.83 +  nmethod*    _nm;
    1.84 +  javaVFrame* _vf;                        // top vframe; may be NULL (for most recent frame)
    1.85 +  methodHandle _method;                   // top method
    1.86 +
    1.87 +  CompiledRFrame(frame fr, JavaThread* thread, RFrame*const  callee);
    1.88 +  void init();
    1.89 +  friend class RFrame;
    1.90 +
    1.91 + public:
    1.92 +  CompiledRFrame(frame fr, JavaThread* thread); // for nmethod triggering its counter (callee == NULL)
    1.93 +  bool is_compiled() const                 { return true; }
    1.94 +  methodHandle top_method() const          { return _method; }
    1.95 +  javaVFrame* top_vframe() const           { return _vf; }
    1.96 +  nmethod* nm() const                      { return _nm; }
    1.97 +  int cost() const;
    1.98 +  void print();
    1.99 +};
   1.100 +
   1.101 +class InterpretedRFrame : public RFrame {    // interpreter frame
   1.102 + protected:
   1.103 +  javaVFrame* _vf;                           // may be NULL (for most recent frame)
   1.104 +  methodHandle   _method;
   1.105 +
   1.106 +  InterpretedRFrame(frame fr, JavaThread* thread, RFrame*const  callee);
   1.107 +  void init();
   1.108 +  friend class RFrame;
   1.109 +
   1.110 + public:
   1.111 +  InterpretedRFrame(frame fr, JavaThread* thread, methodHandle m); // constructor for method triggering its invocation counter
   1.112 +  bool is_interpreted() const                { return true; }
   1.113 +  methodHandle top_method() const            { return _method; }
   1.114 +  javaVFrame* top_vframe() const             { return _vf; }
   1.115 +  int cost() const;
   1.116 +  void print();
   1.117 +};
   1.118 +
   1.119 +// treat deoptimized frames as interpreted
   1.120 +class DeoptimizedRFrame : public InterpretedRFrame {
   1.121 + protected:
   1.122 +  DeoptimizedRFrame(frame fr, JavaThread* thread, RFrame*const  callee);
   1.123 +  friend class RFrame;
   1.124 + public:
   1.125 +  void print();
   1.126 +};
   1.127 +
   1.128 +#endif // SHARE_VM_RUNTIME_RFRAME_HPP

mercurial