annotate src/share/vm/compiler/disassembler.cpp @ 17524:89152779163c

Merge with jdk8-b132
author Gilles Duboscq <duboscq@ssw.jku.at>
date Wed, 15 Oct 2014 11:59:32 +0200
parents b1911c1e44c8
children 52b4284cb496
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17524
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
1 /*
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
2 * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
4 *
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
7 * published by the Free Software Foundation.
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
8 *
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
13 * accompanied this code).
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
14 *
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
15 * You should have received a copy of the GNU General Public License version
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
18 *
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
21 * questions.
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
22 *
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
23 */
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
24
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
25 #include "precompiled.hpp"
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
26 #include "classfile/javaClasses.hpp"
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
27 #include "code/codeCache.hpp"
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
28 #include "compiler/disassembler.hpp"
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
29 #include "gc_interface/collectedHeap.hpp"
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
30 #include "memory/cardTableModRefBS.hpp"
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
31 #include "runtime/fprofiler.hpp"
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
32 #include "runtime/handles.inline.hpp"
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
33 #include "runtime/stubCodeGenerator.hpp"
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
34 #include "runtime/stubRoutines.hpp"
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
35 #ifdef TARGET_ARCH_x86
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
36 # include "depChecker_x86.hpp"
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
37 #endif
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
38 #ifdef TARGET_ARCH_sparc
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
39 # include "depChecker_sparc.hpp"
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
40 #endif
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
41 #ifdef TARGET_ARCH_zero
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
42 # include "depChecker_zero.hpp"
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
43 #endif
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
44 #ifdef TARGET_ARCH_arm
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
45 # include "depChecker_arm.hpp"
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
46 #endif
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
47 #ifdef TARGET_ARCH_ppc
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
48 # include "depChecker_ppc.hpp"
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
49 #endif
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
50 #ifdef SHARK
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
51 #include "shark/sharkEntry.hpp"
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
52 #endif
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
53
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
54 void* Disassembler::_library = NULL;
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
55 bool Disassembler::_tried_to_load_library = false;
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
56
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
57 // This routine is in the shared library:
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
58 Disassembler::decode_func_virtual Disassembler::_decode_instructions_virtual = NULL;
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
59 Disassembler::decode_func Disassembler::_decode_instructions = NULL;
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
60
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
61 static const char hsdis_library_name[] = "hsdis-"HOTSPOT_LIB_ARCH;
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
62 static const char decode_instructions_virtual_name[] = "decode_instructions_virtual";
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
63 static const char decode_instructions_name[] = "decode_instructions";
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
64 static bool use_new_version = true;
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
65 #define COMMENT_COLUMN 40 LP64_ONLY(+8) /*could be an option*/
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
66 #define BYTES_COMMENT ";..." /* funky byte display comment */
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
67
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
68 bool Disassembler::load_library() {
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
69 if (_decode_instructions_virtual != NULL || _decode_instructions != NULL) {
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
70 // Already succeeded.
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
71 return true;
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
72 }
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
73 if (_tried_to_load_library) {
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
74 // Do not try twice.
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
75 // To force retry in debugger: assign _tried_to_load_library=0
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
76 return false;
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
77 }
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
78 // Try to load it.
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
79 char ebuf[1024];
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
80 char buf[JVM_MAXPATHLEN];
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
81 os::jvm_path(buf, sizeof(buf));
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
82 int jvm_offset = -1;
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
83 int lib_offset = -1;
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
84 {
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
85 // Match "jvm[^/]*" in jvm_path.
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
86 const char* base = buf;
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
87 const char* p = strrchr(buf, '/');
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
88 if (p != NULL) lib_offset = p - base + 1;
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
89 p = strstr(p ? p : base, "jvm");
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
90 if (p != NULL) jvm_offset = p - base;
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
91 }
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
92 // Find the disassembler shared library.
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
93 // Search for several paths derived from libjvm, in this order:
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
94 // 1. <home>/jre/lib/<arch>/<vm>/libhsdis-<arch>.so (for compatibility)
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
95 // 2. <home>/jre/lib/<arch>/<vm>/hsdis-<arch>.so
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
96 // 3. <home>/jre/lib/<arch>/hsdis-<arch>.so
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
97 // 4. hsdis-<arch>.so (using LD_LIBRARY_PATH)
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
98 if (jvm_offset >= 0) {
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
99 // 1. <home>/jre/lib/<arch>/<vm>/libhsdis-<arch>.so
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
100 strcpy(&buf[jvm_offset], hsdis_library_name);
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
101 strcat(&buf[jvm_offset], os::dll_file_extension());
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
102 _library = os::dll_load(buf, ebuf, sizeof ebuf);
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
103 if (_library == NULL) {
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
104 // 2. <home>/jre/lib/<arch>/<vm>/hsdis-<arch>.so
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
105 strcpy(&buf[lib_offset], hsdis_library_name);
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
106 strcat(&buf[lib_offset], os::dll_file_extension());
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
107 _library = os::dll_load(buf, ebuf, sizeof ebuf);
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
108 }
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
109 if (_library == NULL) {
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
110 // 3. <home>/jre/lib/<arch>/hsdis-<arch>.so
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
111 buf[lib_offset - 1] = '\0';
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
112 const char* p = strrchr(buf, '/');
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
113 if (p != NULL) {
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
114 lib_offset = p - buf + 1;
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
115 strcpy(&buf[lib_offset], hsdis_library_name);
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
116 strcat(&buf[lib_offset], os::dll_file_extension());
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
117 _library = os::dll_load(buf, ebuf, sizeof ebuf);
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
118 }
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
119 }
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
120 }
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
121 if (_library == NULL) {
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
122 // 4. hsdis-<arch>.so (using LD_LIBRARY_PATH)
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
123 strcpy(&buf[0], hsdis_library_name);
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
124 strcat(&buf[0], os::dll_file_extension());
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
125 _library = os::dll_load(buf, ebuf, sizeof ebuf);
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
126 }
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
127 if (_library != NULL) {
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
128 _decode_instructions_virtual = CAST_TO_FN_PTR(Disassembler::decode_func_virtual,
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
129 os::dll_lookup(_library, decode_instructions_virtual_name));
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
130 }
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
131 if (_decode_instructions_virtual == NULL) {
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
132 // could not spot in new version, try old version
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
133 _decode_instructions = CAST_TO_FN_PTR(Disassembler::decode_func,
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
134 os::dll_lookup(_library, decode_instructions_name));
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
135 use_new_version = false;
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
136 } else {
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
137 use_new_version = true;
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
138 }
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
139 _tried_to_load_library = true;
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
140 if (_decode_instructions_virtual == NULL && _decode_instructions == NULL) {
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
141 tty->print_cr("Could not load %s; %s; %s", buf,
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
142 ((_library != NULL)
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
143 ? "entry point is missing"
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
144 : (WizardMode || PrintMiscellaneous)
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
145 ? (const char*)ebuf
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
146 : "library not loadable"),
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
147 "PrintAssembly is disabled");
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
148 return false;
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
149 }
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
150
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
151 // Success.
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
152 tty->print_cr("Loaded disassembler from %s", buf);
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
153 return true;
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
154 }
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
155
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
156
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
157 class decode_env {
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
158 private:
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
159 nmethod* _nm;
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16719
diff changeset
160 CodeBlob* _code;
8767
a5de0cc2f91c 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 6983
diff changeset
161 CodeStrings _strings;
14752
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
162 outputStream* _output;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
163 address _start, _end;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
164
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
165 char _option_buf[512];
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
166 char _print_raw;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
167 bool _print_pc;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
168 bool _print_bytes;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
169 address _cur_insn;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
170 int _total_ticks;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
171 int _bytes_per_line; // arch-specific formatting option
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
172
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
173 static bool match(const char* event, const char* tag) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
174 size_t taglen = strlen(tag);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
175 if (strncmp(event, tag, taglen) != 0)
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
176 return false;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
177 char delim = event[taglen];
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
178 return delim == '\0' || delim == ' ' || delim == '/' || delim == '=';
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
179 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
180
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
181 void collect_options(const char* p) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
182 if (p == NULL || p[0] == '\0') return;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
183 size_t opt_so_far = strlen(_option_buf);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
184 if (opt_so_far + 1 + strlen(p) + 1 > sizeof(_option_buf)) return;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
185 char* fillp = &_option_buf[opt_so_far];
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
186 if (opt_so_far > 0) *fillp++ = ',';
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
187 strcat(fillp, p);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
188 // replace white space by commas:
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
189 char* q = fillp;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
190 while ((q = strpbrk(q, " \t\n")) != NULL)
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
191 *q++ = ',';
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
192 // Note that multiple PrintAssemblyOptions flags accumulate with \n,
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
193 // which we want to be changed to a comma...
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
194 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
195
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
196 void print_insn_labels();
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
197 void print_insn_bytes(address pc0, address pc);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
198 void print_address(address value);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
199
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
200 public:
8767
a5de0cc2f91c 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 6983
diff changeset
201 decode_env(CodeBlob* code, outputStream* output, CodeStrings c = CodeStrings());
14752
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
202
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
203 address decode_instructions(address start, address end);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
204
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
205 void start_insn(address pc) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
206 _cur_insn = pc;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
207 output()->bol();
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
208 print_insn_labels();
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
209 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
210
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
211 void end_insn(address pc) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
212 address pc0 = cur_insn();
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
213 outputStream* st = output();
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
214 if (_print_bytes && pc > pc0)
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
215 print_insn_bytes(pc0, pc);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
216 if (_nm != NULL) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
217 _nm->print_code_comment_on(st, COMMENT_COLUMN, pc0, pc);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
218 // this calls reloc_string_for which calls oop::print_value_on
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
219 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
220
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
221 // Output pc bucket ticks if we have any
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
222 if (total_ticks() != 0) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
223 address bucket_pc = FlatProfiler::bucket_start_for(pc);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
224 if (bucket_pc != NULL && bucket_pc > pc0 && bucket_pc <= pc) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
225 int bucket_count = FlatProfiler::bucket_count_for(pc0);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
226 if (bucket_count != 0) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
227 st->bol();
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
228 st->print_cr("%3.1f%% [%d]", bucket_count*100.0/total_ticks(), bucket_count);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
229 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
230 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
231 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
232 // follow each complete insn by a nice newline
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
233 st->cr();
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
234 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
235
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
236 address handle_event(const char* event, address arg);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
237
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
238 outputStream* output() { return _output; }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
239 address cur_insn() { return _cur_insn; }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
240 int total_ticks() { return _total_ticks; }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
241 void set_total_ticks(int n) { _total_ticks = n; }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
242 const char* options() { return _option_buf; }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
243 };
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
244
8767
a5de0cc2f91c 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 6983
diff changeset
245 decode_env::decode_env(CodeBlob* code, outputStream* output, CodeStrings c) {
14752
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
246 memset(this, 0, sizeof(*this));
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
247 _output = output ? output : tty;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
248 _code = code;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
249 if (code != NULL && code->is_nmethod())
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
250 _nm = (nmethod*) code;
8767
a5de0cc2f91c 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 6983
diff changeset
251 _strings.assign(c);
14752
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
252
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
253 // by default, output pc but not bytes:
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
254 _print_pc = true;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
255 _print_bytes = false;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
256 _bytes_per_line = Disassembler::pd_instruction_alignment();
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
257
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
258 // parse the global option string:
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
259 collect_options(Disassembler::pd_cpu_opts());
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
260 collect_options(PrintAssemblyOptions);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
261
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
262 if (strstr(options(), "hsdis-")) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
263 if (strstr(options(), "hsdis-print-raw"))
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
264 _print_raw = (strstr(options(), "xml") ? 2 : 1);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
265 if (strstr(options(), "hsdis-print-pc"))
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
266 _print_pc = !_print_pc;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
267 if (strstr(options(), "hsdis-print-bytes"))
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
268 _print_bytes = !_print_bytes;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
269 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
270 if (strstr(options(), "help")) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
271 tty->print_cr("PrintAssemblyOptions help:");
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
272 tty->print_cr(" hsdis-print-raw test plugin by requesting raw output");
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
273 tty->print_cr(" hsdis-print-raw-xml test plugin by requesting raw xml");
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
274 tty->print_cr(" hsdis-print-pc turn off PC printing (on by default)");
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
275 tty->print_cr(" hsdis-print-bytes turn on instruction byte output");
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
276 tty->print_cr("combined options: %s", options());
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
277 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
278 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
279
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
280 address decode_env::handle_event(const char* event, address arg) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
281 if (match(event, "insn")) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
282 start_insn(arg);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
283 } else if (match(event, "/insn")) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
284 end_insn(arg);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
285 } else if (match(event, "addr")) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
286 if (arg != NULL) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
287 print_address(arg);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
288 return arg;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
289 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
290 } else if (match(event, "mach")) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
291 static char buffer[32] = { 0, };
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
292 if (strcmp(buffer, (const char*)arg) != 0 ||
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
293 strlen((const char*)arg) > sizeof(buffer) - 1) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
294 // Only print this when the mach changes
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
295 strncpy(buffer, (const char*)arg, sizeof(buffer) - 1);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
296 output()->print_cr("[Disassembling for mach='%s']", arg);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
297 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
298 } else if (match(event, "format bytes-per-line")) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
299 _bytes_per_line = (int) (intptr_t) arg;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
300 } else {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
301 // ignore unrecognized markup
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
302 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
303 return NULL;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
304 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
305
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
306 // called by the disassembler to print out jump targets and data addresses
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
307 void decode_env::print_address(address adr) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
308 outputStream* st = _output;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
309
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
310 if (adr == NULL) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
311 st->print("NULL");
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
312 return;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
313 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
314
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
315 int small_num = (int)(intptr_t)adr;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
316 if ((intptr_t)adr == (intptr_t)small_num
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
317 && -1 <= small_num && small_num <= 9) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
318 st->print("%d", small_num);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
319 return;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
320 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
321
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
322 if (Universe::is_fully_initialized()) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
323 if (StubRoutines::contains(adr)) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
324 StubCodeDesc* desc = StubCodeDesc::desc_for(adr);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
325 if (desc == NULL)
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
326 desc = StubCodeDesc::desc_for(adr + frame::pc_return_offset);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
327 if (desc != NULL) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
328 st->print("Stub::%s", desc->name());
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
329 if (desc->begin() != adr)
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
330 st->print("%+d 0x%p",adr - desc->begin(), adr);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
331 else if (WizardMode) st->print(" " PTR_FORMAT, adr);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
332 return;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
333 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
334 st->print("Stub::<unknown> " PTR_FORMAT, adr);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
335 return;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
336 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
337
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
338 BarrierSet* bs = Universe::heap()->barrier_set();
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
339 if (bs->kind() == BarrierSet::CardTableModRef &&
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
340 adr == (address)((CardTableModRefBS*)(bs))->byte_map_base) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
341 st->print("word_map_base");
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
342 if (WizardMode) st->print(" " INTPTR_FORMAT, (intptr_t)adr);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
343 return;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
344 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
345
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
346 oop obj;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
347 if (_nm != NULL
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
348 && (obj = _nm->embeddedOop_at(cur_insn())) != NULL
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
349 && (address) obj == adr
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
350 && Universe::heap()->is_in(obj)
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
351 && Universe::heap()->is_in(obj->klass())) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
352 julong c = st->count();
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
353 obj->print_value_on(st);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
354 if (st->count() == c) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
355 // No output. (Can happen in product builds.)
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
356 st->print("(a %s)", obj->klass()->external_name());
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
357 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
358 return;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
359 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
360 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
361
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
362 // Fall through to a simple (hexadecimal) numeral.
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
363 st->print(PTR_FORMAT, adr);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
364 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
365
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
366 void decode_env::print_insn_labels() {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
367 address p = cur_insn();
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
368 outputStream* st = output();
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
369 CodeBlob* cb = _code;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
370 if (cb != NULL) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
371 cb->print_block_comment(st, p);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
372 }
8767
a5de0cc2f91c 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 6983
diff changeset
373 _strings.print_block_comment(st, (intptr_t)(p - _start));
14752
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
374 if (_print_pc) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
375 st->print(" " PTR_FORMAT ": ", p);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
376 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
377 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
378
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
379 void decode_env::print_insn_bytes(address pc, address pc_limit) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
380 outputStream* st = output();
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
381 size_t incr = 1;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
382 size_t perline = _bytes_per_line;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
383 if ((size_t) Disassembler::pd_instruction_alignment() >= sizeof(int)
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
384 && !((uintptr_t)pc % sizeof(int))
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
385 && !((uintptr_t)pc_limit % sizeof(int))) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
386 incr = sizeof(int);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
387 if (perline % incr) perline += incr - (perline % incr);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
388 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
389 while (pc < pc_limit) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
390 // tab to the desired column:
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
391 st->move_to(COMMENT_COLUMN);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
392 address pc0 = pc;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
393 address pc1 = pc + perline;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
394 if (pc1 > pc_limit) pc1 = pc_limit;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
395 for (; pc < pc1; pc += incr) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
396 if (pc == pc0)
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
397 st->print(BYTES_COMMENT);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
398 else if ((uint)(pc - pc0) % sizeof(int) == 0)
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
399 st->print(" "); // put out a space on word boundaries
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
400 if (incr == sizeof(int))
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
401 st->print("%08lx", *(int*)pc);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
402 else st->print("%02x", (*pc)&0xFF);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
403 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
404 st->cr();
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
405 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
406 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
407
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
408
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
409 static void* event_to_env(void* env_pv, const char* event, void* arg) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
410 decode_env* env = (decode_env*) env_pv;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
411 return env->handle_event(event, (address) arg);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
412 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
413
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
414 static int printf_to_env(void* env_pv, const char* format, ...) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
415 decode_env* env = (decode_env*) env_pv;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
416 outputStream* st = env->output();
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
417 size_t flen = strlen(format);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
418 const char* raw = NULL;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
419 if (flen == 0) return 0;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
420 if (flen == 1 && format[0] == '\n') { st->bol(); return 1; }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
421 if (flen < 2 ||
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
422 strchr(format, '%') == NULL) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
423 raw = format;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
424 } else if (format[0] == '%' && format[1] == '%' &&
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
425 strchr(format+2, '%') == NULL) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
426 // happens a lot on machines with names like %foo
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
427 flen--;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
428 raw = format+1;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
429 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
430 if (raw != NULL) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
431 st->print_raw(raw, (int) flen);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
432 return (int) flen;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
433 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
434 va_list ap;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
435 va_start(ap, format);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
436 julong cnt0 = st->count();
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
437 st->vprint(format, ap);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
438 julong cnt1 = st->count();
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
439 va_end(ap);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
440 return (int)(cnt1 - cnt0);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
441 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
442
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
443 address decode_env::decode_instructions(address start, address end) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
444 _start = start; _end = end;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
445
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
446 assert(((((intptr_t)start | (intptr_t)end) % Disassembler::pd_instruction_alignment()) == 0), "misaligned insn addr");
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
447
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
448 const int show_bytes = false; // for disassembler debugging
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
449
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
450 //_version = Disassembler::pd_cpu_version();
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
451
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
452 if (!Disassembler::can_decode()) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
453 return NULL;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
454 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
455
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
456 // decode a series of instructions and return the end of the last instruction
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
457
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
458 if (_print_raw) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
459 // Print whatever the library wants to print, w/o fancy callbacks.
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
460 // This is mainly for debugging the library itself.
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
461 FILE* out = stdout;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
462 FILE* xmlout = (_print_raw > 1 ? out : NULL);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
463 return use_new_version ?
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
464 (address)
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
465 (*Disassembler::_decode_instructions_virtual)((uintptr_t)start, (uintptr_t)end,
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
466 start, end - start,
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
467 NULL, (void*) xmlout,
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
468 NULL, (void*) out,
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
469 options(), 0/*nice new line*/)
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
470 :
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
471 (address)
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
472 (*Disassembler::_decode_instructions)(start, end,
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
473 NULL, (void*) xmlout,
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
474 NULL, (void*) out,
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
475 options());
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
476 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
477
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
478 return use_new_version ?
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
479 (address)
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
480 (*Disassembler::_decode_instructions_virtual)((uintptr_t)start, (uintptr_t)end,
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
481 start, end - start,
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
482 &event_to_env, (void*) this,
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
483 &printf_to_env, (void*) this,
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
484 options(), 0/*nice new line*/)
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
485 :
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
486 (address)
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
487 (*Disassembler::_decode_instructions)(start, end,
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
488 &event_to_env, (void*) this,
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
489 &printf_to_env, (void*) this,
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
490 options());
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
491 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
492
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
493
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
494 void Disassembler::decode(CodeBlob* cb, outputStream* st) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
495 if (!load_library()) return;
16719
b1911c1e44c8 Dump disassembly in crash log
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15099
diff changeset
496 if (cb->is_nmethod()) {
b1911c1e44c8 Dump disassembly in crash log
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15099
diff changeset
497 decode((nmethod*)cb, st);
b1911c1e44c8 Dump disassembly in crash log
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15099
diff changeset
498 return;
b1911c1e44c8 Dump disassembly in crash log
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15099
diff changeset
499 }
14752
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
500 decode_env env(cb, st);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
501 env.output()->print_cr("----------------------------------------------------------------------");
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
502 env.output()->print_cr("%s at [" PTR_FORMAT ", " PTR_FORMAT "] %d bytes", cb->name(), cb->code_begin(), cb->code_end(), ((jlong)(cb->code_end() - cb->code_begin())) * sizeof(unsigned char*));
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
503 env.decode_instructions(cb->code_begin(), cb->code_end());
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
504 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
505
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
506 void Disassembler::decode(address start, address end, outputStream* st, CodeStrings c) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
507 if (!load_library()) return;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
508 decode_env env(CodeCache::find_blob_unsafe(start), st, c);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
509 env.decode_instructions(start, end);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
510 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
511
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
512 void Disassembler::decode(nmethod* nm, outputStream* st) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
513 if (!load_library()) return;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
514 decode_env env(nm, st);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
515 env.output()->print_cr("----------------------------------------------------------------------");
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
516
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
517 #ifdef SHARK
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
518 SharkEntry* entry = (SharkEntry *) nm->code_begin();
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
519 unsigned char* p = entry->code_start();
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
520 unsigned char* end = entry->code_limit();
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
521 #else
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
522 unsigned char* p = nm->code_begin();
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
523 unsigned char* end = nm->code_end();
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
524 #endif // SHARK
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
525
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
526 nm->method()->method_holder()->name()->print_symbol_on(env.output());
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
527 env.output()->print(".");
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
528 nm->method()->name()->print_symbol_on(env.output());
15099
0fab2ac29847 correct size in printed in message
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14909
diff changeset
529 env.output()->print_cr(" [" PTR_FORMAT ", " PTR_FORMAT "] %d bytes", p, end, ((jlong)(end - p)));
14752
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
530
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
531 // If there has been profiling, print the buckets.
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
532 if (FlatProfiler::bucket_start_for(p) != NULL) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
533 unsigned char* p1 = p;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
534 int total_bucket_count = 0;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
535 while (p1 < end) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
536 unsigned char* p0 = p1;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
537 p1 += pd_instruction_alignment();
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
538 address bucket_pc = FlatProfiler::bucket_start_for(p1);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
539 if (bucket_pc != NULL && bucket_pc > p0 && bucket_pc <= p1)
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
540 total_bucket_count += FlatProfiler::bucket_count_for(p0);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
541 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
542 env.set_total_ticks(total_bucket_count);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
543 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
544
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
545 // Print constant table.
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
546 if (nm->consts_size() > 0) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
547 nm->print_nmethod_labels(env.output(), nm->consts_begin());
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
548 int offset = 0;
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
549 for (address p = nm->consts_begin(); p < nm->consts_end(); p += 4, offset += 4) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
550 if ((offset % 8) == 0) {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
551 env.output()->print_cr(" " PTR_FORMAT " (offset: %4d): " PTR32_FORMAT " " PTR64_FORMAT, p, offset, *((int32_t*) p), *((int64_t*) p));
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
552 } else {
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
553 env.output()->print_cr(" " PTR_FORMAT " (offset: %4d): " PTR32_FORMAT, p, offset, *((int32_t*) p));
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
554 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
555 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
556 }
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
557
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
558 env.decode_instructions(p, end);
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
559 }