annotate src/share/vm/ci/ciReplay.cpp @ 9126:bc26f978b0ce

HotSpotResolvedObjectType: implement hasFinalizeSubclass() correctly don't use the (wrong) cached value, but ask the runtime on each request. Fixes regression on xml.* benchmarks @ specjvm2008. The problem was: After the constructor of Object was deoptimized due to an assumption violation, it was recompiled again after some time. However, on recompilation, the value of hasFinalizeSubclass for the class was not updated and it was compiled again with a, now wrong, assumption, which then triggers deoptimization again. This was repeated until it hit the recompilation limit (defined by PerMethodRecompilationCutoff), and therefore only executed by the interpreter from now on, causing the performance regression.
author Bernhard Urban <bernhard.urban@jku.at>
date Mon, 15 Apr 2013 19:54:58 +0200
parents 8391fdd36e1f
children aeaca88565e6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7623
203f64878aab 7102489: RFE: cleanup jlong typedef on __APPLE__and _LLP64 systems.
hseigel
parents: 7185
diff changeset
1 /* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
6972
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"
8001
db9981fd3124 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 7185
diff changeset
33 #include "utilities/macros.hpp"
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
34
7185
90273fc0a981 8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents: 6972
diff changeset
35 #ifndef PRODUCT
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
36
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
37 // ciReplay
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
38
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
39 typedef struct _ciMethodDataRecord {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
40 const char* klass;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
41 const char* method;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
42 const char* signature;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
43 int state;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
44 int current_mileage;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
45 intptr_t* data;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
46 int data_length;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
47 char* orig_data;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
48 int orig_data_length;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
49 int oops_length;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
50 jobject* oops_handles;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
51 int* oops_offsets;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
52 } ciMethodDataRecord;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
53
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
54 typedef struct _ciMethodRecord {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
55 const char* klass;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
56 const char* method;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
57 const char* signature;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
58 int instructions_size;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
59 int interpreter_invocation_count;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
60 int interpreter_throwout_count;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
61 int invocation_counter;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
62 int backedge_counter;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
63 } ciMethodRecord;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
64
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
65 class CompileReplay;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
66 static CompileReplay* replay_state;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
67
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
68 class CompileReplay : public StackObj {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
69 private:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
70 FILE* stream;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
71 Thread* thread;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
72 Handle protection_domain;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
73 Handle loader;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
74
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
75 GrowableArray<ciMethodRecord*> ci_method_records;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
76 GrowableArray<ciMethodDataRecord*> ci_method_data_records;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
77
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
78 const char* _error_message;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
79
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
80 char* bufptr;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
81 char* buffer;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
82 int buffer_length;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
83 int buffer_end;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
84 int line_no;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
85
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
86 public:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
87 CompileReplay(const char* filename, TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
88 thread = THREAD;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
89 loader = Handle(thread, SystemDictionary::java_system_loader());
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
90 stream = fopen(filename, "rt");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
91 if (stream == NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
92 fprintf(stderr, "Can't open replay file %s\n", filename);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
93 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
94 buffer_length = 32;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
95 buffer = NEW_RESOURCE_ARRAY(char, buffer_length);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
96 _error_message = NULL;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
97
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
98 test();
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
101 ~CompileReplay() {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
102 if (stream != NULL) fclose(stream);
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
105 void test() {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
106 strcpy(buffer, "1 2 foo 4 bar 0x9 \"this is it\"");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
107 bufptr = buffer;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
108 assert(parse_int("test") == 1, "what");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
109 assert(parse_int("test") == 2, "what");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
110 assert(strcmp(parse_string(), "foo") == 0, "what");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
111 assert(parse_int("test") == 4, "what");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
112 assert(strcmp(parse_string(), "bar") == 0, "what");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
113 assert(parse_intptr_t("test") == 9, "what");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
114 assert(strcmp(parse_quoted_string(), "this is it") == 0, "what");
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
117 bool had_error() {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
118 return _error_message != NULL || thread->has_pending_exception();
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
121 bool can_replay() {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
122 return !(stream == NULL || had_error());
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
125 void report_error(const char* msg) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
126 _error_message = msg;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
127 // Restore the buffer contents for error reporting
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
128 for (int i = 0; i < buffer_end; i++) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
129 if (buffer[i] == '\0') buffer[i] = ' ';
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
133 int parse_int(const char* label) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
134 if (had_error()) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
135 return 0;
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
138 int v = 0;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
139 int read;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
140 if (sscanf(bufptr, "%i%n", &v, &read) != 1) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
141 report_error(label);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
142 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
143 bufptr += read;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
144 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
145 return v;
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
148 intptr_t parse_intptr_t(const char* label) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
149 if (had_error()) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
150 return 0;
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
153 intptr_t v = 0;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
154 int read;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
155 if (sscanf(bufptr, INTPTR_FORMAT "%n", &v, &read) != 1) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
156 report_error(label);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
157 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
158 bufptr += read;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
159 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
160 return v;
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
163 void skip_ws() {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
164 // Skip any leading whitespace
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
165 while (*bufptr == ' ' || *bufptr == '\t') {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
166 bufptr++;
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
171 char* scan_and_terminate(char delim) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
172 char* str = bufptr;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
173 while (*bufptr != delim && *bufptr != '\0') {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
174 bufptr++;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
175 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
176 if (*bufptr != '\0') {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
177 *bufptr++ = '\0';
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
178 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
179 if (bufptr == str) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
180 // nothing here
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
181 return NULL;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
182 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
183 return str;
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
186 char* parse_string() {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
187 if (had_error()) return NULL;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
188
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
189 skip_ws();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
190 return scan_and_terminate(' ');
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
193 char* parse_quoted_string() {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
194 if (had_error()) return NULL;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
195
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
196 skip_ws();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
197
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
198 if (*bufptr == '"') {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
199 bufptr++;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
200 return scan_and_terminate('"');
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
201 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
202 return scan_and_terminate(' ');
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
206 const char* parse_escaped_string() {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
207 char* result = parse_quoted_string();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
208 if (result != NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
209 unescape_string(result);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
210 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
211 return result;
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
214 // Look for the tag 'tag' followed by an
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
215 bool parse_tag_and_count(const char* tag, int& length) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
216 const char* t = parse_string();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
217 if (t == NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
218 return false;
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
221 if (strcmp(tag, t) != 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
222 report_error(tag);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
223 return false;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
224 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
225 length = parse_int("parse_tag_and_count");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
226 return !had_error();
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
229 // 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
230 // resulting data.
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
231 char* parse_data(const char* tag, int& length) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
232 if (!parse_tag_and_count(tag, length)) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
233 return NULL;
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
236 char * result = NEW_RESOURCE_ARRAY(char, length);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
237 for (int i = 0; i < length; i++) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
238 int val = parse_int("data");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
239 result[i] = val;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
240 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
241 return result;
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
244 // Parse a standard chunk of data emitted as:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
245 // 'tag' <length> # # ...
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
246 // Where each # is an intptr_t item
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
247 intptr_t* parse_intptr_data(const char* tag, int& length) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
248 if (!parse_tag_and_count(tag, length)) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
249 return NULL;
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
252 intptr_t* result = NEW_RESOURCE_ARRAY(intptr_t, length);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
253 for (int i = 0; i < length; i++) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
254 skip_ws();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
255 intptr_t val = parse_intptr_t("data");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
256 result[i] = val;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
257 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
258 return result;
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
261 // Parse a possibly quoted version of a symbol into a symbolOop
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
262 Symbol* parse_symbol(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
263 const char* str = parse_escaped_string();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
264 if (str != NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
265 Symbol* sym = SymbolTable::lookup(str, (int)strlen(str), CHECK_NULL);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
266 return sym;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
267 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
268 return NULL;
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
271 // Parse a valid klass name and look it up
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
272 Klass* parse_klass(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
273 const char* str = parse_escaped_string();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
274 Symbol* klass_name = SymbolTable::lookup(str, (int)strlen(str), CHECK_NULL);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
275 if (klass_name != NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
276 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
277 if (HAS_PENDING_EXCEPTION) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
278 oop throwable = PENDING_EXCEPTION;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
279 java_lang_Throwable::print(throwable, tty);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
280 tty->cr();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
281 report_error(str);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
282 return NULL;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
283 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
284 return k;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
285 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
286 return NULL;
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
289 // Lookup a klass
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
290 Klass* resolve_klass(const char* klass, TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
291 Symbol* klass_name = SymbolTable::lookup(klass, (int)strlen(klass), CHECK_NULL);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
292 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
293 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
294
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
295 // Parse the standard tuple of <klass> <name> <signature>
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
296 Method* parse_method(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
297 InstanceKlass* k = (InstanceKlass*)parse_klass(CHECK_NULL);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
298 Symbol* method_name = parse_symbol(CHECK_NULL);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
299 Symbol* method_signature = parse_symbol(CHECK_NULL);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
300 Method* m = k->find_method(method_name, method_signature);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
301 if (m == NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
302 report_error("can't find method");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
303 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
304 return m;
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
307 // Process each line of the replay file executing each command until
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
308 // the file ends.
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
309 void process(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
310 line_no = 1;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
311 int pos = 0;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
312 int c = getc(stream);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
313 while(c != EOF) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
314 if (pos + 1 >= buffer_length) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
315 int newl = buffer_length * 2;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
316 char* newb = NEW_RESOURCE_ARRAY(char, newl);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
317 memcpy(newb, buffer, pos);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
318 buffer = newb;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
319 buffer_length = newl;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
320 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
321 if (c == '\n') {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
322 // null terminate it, reset the pointer and process the line
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
323 buffer[pos] = '\0';
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
324 buffer_end = pos++;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
325 bufptr = buffer;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
326 process_command(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
327 if (had_error()) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
328 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
329 tty->print_cr("%s", buffer);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
330 assert(false, "error");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
331 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
332 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
333 pos = 0;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
334 buffer_end = 0;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
335 line_no++;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
336 } else if (c == '\r') {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
337 // skip LF
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
338 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
339 buffer[pos++] = c;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
340 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
341 c = getc(stream);
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
345 void process_command(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
346 char* cmd = parse_string();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
347 if (cmd == NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
348 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
349 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
350 if (strcmp("#", cmd) == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
351 // ignore
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
352 } else if (strcmp("compile", cmd) == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
353 process_compile(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
354 } else if (strcmp("ciMethod", cmd) == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
355 process_ciMethod(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
356 } else if (strcmp("ciMethodData", cmd) == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
357 process_ciMethodData(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
358 } else if (strcmp("staticfield", cmd) == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
359 process_staticfield(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
360 } else if (strcmp("ciInstanceKlass", cmd) == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
361 process_ciInstanceKlass(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
362 } else if (strcmp("instanceKlass", cmd) == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
363 process_instanceKlass(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
364 #if INCLUDE_JVMTI
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
365 } else if (strcmp("JvmtiExport", cmd) == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
366 process_JvmtiExport(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
367 #endif // INCLUDE_JVMTI
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
368 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
369 report_error("unknown command");
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
373 // compile <klass> <name> <signature> <entry_bci>
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
374 void process_compile(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
375 // methodHandle method;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
376 Method* method = parse_method(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
377 int entry_bci = parse_int("entry_bci");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
378 Klass* k = method->method_holder();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
379 ((InstanceKlass*)k)->initialize(THREAD);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
380 if (HAS_PENDING_EXCEPTION) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
381 oop throwable = PENDING_EXCEPTION;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
382 java_lang_Throwable::print(throwable, tty);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
383 tty->cr();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
384 if (ReplayIgnoreInitErrors) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
385 CLEAR_PENDING_EXCEPTION;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
386 ((InstanceKlass*)k)->set_init_state(InstanceKlass::fully_initialized);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
387 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
388 return;
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 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
391 // 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
392 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
393 if (nm != NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
394 nm->make_not_entrant();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
395 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
396 replay_state = this;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
397 CompileBroker::compile_method(method, entry_bci, CompLevel_full_optimization,
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
398 methodHandle(), 0, "replay", THREAD);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
399 replay_state = NULL;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
400 reset();
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
403 // 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
404 //
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
405 //
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
406 void process_ciMethod(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
407 Method* method = parse_method(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
408 ciMethodRecord* rec = new_ciMethod(method);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
409 rec->invocation_counter = parse_int("invocation_counter");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
410 rec->backedge_counter = parse_int("backedge_counter");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
411 rec->interpreter_invocation_count = parse_int("interpreter_invocation_count");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
412 rec->interpreter_throwout_count = parse_int("interpreter_throwout_count");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
413 rec->instructions_size = parse_int("instructions_size");
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
416 // 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
417 void process_ciMethodData(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
418 Method* method = parse_method(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
419 /* jsut copied from Method, to build interpret data*/
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
420 if (InstanceRefKlass::owns_pending_list_lock((JavaThread*)THREAD)) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
421 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
422 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
423 // methodOopDesc::build_interpreter_method_data(method, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
424 {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
425 // Grab a lock here to prevent multiple
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
426 // MethodData*s from being created.
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
427 MutexLocker ml(MethodData_lock, THREAD);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
428 if (method->method_data() == NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
429 ClassLoaderData* loader_data = method->method_holder()->class_loader_data();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
430 MethodData* method_data = MethodData::allocate(loader_data, method, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
431 method->set_method_data(method_data);
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
435 // collect and record all the needed information for later
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
436 ciMethodDataRecord* rec = new_ciMethodData(method);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
437 rec->state = parse_int("state");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
438 rec->current_mileage = parse_int("current_mileage");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
439
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
440 rec->orig_data = parse_data("orig", rec->orig_data_length);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
441 if (rec->orig_data == NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
442 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
443 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
444 rec->data = parse_intptr_data("data", rec->data_length);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
445 if (rec->data == NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
446 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
447 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
448 if (!parse_tag_and_count("oops", rec->oops_length)) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
449 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
450 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
451 rec->oops_handles = NEW_RESOURCE_ARRAY(jobject, rec->oops_length);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
452 rec->oops_offsets = NEW_RESOURCE_ARRAY(int, rec->oops_length);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
453 for (int i = 0; i < rec->oops_length; i++) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
454 int offset = parse_int("offset");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
455 if (had_error()) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
456 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
457 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
458 Klass* k = parse_klass(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
459 rec->oops_offsets[i] = offset;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
460 rec->oops_handles[i] = (jobject)(new KlassHandle(THREAD, k));
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
464 // instanceKlass <name>
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
465 //
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
466 // Loads and initializes the klass 'name'. This can be used to
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
467 // create particular class loading environments
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
468 void process_instanceKlass(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
469 // just load the referenced class
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
470 Klass* k = parse_klass(CHECK);
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
473 // ciInstanceKlass <name> <is_linked> <is_initialized> <length> tag # # # ...
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
474 //
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
475 // 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
476 // 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
477 // constant pool tags are in the same state.
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
478 void process_ciInstanceKlass(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
479 InstanceKlass* k = (InstanceKlass *)parse_klass(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
480 int is_linked = parse_int("is_linked");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
481 int is_initialized = parse_int("is_initialized");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
482 int length = parse_int("length");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
483 if (is_initialized) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
484 k->initialize(THREAD);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
485 if (HAS_PENDING_EXCEPTION) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
486 oop throwable = PENDING_EXCEPTION;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
487 java_lang_Throwable::print(throwable, tty);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
488 tty->cr();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
489 if (ReplayIgnoreInitErrors) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
490 CLEAR_PENDING_EXCEPTION;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
491 k->set_init_state(InstanceKlass::fully_initialized);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
492 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
493 return;
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 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
496 } else if (is_linked) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
497 k->link_class(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
498 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
499 ConstantPool* cp = k->constants();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
500 if (length != cp->length()) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
501 report_error("constant pool length mismatch: wrong class files?");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
502 return;
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
505 int parsed_two_word = 0;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
506 for (int i = 1; i < length; i++) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
507 int tag = parse_int("tag");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
508 if (had_error()) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
509 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
510 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
511 switch (cp->tag_at(i).value()) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
512 case JVM_CONSTANT_UnresolvedClass: {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
513 if (tag == JVM_CONSTANT_Class) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
514 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
515 Klass* k = cp->klass_at(i, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
516 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
517 break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
518 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
519 case JVM_CONSTANT_Long:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
520 case JVM_CONSTANT_Double:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
521 parsed_two_word = i + 1;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
522
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
523 case JVM_CONSTANT_ClassIndex:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
524 case JVM_CONSTANT_StringIndex:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
525 case JVM_CONSTANT_String:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
526 case JVM_CONSTANT_UnresolvedClassInError:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
527 case JVM_CONSTANT_Fieldref:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
528 case JVM_CONSTANT_Methodref:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
529 case JVM_CONSTANT_InterfaceMethodref:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
530 case JVM_CONSTANT_NameAndType:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
531 case JVM_CONSTANT_Utf8:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
532 case JVM_CONSTANT_Integer:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
533 case JVM_CONSTANT_Float:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
534 if (tag != cp->tag_at(i).value()) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
535 report_error("tag mismatch: wrong class files?");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
536 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
537 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
538 break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
539
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
540 case JVM_CONSTANT_Class:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
541 if (tag == JVM_CONSTANT_Class) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
542 } else if (tag == JVM_CONSTANT_UnresolvedClass) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
543 tty->print_cr("Warning: entry was unresolved in the replay data");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
544 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
545 report_error("Unexpected tag");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
546 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
547 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
548 break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
549
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
550 case 0:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
551 if (parsed_two_word == i) continue;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
552
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
553 default:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
554 ShouldNotReachHere();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
555 break;
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
561 // 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
562 // 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
563 // static fields but it's impossible to properly rerun the static
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
564 // initiailizer.
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
565 void process_staticfield(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
566 InstanceKlass* k = (InstanceKlass *)parse_klass(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
567
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
568 if (ReplaySuppressInitializers == 0 ||
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
569 ReplaySuppressInitializers == 2 && k->class_loader() == NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
570 return;
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
573 assert(k->is_initialized(), "must be");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
574
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
575 const char* field_name = parse_escaped_string();;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
576 const char* field_signature = parse_string();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
577 fieldDescriptor fd;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
578 Symbol* name = SymbolTable::lookup(field_name, (int)strlen(field_name), CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
579 Symbol* sig = SymbolTable::lookup(field_signature, (int)strlen(field_signature), CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
580 if (!k->find_local_field(name, sig, &fd) ||
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
581 !fd.is_static() ||
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
582 fd.has_initial_value()) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
583 report_error(field_name);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
584 return;
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
587 oop java_mirror = k->java_mirror();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
588 if (field_signature[0] == '[') {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
589 int length = parse_int("array length");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
590 oop value = NULL;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
591
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
592 if (field_signature[1] == '[') {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
593 // multi dimensional array
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
594 ArrayKlass* kelem = (ArrayKlass *)parse_klass(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
595 int rank = 0;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
596 while (field_signature[rank] == '[') {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
597 rank++;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
598 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
599 int* dims = NEW_RESOURCE_ARRAY(int, rank);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
600 dims[0] = length;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
601 for (int i = 1; i < rank; i++) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
602 dims[i] = 1; // These aren't relevant to the compiler
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
603 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
604 value = kelem->multi_allocate(rank, dims, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
605 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
606 if (strcmp(field_signature, "[B") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
607 value = oopFactory::new_byteArray(length, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
608 } else if (strcmp(field_signature, "[Z") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
609 value = oopFactory::new_boolArray(length, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
610 } else if (strcmp(field_signature, "[C") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
611 value = oopFactory::new_charArray(length, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
612 } else if (strcmp(field_signature, "[S") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
613 value = oopFactory::new_shortArray(length, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
614 } else if (strcmp(field_signature, "[F") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
615 value = oopFactory::new_singleArray(length, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
616 } else if (strcmp(field_signature, "[D") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
617 value = oopFactory::new_doubleArray(length, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
618 } else if (strcmp(field_signature, "[I") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
619 value = oopFactory::new_intArray(length, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
620 } else if (strcmp(field_signature, "[J") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
621 value = oopFactory::new_longArray(length, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
622 } else if (field_signature[0] == '[' && field_signature[1] == 'L') {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
623 KlassHandle kelem = resolve_klass(field_signature + 1, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
624 value = oopFactory::new_objArray(kelem(), length, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
625 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
626 report_error("unhandled array staticfield");
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 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
629 java_mirror->obj_field_put(fd.offset(), value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
630 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
631 const char* string_value = parse_escaped_string();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
632 if (strcmp(field_signature, "I") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
633 int value = atoi(string_value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
634 java_mirror->int_field_put(fd.offset(), value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
635 } else if (strcmp(field_signature, "B") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
636 int value = atoi(string_value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
637 java_mirror->byte_field_put(fd.offset(), value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
638 } else if (strcmp(field_signature, "C") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
639 int value = atoi(string_value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
640 java_mirror->char_field_put(fd.offset(), value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
641 } else if (strcmp(field_signature, "S") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
642 int value = atoi(string_value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
643 java_mirror->short_field_put(fd.offset(), value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
644 } else if (strcmp(field_signature, "Z") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
645 int value = atol(string_value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
646 java_mirror->bool_field_put(fd.offset(), value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
647 } else if (strcmp(field_signature, "J") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
648 jlong value;
7623
203f64878aab 7102489: RFE: cleanup jlong typedef on __APPLE__and _LLP64 systems.
hseigel
parents: 7185
diff changeset
649 if (sscanf(string_value, JLONG_FORMAT, &value) != 1) {
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
650 fprintf(stderr, "Error parsing long: %s\n", string_value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
651 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
652 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
653 java_mirror->long_field_put(fd.offset(), value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
654 } else if (strcmp(field_signature, "F") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
655 float value = atof(string_value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
656 java_mirror->float_field_put(fd.offset(), value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
657 } else if (strcmp(field_signature, "D") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
658 double value = atof(string_value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
659 java_mirror->double_field_put(fd.offset(), value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
660 } else if (strcmp(field_signature, "Ljava/lang/String;") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
661 Handle value = java_lang_String::create_from_str(string_value, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
662 java_mirror->obj_field_put(fd.offset(), value());
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
663 } else if (field_signature[0] == 'L') {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
664 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
665 KlassHandle kelem = resolve_klass(field_signature, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
666 oop value = ((InstanceKlass*)kelem())->allocate_instance(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
667 java_mirror->obj_field_put(fd.offset(), value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
668 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
669 report_error("unhandled staticfield");
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
674 #if INCLUDE_JVMTI
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
675 void process_JvmtiExport(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
676 const char* field = parse_string();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
677 bool value = parse_int("JvmtiExport flag") != 0;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
678 if (strcmp(field, "can_access_local_variables") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
679 JvmtiExport::set_can_access_local_variables(value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
680 } else if (strcmp(field, "can_hotswap_or_post_breakpoint") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
681 JvmtiExport::set_can_hotswap_or_post_breakpoint(value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
682 } else if (strcmp(field, "can_post_on_exceptions") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
683 JvmtiExport::set_can_post_on_exceptions(value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
684 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
685 report_error("Unrecognized JvmtiExport directive");
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 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
688 #endif // INCLUDE_JVMTI
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
689
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
690 // Create and initialize a record for a ciMethod
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
691 ciMethodRecord* new_ciMethod(Method* method) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
692 ciMethodRecord* rec = NEW_RESOURCE_OBJ(ciMethodRecord);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
693 rec->klass = method->method_holder()->name()->as_utf8();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
694 rec->method = method->name()->as_utf8();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
695 rec->signature = method->signature()->as_utf8();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
696 ci_method_records.append(rec);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
697 return rec;
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
700 // Lookup data for a ciMethod
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
701 ciMethodRecord* find_ciMethodRecord(Method* method) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
702 const char* klass_name = method->method_holder()->name()->as_utf8();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
703 const char* method_name = method->name()->as_utf8();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
704 const char* signature = method->signature()->as_utf8();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
705 for (int i = 0; i < ci_method_records.length(); i++) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
706 ciMethodRecord* rec = ci_method_records.at(i);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
707 if (strcmp(rec->klass, klass_name) == 0 &&
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
708 strcmp(rec->method, method_name) == 0 &&
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
709 strcmp(rec->signature, signature) == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
710 return rec;
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 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
713 return NULL;
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
716 // Create and initialize a record for a ciMethodData
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
717 ciMethodDataRecord* new_ciMethodData(Method* method) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
718 ciMethodDataRecord* rec = NEW_RESOURCE_OBJ(ciMethodDataRecord);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
719 rec->klass = method->method_holder()->name()->as_utf8();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
720 rec->method = method->name()->as_utf8();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
721 rec->signature = method->signature()->as_utf8();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
722 ci_method_data_records.append(rec);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
723 return rec;
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
726 // Lookup data for a ciMethodData
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
727 ciMethodDataRecord* find_ciMethodDataRecord(Method* method) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
728 const char* klass_name = method->method_holder()->name()->as_utf8();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
729 const char* method_name = method->name()->as_utf8();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
730 const char* signature = method->signature()->as_utf8();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
731 for (int i = 0; i < ci_method_data_records.length(); i++) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
732 ciMethodDataRecord* rec = ci_method_data_records.at(i);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
733 if (strcmp(rec->klass, klass_name) == 0 &&
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
734 strcmp(rec->method, method_name) == 0 &&
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
735 strcmp(rec->signature, signature) == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
736 return rec;
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 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
739 return NULL;
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
742 const char* error_message() {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
743 return _error_message;
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
746 void reset() {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
747 _error_message = NULL;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
748 ci_method_records.clear();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
749 ci_method_data_records.clear();
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
752 // 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
753 // in place.
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
754 static void unescape_string(char* value) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
755 char* from = value;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
756 char* to = value;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
757 while (*from != '\0') {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
758 if (*from != '\\') {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
759 *from++ = *to++;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
760 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
761 switch (from[1]) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
762 case 'u': {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
763 from += 2;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
764 jchar value=0;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
765 for (int i=0; i<4; i++) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
766 char c = *from++;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
767 switch (c) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
768 case '0': case '1': case '2': case '3': case '4':
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
769 case '5': case '6': case '7': case '8': case '9':
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
770 value = (value << 4) + c - '0';
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
771 break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
772 case 'a': case 'b': case 'c':
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
773 case 'd': case 'e': case 'f':
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
774 value = (value << 4) + 10 + c - 'a';
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
775 break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
776 case 'A': case 'B': case 'C':
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
777 case 'D': case 'E': case 'F':
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
778 value = (value << 4) + 10 + c - 'A';
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
779 break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
780 default:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
781 ShouldNotReachHere();
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 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
784 UNICODE::convert_to_utf8(&value, 1, to);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
785 to++;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
786 break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
787 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
788 case 't': *to++ = '\t'; from += 2; break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
789 case 'n': *to++ = '\n'; from += 2; break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
790 case 'r': *to++ = '\r'; from += 2; break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
791 case 'f': *to++ = '\f'; from += 2; break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
792 default:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
793 ShouldNotReachHere();
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 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
797 *from = *to;
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
801 void ciReplay::replay(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
802 int exit_code = replay_impl(THREAD);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
803
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
804 Threads::destroy_vm();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
805
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
806 vm_exit(exit_code);
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
809 int ciReplay::replay_impl(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
810 HandleMark hm;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
811 ResourceMark rm;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
812 // Make sure we don't run with background compilation
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
813 BackgroundCompilation = false;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
814
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
815 if (ReplaySuppressInitializers > 2) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
816 // ReplaySuppressInitializers > 2 means that we want to allow
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
817 // normal VM bootstrap but once we get into the replay itself
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
818 // don't allow any intializers to be run.
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
819 ReplaySuppressInitializers = 1;
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
822 // Load and parse the replay data
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
823 CompileReplay rp(ReplayDataFile, THREAD);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
824 int exit_code = 0;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
825 if (rp.can_replay()) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
826 rp.process(THREAD);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
827 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
828 exit_code = 1;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
829 return exit_code;
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
832 if (HAS_PENDING_EXCEPTION) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
833 oop throwable = PENDING_EXCEPTION;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
834 CLEAR_PENDING_EXCEPTION;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
835 java_lang_Throwable::print(throwable, tty);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
836 tty->cr();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
837 java_lang_Throwable::print_stack_trace(throwable, tty);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
838 tty->cr();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
839 exit_code = 2;
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
842 if (rp.had_error()) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
843 tty->print_cr("Failed on %s", rp.error_message());
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
844 exit_code = 1;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
845 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
846 return exit_code;
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
850 void ciReplay::initialize(ciMethodData* m) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
851 if (replay_state == NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
852 return;
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
855 ASSERT_IN_VM;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
856 ResourceMark rm;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
857
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
858 Method* method = m->get_MethodData()->method();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
859 ciMethodDataRecord* rec = replay_state->find_ciMethodDataRecord(method);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
860 if (rec == NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
861 // This indicates some mismatch with the original environment and
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
862 // the replay environment though it's not always enough to
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
863 // interfere with reproducing a bug
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
864 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
865 method->print_name(tty);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
866 tty->cr();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
867 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
868 m->_state = rec->state;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
869 m->_current_mileage = rec->current_mileage;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
870 if (rec->data_length != 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
871 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
872
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
873 // Write the correct ciObjects back into the profile data
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
874 ciEnv* env = ciEnv::current();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
875 for (int i = 0; i < rec->oops_length; i++) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
876 KlassHandle *h = (KlassHandle *)rec->oops_handles[i];
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
877 *(ciMetadata**)(rec->data + rec->oops_offsets[i]) =
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
878 env->get_metadata((*h)());
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
879 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
880 // Copy the updated profile data into place as intptr_ts
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
881 #ifdef _LP64
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
882 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
883 #else
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
884 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
885 #endif
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
888 // copy in the original header
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
889 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
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
894 bool ciReplay::should_not_inline(ciMethod* method) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
895 if (replay_state == NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
896 return false;
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
899 VM_ENTRY_MARK;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
900 // ciMethod without a record shouldn't be inlined.
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
901 return replay_state->find_ciMethodRecord(method->get_Method()) == NULL;
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
905 void ciReplay::initialize(ciMethod* m) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
906 if (replay_state == NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
907 return;
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
910 ASSERT_IN_VM;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
911 ResourceMark rm;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
912
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
913 Method* method = m->get_Method();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
914 ciMethodRecord* rec = replay_state->find_ciMethodRecord(method);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
915 if (rec == NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
916 // This indicates some mismatch with the original environment and
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
917 // the replay environment though it's not always enough to
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
918 // interfere with reproducing a bug
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
919 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
920 method->print_name(tty);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
921 tty->cr();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
922 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
923 // m->_instructions_size = rec->instructions_size;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
924 m->_instructions_size = -1;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
925 m->_interpreter_invocation_count = rec->interpreter_invocation_count;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
926 m->_interpreter_throwout_count = rec->interpreter_throwout_count;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
927 method->invocation_counter()->_counter = rec->invocation_counter;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
928 method->backedge_counter()->_counter = rec->backedge_counter;
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
932 bool ciReplay::is_loaded(Method* method) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
933 if (replay_state == NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
934 return true;
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
937 ASSERT_IN_VM;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
938 ResourceMark rm;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
939
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
940 ciMethodRecord* rec = replay_state->find_ciMethodRecord(method);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
941 return rec != NULL;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
942 }
7185
90273fc0a981 8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents: 6972
diff changeset
943 #endif // PRODUCT