annotate src/share/vm/runtime/rframe.cpp @ 18096:ca6d25be853b jdk8u25-b13

8044269: Analysis of archive files. Summary: Add checksum verification. Reviewed-by: iklam, dholmes, mschoene
author jiangli
date Tue, 12 Aug 2014 17:46:16 -0400
parents 1d1603768966
children 409ef3a68dc8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
2426
1d1603768966 7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass
trims
parents: 2177
diff changeset
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
26 #include "interpreter/interpreter.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
27 #include "oops/oop.inline.hpp"
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
28 #include "oops/symbol.hpp"
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
29 #include "runtime/frame.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
30 #include "runtime/rframe.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
31 #include "runtime/vframe.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
32 #include "runtime/vframe_hp.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
33
a61af66fc99e Initial load
duke
parents:
diff changeset
34
a61af66fc99e Initial load
duke
parents:
diff changeset
35 static RFrame*const noCaller = (RFrame*) 0x1; // no caller (i.e., initial frame)
a61af66fc99e Initial load
duke
parents:
diff changeset
36 static RFrame*const noCallerYet = (RFrame*) 0x0; // caller not yet computed
a61af66fc99e Initial load
duke
parents:
diff changeset
37
a61af66fc99e Initial load
duke
parents:
diff changeset
38 RFrame::RFrame(frame fr, JavaThread* thread, RFrame*const callee) :
a61af66fc99e Initial load
duke
parents:
diff changeset
39 _fr(fr), _thread(thread), _callee(callee), _num(callee ? callee->num() + 1 : 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
40 _caller = (RFrame*)noCallerYet;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 _invocations = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 _distance = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
43 }
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 void RFrame::set_distance(int d) {
a61af66fc99e Initial load
duke
parents:
diff changeset
46 assert(is_compiled() || d >= 0, "should be positive");
a61af66fc99e Initial load
duke
parents:
diff changeset
47 _distance = d;
a61af66fc99e Initial load
duke
parents:
diff changeset
48 }
a61af66fc99e Initial load
duke
parents:
diff changeset
49
a61af66fc99e Initial load
duke
parents:
diff changeset
50 InterpretedRFrame::InterpretedRFrame(frame fr, JavaThread* thread, RFrame*const callee)
a61af66fc99e Initial load
duke
parents:
diff changeset
51 : RFrame(fr, thread, callee) {
a61af66fc99e Initial load
duke
parents:
diff changeset
52 RegisterMap map(thread, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
53 _vf = javaVFrame::cast(vframe::new_vframe(&_fr, &map, thread));
a61af66fc99e Initial load
duke
parents:
diff changeset
54 _method = methodHandle(thread, _vf->method());
a61af66fc99e Initial load
duke
parents:
diff changeset
55 assert( _vf->is_interpreted_frame(), "must be interpreted");
a61af66fc99e Initial load
duke
parents:
diff changeset
56 init();
a61af66fc99e Initial load
duke
parents:
diff changeset
57 }
a61af66fc99e Initial load
duke
parents:
diff changeset
58
a61af66fc99e Initial load
duke
parents:
diff changeset
59 InterpretedRFrame::InterpretedRFrame(frame fr, JavaThread* thread, methodHandle m)
a61af66fc99e Initial load
duke
parents:
diff changeset
60 : RFrame(fr, thread, NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
61 RegisterMap map(thread, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
62 _vf = javaVFrame::cast(vframe::new_vframe(&_fr, &map, thread));
a61af66fc99e Initial load
duke
parents:
diff changeset
63 _method = m;
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65 assert( _vf->is_interpreted_frame(), "must be interpreted");
a61af66fc99e Initial load
duke
parents:
diff changeset
66 init();
a61af66fc99e Initial load
duke
parents:
diff changeset
67 }
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 CompiledRFrame::CompiledRFrame(frame fr, JavaThread* thread, RFrame*const callee)
a61af66fc99e Initial load
duke
parents:
diff changeset
70 : RFrame(fr, thread, callee) {
a61af66fc99e Initial load
duke
parents:
diff changeset
71 init();
a61af66fc99e Initial load
duke
parents:
diff changeset
72 }
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74 CompiledRFrame::CompiledRFrame(frame fr, JavaThread* thread)
a61af66fc99e Initial load
duke
parents:
diff changeset
75 : RFrame(fr, thread, NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
76 init();
a61af66fc99e Initial load
duke
parents:
diff changeset
77 }
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 DeoptimizedRFrame::DeoptimizedRFrame(frame fr, JavaThread* thread, RFrame*const callee)
a61af66fc99e Initial load
duke
parents:
diff changeset
80 : InterpretedRFrame(fr, thread, callee) {}
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 RFrame* RFrame::new_RFrame(frame fr, JavaThread* thread, RFrame*const callee) {
a61af66fc99e Initial load
duke
parents:
diff changeset
83 RFrame* rf;
a61af66fc99e Initial load
duke
parents:
diff changeset
84 int dist = callee ? callee->distance() : -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
85 if (fr.is_interpreted_frame()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
86 rf = new InterpretedRFrame(fr, thread, callee);
a61af66fc99e Initial load
duke
parents:
diff changeset
87 dist++;
a61af66fc99e Initial load
duke
parents:
diff changeset
88 } else if (fr.is_compiled_frame()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
89 // Even deopted frames look compiled because the deopt
a61af66fc99e Initial load
duke
parents:
diff changeset
90 // is invisible until it happens.
a61af66fc99e Initial load
duke
parents:
diff changeset
91 rf = new CompiledRFrame(fr, thread, callee);
a61af66fc99e Initial load
duke
parents:
diff changeset
92 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
93 assert(false, "Unhandled frame type");
a61af66fc99e Initial load
duke
parents:
diff changeset
94 }
a61af66fc99e Initial load
duke
parents:
diff changeset
95 rf->set_distance(dist);
a61af66fc99e Initial load
duke
parents:
diff changeset
96 rf->init();
a61af66fc99e Initial load
duke
parents:
diff changeset
97 return rf;
a61af66fc99e Initial load
duke
parents:
diff changeset
98 }
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 RFrame* RFrame::caller() {
a61af66fc99e Initial load
duke
parents:
diff changeset
101 if (_caller != noCallerYet) return (_caller == noCaller) ? NULL : _caller; // already computed caller
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103 // caller not yet computed; do it now
a61af66fc99e Initial load
duke
parents:
diff changeset
104 if (_fr.is_first_java_frame()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
105 _caller = (RFrame*)noCaller;
a61af66fc99e Initial load
duke
parents:
diff changeset
106 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
107 }
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109 RegisterMap map(_thread, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
110 frame sender = _fr.real_sender(&map);
a61af66fc99e Initial load
duke
parents:
diff changeset
111 if (sender.is_java_frame()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
112 _caller = new_RFrame(sender, thread(), this);
a61af66fc99e Initial load
duke
parents:
diff changeset
113 return _caller;
a61af66fc99e Initial load
duke
parents:
diff changeset
114 }
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 // Real caller is not java related
a61af66fc99e Initial load
duke
parents:
diff changeset
117 _caller = (RFrame*)noCaller;
a61af66fc99e Initial load
duke
parents:
diff changeset
118 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
119 }
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121 int InterpretedRFrame::cost() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
122 return _method->code_size(); // fix this
a61af66fc99e Initial load
duke
parents:
diff changeset
123 //return _method->estimated_inline_cost(_receiverKlass);
a61af66fc99e Initial load
duke
parents:
diff changeset
124 }
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 int CompiledRFrame::cost() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
127 nmethod* nm = top_method()->code();
a61af66fc99e Initial load
duke
parents:
diff changeset
128 if (nm != NULL) {
1748
3e8fbc61cee8 6978355: renaming for 6961697
twisti
parents: 1552
diff changeset
129 return nm->insts_size();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
130 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
131 return top_method()->code_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
132 }
a61af66fc99e Initial load
duke
parents:
diff changeset
133 }
a61af66fc99e Initial load
duke
parents:
diff changeset
134
a61af66fc99e Initial load
duke
parents:
diff changeset
135 void CompiledRFrame::init() {
a61af66fc99e Initial load
duke
parents:
diff changeset
136 RegisterMap map(thread(), false);
a61af66fc99e Initial load
duke
parents:
diff changeset
137 vframe* vf = vframe::new_vframe(&_fr, &map, thread());
a61af66fc99e Initial load
duke
parents:
diff changeset
138 assert(vf->is_compiled_frame(), "must be compiled");
a61af66fc99e Initial load
duke
parents:
diff changeset
139 _nm = compiledVFrame::cast(vf)->code();
a61af66fc99e Initial load
duke
parents:
diff changeset
140 vf = vf->top();
a61af66fc99e Initial load
duke
parents:
diff changeset
141 _vf = javaVFrame::cast(vf);
a61af66fc99e Initial load
duke
parents:
diff changeset
142 _method = methodHandle(thread(), CodeCache::find_nmethod(_fr.pc())->method());
a61af66fc99e Initial load
duke
parents:
diff changeset
143 assert(_method(), "should have found a method");
a61af66fc99e Initial load
duke
parents:
diff changeset
144 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
145 _invocations = _method->compiled_invocation_count();
a61af66fc99e Initial load
duke
parents:
diff changeset
146 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
147 }
a61af66fc99e Initial load
duke
parents:
diff changeset
148
a61af66fc99e Initial load
duke
parents:
diff changeset
149 void InterpretedRFrame::init() {
a61af66fc99e Initial load
duke
parents:
diff changeset
150 _invocations = _method->invocation_count() + _method->backedge_count();
a61af66fc99e Initial load
duke
parents:
diff changeset
151 }
a61af66fc99e Initial load
duke
parents:
diff changeset
152
a61af66fc99e Initial load
duke
parents:
diff changeset
153 void RFrame::print(const char* kind) {
a61af66fc99e Initial load
duke
parents:
diff changeset
154 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
155 #ifdef COMPILER2
a61af66fc99e Initial load
duke
parents:
diff changeset
156 int cnt = top_method()->interpreter_invocation_count();
a61af66fc99e Initial load
duke
parents:
diff changeset
157 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
158 int cnt = top_method()->invocation_count();
a61af66fc99e Initial load
duke
parents:
diff changeset
159 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
160 tty->print("%3d %s ", _num, is_interpreted() ? "I" : "C");
a61af66fc99e Initial load
duke
parents:
diff changeset
161 top_method()->print_short_name(tty);
a61af66fc99e Initial load
duke
parents:
diff changeset
162 tty->print_cr(": inv=%5d(%d) cst=%4d", _invocations, cnt, cost());
a61af66fc99e Initial load
duke
parents:
diff changeset
163 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
164 }
a61af66fc99e Initial load
duke
parents:
diff changeset
165
a61af66fc99e Initial load
duke
parents:
diff changeset
166 void CompiledRFrame::print() {
a61af66fc99e Initial load
duke
parents:
diff changeset
167 RFrame::print("comp");
a61af66fc99e Initial load
duke
parents:
diff changeset
168 }
a61af66fc99e Initial load
duke
parents:
diff changeset
169
a61af66fc99e Initial load
duke
parents:
diff changeset
170 void InterpretedRFrame::print() {
a61af66fc99e Initial load
duke
parents:
diff changeset
171 RFrame::print("int.");
a61af66fc99e Initial load
duke
parents:
diff changeset
172 }
a61af66fc99e Initial load
duke
parents:
diff changeset
173
a61af66fc99e Initial load
duke
parents:
diff changeset
174 void DeoptimizedRFrame::print() {
a61af66fc99e Initial load
duke
parents:
diff changeset
175 RFrame::print("deopt.");
a61af66fc99e Initial load
duke
parents:
diff changeset
176 }