annotate src/hotspot/share/runtime/rframe.hpp @ 52291:35a6956f4243

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