author | jlaskey |
Tue, 23 Jul 2013 12:00:29 -0300 | |
changeset 19089 | 51cfdcf21d35 |
parent 8921 | 14bfe81f2a9d |
child 25715 | d5a8dbdc5150 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
8921
14bfe81f2a9d
7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass
trims
parents:
8076
diff
changeset
|
2 |
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "interpreter/interpreter.hpp" |
|
27 |
#include "oops/oop.inline.hpp" |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
28 |
#include "oops/symbol.hpp" |
7397 | 29 |
#include "runtime/frame.inline.hpp" |
30 |
#include "runtime/rframe.hpp" |
|
31 |
#include "runtime/vframe.hpp" |
|
32 |
#include "runtime/vframe_hp.hpp" |
|
1 | 33 |
|
34 |
||
35 |
static RFrame*const noCaller = (RFrame*) 0x1; // no caller (i.e., initial frame) |
|
36 |
static RFrame*const noCallerYet = (RFrame*) 0x0; // caller not yet computed |
|
37 |
||
38 |
RFrame::RFrame(frame fr, JavaThread* thread, RFrame*const callee) : |
|
39 |
_fr(fr), _thread(thread), _callee(callee), _num(callee ? callee->num() + 1 : 0) { |
|
40 |
_caller = (RFrame*)noCallerYet; |
|
41 |
_invocations = 0; |
|
42 |
_distance = 0; |
|
43 |
} |
|
44 |
||
45 |
void RFrame::set_distance(int d) { |
|
46 |
assert(is_compiled() || d >= 0, "should be positive"); |
|
47 |
_distance = d; |
|
48 |
} |
|
49 |
||
50 |
InterpretedRFrame::InterpretedRFrame(frame fr, JavaThread* thread, RFrame*const callee) |
|
51 |
: RFrame(fr, thread, callee) { |
|
52 |
RegisterMap map(thread, false); |
|
53 |
_vf = javaVFrame::cast(vframe::new_vframe(&_fr, &map, thread)); |
|
54 |
_method = methodHandle(thread, _vf->method()); |
|
55 |
assert( _vf->is_interpreted_frame(), "must be interpreted"); |
|
56 |
init(); |
|
57 |
} |
|
58 |
||
59 |
InterpretedRFrame::InterpretedRFrame(frame fr, JavaThread* thread, methodHandle m) |
|
60 |
: RFrame(fr, thread, NULL) { |
|
61 |
RegisterMap map(thread, false); |
|
62 |
_vf = javaVFrame::cast(vframe::new_vframe(&_fr, &map, thread)); |
|
63 |
_method = m; |
|
64 |
||
65 |
assert( _vf->is_interpreted_frame(), "must be interpreted"); |
|
66 |
init(); |
|
67 |
} |
|
68 |
||
69 |
CompiledRFrame::CompiledRFrame(frame fr, JavaThread* thread, RFrame*const callee) |
|
70 |
: RFrame(fr, thread, callee) { |
|
71 |
init(); |
|
72 |
} |
|
73 |
||
74 |
CompiledRFrame::CompiledRFrame(frame fr, JavaThread* thread) |
|
75 |
: RFrame(fr, thread, NULL) { |
|
76 |
init(); |
|
77 |
} |
|
78 |
||
79 |
DeoptimizedRFrame::DeoptimizedRFrame(frame fr, JavaThread* thread, RFrame*const callee) |
|
80 |
: InterpretedRFrame(fr, thread, callee) {} |
|
81 |
||
82 |
RFrame* RFrame::new_RFrame(frame fr, JavaThread* thread, RFrame*const callee) { |
|
83 |
RFrame* rf; |
|
84 |
int dist = callee ? callee->distance() : -1; |
|
85 |
if (fr.is_interpreted_frame()) { |
|
86 |
rf = new InterpretedRFrame(fr, thread, callee); |
|
87 |
dist++; |
|
88 |
} else if (fr.is_compiled_frame()) { |
|
89 |
// Even deopted frames look compiled because the deopt |
|
90 |
// is invisible until it happens. |
|
91 |
rf = new CompiledRFrame(fr, thread, callee); |
|
92 |
} else { |
|
93 |
assert(false, "Unhandled frame type"); |
|
94 |
} |
|
95 |
rf->set_distance(dist); |
|
96 |
rf->init(); |
|
97 |
return rf; |
|
98 |
} |
|
99 |
||
100 |
RFrame* RFrame::caller() { |
|
101 |
if (_caller != noCallerYet) return (_caller == noCaller) ? NULL : _caller; // already computed caller |
|
102 |
||
103 |
// caller not yet computed; do it now |
|
104 |
if (_fr.is_first_java_frame()) { |
|
105 |
_caller = (RFrame*)noCaller; |
|
106 |
return NULL; |
|
107 |
} |
|
108 |
||
109 |
RegisterMap map(_thread, false); |
|
110 |
frame sender = _fr.real_sender(&map); |
|
111 |
if (sender.is_java_frame()) { |
|
112 |
_caller = new_RFrame(sender, thread(), this); |
|
113 |
return _caller; |
|
114 |
} |
|
115 |
||
116 |
// Real caller is not java related |
|
117 |
_caller = (RFrame*)noCaller; |
|
118 |
return NULL; |
|
119 |
} |
|
120 |
||
121 |
int InterpretedRFrame::cost() const { |
|
122 |
return _method->code_size(); // fix this |
|
123 |
//return _method->estimated_inline_cost(_receiverKlass); |
|
124 |
} |
|
125 |
||
126 |
int CompiledRFrame::cost() const { |
|
127 |
nmethod* nm = top_method()->code(); |
|
128 |
if (nm != NULL) { |
|
6418 | 129 |
return nm->insts_size(); |
1 | 130 |
} else { |
131 |
return top_method()->code_size(); |
|
132 |
} |
|
133 |
} |
|
134 |
||
135 |
void CompiledRFrame::init() { |
|
136 |
RegisterMap map(thread(), false); |
|
137 |
vframe* vf = vframe::new_vframe(&_fr, &map, thread()); |
|
138 |
assert(vf->is_compiled_frame(), "must be compiled"); |
|
139 |
_nm = compiledVFrame::cast(vf)->code(); |
|
140 |
vf = vf->top(); |
|
141 |
_vf = javaVFrame::cast(vf); |
|
142 |
_method = methodHandle(thread(), CodeCache::find_nmethod(_fr.pc())->method()); |
|
143 |
assert(_method(), "should have found a method"); |
|
144 |
#ifndef PRODUCT |
|
145 |
_invocations = _method->compiled_invocation_count(); |
|
146 |
#endif |
|
147 |
} |
|
148 |
||
149 |
void InterpretedRFrame::init() { |
|
150 |
_invocations = _method->invocation_count() + _method->backedge_count(); |
|
151 |
} |
|
152 |
||
153 |
void RFrame::print(const char* kind) { |
|
154 |
#ifndef PRODUCT |
|
155 |
#ifdef COMPILER2 |
|
156 |
int cnt = top_method()->interpreter_invocation_count(); |
|
157 |
#else |
|
158 |
int cnt = top_method()->invocation_count(); |
|
159 |
#endif |
|
160 |
tty->print("%3d %s ", _num, is_interpreted() ? "I" : "C"); |
|
161 |
top_method()->print_short_name(tty); |
|
162 |
tty->print_cr(": inv=%5d(%d) cst=%4d", _invocations, cnt, cost()); |
|
163 |
#endif |
|
164 |
} |
|
165 |
||
166 |
void CompiledRFrame::print() { |
|
167 |
RFrame::print("comp"); |
|
168 |
} |
|
169 |
||
170 |
void InterpretedRFrame::print() { |
|
171 |
RFrame::print("int."); |
|
172 |
} |
|
173 |
||
174 |
void DeoptimizedRFrame::print() { |
|
175 |
RFrame::print("deopt."); |
|
176 |
} |