Mercurial > hg > truffle
annotate src/share/vm/ci/ciReplay.cpp @ 11722:ff05c78a7f64
use time passed to decide what methods to compile or inline
author | Christian Wirth <christian.wirth@oracle.com> |
---|---|
date | Thu, 19 Sep 2013 10:36:56 +0200 |
parents | f9be75d21404 |
children | 1b6395189726 |
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) { |
10195
e12c9b3740db
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
10105
diff
changeset
|
92 fprintf(stderr, "ERROR: Can't open replay file %s\n", filename); |
6972
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 return; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
331 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
332 pos = 0; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
333 buffer_end = 0; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
334 line_no++; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
335 } else if (c == '\r') { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
336 // skip LF |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
337 } else { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
338 buffer[pos++] = c; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
339 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
340 c = getc(stream); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
341 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
342 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
343 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
344 void process_command(TRAPS) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
345 char* cmd = parse_string(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
346 if (cmd == NULL) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
347 return; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
348 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
349 if (strcmp("#", cmd) == 0) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
350 // ignore |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
351 } else if (strcmp("compile", cmd) == 0) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
352 process_compile(CHECK); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
353 } else if (strcmp("ciMethod", cmd) == 0) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
354 process_ciMethod(CHECK); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
355 } else if (strcmp("ciMethodData", cmd) == 0) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
356 process_ciMethodData(CHECK); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
357 } else if (strcmp("staticfield", cmd) == 0) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
358 process_staticfield(CHECK); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
359 } else if (strcmp("ciInstanceKlass", cmd) == 0) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
360 process_ciInstanceKlass(CHECK); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
361 } else if (strcmp("instanceKlass", cmd) == 0) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
362 process_instanceKlass(CHECK); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
363 #if INCLUDE_JVMTI |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
364 } else if (strcmp("JvmtiExport", cmd) == 0) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
365 process_JvmtiExport(CHECK); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
366 #endif // INCLUDE_JVMTI |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
367 } else { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
368 report_error("unknown command"); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
369 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
370 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
371 |
10197
7b23cb975cf2
8011675: adding compilation level to replay data
iignatyev
parents:
10195
diff
changeset
|
372 // validation of comp_level |
7b23cb975cf2
8011675: adding compilation level to replay data
iignatyev
parents:
10195
diff
changeset
|
373 bool is_valid_comp_level(int comp_level) { |
7b23cb975cf2
8011675: adding compilation level to replay data
iignatyev
parents:
10195
diff
changeset
|
374 const int msg_len = 256; |
7b23cb975cf2
8011675: adding compilation level to replay data
iignatyev
parents:
10195
diff
changeset
|
375 char* msg = NULL; |
7b23cb975cf2
8011675: adding compilation level to replay data
iignatyev
parents:
10195
diff
changeset
|
376 if (!is_compile(comp_level)) { |
7b23cb975cf2
8011675: adding compilation level to replay data
iignatyev
parents:
10195
diff
changeset
|
377 msg = NEW_RESOURCE_ARRAY(char, msg_len); |
7b23cb975cf2
8011675: adding compilation level to replay data
iignatyev
parents:
10195
diff
changeset
|
378 jio_snprintf(msg, msg_len, "%d isn't compilation level", comp_level); |
7b23cb975cf2
8011675: adding compilation level to replay data
iignatyev
parents:
10195
diff
changeset
|
379 } else if (!TieredCompilation && (comp_level != CompLevel_highest_tier)) { |
7b23cb975cf2
8011675: adding compilation level to replay data
iignatyev
parents:
10195
diff
changeset
|
380 msg = NEW_RESOURCE_ARRAY(char, msg_len); |
7b23cb975cf2
8011675: adding compilation level to replay data
iignatyev
parents:
10195
diff
changeset
|
381 switch (comp_level) { |
7b23cb975cf2
8011675: adding compilation level to replay data
iignatyev
parents:
10195
diff
changeset
|
382 case CompLevel_simple: |
7b23cb975cf2
8011675: adding compilation level to replay data
iignatyev
parents:
10195
diff
changeset
|
383 jio_snprintf(msg, msg_len, "compilation level %d requires Client VM or TieredCompilation", comp_level); |
7b23cb975cf2
8011675: adding compilation level to replay data
iignatyev
parents:
10195
diff
changeset
|
384 break; |
7b23cb975cf2
8011675: adding compilation level to replay data
iignatyev
parents:
10195
diff
changeset
|
385 case CompLevel_full_optimization: |
7b23cb975cf2
8011675: adding compilation level to replay data
iignatyev
parents:
10195
diff
changeset
|
386 jio_snprintf(msg, msg_len, "compilation level %d requires Server VM", comp_level); |
7b23cb975cf2
8011675: adding compilation level to replay data
iignatyev
parents:
10195
diff
changeset
|
387 break; |
7b23cb975cf2
8011675: adding compilation level to replay data
iignatyev
parents:
10195
diff
changeset
|
388 default: |
7b23cb975cf2
8011675: adding compilation level to replay data
iignatyev
parents:
10195
diff
changeset
|
389 jio_snprintf(msg, msg_len, "compilation level %d requires TieredCompilation", comp_level); |
7b23cb975cf2
8011675: adding compilation level to replay data
iignatyev
parents:
10195
diff
changeset
|
390 } |
7b23cb975cf2
8011675: adding compilation level to replay data
iignatyev
parents:
10195
diff
changeset
|
391 } |
7b23cb975cf2
8011675: adding compilation level to replay data
iignatyev
parents:
10195
diff
changeset
|
392 if (msg != NULL) { |
7b23cb975cf2
8011675: adding compilation level to replay data
iignatyev
parents:
10195
diff
changeset
|
393 report_error(msg); |
7b23cb975cf2
8011675: adding compilation level to replay data
iignatyev
parents:
10195
diff
changeset
|
394 return false; |
7b23cb975cf2
8011675: adding compilation level to replay data
iignatyev
parents:
10195
diff
changeset
|
395 } |
7b23cb975cf2
8011675: adding compilation level to replay data
iignatyev
parents:
10195
diff
changeset
|
396 return true; |
7b23cb975cf2
8011675: adding compilation level to replay data
iignatyev
parents:
10195
diff
changeset
|
397 } |
7b23cb975cf2
8011675: adding compilation level to replay data
iignatyev
parents:
10195
diff
changeset
|
398 |
7b23cb975cf2
8011675: adding compilation level to replay data
iignatyev
parents:
10195
diff
changeset
|
399 // compile <klass> <name> <signature> <entry_bci> <comp_level> |
6972
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
400 void process_compile(TRAPS) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
401 // methodHandle method; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
402 Method* method = parse_method(CHECK); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
403 int entry_bci = parse_int("entry_bci"); |
10197
7b23cb975cf2
8011675: adding compilation level to replay data
iignatyev
parents:
10195
diff
changeset
|
404 const char* comp_level_label = "comp_level"; |
7b23cb975cf2
8011675: adding compilation level to replay data
iignatyev
parents:
10195
diff
changeset
|
405 int comp_level = parse_int(comp_level_label); |
7b23cb975cf2
8011675: adding compilation level to replay data
iignatyev
parents:
10195
diff
changeset
|
406 // old version w/o comp_level |
7b23cb975cf2
8011675: adding compilation level to replay data
iignatyev
parents:
10195
diff
changeset
|
407 if (had_error() && (error_message() == comp_level_label)) { |
7b23cb975cf2
8011675: adding compilation level to replay data
iignatyev
parents:
10195
diff
changeset
|
408 comp_level = CompLevel_full_optimization; |
7b23cb975cf2
8011675: adding compilation level to replay data
iignatyev
parents:
10195
diff
changeset
|
409 } |
7b23cb975cf2
8011675: adding compilation level to replay data
iignatyev
parents:
10195
diff
changeset
|
410 if (!is_valid_comp_level(comp_level)) { |
7b23cb975cf2
8011675: adding compilation level to replay data
iignatyev
parents:
10195
diff
changeset
|
411 return; |
7b23cb975cf2
8011675: adding compilation level to replay data
iignatyev
parents:
10195
diff
changeset
|
412 } |
6972
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
413 Klass* k = method->method_holder(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
414 ((InstanceKlass*)k)->initialize(THREAD); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
415 if (HAS_PENDING_EXCEPTION) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
416 oop throwable = PENDING_EXCEPTION; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
417 java_lang_Throwable::print(throwable, tty); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
418 tty->cr(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
419 if (ReplayIgnoreInitErrors) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
420 CLEAR_PENDING_EXCEPTION; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
421 ((InstanceKlass*)k)->set_init_state(InstanceKlass::fully_initialized); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
422 } else { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
423 return; |
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 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
426 // Make sure the existence of a prior compile doesn't stop this one |
10197
7b23cb975cf2
8011675: adding compilation level to replay data
iignatyev
parents:
10195
diff
changeset
|
427 nmethod* nm = (entry_bci != InvocationEntryBci) ? method->lookup_osr_nmethod_for(entry_bci, comp_level, true) : method->code(); |
6972
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
428 if (nm != NULL) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
429 nm->make_not_entrant(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
430 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
431 replay_state = this; |
10197
7b23cb975cf2
8011675: adding compilation level to replay data
iignatyev
parents:
10195
diff
changeset
|
432 CompileBroker::compile_method(method, entry_bci, comp_level, |
6972
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
433 methodHandle(), 0, "replay", THREAD); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
434 replay_state = NULL; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
435 reset(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
436 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
437 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
438 // 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
|
439 // |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
440 // |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
441 void process_ciMethod(TRAPS) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
442 Method* method = parse_method(CHECK); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
443 ciMethodRecord* rec = new_ciMethod(method); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
444 rec->invocation_counter = parse_int("invocation_counter"); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
445 rec->backedge_counter = parse_int("backedge_counter"); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
446 rec->interpreter_invocation_count = parse_int("interpreter_invocation_count"); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
447 rec->interpreter_throwout_count = parse_int("interpreter_throwout_count"); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
448 rec->instructions_size = parse_int("instructions_size"); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
449 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
450 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
451 // 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
|
452 void process_ciMethodData(TRAPS) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
453 Method* method = parse_method(CHECK); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
454 /* jsut copied from Method, to build interpret data*/ |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
455 if (InstanceRefKlass::owns_pending_list_lock((JavaThread*)THREAD)) { |
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 // methodOopDesc::build_interpreter_method_data(method, CHECK); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
459 { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
460 // Grab a lock here to prevent multiple |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
461 // MethodData*s from being created. |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
462 MutexLocker ml(MethodData_lock, THREAD); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
463 if (method->method_data() == NULL) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
464 ClassLoaderData* loader_data = method->method_holder()->class_loader_data(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
465 MethodData* method_data = MethodData::allocate(loader_data, method, CHECK); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
466 method->set_method_data(method_data); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
467 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
468 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
469 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
470 // collect and record all the needed information for later |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
471 ciMethodDataRecord* rec = new_ciMethodData(method); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
472 rec->state = parse_int("state"); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
473 rec->current_mileage = parse_int("current_mileage"); |
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 rec->orig_data = parse_data("orig", rec->orig_data_length); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
476 if (rec->orig_data == NULL) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
477 return; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
478 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
479 rec->data = parse_intptr_data("data", rec->data_length); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
480 if (rec->data == NULL) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
481 return; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
482 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
483 if (!parse_tag_and_count("oops", rec->oops_length)) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
484 return; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
485 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
486 rec->oops_handles = NEW_RESOURCE_ARRAY(jobject, rec->oops_length); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
487 rec->oops_offsets = NEW_RESOURCE_ARRAY(int, rec->oops_length); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
488 for (int i = 0; i < rec->oops_length; i++) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
489 int offset = parse_int("offset"); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
490 if (had_error()) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
491 return; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
492 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
493 Klass* k = parse_klass(CHECK); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
494 rec->oops_offsets[i] = offset; |
10271
f9be75d21404
8012902: remove use of global operator new - take 2
minqi
parents:
10197
diff
changeset
|
495 KlassHandle *kh = NEW_C_HEAP_OBJ(KlassHandle, mtCompiler); |
f9be75d21404
8012902: remove use of global operator new - take 2
minqi
parents:
10197
diff
changeset
|
496 ::new ((void*)kh) KlassHandle(THREAD, k); |
f9be75d21404
8012902: remove use of global operator new - take 2
minqi
parents:
10197
diff
changeset
|
497 rec->oops_handles[i] = (jobject)kh; |
6972
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 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
500 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
501 // instanceKlass <name> |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
502 // |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
503 // Loads and initializes the klass 'name'. This can be used to |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
504 // create particular class loading environments |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
505 void process_instanceKlass(TRAPS) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
506 // just load the referenced class |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
507 Klass* k = parse_klass(CHECK); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
508 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
509 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
510 // ciInstanceKlass <name> <is_linked> <is_initialized> <length> tag # # # ... |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
511 // |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
512 // 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
|
513 // 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
|
514 // constant pool tags are in the same state. |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
515 void process_ciInstanceKlass(TRAPS) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
516 InstanceKlass* k = (InstanceKlass *)parse_klass(CHECK); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
517 int is_linked = parse_int("is_linked"); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
518 int is_initialized = parse_int("is_initialized"); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
519 int length = parse_int("length"); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
520 if (is_initialized) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
521 k->initialize(THREAD); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
522 if (HAS_PENDING_EXCEPTION) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
523 oop throwable = PENDING_EXCEPTION; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
524 java_lang_Throwable::print(throwable, tty); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
525 tty->cr(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
526 if (ReplayIgnoreInitErrors) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
527 CLEAR_PENDING_EXCEPTION; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
528 k->set_init_state(InstanceKlass::fully_initialized); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
529 } else { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
530 return; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
531 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
532 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
533 } else if (is_linked) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
534 k->link_class(CHECK); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
535 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
536 ConstantPool* cp = k->constants(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
537 if (length != cp->length()) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
538 report_error("constant pool length mismatch: wrong class files?"); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
539 return; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
540 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
541 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
542 int parsed_two_word = 0; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
543 for (int i = 1; i < length; i++) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
544 int tag = parse_int("tag"); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
545 if (had_error()) { |
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 switch (cp->tag_at(i).value()) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
549 case JVM_CONSTANT_UnresolvedClass: { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
550 if (tag == JVM_CONSTANT_Class) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
551 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
|
552 Klass* k = cp->klass_at(i, CHECK); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
553 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
554 break; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
555 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
556 case JVM_CONSTANT_Long: |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
557 case JVM_CONSTANT_Double: |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
558 parsed_two_word = i + 1; |
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 case JVM_CONSTANT_ClassIndex: |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
561 case JVM_CONSTANT_StringIndex: |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
562 case JVM_CONSTANT_String: |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
563 case JVM_CONSTANT_UnresolvedClassInError: |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
564 case JVM_CONSTANT_Fieldref: |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
565 case JVM_CONSTANT_Methodref: |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
566 case JVM_CONSTANT_InterfaceMethodref: |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
567 case JVM_CONSTANT_NameAndType: |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
568 case JVM_CONSTANT_Utf8: |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
569 case JVM_CONSTANT_Integer: |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
570 case JVM_CONSTANT_Float: |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
571 if (tag != cp->tag_at(i).value()) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
572 report_error("tag mismatch: wrong class files?"); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
573 return; |
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 break; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
576 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
577 case JVM_CONSTANT_Class: |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
578 if (tag == JVM_CONSTANT_Class) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
579 } else if (tag == JVM_CONSTANT_UnresolvedClass) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
580 tty->print_cr("Warning: entry was unresolved in the replay data"); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
581 } else { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
582 report_error("Unexpected tag"); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
583 return; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
584 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
585 break; |
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 case 0: |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
588 if (parsed_two_word == i) continue; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
589 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
590 default: |
10195
e12c9b3740db
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
10105
diff
changeset
|
591 fatal(err_msg_res("Unexpected tag: %d", cp->tag_at(i).value())); |
6972
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
592 break; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
593 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
594 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
595 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
596 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
597 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
598 // 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
|
599 // 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
|
600 // static fields but it's impossible to properly rerun the static |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
601 // initiailizer. |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
602 void process_staticfield(TRAPS) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
603 InstanceKlass* k = (InstanceKlass *)parse_klass(CHECK); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
604 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
605 if (ReplaySuppressInitializers == 0 || |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
606 ReplaySuppressInitializers == 2 && k->class_loader() == NULL) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
607 return; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
608 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
609 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
610 assert(k->is_initialized(), "must be"); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
611 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
612 const char* field_name = parse_escaped_string();; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
613 const char* field_signature = parse_string(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
614 fieldDescriptor fd; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
615 Symbol* name = SymbolTable::lookup(field_name, (int)strlen(field_name), CHECK); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
616 Symbol* sig = SymbolTable::lookup(field_signature, (int)strlen(field_signature), CHECK); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
617 if (!k->find_local_field(name, sig, &fd) || |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
618 !fd.is_static() || |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
619 fd.has_initial_value()) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
620 report_error(field_name); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
621 return; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
622 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
623 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
624 oop java_mirror = k->java_mirror(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
625 if (field_signature[0] == '[') { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
626 int length = parse_int("array length"); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
627 oop value = NULL; |
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 if (field_signature[1] == '[') { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
630 // multi dimensional array |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
631 ArrayKlass* kelem = (ArrayKlass *)parse_klass(CHECK); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
632 int rank = 0; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
633 while (field_signature[rank] == '[') { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
634 rank++; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
635 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
636 int* dims = NEW_RESOURCE_ARRAY(int, rank); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
637 dims[0] = length; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
638 for (int i = 1; i < rank; i++) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
639 dims[i] = 1; // These aren't relevant to the compiler |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
640 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
641 value = kelem->multi_allocate(rank, dims, CHECK); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
642 } else { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
643 if (strcmp(field_signature, "[B") == 0) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
644 value = oopFactory::new_byteArray(length, CHECK); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
645 } else if (strcmp(field_signature, "[Z") == 0) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
646 value = oopFactory::new_boolArray(length, CHECK); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
647 } else if (strcmp(field_signature, "[C") == 0) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
648 value = oopFactory::new_charArray(length, CHECK); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
649 } else if (strcmp(field_signature, "[S") == 0) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
650 value = oopFactory::new_shortArray(length, CHECK); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
651 } else if (strcmp(field_signature, "[F") == 0) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
652 value = oopFactory::new_singleArray(length, CHECK); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
653 } else if (strcmp(field_signature, "[D") == 0) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
654 value = oopFactory::new_doubleArray(length, CHECK); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
655 } else if (strcmp(field_signature, "[I") == 0) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
656 value = oopFactory::new_intArray(length, CHECK); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
657 } else if (strcmp(field_signature, "[J") == 0) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
658 value = oopFactory::new_longArray(length, CHECK); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
659 } else if (field_signature[0] == '[' && field_signature[1] == 'L') { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
660 KlassHandle kelem = resolve_klass(field_signature + 1, CHECK); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
661 value = oopFactory::new_objArray(kelem(), length, CHECK); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
662 } else { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
663 report_error("unhandled array staticfield"); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
664 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
665 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
666 java_mirror->obj_field_put(fd.offset(), value); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
667 } else { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
668 const char* string_value = parse_escaped_string(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
669 if (strcmp(field_signature, "I") == 0) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
670 int value = atoi(string_value); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
671 java_mirror->int_field_put(fd.offset(), value); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
672 } else if (strcmp(field_signature, "B") == 0) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
673 int value = atoi(string_value); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
674 java_mirror->byte_field_put(fd.offset(), value); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
675 } else if (strcmp(field_signature, "C") == 0) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
676 int value = atoi(string_value); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
677 java_mirror->char_field_put(fd.offset(), value); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
678 } else if (strcmp(field_signature, "S") == 0) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
679 int value = atoi(string_value); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
680 java_mirror->short_field_put(fd.offset(), value); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
681 } else if (strcmp(field_signature, "Z") == 0) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
682 int value = atol(string_value); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
683 java_mirror->bool_field_put(fd.offset(), value); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
684 } else if (strcmp(field_signature, "J") == 0) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
685 jlong value; |
7623
203f64878aab
7102489: RFE: cleanup jlong typedef on __APPLE__and _LLP64 systems.
hseigel
parents:
7185
diff
changeset
|
686 if (sscanf(string_value, JLONG_FORMAT, &value) != 1) { |
6972
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
687 fprintf(stderr, "Error parsing long: %s\n", string_value); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
688 return; |
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 java_mirror->long_field_put(fd.offset(), value); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
691 } else if (strcmp(field_signature, "F") == 0) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
692 float value = atof(string_value); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
693 java_mirror->float_field_put(fd.offset(), value); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
694 } else if (strcmp(field_signature, "D") == 0) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
695 double value = atof(string_value); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
696 java_mirror->double_field_put(fd.offset(), value); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
697 } else if (strcmp(field_signature, "Ljava/lang/String;") == 0) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
698 Handle value = java_lang_String::create_from_str(string_value, CHECK); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
699 java_mirror->obj_field_put(fd.offset(), value()); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
700 } else if (field_signature[0] == 'L') { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
701 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
|
702 KlassHandle kelem = resolve_klass(field_signature, CHECK); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
703 oop value = ((InstanceKlass*)kelem())->allocate_instance(CHECK); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
704 java_mirror->obj_field_put(fd.offset(), value); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
705 } else { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
706 report_error("unhandled staticfield"); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
707 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
708 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
709 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
710 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
711 #if INCLUDE_JVMTI |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
712 void process_JvmtiExport(TRAPS) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
713 const char* field = parse_string(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
714 bool value = parse_int("JvmtiExport flag") != 0; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
715 if (strcmp(field, "can_access_local_variables") == 0) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
716 JvmtiExport::set_can_access_local_variables(value); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
717 } else if (strcmp(field, "can_hotswap_or_post_breakpoint") == 0) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
718 JvmtiExport::set_can_hotswap_or_post_breakpoint(value); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
719 } else if (strcmp(field, "can_post_on_exceptions") == 0) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
720 JvmtiExport::set_can_post_on_exceptions(value); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
721 } else { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
722 report_error("Unrecognized JvmtiExport directive"); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
723 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
724 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
725 #endif // INCLUDE_JVMTI |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
726 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
727 // Create and initialize a record for a ciMethod |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
728 ciMethodRecord* new_ciMethod(Method* method) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
729 ciMethodRecord* rec = NEW_RESOURCE_OBJ(ciMethodRecord); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
730 rec->klass = method->method_holder()->name()->as_utf8(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
731 rec->method = method->name()->as_utf8(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
732 rec->signature = method->signature()->as_utf8(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
733 ci_method_records.append(rec); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
734 return rec; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
735 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
736 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
737 // Lookup data for a ciMethod |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
738 ciMethodRecord* find_ciMethodRecord(Method* method) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
739 const char* klass_name = method->method_holder()->name()->as_utf8(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
740 const char* method_name = method->name()->as_utf8(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
741 const char* signature = method->signature()->as_utf8(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
742 for (int i = 0; i < ci_method_records.length(); i++) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
743 ciMethodRecord* rec = ci_method_records.at(i); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
744 if (strcmp(rec->klass, klass_name) == 0 && |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
745 strcmp(rec->method, method_name) == 0 && |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
746 strcmp(rec->signature, signature) == 0) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
747 return rec; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
748 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
749 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
750 return NULL; |
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 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
753 // Create and initialize a record for a ciMethodData |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
754 ciMethodDataRecord* new_ciMethodData(Method* method) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
755 ciMethodDataRecord* rec = NEW_RESOURCE_OBJ(ciMethodDataRecord); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
756 rec->klass = method->method_holder()->name()->as_utf8(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
757 rec->method = method->name()->as_utf8(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
758 rec->signature = method->signature()->as_utf8(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
759 ci_method_data_records.append(rec); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
760 return rec; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
761 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
762 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
763 // Lookup data for a ciMethodData |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
764 ciMethodDataRecord* find_ciMethodDataRecord(Method* method) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
765 const char* klass_name = method->method_holder()->name()->as_utf8(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
766 const char* method_name = method->name()->as_utf8(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
767 const char* signature = method->signature()->as_utf8(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
768 for (int i = 0; i < ci_method_data_records.length(); i++) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
769 ciMethodDataRecord* rec = ci_method_data_records.at(i); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
770 if (strcmp(rec->klass, klass_name) == 0 && |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
771 strcmp(rec->method, method_name) == 0 && |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
772 strcmp(rec->signature, signature) == 0) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
773 return rec; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
774 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
775 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
776 return NULL; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
777 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
778 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
779 const char* error_message() { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
780 return _error_message; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
781 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
782 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
783 void reset() { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
784 _error_message = NULL; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
785 ci_method_records.clear(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
786 ci_method_data_records.clear(); |
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 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
789 // 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
|
790 // in place. |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
791 static void unescape_string(char* value) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
792 char* from = value; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
793 char* to = value; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
794 while (*from != '\0') { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
795 if (*from != '\\') { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
796 *from++ = *to++; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
797 } else { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
798 switch (from[1]) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
799 case 'u': { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
800 from += 2; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
801 jchar value=0; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
802 for (int i=0; i<4; i++) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
803 char c = *from++; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
804 switch (c) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
805 case '0': case '1': case '2': case '3': case '4': |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
806 case '5': case '6': case '7': case '8': case '9': |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
807 value = (value << 4) + c - '0'; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
808 break; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
809 case 'a': case 'b': case 'c': |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
810 case 'd': case 'e': case 'f': |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
811 value = (value << 4) + 10 + c - 'a'; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
812 break; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
813 case 'A': case 'B': case 'C': |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
814 case 'D': case 'E': case 'F': |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
815 value = (value << 4) + 10 + c - 'A'; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
816 break; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
817 default: |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
818 ShouldNotReachHere(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
819 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
820 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
821 UNICODE::convert_to_utf8(&value, 1, to); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
822 to++; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
823 break; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
824 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
825 case 't': *to++ = '\t'; from += 2; break; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
826 case 'n': *to++ = '\n'; from += 2; break; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
827 case 'r': *to++ = '\r'; from += 2; break; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
828 case 'f': *to++ = '\f'; from += 2; break; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
829 default: |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
830 ShouldNotReachHere(); |
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 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
833 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
834 *from = *to; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
835 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
836 }; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
837 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
838 void ciReplay::replay(TRAPS) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
839 int exit_code = replay_impl(THREAD); |
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 Threads::destroy_vm(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
842 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
843 vm_exit(exit_code); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
844 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
845 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
846 int ciReplay::replay_impl(TRAPS) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
847 HandleMark hm; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
848 ResourceMark rm; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
849 // Make sure we don't run with background compilation |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
850 BackgroundCompilation = false; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
851 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
852 if (ReplaySuppressInitializers > 2) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
853 // ReplaySuppressInitializers > 2 means that we want to allow |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
854 // normal VM bootstrap but once we get into the replay itself |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
855 // don't allow any intializers to be run. |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
856 ReplaySuppressInitializers = 1; |
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 |
10195
e12c9b3740db
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
10105
diff
changeset
|
859 if (FLAG_IS_DEFAULT(ReplayDataFile)) { |
e12c9b3740db
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
10105
diff
changeset
|
860 tty->print_cr("ERROR: no compiler replay data file specified (use -XX:ReplayDataFile=replay_pid12345.txt)."); |
e12c9b3740db
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
10105
diff
changeset
|
861 return 1; |
e12c9b3740db
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
10105
diff
changeset
|
862 } |
e12c9b3740db
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
10105
diff
changeset
|
863 |
6972
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
864 // Load and parse the replay data |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
865 CompileReplay rp(ReplayDataFile, THREAD); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
866 int exit_code = 0; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
867 if (rp.can_replay()) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
868 rp.process(THREAD); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
869 } else { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
870 exit_code = 1; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
871 return exit_code; |
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 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
874 if (HAS_PENDING_EXCEPTION) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
875 oop throwable = PENDING_EXCEPTION; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
876 CLEAR_PENDING_EXCEPTION; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
877 java_lang_Throwable::print(throwable, tty); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
878 tty->cr(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
879 java_lang_Throwable::print_stack_trace(throwable, tty); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
880 tty->cr(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
881 exit_code = 2; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
882 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
883 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
884 if (rp.had_error()) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
885 tty->print_cr("Failed on %s", rp.error_message()); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
886 exit_code = 1; |
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 return exit_code; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
889 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
890 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
891 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
892 void ciReplay::initialize(ciMethodData* m) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
893 if (replay_state == NULL) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
894 return; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
895 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
896 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
897 ASSERT_IN_VM; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
898 ResourceMark rm; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
899 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
900 Method* method = m->get_MethodData()->method(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
901 ciMethodDataRecord* rec = replay_state->find_ciMethodDataRecord(method); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
902 if (rec == NULL) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
903 // This indicates some mismatch with the original environment and |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
904 // the replay environment though it's not always enough to |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
905 // interfere with reproducing a bug |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
906 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
|
907 method->print_name(tty); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
908 tty->cr(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
909 } else { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
910 m->_state = rec->state; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
911 m->_current_mileage = rec->current_mileage; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
912 if (rec->data_length != 0) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
913 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
|
914 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
915 // Write the correct ciObjects back into the profile data |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
916 ciEnv* env = ciEnv::current(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
917 for (int i = 0; i < rec->oops_length; i++) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
918 KlassHandle *h = (KlassHandle *)rec->oops_handles[i]; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
919 *(ciMetadata**)(rec->data + rec->oops_offsets[i]) = |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
920 env->get_metadata((*h)()); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
921 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
922 // Copy the updated profile data into place as intptr_ts |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
923 #ifdef _LP64 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
924 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
|
925 #else |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
926 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
|
927 #endif |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
928 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
929 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
930 // copy in the original header |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
931 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
|
932 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
933 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
934 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
935 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
936 bool ciReplay::should_not_inline(ciMethod* method) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
937 if (replay_state == NULL) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
938 return false; |
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 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
941 VM_ENTRY_MARK; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
942 // ciMethod without a record shouldn't be inlined. |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
943 return replay_state->find_ciMethodRecord(method->get_Method()) == NULL; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
944 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
945 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
946 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
947 void ciReplay::initialize(ciMethod* m) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
948 if (replay_state == NULL) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
949 return; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
950 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
951 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
952 ASSERT_IN_VM; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
953 ResourceMark rm; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
954 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
955 Method* method = m->get_Method(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
956 ciMethodRecord* rec = replay_state->find_ciMethodRecord(method); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
957 if (rec == NULL) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
958 // This indicates some mismatch with the original environment and |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
959 // the replay environment though it's not always enough to |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
960 // interfere with reproducing a bug |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
961 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
|
962 method->print_name(tty); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
963 tty->cr(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
964 } else { |
10105
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8002
diff
changeset
|
965 EXCEPTION_CONTEXT; |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8002
diff
changeset
|
966 MethodCounters* mcs = method->method_counters(); |
6972
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
967 // m->_instructions_size = rec->instructions_size; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
968 m->_instructions_size = -1; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
969 m->_interpreter_invocation_count = rec->interpreter_invocation_count; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
970 m->_interpreter_throwout_count = rec->interpreter_throwout_count; |
10105
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8002
diff
changeset
|
971 if (mcs == NULL) { |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8002
diff
changeset
|
972 mcs = Method::build_method_counters(method, CHECK_AND_CLEAR); |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8002
diff
changeset
|
973 } |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8002
diff
changeset
|
974 mcs->invocation_counter()->_counter = rec->invocation_counter; |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8002
diff
changeset
|
975 mcs->backedge_counter()->_counter = rec->backedge_counter; |
6972
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
976 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
977 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
978 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
979 bool ciReplay::is_loaded(Method* method) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
980 if (replay_state == NULL) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
981 return true; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
982 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
983 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
984 ASSERT_IN_VM; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
985 ResourceMark rm; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
986 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
987 ciMethodRecord* rec = replay_state->find_ciMethodRecord(method); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
988 return rec != NULL; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
diff
changeset
|
989 } |
7185
90273fc0a981
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
6972
diff
changeset
|
990 #endif // PRODUCT |