Mercurial > hg > graal-compiler
annotate src/share/vm/compiler/disassembler.cpp @ 3318:188c9a5d6a6d
7040485: Use transparent huge page on linux by default
Summary: Turn on UseLargePages by default but try only HugeTLBFS method if it is not explicitly specified on the command line.
Reviewed-by: ysr
author | iveresov |
---|---|
date | Fri, 29 Apr 2011 12:39:32 -0700 |
parents | 1d1603768966 |
children | 167b70ff3abc |
rev | line source |
---|---|
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
1 /* |
2426
1d1603768966
7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass
trims
parents:
2192
diff
changeset
|
2 * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. |
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
4 * |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
8 * |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
13 * accompanied this code). |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
14 * |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
18 * |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1155
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1155
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:
1155
diff
changeset
|
21 * questions. |
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
22 * |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
23 */ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
24 |
1972 | 25 #include "precompiled.hpp" |
26 #include "classfile/javaClasses.hpp" | |
27 #include "code/codeCache.hpp" | |
28 #include "compiler/disassembler.hpp" | |
29 #include "gc_interface/collectedHeap.hpp" | |
30 #include "memory/cardTableModRefBS.hpp" | |
31 #include "runtime/fprofiler.hpp" | |
32 #include "runtime/handles.inline.hpp" | |
33 #include "runtime/stubCodeGenerator.hpp" | |
34 #include "runtime/stubRoutines.hpp" | |
35 #ifdef TARGET_ARCH_x86 | |
36 # include "depChecker_x86.hpp" | |
37 #endif | |
38 #ifdef TARGET_ARCH_sparc | |
39 # include "depChecker_sparc.hpp" | |
40 #endif | |
41 #ifdef TARGET_ARCH_zero | |
42 # include "depChecker_zero.hpp" | |
43 #endif | |
2192
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2014
diff
changeset
|
44 #ifdef TARGET_ARCH_arm |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2014
diff
changeset
|
45 # include "depChecker_arm.hpp" |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2014
diff
changeset
|
46 #endif |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2014
diff
changeset
|
47 #ifdef TARGET_ARCH_ppc |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2014
diff
changeset
|
48 # include "depChecker_ppc.hpp" |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2014
diff
changeset
|
49 #endif |
1972 | 50 #ifdef SHARK |
51 #include "shark/sharkEntry.hpp" | |
52 #endif | |
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
53 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
54 void* Disassembler::_library = NULL; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
55 bool Disassembler::_tried_to_load_library = false; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
56 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
57 // This routine is in the shared library: |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
58 Disassembler::decode_func Disassembler::_decode_instructions = NULL; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
59 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
60 static const char hsdis_library_name[] = "hsdis-"HOTSPOT_LIB_ARCH; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
61 static const char decode_instructions_name[] = "decode_instructions"; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
62 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
63 #define COMMENT_COLUMN 40 LP64_ONLY(+8) /*could be an option*/ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
64 #define BYTES_COMMENT ";..." /* funky byte display comment */ |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
65 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
66 bool Disassembler::load_library() { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
67 if (_decode_instructions != NULL) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
68 // Already succeeded. |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
69 return true; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
70 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
71 if (_tried_to_load_library) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
72 // Do not try twice. |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
73 // To force retry in debugger: assign _tried_to_load_library=0 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
74 return false; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
75 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
76 // Try to load it. |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
77 char ebuf[1024]; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
78 char buf[JVM_MAXPATHLEN]; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
79 os::jvm_path(buf, sizeof(buf)); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
80 int jvm_offset = -1; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
81 { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
82 // Match "jvm[^/]*" in jvm_path. |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
83 const char* base = buf; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
84 const char* p = strrchr(buf, '/'); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
85 p = strstr(p ? p : base, "jvm"); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
86 if (p != NULL) jvm_offset = p - base; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
87 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
88 if (jvm_offset >= 0) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
89 // Find the disassembler next to libjvm.so. |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
90 strcpy(&buf[jvm_offset], hsdis_library_name); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
91 strcat(&buf[jvm_offset], os::dll_file_extension()); |
1980
828eafbd85cc
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
1972
diff
changeset
|
92 _library = os::dll_load(buf, ebuf, sizeof ebuf); |
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
93 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
94 if (_library == NULL) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
95 // Try a free-floating lookup. |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
96 strcpy(&buf[0], hsdis_library_name); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
97 strcat(&buf[0], os::dll_file_extension()); |
1980
828eafbd85cc
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
1972
diff
changeset
|
98 _library = os::dll_load(buf, ebuf, sizeof ebuf); |
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
99 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
100 if (_library != NULL) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
101 _decode_instructions = CAST_TO_FN_PTR(Disassembler::decode_func, |
1980
828eafbd85cc
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
1972
diff
changeset
|
102 os::dll_lookup(_library, decode_instructions_name)); |
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
103 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
104 _tried_to_load_library = true; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
105 if (_decode_instructions == NULL) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
106 tty->print_cr("Could not load %s; %s; %s", buf, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
107 ((_library != NULL) |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
108 ? "entry point is missing" |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
109 : (WizardMode || PrintMiscellaneous) |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
110 ? (const char*)ebuf |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
111 : "library not loadable"), |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
112 "PrintAssembly is disabled"); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
113 return false; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
114 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
115 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
116 // Success. |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
117 tty->print_cr("Loaded disassembler from %s", buf); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
118 return true; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
119 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
120 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
121 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
122 class decode_env { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
123 private: |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
124 nmethod* _nm; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
125 CodeBlob* _code; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
126 outputStream* _output; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
127 address _start, _end; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
128 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
129 char _option_buf[512]; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
130 char _print_raw; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
131 bool _print_pc; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
132 bool _print_bytes; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
133 address _cur_insn; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
134 int _total_ticks; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
135 int _bytes_per_line; // arch-specific formatting option |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
136 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
137 static bool match(const char* event, const char* tag) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
138 size_t taglen = strlen(tag); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
139 if (strncmp(event, tag, taglen) != 0) |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
140 return false; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
141 char delim = event[taglen]; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
142 return delim == '\0' || delim == ' ' || delim == '/' || delim == '='; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
143 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
144 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
145 void collect_options(const char* p) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
146 if (p == NULL || p[0] == '\0') return; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
147 size_t opt_so_far = strlen(_option_buf); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
148 if (opt_so_far + 1 + strlen(p) + 1 > sizeof(_option_buf)) return; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
149 char* fillp = &_option_buf[opt_so_far]; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
150 if (opt_so_far > 0) *fillp++ = ','; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
151 strcat(fillp, p); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
152 // replace white space by commas: |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
153 char* q = fillp; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
154 while ((q = strpbrk(q, " \t\n")) != NULL) |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
155 *q++ = ','; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
156 // Note that multiple PrintAssemblyOptions flags accumulate with \n, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
157 // which we want to be changed to a comma... |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
158 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
159 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
160 void print_insn_labels(); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
161 void print_insn_bytes(address pc0, address pc); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
162 void print_address(address value); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
163 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
164 public: |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
165 decode_env(CodeBlob* code, outputStream* output); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
166 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
167 address decode_instructions(address start, address end); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
168 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
169 void start_insn(address pc) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
170 _cur_insn = pc; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
171 output()->bol(); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
172 print_insn_labels(); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
173 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
174 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
175 void end_insn(address pc) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
176 address pc0 = cur_insn(); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
177 outputStream* st = output(); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
178 if (_print_bytes && pc > pc0) |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
179 print_insn_bytes(pc0, pc); |
1155
4e6abf09f540
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
100
diff
changeset
|
180 if (_nm != NULL) { |
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
181 _nm->print_code_comment_on(st, COMMENT_COLUMN, pc0, pc); |
1155
4e6abf09f540
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
100
diff
changeset
|
182 // this calls reloc_string_for which calls oop::print_value_on |
4e6abf09f540
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
100
diff
changeset
|
183 } |
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
184 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
185 // Output pc bucket ticks if we have any |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
186 if (total_ticks() != 0) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
187 address bucket_pc = FlatProfiler::bucket_start_for(pc); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
188 if (bucket_pc != NULL && bucket_pc > pc0 && bucket_pc <= pc) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
189 int bucket_count = FlatProfiler::bucket_count_for(pc0); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
190 if (bucket_count != 0) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
191 st->bol(); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
192 st->print_cr("%3.1f%% [%d]", bucket_count*100.0/total_ticks(), bucket_count); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
193 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
194 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
195 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
196 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
197 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
198 address handle_event(const char* event, address arg); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
199 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
200 outputStream* output() { return _output; } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
201 address cur_insn() { return _cur_insn; } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
202 int total_ticks() { return _total_ticks; } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
203 void set_total_ticks(int n) { _total_ticks = n; } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
204 const char* options() { return _option_buf; } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
205 }; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
206 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
207 decode_env::decode_env(CodeBlob* code, outputStream* output) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
208 memset(this, 0, sizeof(*this)); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
209 _output = output ? output : tty; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
210 _code = code; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
211 if (code != NULL && code->is_nmethod()) |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
212 _nm = (nmethod*) code; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
213 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
214 // by default, output pc but not bytes: |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
215 _print_pc = true; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
216 _print_bytes = false; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
217 _bytes_per_line = Disassembler::pd_instruction_alignment(); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
218 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
219 // parse the global option string: |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
220 collect_options(Disassembler::pd_cpu_opts()); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
221 collect_options(PrintAssemblyOptions); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
222 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
223 if (strstr(options(), "hsdis-")) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
224 if (strstr(options(), "hsdis-print-raw")) |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
225 _print_raw = (strstr(options(), "xml") ? 2 : 1); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
226 if (strstr(options(), "hsdis-print-pc")) |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
227 _print_pc = !_print_pc; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
228 if (strstr(options(), "hsdis-print-bytes")) |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
229 _print_bytes = !_print_bytes; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
230 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
231 if (strstr(options(), "help")) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
232 tty->print_cr("PrintAssemblyOptions help:"); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
233 tty->print_cr(" hsdis-print-raw test plugin by requesting raw output"); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
234 tty->print_cr(" hsdis-print-raw-xml test plugin by requesting raw xml"); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
235 tty->print_cr(" hsdis-print-pc turn off PC printing (on by default)"); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
236 tty->print_cr(" hsdis-print-bytes turn on instruction byte output"); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
237 tty->print_cr("combined options: %s", options()); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
238 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
239 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
240 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
241 address decode_env::handle_event(const char* event, address arg) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
242 if (match(event, "insn")) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
243 start_insn(arg); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
244 } else if (match(event, "/insn")) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
245 end_insn(arg); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
246 } else if (match(event, "addr")) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
247 if (arg != NULL) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
248 print_address(arg); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
249 return arg; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
250 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
251 } else if (match(event, "mach")) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
252 output()->print_cr("[Disassembling for mach='%s']", arg); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
253 } else if (match(event, "format bytes-per-line")) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
254 _bytes_per_line = (int) (intptr_t) arg; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
255 } else { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
256 // ignore unrecognized markup |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
257 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
258 return NULL; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
259 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
260 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
261 // called by the disassembler to print out jump targets and data addresses |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
262 void decode_env::print_address(address adr) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
263 outputStream* st = _output; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
264 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
265 if (adr == NULL) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
266 st->print("NULL"); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
267 return; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
268 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
269 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
270 int small_num = (int)(intptr_t)adr; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
271 if ((intptr_t)adr == (intptr_t)small_num |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
272 && -1 <= small_num && small_num <= 9) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
273 st->print("%d", small_num); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
274 return; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
275 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
276 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
277 if (Universe::is_fully_initialized()) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
278 if (StubRoutines::contains(adr)) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
279 StubCodeDesc* desc = StubCodeDesc::desc_for(adr); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
280 if (desc == NULL) |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
281 desc = StubCodeDesc::desc_for(adr + frame::pc_return_offset); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
282 if (desc != NULL) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
283 st->print("Stub::%s", desc->name()); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
284 if (desc->begin() != adr) |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
285 st->print("%+d 0x%p",adr - desc->begin(), adr); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
286 else if (WizardMode) st->print(" " INTPTR_FORMAT, adr); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
287 return; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
288 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
289 st->print("Stub::<unknown> " INTPTR_FORMAT, adr); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
290 return; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
291 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
292 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
293 BarrierSet* bs = Universe::heap()->barrier_set(); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
294 if (bs->kind() == BarrierSet::CardTableModRef && |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
295 adr == (address)((CardTableModRefBS*)(bs))->byte_map_base) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
296 st->print("word_map_base"); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
297 if (WizardMode) st->print(" " INTPTR_FORMAT, (intptr_t)adr); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
298 return; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
299 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
300 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
301 oop obj; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
302 if (_nm != NULL |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
303 && (obj = _nm->embeddedOop_at(cur_insn())) != NULL |
1155
4e6abf09f540
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
100
diff
changeset
|
304 && (address) obj == adr |
4e6abf09f540
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
100
diff
changeset
|
305 && Universe::heap()->is_in(obj) |
4e6abf09f540
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
100
diff
changeset
|
306 && Universe::heap()->is_in(obj->klass())) { |
4e6abf09f540
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
100
diff
changeset
|
307 julong c = st->count(); |
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
308 obj->print_value_on(st); |
1155
4e6abf09f540
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
100
diff
changeset
|
309 if (st->count() == c) { |
4e6abf09f540
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
100
diff
changeset
|
310 // No output. (Can happen in product builds.) |
4e6abf09f540
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
100
diff
changeset
|
311 st->print("(a %s)", Klass::cast(obj->klass())->external_name()); |
4e6abf09f540
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
100
diff
changeset
|
312 } |
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
313 return; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
314 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
315 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
316 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
317 // Fall through to a simple numeral. |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
318 st->print(INTPTR_FORMAT, (intptr_t)adr); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
319 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
320 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
321 void decode_env::print_insn_labels() { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
322 address p = cur_insn(); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
323 outputStream* st = output(); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
324 CodeBlob* cb = _code; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
325 if (cb != NULL) { |
1155
4e6abf09f540
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
100
diff
changeset
|
326 cb->print_block_comment(st, p); |
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
327 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
328 if (_print_pc) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
329 st->print(" " INTPTR_FORMAT ": ", (intptr_t) p); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
330 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
331 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
332 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
333 void decode_env::print_insn_bytes(address pc, address pc_limit) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
334 outputStream* st = output(); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
335 size_t incr = 1; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
336 size_t perline = _bytes_per_line; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
337 if ((size_t) Disassembler::pd_instruction_alignment() >= sizeof(int) |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
338 && !((uintptr_t)pc % sizeof(int)) |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
339 && !((uintptr_t)pc_limit % sizeof(int))) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
340 incr = sizeof(int); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
341 if (perline % incr) perline += incr - (perline % incr); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
342 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
343 while (pc < pc_limit) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
344 // tab to the desired column: |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
345 st->move_to(COMMENT_COLUMN); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
346 address pc0 = pc; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
347 address pc1 = pc + perline; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
348 if (pc1 > pc_limit) pc1 = pc_limit; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
349 for (; pc < pc1; pc += incr) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
350 if (pc == pc0) |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
351 st->print(BYTES_COMMENT); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
352 else if ((uint)(pc - pc0) % sizeof(int) == 0) |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
353 st->print(" "); // put out a space on word boundaries |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
354 if (incr == sizeof(int)) |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
355 st->print("%08lx", *(int*)pc); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
356 else st->print("%02x", (*pc)&0xFF); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
357 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
358 st->cr(); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
359 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
360 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
361 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
362 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
363 static void* event_to_env(void* env_pv, const char* event, void* arg) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
364 decode_env* env = (decode_env*) env_pv; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
365 return env->handle_event(event, (address) arg); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
366 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
367 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
368 static int printf_to_env(void* env_pv, const char* format, ...) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
369 decode_env* env = (decode_env*) env_pv; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
370 outputStream* st = env->output(); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
371 size_t flen = strlen(format); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
372 const char* raw = NULL; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
373 if (flen == 0) return 0; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
374 if (flen == 1 && format[0] == '\n') { st->bol(); return 1; } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
375 if (flen < 2 || |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
376 strchr(format, '%') == NULL) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
377 raw = format; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
378 } else if (format[0] == '%' && format[1] == '%' && |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
379 strchr(format+2, '%') == NULL) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
380 // happens a lot on machines with names like %foo |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
381 flen--; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
382 raw = format+1; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
383 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
384 if (raw != NULL) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
385 st->print_raw(raw, (int) flen); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
386 return (int) flen; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
387 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
388 va_list ap; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
389 va_start(ap, format); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
390 julong cnt0 = st->count(); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
391 st->vprint(format, ap); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
392 julong cnt1 = st->count(); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
393 va_end(ap); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
394 return (int)(cnt1 - cnt0); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
395 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
396 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
397 address decode_env::decode_instructions(address start, address end) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
398 _start = start; _end = end; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
399 |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
400 assert(((((intptr_t)start | (intptr_t)end) % Disassembler::pd_instruction_alignment()) == 0), "misaligned insn addr"); |
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
401 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
402 const int show_bytes = false; // for disassembler debugging |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
403 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
404 //_version = Disassembler::pd_cpu_version(); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
405 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
406 if (!Disassembler::can_decode()) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
407 return NULL; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
408 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
409 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
410 // decode a series of instructions and return the end of the last instruction |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
411 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
412 if (_print_raw) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
413 // Print whatever the library wants to print, w/o fancy callbacks. |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
414 // This is mainly for debugging the library itself. |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
415 FILE* out = stdout; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
416 FILE* xmlout = (_print_raw > 1 ? out : NULL); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
417 return (address) |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
418 (*Disassembler::_decode_instructions)(start, end, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
419 NULL, (void*) xmlout, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
420 NULL, (void*) out, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
421 options()); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
422 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
423 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
424 return (address) |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
425 (*Disassembler::_decode_instructions)(start, end, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
426 &event_to_env, (void*) this, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
427 &printf_to_env, (void*) this, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
428 options()); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
429 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
430 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
431 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
432 void Disassembler::decode(CodeBlob* cb, outputStream* st) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
433 if (!load_library()) return; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
434 decode_env env(cb, st); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
435 env.output()->print_cr("Decoding CodeBlob " INTPTR_FORMAT, cb); |
1748 | 436 env.decode_instructions(cb->code_begin(), cb->code_end()); |
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
437 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
438 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
439 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
440 void Disassembler::decode(address start, address end, outputStream* st) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
441 if (!load_library()) return; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
442 decode_env env(CodeCache::find_blob_unsafe(start), st); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
443 env.decode_instructions(start, end); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
444 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
445 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
446 void Disassembler::decode(nmethod* nm, outputStream* st) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
447 if (!load_library()) return; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
448 decode_env env(nm, st); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
449 env.output()->print_cr("Decoding compiled method " INTPTR_FORMAT ":", nm); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
450 env.output()->print_cr("Code:"); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
451 |
1692 | 452 #ifdef SHARK |
1748 | 453 SharkEntry* entry = (SharkEntry *) nm->code_begin(); |
454 unsigned char* p = entry->code_start(); | |
1692 | 455 unsigned char* end = entry->code_limit(); |
456 #else | |
1748 | 457 unsigned char* p = nm->code_begin(); |
458 unsigned char* end = nm->code_end(); | |
1692 | 459 #endif // SHARK |
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
460 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
461 // If there has been profiling, print the buckets. |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
462 if (FlatProfiler::bucket_start_for(p) != NULL) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
463 unsigned char* p1 = p; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
464 int total_bucket_count = 0; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
465 while (p1 < end) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
466 unsigned char* p0 = p1; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
467 p1 += pd_instruction_alignment(); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
468 address bucket_pc = FlatProfiler::bucket_start_for(p1); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
469 if (bucket_pc != NULL && bucket_pc > p0 && bucket_pc <= p1) |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
470 total_bucket_count += FlatProfiler::bucket_count_for(p0); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
471 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
472 env.set_total_ticks(total_bucket_count); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
473 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
474 |
2008 | 475 // Print constant table. |
476 if (nm->consts_size() > 0) { | |
477 nm->print_nmethod_labels(env.output(), nm->consts_begin()); | |
478 int offset = 0; | |
479 for (address p = nm->consts_begin(); p < nm->consts_end(); p += 4, offset += 4) { | |
480 if ((offset % 8) == 0) { | |
481 env.output()->print_cr(" " INTPTR_FORMAT " (offset: %4d): " PTR32_FORMAT " " PTR64_FORMAT, (intptr_t) p, offset, *((int32_t*) p), *((int64_t*) p)); | |
482 } else { | |
483 env.output()->print_cr(" " INTPTR_FORMAT " (offset: %4d): " PTR32_FORMAT, (intptr_t) p, offset, *((int32_t*) p)); | |
484 } | |
485 } | |
486 } | |
487 | |
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
488 env.decode_instructions(p, end); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
489 } |