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