author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 38133 | hotspot/src/share/vm/runtime/rframe.cpp@78b95467b9f1 |
child 47799 | 1772ebf07d1f |
permissions | -rw-r--r-- |
1 | 1 |
/* |
38133
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
33160
diff
changeset
|
2 |
* Copyright (c) 1997, 2016, 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" |
25715
d5a8dbdc5150
8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents:
8921
diff
changeset
|
26 |
#include "code/codeCache.hpp" |
7397 | 27 |
#include "interpreter/interpreter.hpp" |
28 |
#include "oops/oop.inline.hpp" |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
29 |
#include "oops/symbol.hpp" |
7397 | 30 |
#include "runtime/frame.inline.hpp" |
31 |
#include "runtime/rframe.hpp" |
|
32 |
#include "runtime/vframe.hpp" |
|
33 |
#include "runtime/vframe_hp.hpp" |
|
1 | 34 |
|
35 |
||
36 |
static RFrame*const noCaller = (RFrame*) 0x1; // no caller (i.e., initial frame) |
|
37 |
static RFrame*const noCallerYet = (RFrame*) 0x0; // caller not yet computed |
|
38 |
||
39 |
RFrame::RFrame(frame fr, JavaThread* thread, RFrame*const callee) : |
|
40 |
_fr(fr), _thread(thread), _callee(callee), _num(callee ? callee->num() + 1 : 0) { |
|
41 |
_caller = (RFrame*)noCallerYet; |
|
42 |
_invocations = 0; |
|
43 |
_distance = 0; |
|
44 |
} |
|
45 |
||
46 |
void RFrame::set_distance(int d) { |
|
47 |
assert(is_compiled() || d >= 0, "should be positive"); |
|
48 |
_distance = d; |
|
49 |
} |
|
50 |
||
51 |
InterpretedRFrame::InterpretedRFrame(frame fr, JavaThread* thread, RFrame*const callee) |
|
52 |
: RFrame(fr, thread, callee) { |
|
53 |
RegisterMap map(thread, false); |
|
54 |
_vf = javaVFrame::cast(vframe::new_vframe(&_fr, &map, thread)); |
|
31521
f57b2ce43484
8079775: Java 9-fastdebug ia32 Error: Unimplemented with "-XX:CompilationPolicyChoice=1 -XX:-TieredCompilation" options
iveresov
parents:
25715
diff
changeset
|
55 |
_method = _vf->method(); |
1 | 56 |
assert( _vf->is_interpreted_frame(), "must be interpreted"); |
57 |
init(); |
|
58 |
} |
|
59 |
||
31521
f57b2ce43484
8079775: Java 9-fastdebug ia32 Error: Unimplemented with "-XX:CompilationPolicyChoice=1 -XX:-TieredCompilation" options
iveresov
parents:
25715
diff
changeset
|
60 |
InterpretedRFrame::InterpretedRFrame(frame fr, JavaThread* thread, Method* m) |
1 | 61 |
: RFrame(fr, thread, NULL) { |
62 |
RegisterMap map(thread, false); |
|
63 |
_vf = javaVFrame::cast(vframe::new_vframe(&_fr, &map, thread)); |
|
64 |
_method = m; |
|
65 |
||
66 |
assert( _vf->is_interpreted_frame(), "must be interpreted"); |
|
67 |
init(); |
|
68 |
} |
|
69 |
||
70 |
CompiledRFrame::CompiledRFrame(frame fr, JavaThread* thread, RFrame*const callee) |
|
71 |
: RFrame(fr, thread, callee) { |
|
72 |
init(); |
|
73 |
} |
|
74 |
||
75 |
CompiledRFrame::CompiledRFrame(frame fr, JavaThread* thread) |
|
76 |
: RFrame(fr, thread, NULL) { |
|
77 |
init(); |
|
78 |
} |
|
79 |
||
80 |
DeoptimizedRFrame::DeoptimizedRFrame(frame fr, JavaThread* thread, RFrame*const callee) |
|
81 |
: InterpretedRFrame(fr, thread, callee) {} |
|
82 |
||
83 |
RFrame* RFrame::new_RFrame(frame fr, JavaThread* thread, RFrame*const callee) { |
|
31851
ec2f9350c499
8079825: Uninitialised variable in hotspot/src/share/vm & cpu/x86/vm (runtime)
ccheung
parents:
31521
diff
changeset
|
84 |
RFrame* rf = NULL; |
1 | 85 |
int dist = callee ? callee->distance() : -1; |
86 |
if (fr.is_interpreted_frame()) { |
|
87 |
rf = new InterpretedRFrame(fr, thread, callee); |
|
88 |
dist++; |
|
89 |
} else if (fr.is_compiled_frame()) { |
|
90 |
// Even deopted frames look compiled because the deopt |
|
91 |
// is invisible until it happens. |
|
92 |
rf = new CompiledRFrame(fr, thread, callee); |
|
93 |
} else { |
|
94 |
assert(false, "Unhandled frame type"); |
|
95 |
} |
|
31851
ec2f9350c499
8079825: Uninitialised variable in hotspot/src/share/vm & cpu/x86/vm (runtime)
ccheung
parents:
31521
diff
changeset
|
96 |
if (rf != NULL) { |
ec2f9350c499
8079825: Uninitialised variable in hotspot/src/share/vm & cpu/x86/vm (runtime)
ccheung
parents:
31521
diff
changeset
|
97 |
rf->set_distance(dist); |
ec2f9350c499
8079825: Uninitialised variable in hotspot/src/share/vm & cpu/x86/vm (runtime)
ccheung
parents:
31521
diff
changeset
|
98 |
rf->init(); |
ec2f9350c499
8079825: Uninitialised variable in hotspot/src/share/vm & cpu/x86/vm (runtime)
ccheung
parents:
31521
diff
changeset
|
99 |
} |
1 | 100 |
return rf; |
101 |
} |
|
102 |
||
103 |
RFrame* RFrame::caller() { |
|
104 |
if (_caller != noCallerYet) return (_caller == noCaller) ? NULL : _caller; // already computed caller |
|
105 |
||
106 |
// caller not yet computed; do it now |
|
107 |
if (_fr.is_first_java_frame()) { |
|
108 |
_caller = (RFrame*)noCaller; |
|
109 |
return NULL; |
|
110 |
} |
|
111 |
||
112 |
RegisterMap map(_thread, false); |
|
113 |
frame sender = _fr.real_sender(&map); |
|
114 |
if (sender.is_java_frame()) { |
|
115 |
_caller = new_RFrame(sender, thread(), this); |
|
116 |
return _caller; |
|
117 |
} |
|
118 |
||
119 |
// Real caller is not java related |
|
120 |
_caller = (RFrame*)noCaller; |
|
121 |
return NULL; |
|
122 |
} |
|
123 |
||
124 |
int InterpretedRFrame::cost() const { |
|
125 |
return _method->code_size(); // fix this |
|
126 |
//return _method->estimated_inline_cost(_receiverKlass); |
|
127 |
} |
|
128 |
||
129 |
int CompiledRFrame::cost() const { |
|
38133
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
33160
diff
changeset
|
130 |
CompiledMethod* nm = top_method()->code(); |
1 | 131 |
if (nm != NULL) { |
6418 | 132 |
return nm->insts_size(); |
1 | 133 |
} else { |
134 |
return top_method()->code_size(); |
|
135 |
} |
|
136 |
} |
|
137 |
||
138 |
void CompiledRFrame::init() { |
|
139 |
RegisterMap map(thread(), false); |
|
140 |
vframe* vf = vframe::new_vframe(&_fr, &map, thread()); |
|
141 |
assert(vf->is_compiled_frame(), "must be compiled"); |
|
38133
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
33160
diff
changeset
|
142 |
_nm = compiledVFrame::cast(vf)->code()->as_nmethod(); |
1 | 143 |
vf = vf->top(); |
144 |
_vf = javaVFrame::cast(vf); |
|
31521
f57b2ce43484
8079775: Java 9-fastdebug ia32 Error: Unimplemented with "-XX:CompilationPolicyChoice=1 -XX:-TieredCompilation" options
iveresov
parents:
25715
diff
changeset
|
145 |
_method = CodeCache::find_nmethod(_fr.pc())->method(); |
f57b2ce43484
8079775: Java 9-fastdebug ia32 Error: Unimplemented with "-XX:CompilationPolicyChoice=1 -XX:-TieredCompilation" options
iveresov
parents:
25715
diff
changeset
|
146 |
assert(_method, "should have found a method"); |
1 | 147 |
#ifndef PRODUCT |
148 |
_invocations = _method->compiled_invocation_count(); |
|
149 |
#endif |
|
150 |
} |
|
151 |
||
152 |
void InterpretedRFrame::init() { |
|
153 |
_invocations = _method->invocation_count() + _method->backedge_count(); |
|
154 |
} |
|
155 |
||
156 |
void RFrame::print(const char* kind) { |
|
157 |
#ifndef PRODUCT |
|
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31851
diff
changeset
|
158 |
#if defined(COMPILER2) || INCLUDE_JVMCI |
1 | 159 |
int cnt = top_method()->interpreter_invocation_count(); |
160 |
#else |
|
161 |
int cnt = top_method()->invocation_count(); |
|
162 |
#endif |
|
163 |
tty->print("%3d %s ", _num, is_interpreted() ? "I" : "C"); |
|
164 |
top_method()->print_short_name(tty); |
|
165 |
tty->print_cr(": inv=%5d(%d) cst=%4d", _invocations, cnt, cost()); |
|
166 |
#endif |
|
167 |
} |
|
168 |
||
169 |
void CompiledRFrame::print() { |
|
170 |
RFrame::print("comp"); |
|
171 |
} |
|
172 |
||
173 |
void InterpretedRFrame::print() { |
|
174 |
RFrame::print("int."); |
|
175 |
} |
|
176 |
||
177 |
void DeoptimizedRFrame::print() { |
|
178 |
RFrame::print("deopt."); |
|
179 |
} |