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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "interpreter/bytecodeStream.hpp"
27 #include "logging/log.hpp"
28 #include "oops/generateOopMap.hpp"
29 #include "oops/oop.inline.hpp"
30 #include "oops/symbol.hpp"
31 #include "prims/jvm.h"
32 #include "runtime/handles.inline.hpp"
33 #include "runtime/java.hpp"
34 #include "runtime/relocator.hpp"
35 #include "runtime/timerTrace.hpp"
36 #include "utilities/bitMap.inline.hpp"
37 #include "utilities/ostream.hpp"
38
39 //
40 //
41 // Compute stack layouts for each instruction in method.
42 //
43 // Problems:
44 // - What to do about jsr with different types of local vars?
45 // Need maps that are conditional on jsr path?
46 // - Jsr and exceptions should be done more efficiently (the retAddr stuff)
47 //
1238 }
1239
1240 // We pessimistically assume that this exception can escape the
1241 // method. (It is possible that it will always be caught, but
1242 // we don't care to analyse the types of the catch clauses.)
1243
1244 // We don't set _monitor_top to bad_monitors because there are no successors
1245 // to this exceptional exit.
1246
1247 if (log_is_enabled(Info, monitormismatch) && _monitor_safe) {
1248 // We check _monitor_safe so that we only report the first mismatched
1249 // exceptional exit.
1250 report_monitor_mismatch("non-empty monitor stack at exceptional exit");
1251 }
1252 _monitor_safe = false;
1253
1254 }
1255
1256 void GenerateOopMap::report_monitor_mismatch(const char *msg) {
1257 ResourceMark rm;
1258 outputStream* out = Log(monitormismatch)::info_stream();
1259 out->print("Monitor mismatch in method ");
1260 method()->print_short_name(out);
1261 out->print_cr(": %s", msg);
1262 }
1263
1264 void GenerateOopMap::print_states(outputStream *os,
1265 CellTypeState* vec, int num) {
1266 for (int i = 0; i < num; i++) {
1267 vec[i].print(tty);
1268 }
1269 }
1270
1271 // Print the state values at the current bytecode.
1272 void GenerateOopMap::print_current_state(outputStream *os,
1273 BytecodeStream *currentBC,
1274 bool detailed) {
1275
1276 if (detailed) {
1277 os->print(" %4d vars = ", currentBC->bci());
1278 print_states(os, vars(), _max_locals);
1279 os->print(" %s", Bytecodes::name(currentBC->code()));
1280 switch(currentBC->code()) {
1281 case Bytecodes::_invokevirtual:
|
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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "interpreter/bytecodeStream.hpp"
27 #include "logging/log.hpp"
28 #include "logging/logStream.hpp"
29 #include "oops/generateOopMap.hpp"
30 #include "oops/oop.inline.hpp"
31 #include "oops/symbol.hpp"
32 #include "prims/jvm.h"
33 #include "runtime/handles.inline.hpp"
34 #include "runtime/java.hpp"
35 #include "runtime/relocator.hpp"
36 #include "runtime/timerTrace.hpp"
37 #include "utilities/bitMap.inline.hpp"
38 #include "utilities/ostream.hpp"
39
40 //
41 //
42 // Compute stack layouts for each instruction in method.
43 //
44 // Problems:
45 // - What to do about jsr with different types of local vars?
46 // Need maps that are conditional on jsr path?
47 // - Jsr and exceptions should be done more efficiently (the retAddr stuff)
48 //
1239 }
1240
1241 // We pessimistically assume that this exception can escape the
1242 // method. (It is possible that it will always be caught, but
1243 // we don't care to analyse the types of the catch clauses.)
1244
1245 // We don't set _monitor_top to bad_monitors because there are no successors
1246 // to this exceptional exit.
1247
1248 if (log_is_enabled(Info, monitormismatch) && _monitor_safe) {
1249 // We check _monitor_safe so that we only report the first mismatched
1250 // exceptional exit.
1251 report_monitor_mismatch("non-empty monitor stack at exceptional exit");
1252 }
1253 _monitor_safe = false;
1254
1255 }
1256
1257 void GenerateOopMap::report_monitor_mismatch(const char *msg) {
1258 ResourceMark rm;
1259 LogStream ls(Log(monitormismatch)::info());
1260 ls.print("Monitor mismatch in method ");
1261 method()->print_short_name(&ls);
1262 ls.print_cr(": %s", msg);
1263 }
1264
1265 void GenerateOopMap::print_states(outputStream *os,
1266 CellTypeState* vec, int num) {
1267 for (int i = 0; i < num; i++) {
1268 vec[i].print(tty);
1269 }
1270 }
1271
1272 // Print the state values at the current bytecode.
1273 void GenerateOopMap::print_current_state(outputStream *os,
1274 BytecodeStream *currentBC,
1275 bool detailed) {
1276
1277 if (detailed) {
1278 os->print(" %4d vars = ", currentBC->bci());
1279 print_states(os, vars(), _max_locals);
1280 os->print(" %s", Bytecodes::name(currentBC->code()));
1281 switch(currentBC->code()) {
1282 case Bytecodes::_invokevirtual:
|