annotate src/share/vm/ci/ciReplay.cpp @ 6972:bd7a7ce2e264

6830717: replay of compilations would help with debugging Summary: When java process crashed in compiler thread, repeat the compilation process will help finding root cause. This is done with using SA dump application class data and replay data from core dump, then use debug version of jvm to recompile the problematic java method. Reviewed-by: kvn, twisti, sspitsyn Contributed-by: yumin.qi@oracle.com
author minqi
date Mon, 12 Nov 2012 14:03:53 -0800
parents
children 90273fc0a981
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1 /* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
3 *
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
4 * This code is free software; you can redistribute it and/or modify it
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
5 * under the terms of the GNU General Public License version 2 only, as
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
6 * published by the Free Software Foundation.
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
7 *
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
8 * This code is distributed in the hope that it will be useful, but WITHOUT
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
11 * version 2 for more details (a copy is included in the LICENSE file that
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
12 * accompanied this code).
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
13 *
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License version
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
15 * 2 along with this work; if not, write to the Free Software Foundation,
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
17 *
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
19 * or visit www.oracle.com if you need additional information or have any
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
20 * questions.
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
21 *
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
22 */
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
23
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
24 #include "precompiled.hpp"
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
25 #include "ci/ciMethodData.hpp"
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
26 #include "ci/ciReplay.hpp"
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
27 #include "ci/ciUtilities.hpp"
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
28 #include "compiler/compileBroker.hpp"
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
29 #include "memory/allocation.inline.hpp"
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
30 #include "memory/oopFactory.hpp"
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
31 #include "memory/resourceArea.hpp"
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
32 #include "utilities/copy.hpp"
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
33
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
34 #ifdef ASSERT
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
35
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
36 // ciReplay
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
37
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
38 typedef struct _ciMethodDataRecord {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
39 const char* klass;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
40 const char* method;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
41 const char* signature;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
42 int state;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
43 int current_mileage;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
44 intptr_t* data;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
45 int data_length;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
46 char* orig_data;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
47 int orig_data_length;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
48 int oops_length;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
49 jobject* oops_handles;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
50 int* oops_offsets;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
51 } ciMethodDataRecord;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
52
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
53 typedef struct _ciMethodRecord {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
54 const char* klass;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
55 const char* method;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
56 const char* signature;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
57 int instructions_size;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
58 int interpreter_invocation_count;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
59 int interpreter_throwout_count;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
60 int invocation_counter;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
61 int backedge_counter;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
62 } ciMethodRecord;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
63
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
64 class CompileReplay;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
65 static CompileReplay* replay_state;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
66
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
67 class CompileReplay : public StackObj {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
68 private:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
69 FILE* stream;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
70 Thread* thread;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
71 Handle protection_domain;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
72 Handle loader;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
73
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
74 GrowableArray<ciMethodRecord*> ci_method_records;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
75 GrowableArray<ciMethodDataRecord*> ci_method_data_records;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
76
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
77 const char* _error_message;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
78
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
79 char* bufptr;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
80 char* buffer;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
81 int buffer_length;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
82 int buffer_end;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
83 int line_no;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
84
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
85 public:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
86 CompileReplay(const char* filename, TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
87 thread = THREAD;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
88 loader = Handle(thread, SystemDictionary::java_system_loader());
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
89 stream = fopen(filename, "rt");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
90 if (stream == NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
91 fprintf(stderr, "Can't open replay file %s\n", filename);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
92 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
93 buffer_length = 32;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
94 buffer = NEW_RESOURCE_ARRAY(char, buffer_length);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
95 _error_message = NULL;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
96
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
97 test();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
98 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
99
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
100 ~CompileReplay() {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
101 if (stream != NULL) fclose(stream);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
102 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
103
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
104 void test() {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
105 strcpy(buffer, "1 2 foo 4 bar 0x9 \"this is it\"");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
106 bufptr = buffer;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
107 assert(parse_int("test") == 1, "what");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
108 assert(parse_int("test") == 2, "what");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
109 assert(strcmp(parse_string(), "foo") == 0, "what");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
110 assert(parse_int("test") == 4, "what");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
111 assert(strcmp(parse_string(), "bar") == 0, "what");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
112 assert(parse_intptr_t("test") == 9, "what");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
113 assert(strcmp(parse_quoted_string(), "this is it") == 0, "what");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
114 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
115
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
116 bool had_error() {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
117 return _error_message != NULL || thread->has_pending_exception();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
118 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
119
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
120 bool can_replay() {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
121 return !(stream == NULL || had_error());
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
122 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
123
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
124 void report_error(const char* msg) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
125 _error_message = msg;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
126 // Restore the buffer contents for error reporting
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
127 for (int i = 0; i < buffer_end; i++) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
128 if (buffer[i] == '\0') buffer[i] = ' ';
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
129 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
130 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
131
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
132 int parse_int(const char* label) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
133 if (had_error()) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
134 return 0;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
135 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
136
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
137 int v = 0;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
138 int read;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
139 if (sscanf(bufptr, "%i%n", &v, &read) != 1) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
140 report_error(label);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
141 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
142 bufptr += read;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
143 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
144 return v;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
145 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
146
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
147 intptr_t parse_intptr_t(const char* label) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
148 if (had_error()) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
149 return 0;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
150 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
151
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
152 intptr_t v = 0;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
153 int read;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
154 if (sscanf(bufptr, INTPTR_FORMAT "%n", &v, &read) != 1) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
155 report_error(label);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
156 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
157 bufptr += read;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
158 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
159 return v;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
160 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
161
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
162 void skip_ws() {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
163 // Skip any leading whitespace
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
164 while (*bufptr == ' ' || *bufptr == '\t') {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
165 bufptr++;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
166 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
167 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
168
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
169
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
170 char* scan_and_terminate(char delim) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
171 char* str = bufptr;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
172 while (*bufptr != delim && *bufptr != '\0') {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
173 bufptr++;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
174 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
175 if (*bufptr != '\0') {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
176 *bufptr++ = '\0';
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
177 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
178 if (bufptr == str) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
179 // nothing here
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
180 return NULL;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
181 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
182 return str;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
183 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
184
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
185 char* parse_string() {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
186 if (had_error()) return NULL;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
187
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
188 skip_ws();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
189 return scan_and_terminate(' ');
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
190 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
191
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
192 char* parse_quoted_string() {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
193 if (had_error()) return NULL;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
194
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
195 skip_ws();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
196
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
197 if (*bufptr == '"') {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
198 bufptr++;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
199 return scan_and_terminate('"');
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
200 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
201 return scan_and_terminate(' ');
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
202 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
203 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
204
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
205 const char* parse_escaped_string() {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
206 char* result = parse_quoted_string();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
207 if (result != NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
208 unescape_string(result);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
209 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
210 return result;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
211 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
212
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
213 // Look for the tag 'tag' followed by an
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
214 bool parse_tag_and_count(const char* tag, int& length) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
215 const char* t = parse_string();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
216 if (t == NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
217 return false;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
218 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
219
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
220 if (strcmp(tag, t) != 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
221 report_error(tag);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
222 return false;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
223 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
224 length = parse_int("parse_tag_and_count");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
225 return !had_error();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
226 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
227
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
228 // Parse a sequence of raw data encoded as bytes and return the
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
229 // resulting data.
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
230 char* parse_data(const char* tag, int& length) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
231 if (!parse_tag_and_count(tag, length)) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
232 return NULL;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
233 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
234
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
235 char * result = NEW_RESOURCE_ARRAY(char, length);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
236 for (int i = 0; i < length; i++) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
237 int val = parse_int("data");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
238 result[i] = val;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
239 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
240 return result;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
241 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
242
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
243 // Parse a standard chunk of data emitted as:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
244 // 'tag' <length> # # ...
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
245 // Where each # is an intptr_t item
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
246 intptr_t* parse_intptr_data(const char* tag, int& length) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
247 if (!parse_tag_and_count(tag, length)) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
248 return NULL;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
249 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
250
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
251 intptr_t* result = NEW_RESOURCE_ARRAY(intptr_t, length);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
252 for (int i = 0; i < length; i++) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
253 skip_ws();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
254 intptr_t val = parse_intptr_t("data");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
255 result[i] = val;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
256 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
257 return result;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
258 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
259
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
260 // Parse a possibly quoted version of a symbol into a symbolOop
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
261 Symbol* parse_symbol(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
262 const char* str = parse_escaped_string();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
263 if (str != NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
264 Symbol* sym = SymbolTable::lookup(str, (int)strlen(str), CHECK_NULL);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
265 return sym;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
266 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
267 return NULL;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
268 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
269
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
270 // Parse a valid klass name and look it up
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
271 Klass* parse_klass(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
272 const char* str = parse_escaped_string();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
273 Symbol* klass_name = SymbolTable::lookup(str, (int)strlen(str), CHECK_NULL);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
274 if (klass_name != NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
275 Klass* k = SystemDictionary::resolve_or_fail(klass_name, loader, protection_domain, true, THREAD);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
276 if (HAS_PENDING_EXCEPTION) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
277 oop throwable = PENDING_EXCEPTION;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
278 java_lang_Throwable::print(throwable, tty);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
279 tty->cr();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
280 report_error(str);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
281 return NULL;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
282 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
283 return k;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
284 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
285 return NULL;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
286 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
287
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
288 // Lookup a klass
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
289 Klass* resolve_klass(const char* klass, TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
290 Symbol* klass_name = SymbolTable::lookup(klass, (int)strlen(klass), CHECK_NULL);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
291 return SystemDictionary::resolve_or_fail(klass_name, loader, protection_domain, true, CHECK_NULL);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
292 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
293
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
294 // Parse the standard tuple of <klass> <name> <signature>
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
295 Method* parse_method(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
296 InstanceKlass* k = (InstanceKlass*)parse_klass(CHECK_NULL);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
297 Symbol* method_name = parse_symbol(CHECK_NULL);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
298 Symbol* method_signature = parse_symbol(CHECK_NULL);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
299 Method* m = k->find_method(method_name, method_signature);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
300 if (m == NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
301 report_error("can't find method");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
302 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
303 return m;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
304 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
305
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
306 // Process each line of the replay file executing each command until
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
307 // the file ends.
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
308 void process(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
309 line_no = 1;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
310 int pos = 0;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
311 int c = getc(stream);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
312 while(c != EOF) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
313 if (pos + 1 >= buffer_length) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
314 int newl = buffer_length * 2;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
315 char* newb = NEW_RESOURCE_ARRAY(char, newl);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
316 memcpy(newb, buffer, pos);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
317 buffer = newb;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
318 buffer_length = newl;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
319 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
320 if (c == '\n') {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
321 // null terminate it, reset the pointer and process the line
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
322 buffer[pos] = '\0';
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
323 buffer_end = pos++;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
324 bufptr = buffer;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
325 process_command(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
326 if (had_error()) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
327 tty->print_cr("Error while parsing line %d: %s\n", line_no, _error_message);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
328 tty->print_cr("%s", buffer);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
329 assert(false, "error");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
330 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
331 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
332 pos = 0;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
333 buffer_end = 0;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
334 line_no++;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
335 } else if (c == '\r') {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
336 // skip LF
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
337 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
338 buffer[pos++] = c;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
339 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
340 c = getc(stream);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
341 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
342 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
343
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
344 void process_command(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
345 char* cmd = parse_string();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
346 if (cmd == NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
347 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
348 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
349 if (strcmp("#", cmd) == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
350 // ignore
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
351 } else if (strcmp("compile", cmd) == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
352 process_compile(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
353 } else if (strcmp("ciMethod", cmd) == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
354 process_ciMethod(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
355 } else if (strcmp("ciMethodData", cmd) == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
356 process_ciMethodData(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
357 } else if (strcmp("staticfield", cmd) == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
358 process_staticfield(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
359 } else if (strcmp("ciInstanceKlass", cmd) == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
360 process_ciInstanceKlass(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
361 } else if (strcmp("instanceKlass", cmd) == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
362 process_instanceKlass(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
363 #if INCLUDE_JVMTI
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
364 } else if (strcmp("JvmtiExport", cmd) == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
365 process_JvmtiExport(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
366 #endif // INCLUDE_JVMTI
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
367 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
368 report_error("unknown command");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
369 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
370 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
371
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
372 // compile <klass> <name> <signature> <entry_bci>
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
373 void process_compile(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
374 // methodHandle method;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
375 Method* method = parse_method(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
376 int entry_bci = parse_int("entry_bci");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
377 Klass* k = method->method_holder();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
378 ((InstanceKlass*)k)->initialize(THREAD);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
379 if (HAS_PENDING_EXCEPTION) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
380 oop throwable = PENDING_EXCEPTION;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
381 java_lang_Throwable::print(throwable, tty);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
382 tty->cr();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
383 if (ReplayIgnoreInitErrors) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
384 CLEAR_PENDING_EXCEPTION;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
385 ((InstanceKlass*)k)->set_init_state(InstanceKlass::fully_initialized);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
386 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
387 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
388 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
389 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
390 // Make sure the existence of a prior compile doesn't stop this one
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
391 nmethod* nm = (entry_bci != InvocationEntryBci) ? method->lookup_osr_nmethod_for(entry_bci, CompLevel_full_optimization, true) : method->code();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
392 if (nm != NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
393 nm->make_not_entrant();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
394 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
395 replay_state = this;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
396 CompileBroker::compile_method(method, entry_bci, CompLevel_full_optimization,
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
397 methodHandle(), 0, "replay", THREAD);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
398 replay_state = NULL;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
399 reset();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
400 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
401
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
402 // ciMethod <klass> <name> <signature> <invocation_counter> <backedge_counter> <interpreter_invocation_count> <interpreter_throwout_count> <instructions_size>
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
403 //
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
404 //
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
405 void process_ciMethod(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
406 Method* method = parse_method(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
407 ciMethodRecord* rec = new_ciMethod(method);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
408 rec->invocation_counter = parse_int("invocation_counter");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
409 rec->backedge_counter = parse_int("backedge_counter");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
410 rec->interpreter_invocation_count = parse_int("interpreter_invocation_count");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
411 rec->interpreter_throwout_count = parse_int("interpreter_throwout_count");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
412 rec->instructions_size = parse_int("instructions_size");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
413 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
414
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
415 // ciMethodData <klass> <name> <signature> <state> <current mileage> orig <length> # # ... data <length> # # ... oops <length>
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
416 void process_ciMethodData(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
417 Method* method = parse_method(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
418 /* jsut copied from Method, to build interpret data*/
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
419 if (InstanceRefKlass::owns_pending_list_lock((JavaThread*)THREAD)) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
420 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
421 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
422 // methodOopDesc::build_interpreter_method_data(method, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
423 {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
424 // Grab a lock here to prevent multiple
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
425 // MethodData*s from being created.
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
426 MutexLocker ml(MethodData_lock, THREAD);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
427 if (method->method_data() == NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
428 ClassLoaderData* loader_data = method->method_holder()->class_loader_data();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
429 MethodData* method_data = MethodData::allocate(loader_data, method, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
430 method->set_method_data(method_data);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
431 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
432 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
433
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
434 // collect and record all the needed information for later
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
435 ciMethodDataRecord* rec = new_ciMethodData(method);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
436 rec->state = parse_int("state");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
437 rec->current_mileage = parse_int("current_mileage");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
438
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
439 rec->orig_data = parse_data("orig", rec->orig_data_length);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
440 if (rec->orig_data == NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
441 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
442 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
443 rec->data = parse_intptr_data("data", rec->data_length);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
444 if (rec->data == NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
445 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
446 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
447 if (!parse_tag_and_count("oops", rec->oops_length)) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
448 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
449 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
450 rec->oops_handles = NEW_RESOURCE_ARRAY(jobject, rec->oops_length);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
451 rec->oops_offsets = NEW_RESOURCE_ARRAY(int, rec->oops_length);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
452 for (int i = 0; i < rec->oops_length; i++) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
453 int offset = parse_int("offset");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
454 if (had_error()) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
455 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
456 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
457 Klass* k = parse_klass(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
458 rec->oops_offsets[i] = offset;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
459 rec->oops_handles[i] = (jobject)(new KlassHandle(THREAD, k));
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
460 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
461 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
462
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
463 // instanceKlass <name>
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
464 //
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
465 // Loads and initializes the klass 'name'. This can be used to
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
466 // create particular class loading environments
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
467 void process_instanceKlass(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
468 // just load the referenced class
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
469 Klass* k = parse_klass(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
470 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
471
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
472 // ciInstanceKlass <name> <is_linked> <is_initialized> <length> tag # # # ...
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
473 //
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
474 // Load the klass 'name' and link or initialize it. Verify that the
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
475 // constant pool is the same length as 'length' and make sure the
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
476 // constant pool tags are in the same state.
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
477 void process_ciInstanceKlass(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
478 InstanceKlass* k = (InstanceKlass *)parse_klass(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
479 int is_linked = parse_int("is_linked");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
480 int is_initialized = parse_int("is_initialized");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
481 int length = parse_int("length");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
482 if (is_initialized) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
483 k->initialize(THREAD);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
484 if (HAS_PENDING_EXCEPTION) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
485 oop throwable = PENDING_EXCEPTION;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
486 java_lang_Throwable::print(throwable, tty);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
487 tty->cr();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
488 if (ReplayIgnoreInitErrors) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
489 CLEAR_PENDING_EXCEPTION;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
490 k->set_init_state(InstanceKlass::fully_initialized);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
491 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
492 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
493 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
494 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
495 } else if (is_linked) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
496 k->link_class(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
497 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
498 ConstantPool* cp = k->constants();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
499 if (length != cp->length()) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
500 report_error("constant pool length mismatch: wrong class files?");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
501 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
502 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
503
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
504 int parsed_two_word = 0;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
505 for (int i = 1; i < length; i++) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
506 int tag = parse_int("tag");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
507 if (had_error()) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
508 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
509 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
510 switch (cp->tag_at(i).value()) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
511 case JVM_CONSTANT_UnresolvedClass: {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
512 if (tag == JVM_CONSTANT_Class) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
513 tty->print_cr("Resolving klass %s at %d", cp->unresolved_klass_at(i)->as_utf8(), i);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
514 Klass* k = cp->klass_at(i, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
515 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
516 break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
517 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
518 case JVM_CONSTANT_Long:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
519 case JVM_CONSTANT_Double:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
520 parsed_two_word = i + 1;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
521
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
522 case JVM_CONSTANT_ClassIndex:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
523 case JVM_CONSTANT_StringIndex:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
524 case JVM_CONSTANT_String:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
525 case JVM_CONSTANT_UnresolvedClassInError:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
526 case JVM_CONSTANT_Fieldref:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
527 case JVM_CONSTANT_Methodref:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
528 case JVM_CONSTANT_InterfaceMethodref:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
529 case JVM_CONSTANT_NameAndType:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
530 case JVM_CONSTANT_Utf8:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
531 case JVM_CONSTANT_Integer:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
532 case JVM_CONSTANT_Float:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
533 if (tag != cp->tag_at(i).value()) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
534 report_error("tag mismatch: wrong class files?");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
535 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
536 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
537 break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
538
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
539 case JVM_CONSTANT_Class:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
540 if (tag == JVM_CONSTANT_Class) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
541 } else if (tag == JVM_CONSTANT_UnresolvedClass) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
542 tty->print_cr("Warning: entry was unresolved in the replay data");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
543 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
544 report_error("Unexpected tag");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
545 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
546 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
547 break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
548
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
549 case 0:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
550 if (parsed_two_word == i) continue;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
551
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
552 default:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
553 ShouldNotReachHere();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
554 break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
555 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
556
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
557 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
558 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
559
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
560 // Initialize a class and fill in the value for a static field.
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
561 // This is useful when the compile was dependent on the value of
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
562 // static fields but it's impossible to properly rerun the static
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
563 // initiailizer.
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
564 void process_staticfield(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
565 InstanceKlass* k = (InstanceKlass *)parse_klass(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
566
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
567 if (ReplaySuppressInitializers == 0 ||
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
568 ReplaySuppressInitializers == 2 && k->class_loader() == NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
569 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
570 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
571
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
572 assert(k->is_initialized(), "must be");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
573
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
574 const char* field_name = parse_escaped_string();;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
575 const char* field_signature = parse_string();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
576 fieldDescriptor fd;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
577 Symbol* name = SymbolTable::lookup(field_name, (int)strlen(field_name), CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
578 Symbol* sig = SymbolTable::lookup(field_signature, (int)strlen(field_signature), CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
579 if (!k->find_local_field(name, sig, &fd) ||
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
580 !fd.is_static() ||
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
581 fd.has_initial_value()) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
582 report_error(field_name);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
583 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
584 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
585
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
586 oop java_mirror = k->java_mirror();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
587 if (field_signature[0] == '[') {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
588 int length = parse_int("array length");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
589 oop value = NULL;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
590
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
591 if (field_signature[1] == '[') {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
592 // multi dimensional array
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
593 ArrayKlass* kelem = (ArrayKlass *)parse_klass(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
594 int rank = 0;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
595 while (field_signature[rank] == '[') {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
596 rank++;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
597 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
598 int* dims = NEW_RESOURCE_ARRAY(int, rank);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
599 dims[0] = length;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
600 for (int i = 1; i < rank; i++) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
601 dims[i] = 1; // These aren't relevant to the compiler
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
602 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
603 value = kelem->multi_allocate(rank, dims, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
604 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
605 if (strcmp(field_signature, "[B") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
606 value = oopFactory::new_byteArray(length, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
607 } else if (strcmp(field_signature, "[Z") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
608 value = oopFactory::new_boolArray(length, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
609 } else if (strcmp(field_signature, "[C") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
610 value = oopFactory::new_charArray(length, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
611 } else if (strcmp(field_signature, "[S") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
612 value = oopFactory::new_shortArray(length, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
613 } else if (strcmp(field_signature, "[F") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
614 value = oopFactory::new_singleArray(length, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
615 } else if (strcmp(field_signature, "[D") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
616 value = oopFactory::new_doubleArray(length, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
617 } else if (strcmp(field_signature, "[I") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
618 value = oopFactory::new_intArray(length, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
619 } else if (strcmp(field_signature, "[J") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
620 value = oopFactory::new_longArray(length, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
621 } else if (field_signature[0] == '[' && field_signature[1] == 'L') {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
622 KlassHandle kelem = resolve_klass(field_signature + 1, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
623 value = oopFactory::new_objArray(kelem(), length, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
624 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
625 report_error("unhandled array staticfield");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
626 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
627 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
628 java_mirror->obj_field_put(fd.offset(), value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
629 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
630 const char* string_value = parse_escaped_string();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
631 if (strcmp(field_signature, "I") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
632 int value = atoi(string_value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
633 java_mirror->int_field_put(fd.offset(), value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
634 } else if (strcmp(field_signature, "B") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
635 int value = atoi(string_value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
636 java_mirror->byte_field_put(fd.offset(), value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
637 } else if (strcmp(field_signature, "C") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
638 int value = atoi(string_value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
639 java_mirror->char_field_put(fd.offset(), value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
640 } else if (strcmp(field_signature, "S") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
641 int value = atoi(string_value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
642 java_mirror->short_field_put(fd.offset(), value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
643 } else if (strcmp(field_signature, "Z") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
644 int value = atol(string_value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
645 java_mirror->bool_field_put(fd.offset(), value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
646 } else if (strcmp(field_signature, "J") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
647 jlong value;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
648 if (sscanf(string_value, INT64_FORMAT, &value) != 1) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
649 fprintf(stderr, "Error parsing long: %s\n", string_value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
650 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
651 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
652 java_mirror->long_field_put(fd.offset(), value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
653 } else if (strcmp(field_signature, "F") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
654 float value = atof(string_value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
655 java_mirror->float_field_put(fd.offset(), value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
656 } else if (strcmp(field_signature, "D") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
657 double value = atof(string_value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
658 java_mirror->double_field_put(fd.offset(), value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
659 } else if (strcmp(field_signature, "Ljava/lang/String;") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
660 Handle value = java_lang_String::create_from_str(string_value, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
661 java_mirror->obj_field_put(fd.offset(), value());
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
662 } else if (field_signature[0] == 'L') {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
663 Symbol* klass_name = SymbolTable::lookup(field_signature, (int)strlen(field_signature), CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
664 KlassHandle kelem = resolve_klass(field_signature, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
665 oop value = ((InstanceKlass*)kelem())->allocate_instance(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
666 java_mirror->obj_field_put(fd.offset(), value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
667 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
668 report_error("unhandled staticfield");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
669 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
670 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
671 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
672
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
673 #if INCLUDE_JVMTI
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
674 void process_JvmtiExport(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
675 const char* field = parse_string();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
676 bool value = parse_int("JvmtiExport flag") != 0;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
677 if (strcmp(field, "can_access_local_variables") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
678 JvmtiExport::set_can_access_local_variables(value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
679 } else if (strcmp(field, "can_hotswap_or_post_breakpoint") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
680 JvmtiExport::set_can_hotswap_or_post_breakpoint(value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
681 } else if (strcmp(field, "can_post_on_exceptions") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
682 JvmtiExport::set_can_post_on_exceptions(value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
683 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
684 report_error("Unrecognized JvmtiExport directive");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
685 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
686 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
687 #endif // INCLUDE_JVMTI
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
688
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
689 // Create and initialize a record for a ciMethod
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
690 ciMethodRecord* new_ciMethod(Method* method) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
691 ciMethodRecord* rec = NEW_RESOURCE_OBJ(ciMethodRecord);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
692 rec->klass = method->method_holder()->name()->as_utf8();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
693 rec->method = method->name()->as_utf8();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
694 rec->signature = method->signature()->as_utf8();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
695 ci_method_records.append(rec);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
696 return rec;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
697 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
698
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
699 // Lookup data for a ciMethod
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
700 ciMethodRecord* find_ciMethodRecord(Method* method) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
701 const char* klass_name = method->method_holder()->name()->as_utf8();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
702 const char* method_name = method->name()->as_utf8();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
703 const char* signature = method->signature()->as_utf8();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
704 for (int i = 0; i < ci_method_records.length(); i++) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
705 ciMethodRecord* rec = ci_method_records.at(i);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
706 if (strcmp(rec->klass, klass_name) == 0 &&
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
707 strcmp(rec->method, method_name) == 0 &&
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
708 strcmp(rec->signature, signature) == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
709 return rec;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
710 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
711 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
712 return NULL;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
713 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
714
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
715 // Create and initialize a record for a ciMethodData
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
716 ciMethodDataRecord* new_ciMethodData(Method* method) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
717 ciMethodDataRecord* rec = NEW_RESOURCE_OBJ(ciMethodDataRecord);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
718 rec->klass = method->method_holder()->name()->as_utf8();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
719 rec->method = method->name()->as_utf8();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
720 rec->signature = method->signature()->as_utf8();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
721 ci_method_data_records.append(rec);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
722 return rec;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
723 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
724
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
725 // Lookup data for a ciMethodData
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
726 ciMethodDataRecord* find_ciMethodDataRecord(Method* method) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
727 const char* klass_name = method->method_holder()->name()->as_utf8();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
728 const char* method_name = method->name()->as_utf8();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
729 const char* signature = method->signature()->as_utf8();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
730 for (int i = 0; i < ci_method_data_records.length(); i++) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
731 ciMethodDataRecord* rec = ci_method_data_records.at(i);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
732 if (strcmp(rec->klass, klass_name) == 0 &&
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
733 strcmp(rec->method, method_name) == 0 &&
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
734 strcmp(rec->signature, signature) == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
735 return rec;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
736 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
737 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
738 return NULL;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
739 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
740
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
741 const char* error_message() {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
742 return _error_message;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
743 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
744
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
745 void reset() {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
746 _error_message = NULL;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
747 ci_method_records.clear();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
748 ci_method_data_records.clear();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
749 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
750
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
751 // Take an ascii string contain \u#### escapes and convert it to utf8
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
752 // in place.
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
753 static void unescape_string(char* value) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
754 char* from = value;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
755 char* to = value;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
756 while (*from != '\0') {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
757 if (*from != '\\') {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
758 *from++ = *to++;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
759 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
760 switch (from[1]) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
761 case 'u': {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
762 from += 2;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
763 jchar value=0;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
764 for (int i=0; i<4; i++) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
765 char c = *from++;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
766 switch (c) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
767 case '0': case '1': case '2': case '3': case '4':
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
768 case '5': case '6': case '7': case '8': case '9':
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
769 value = (value << 4) + c - '0';
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
770 break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
771 case 'a': case 'b': case 'c':
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
772 case 'd': case 'e': case 'f':
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
773 value = (value << 4) + 10 + c - 'a';
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
774 break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
775 case 'A': case 'B': case 'C':
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
776 case 'D': case 'E': case 'F':
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
777 value = (value << 4) + 10 + c - 'A';
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
778 break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
779 default:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
780 ShouldNotReachHere();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
781 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
782 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
783 UNICODE::convert_to_utf8(&value, 1, to);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
784 to++;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
785 break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
786 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
787 case 't': *to++ = '\t'; from += 2; break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
788 case 'n': *to++ = '\n'; from += 2; break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
789 case 'r': *to++ = '\r'; from += 2; break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
790 case 'f': *to++ = '\f'; from += 2; break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
791 default:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
792 ShouldNotReachHere();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
793 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
794 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
795 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
796 *from = *to;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
797 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
798 };
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
799
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
800 void ciReplay::replay(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
801 int exit_code = replay_impl(THREAD);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
802
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
803 Threads::destroy_vm();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
804
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
805 vm_exit(exit_code);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
806 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
807
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
808 int ciReplay::replay_impl(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
809 HandleMark hm;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
810 ResourceMark rm;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
811 // Make sure we don't run with background compilation
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
812 BackgroundCompilation = false;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
813
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
814 if (ReplaySuppressInitializers > 2) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
815 // ReplaySuppressInitializers > 2 means that we want to allow
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
816 // normal VM bootstrap but once we get into the replay itself
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
817 // don't allow any intializers to be run.
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
818 ReplaySuppressInitializers = 1;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
819 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
820
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
821 // Load and parse the replay data
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
822 CompileReplay rp(ReplayDataFile, THREAD);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
823 int exit_code = 0;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
824 if (rp.can_replay()) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
825 rp.process(THREAD);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
826 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
827 exit_code = 1;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
828 return exit_code;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
829 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
830
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
831 if (HAS_PENDING_EXCEPTION) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
832 oop throwable = PENDING_EXCEPTION;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
833 CLEAR_PENDING_EXCEPTION;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
834 java_lang_Throwable::print(throwable, tty);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
835 tty->cr();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
836 java_lang_Throwable::print_stack_trace(throwable, tty);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
837 tty->cr();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
838 exit_code = 2;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
839 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
840
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
841 if (rp.had_error()) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
842 tty->print_cr("Failed on %s", rp.error_message());
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
843 exit_code = 1;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
844 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
845 return exit_code;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
846 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
847
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
848
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
849 void ciReplay::initialize(ciMethodData* m) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
850 if (replay_state == NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
851 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
852 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
853
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
854 ASSERT_IN_VM;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
855 ResourceMark rm;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
856
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
857 Method* method = m->get_MethodData()->method();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
858 ciMethodDataRecord* rec = replay_state->find_ciMethodDataRecord(method);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
859 if (rec == NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
860 // This indicates some mismatch with the original environment and
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
861 // the replay environment though it's not always enough to
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
862 // interfere with reproducing a bug
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
863 tty->print_cr("Warning: requesting ciMethodData record for method with no data: ");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
864 method->print_name(tty);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
865 tty->cr();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
866 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
867 m->_state = rec->state;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
868 m->_current_mileage = rec->current_mileage;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
869 if (rec->data_length != 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
870 assert(m->_data_size == rec->data_length * (int)sizeof(rec->data[0]), "must agree");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
871
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
872 // Write the correct ciObjects back into the profile data
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
873 ciEnv* env = ciEnv::current();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
874 for (int i = 0; i < rec->oops_length; i++) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
875 KlassHandle *h = (KlassHandle *)rec->oops_handles[i];
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
876 *(ciMetadata**)(rec->data + rec->oops_offsets[i]) =
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
877 env->get_metadata((*h)());
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
878 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
879 // Copy the updated profile data into place as intptr_ts
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
880 #ifdef _LP64
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
881 Copy::conjoint_jlongs_atomic((jlong *)rec->data, (jlong *)m->_data, rec->data_length);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
882 #else
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
883 Copy::conjoint_jints_atomic((jint *)rec->data, (jint *)m->_data, rec->data_length);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
884 #endif
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
885 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
886
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
887 // copy in the original header
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
888 Copy::conjoint_jbytes(rec->orig_data, (char*)&m->_orig, rec->orig_data_length);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
889 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
890 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
891
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
892
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
893 bool ciReplay::should_not_inline(ciMethod* method) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
894 if (replay_state == NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
895 return false;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
896 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
897
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
898 VM_ENTRY_MARK;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
899 // ciMethod without a record shouldn't be inlined.
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
900 return replay_state->find_ciMethodRecord(method->get_Method()) == NULL;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
901 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
902
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
903
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
904 void ciReplay::initialize(ciMethod* m) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
905 if (replay_state == NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
906 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
907 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
908
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
909 ASSERT_IN_VM;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
910 ResourceMark rm;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
911
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
912 Method* method = m->get_Method();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
913 ciMethodRecord* rec = replay_state->find_ciMethodRecord(method);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
914 if (rec == NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
915 // This indicates some mismatch with the original environment and
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
916 // the replay environment though it's not always enough to
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
917 // interfere with reproducing a bug
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
918 tty->print_cr("Warning: requesting ciMethod record for method with no data: ");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
919 method->print_name(tty);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
920 tty->cr();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
921 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
922 // m->_instructions_size = rec->instructions_size;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
923 m->_instructions_size = -1;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
924 m->_interpreter_invocation_count = rec->interpreter_invocation_count;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
925 m->_interpreter_throwout_count = rec->interpreter_throwout_count;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
926 method->invocation_counter()->_counter = rec->invocation_counter;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
927 method->backedge_counter()->_counter = rec->backedge_counter;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
928 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
929 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
930
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
931 bool ciReplay::is_loaded(Method* method) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
932 if (replay_state == NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
933 return true;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
934 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
935
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
936 ASSERT_IN_VM;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
937 ResourceMark rm;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
938
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
939 ciMethodRecord* rec = replay_state->find_ciMethodRecord(method);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
940 return rec != NULL;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
941 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
942 #endif