annotate src/share/vm/ci/ciReplay.cpp @ 17912:653e11c86c5a

8041959: Skip replay parsing errors with ReplayIgnoreInitErrors Summary: Allow replay compilation with replay file parsing error. Reviewed-by: twisti, iveresov
author kvn
date Tue, 29 Apr 2014 10:29:56 -0700
parents 849eb7bfceac
children 52b4284cb496
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7623
203f64878aab 7102489: RFE: cleanup jlong typedef on __APPLE__and _LLP64 systems.
hseigel
parents: 7185
diff changeset
1 /* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
3 *
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
4 * This code is free software; you can redistribute it and/or modify it
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
5 * under the terms of the GNU General Public License version 2 only, as
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
6 * published by the Free Software Foundation.
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
7 *
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
8 * This code is distributed in the hope that it will be useful, but WITHOUT
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
11 * version 2 for more details (a copy is included in the LICENSE file that
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
12 * accompanied this code).
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
13 *
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License version
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
15 * 2 along with this work; if not, write to the Free Software Foundation,
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
17 *
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
19 * or visit www.oracle.com if you need additional information or have any
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
20 * questions.
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
21 *
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
22 */
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
23
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
24 #include "precompiled.hpp"
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
25 #include "ci/ciMethodData.hpp"
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
26 #include "ci/ciReplay.hpp"
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
27 #include "ci/ciSymbol.hpp"
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
28 #include "ci/ciKlass.hpp"
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
29 #include "ci/ciUtilities.hpp"
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
30 #include "compiler/compileBroker.hpp"
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
31 #include "memory/allocation.inline.hpp"
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
32 #include "memory/oopFactory.hpp"
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
33 #include "memory/resourceArea.hpp"
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
34 #include "utilities/copy.hpp"
8001
db9981fd3124 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 7185
diff changeset
35 #include "utilities/macros.hpp"
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
36
7185
90273fc0a981 8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents: 6972
diff changeset
37 #ifndef PRODUCT
6972
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 // ciReplay
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
40
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
41 typedef struct _ciMethodDataRecord {
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
42 const char* _klass_name;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
43 const char* _method_name;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
44 const char* _signature;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
45
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
46 int _state;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
47 int _current_mileage;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
48
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
49 intptr_t* _data;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
50 char* _orig_data;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
51 jobject* _oops_handles;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
52 int* _oops_offsets;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
53 int _data_length;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
54 int _orig_data_length;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
55 int _oops_length;
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
56 } ciMethodDataRecord;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
57
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
58 typedef struct _ciMethodRecord {
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
59 const char* _klass_name;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
60 const char* _method_name;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
61 const char* _signature;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
62
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
63 int _instructions_size;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
64 int _interpreter_invocation_count;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
65 int _interpreter_throwout_count;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
66 int _invocation_counter;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
67 int _backedge_counter;
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
68 } ciMethodRecord;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
69
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
70 typedef struct _ciInlineRecord {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
71 const char* _klass_name;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
72 const char* _method_name;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
73 const char* _signature;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
74
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
75 int _inline_depth;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
76 int _inline_bci;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
77 } ciInlineRecord;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
78
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
79 class CompileReplay;
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
80 static CompileReplay* replay_state;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
81
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
82 class CompileReplay : public StackObj {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
83 private:
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
84 FILE* _stream;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
85 Thread* _thread;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
86 Handle _protection_domain;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
87 Handle _loader;
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
88
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
89 GrowableArray<ciMethodRecord*> _ci_method_records;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
90 GrowableArray<ciMethodDataRecord*> _ci_method_data_records;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
91
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
92 // Use pointer because we may need to return inline records
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
93 // without destroying them.
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
94 GrowableArray<ciInlineRecord*>* _ci_inline_records;
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
95
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
96 const char* _error_message;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
97
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
98 char* _bufptr;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
99 char* _buffer;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
100 int _buffer_length;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
101 int _buffer_pos;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
102
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
103 // "compile" data
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
104 ciKlass* _iklass;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
105 Method* _imethod;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
106 int _entry_bci;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
107 int _comp_level;
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
108
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
109 public:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
110 CompileReplay(const char* filename, TRAPS) {
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
111 _thread = THREAD;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
112 _loader = Handle(_thread, SystemDictionary::java_system_loader());
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
113 _protection_domain = Handle();
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
114
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
115 _stream = fopen(filename, "rt");
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
116 if (_stream == NULL) {
10195
e12c9b3740db 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 10105
diff changeset
117 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
118 }
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
119
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
120 _ci_inline_records = NULL;
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
121 _error_message = NULL;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
122
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
123 _buffer_length = 32;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
124 _buffer = NEW_RESOURCE_ARRAY(char, _buffer_length);
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
125 _bufptr = _buffer;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
126 _buffer_pos = 0;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
127
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
128 _imethod = NULL;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
129 _iklass = NULL;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
130 _entry_bci = 0;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
131 _comp_level = 0;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
132
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
133 test();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
134 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
135
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
136 ~CompileReplay() {
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
137 if (_stream != NULL) fclose(_stream);
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
138 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
139
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
140 void test() {
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
141 strcpy(_buffer, "1 2 foo 4 bar 0x9 \"this is it\"");
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
142 _bufptr = _buffer;
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
143 assert(parse_int("test") == 1, "what");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
144 assert(parse_int("test") == 2, "what");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
145 assert(strcmp(parse_string(), "foo") == 0, "what");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
146 assert(parse_int("test") == 4, "what");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
147 assert(strcmp(parse_string(), "bar") == 0, "what");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
148 assert(parse_intptr_t("test") == 9, "what");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
149 assert(strcmp(parse_quoted_string(), "this is it") == 0, "what");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
150 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
151
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
152 bool had_error() {
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
153 return _error_message != NULL || _thread->has_pending_exception();
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
154 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
155
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
156 bool can_replay() {
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
157 return !(_stream == NULL || had_error());
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
158 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
159
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
160 void report_error(const char* msg) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
161 _error_message = msg;
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
162 // Restore the _buffer contents for error reporting
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
163 for (int i = 0; i < _buffer_pos; i++) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
164 if (_buffer[i] == '\0') _buffer[i] = ' ';
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
165 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
166 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
167
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
168 int parse_int(const char* label) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
169 if (had_error()) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
170 return 0;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
171 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
172
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
173 int v = 0;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
174 int read;
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
175 if (sscanf(_bufptr, "%i%n", &v, &read) != 1) {
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
176 report_error(label);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
177 } else {
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
178 _bufptr += read;
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
179 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
180 return v;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
181 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
182
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
183 intptr_t parse_intptr_t(const char* label) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
184 if (had_error()) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
185 return 0;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
186 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
187
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
188 intptr_t v = 0;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
189 int read;
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
190 if (sscanf(_bufptr, INTPTR_FORMAT "%n", &v, &read) != 1) {
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
191 report_error(label);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
192 } else {
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
193 _bufptr += read;
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
194 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
195 return v;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
196 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
197
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
198 void skip_ws() {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
199 // Skip any leading whitespace
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
200 while (*_bufptr == ' ' || *_bufptr == '\t') {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
201 _bufptr++;
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
202 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
203 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
204
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
205
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
206 char* scan_and_terminate(char delim) {
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
207 char* str = _bufptr;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
208 while (*_bufptr != delim && *_bufptr != '\0') {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
209 _bufptr++;
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
210 }
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
211 if (*_bufptr != '\0') {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
212 *_bufptr++ = '\0';
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
213 }
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
214 if (_bufptr == str) {
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
215 // nothing here
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
216 return NULL;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
217 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
218 return str;
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 char* parse_string() {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
222 if (had_error()) return NULL;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
223
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
224 skip_ws();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
225 return scan_and_terminate(' ');
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
226 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
227
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
228 char* parse_quoted_string() {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
229 if (had_error()) return NULL;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
230
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
231 skip_ws();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
232
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
233 if (*_bufptr == '"') {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
234 _bufptr++;
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
235 return scan_and_terminate('"');
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
236 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
237 return scan_and_terminate(' ');
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
238 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
239 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
240
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
241 const char* parse_escaped_string() {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
242 char* result = parse_quoted_string();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
243 if (result != NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
244 unescape_string(result);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
245 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
246 return result;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
247 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
248
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
249 // Look for the tag 'tag' followed by an
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
250 bool parse_tag_and_count(const char* tag, int& length) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
251 const char* t = parse_string();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
252 if (t == NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
253 return false;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
254 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
255
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
256 if (strcmp(tag, t) != 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
257 report_error(tag);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
258 return false;
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 length = parse_int("parse_tag_and_count");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
261 return !had_error();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
262 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
263
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
264 // 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
265 // resulting data.
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
266 char* parse_data(const char* tag, int& length) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
267 if (!parse_tag_and_count(tag, length)) {
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 char * result = NEW_RESOURCE_ARRAY(char, length);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
272 for (int i = 0; i < length; i++) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
273 int val = parse_int("data");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
274 result[i] = val;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
275 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
276 return result;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
277 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
278
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
279 // Parse a standard chunk of data emitted as:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
280 // 'tag' <length> # # ...
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
281 // Where each # is an intptr_t item
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
282 intptr_t* parse_intptr_data(const char* tag, int& length) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
283 if (!parse_tag_and_count(tag, length)) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
284 return NULL;
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
287 intptr_t* result = NEW_RESOURCE_ARRAY(intptr_t, length);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
288 for (int i = 0; i < length; i++) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
289 skip_ws();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
290 intptr_t val = parse_intptr_t("data");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
291 result[i] = val;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
292 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
293 return result;
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
296 // Parse a possibly quoted version of a symbol into a symbolOop
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
297 Symbol* parse_symbol(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
298 const char* str = parse_escaped_string();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
299 if (str != NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
300 Symbol* sym = SymbolTable::lookup(str, (int)strlen(str), CHECK_NULL);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
301 return sym;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
302 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
303 return NULL;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
304 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
305
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
306 // Parse a valid klass name and look it up
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
307 Klass* parse_klass(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
308 const char* str = parse_escaped_string();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
309 Symbol* klass_name = SymbolTable::lookup(str, (int)strlen(str), CHECK_NULL);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
310 if (klass_name != NULL) {
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
311 Klass* k = NULL;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
312 if (_iklass != NULL) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
313 k = (Klass*)_iklass->find_klass(ciSymbol::make(klass_name->as_C_string()))->constant_encoding();
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
314 } else {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
315 k = SystemDictionary::resolve_or_fail(klass_name, _loader, _protection_domain, true, THREAD);
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
316 }
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
317 if (HAS_PENDING_EXCEPTION) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
318 oop throwable = PENDING_EXCEPTION;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
319 java_lang_Throwable::print(throwable, tty);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
320 tty->cr();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
321 report_error(str);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
322 return NULL;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
323 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
324 return k;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
325 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
326 return NULL;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
327 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
328
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
329 // Lookup a klass
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
330 Klass* resolve_klass(const char* klass, TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
331 Symbol* klass_name = SymbolTable::lookup(klass, (int)strlen(klass), CHECK_NULL);
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
332 return SystemDictionary::resolve_or_fail(klass_name, _loader, _protection_domain, true, CHECK_NULL);
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
333 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
334
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
335 // Parse the standard tuple of <klass> <name> <signature>
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
336 Method* parse_method(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
337 InstanceKlass* k = (InstanceKlass*)parse_klass(CHECK_NULL);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
338 Symbol* method_name = parse_symbol(CHECK_NULL);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
339 Symbol* method_signature = parse_symbol(CHECK_NULL);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
340 Method* m = k->find_method(method_name, method_signature);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
341 if (m == NULL) {
11963
1b6395189726 8012263: ciReplay: gracefully exit & report meaningful error when replay data parsing fails
minqi
parents: 10271
diff changeset
342 report_error("Can't find method");
6972
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 return m;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
345 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
346
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
347 int get_line(int c) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
348 while(c != EOF) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
349 if (_buffer_pos + 1 >= _buffer_length) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
350 int new_length = _buffer_length * 2;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
351 // Next call will throw error in case of OOM.
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
352 _buffer = REALLOC_RESOURCE_ARRAY(char, _buffer, _buffer_length, new_length);
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
353 _buffer_length = new_length;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
354 }
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
355 if (c == '\n') {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
356 c = getc(_stream); // get next char
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
357 break;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
358 } else if (c == '\r') {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
359 // skip LF
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
360 } else {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
361 _buffer[_buffer_pos++] = c;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
362 }
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
363 c = getc(_stream);
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
364 }
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
365 // null terminate it, reset the pointer
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
366 _buffer[_buffer_pos] = '\0'; // NL or EOF
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
367 _buffer_pos = 0;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
368 _bufptr = _buffer;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
369 return c;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
370 }
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
371
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
372 // Process each line of the replay file executing each command until
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
373 // the file ends.
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
374 void process(TRAPS) {
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
375 int line_no = 1;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
376 int c = getc(_stream);
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
377 while(c != EOF) {
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
378 c = get_line(c);
17912
653e11c86c5a 8041959: Skip replay parsing errors with ReplayIgnoreInitErrors
kvn
parents: 17622
diff changeset
379 process_command(THREAD);
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
380 if (had_error()) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
381 tty->print_cr("Error while parsing line %d: %s\n", line_no, _error_message);
17912
653e11c86c5a 8041959: Skip replay parsing errors with ReplayIgnoreInitErrors
kvn
parents: 17622
diff changeset
382 if (ReplayIgnoreInitErrors) {
653e11c86c5a 8041959: Skip replay parsing errors with ReplayIgnoreInitErrors
kvn
parents: 17622
diff changeset
383 CLEAR_PENDING_EXCEPTION;
653e11c86c5a 8041959: Skip replay parsing errors with ReplayIgnoreInitErrors
kvn
parents: 17622
diff changeset
384 _error_message = NULL;
653e11c86c5a 8041959: Skip replay parsing errors with ReplayIgnoreInitErrors
kvn
parents: 17622
diff changeset
385 } else {
653e11c86c5a 8041959: Skip replay parsing errors with ReplayIgnoreInitErrors
kvn
parents: 17622
diff changeset
386 return;
653e11c86c5a 8041959: Skip replay parsing errors with ReplayIgnoreInitErrors
kvn
parents: 17622
diff changeset
387 }
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
388 }
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
389 line_no++;
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
390 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
391 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
392
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
393 void process_command(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
394 char* cmd = parse_string();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
395 if (cmd == NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
396 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
397 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
398 if (strcmp("#", cmd) == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
399 // ignore
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
400 } else if (strcmp("compile", cmd) == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
401 process_compile(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
402 } else if (strcmp("ciMethod", cmd) == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
403 process_ciMethod(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
404 } else if (strcmp("ciMethodData", cmd) == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
405 process_ciMethodData(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
406 } else if (strcmp("staticfield", cmd) == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
407 process_staticfield(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
408 } else if (strcmp("ciInstanceKlass", cmd) == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
409 process_ciInstanceKlass(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
410 } else if (strcmp("instanceKlass", cmd) == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
411 process_instanceKlass(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
412 #if INCLUDE_JVMTI
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
413 } else if (strcmp("JvmtiExport", cmd) == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
414 process_JvmtiExport(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
415 #endif // INCLUDE_JVMTI
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
416 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
417 report_error("unknown command");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
418 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
419 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
420
10197
7b23cb975cf2 8011675: adding compilation level to replay data
iignatyev
parents: 10195
diff changeset
421 // validation of comp_level
7b23cb975cf2 8011675: adding compilation level to replay data
iignatyev
parents: 10195
diff changeset
422 bool is_valid_comp_level(int comp_level) {
7b23cb975cf2 8011675: adding compilation level to replay data
iignatyev
parents: 10195
diff changeset
423 const int msg_len = 256;
7b23cb975cf2 8011675: adding compilation level to replay data
iignatyev
parents: 10195
diff changeset
424 char* msg = NULL;
7b23cb975cf2 8011675: adding compilation level to replay data
iignatyev
parents: 10195
diff changeset
425 if (!is_compile(comp_level)) {
7b23cb975cf2 8011675: adding compilation level to replay data
iignatyev
parents: 10195
diff changeset
426 msg = NEW_RESOURCE_ARRAY(char, msg_len);
7b23cb975cf2 8011675: adding compilation level to replay data
iignatyev
parents: 10195
diff changeset
427 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
428 } else if (!TieredCompilation && (comp_level != CompLevel_highest_tier)) {
7b23cb975cf2 8011675: adding compilation level to replay data
iignatyev
parents: 10195
diff changeset
429 msg = NEW_RESOURCE_ARRAY(char, msg_len);
7b23cb975cf2 8011675: adding compilation level to replay data
iignatyev
parents: 10195
diff changeset
430 switch (comp_level) {
7b23cb975cf2 8011675: adding compilation level to replay data
iignatyev
parents: 10195
diff changeset
431 case CompLevel_simple:
7b23cb975cf2 8011675: adding compilation level to replay data
iignatyev
parents: 10195
diff changeset
432 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
433 break;
7b23cb975cf2 8011675: adding compilation level to replay data
iignatyev
parents: 10195
diff changeset
434 case CompLevel_full_optimization:
7b23cb975cf2 8011675: adding compilation level to replay data
iignatyev
parents: 10195
diff changeset
435 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
436 break;
7b23cb975cf2 8011675: adding compilation level to replay data
iignatyev
parents: 10195
diff changeset
437 default:
7b23cb975cf2 8011675: adding compilation level to replay data
iignatyev
parents: 10195
diff changeset
438 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
439 }
7b23cb975cf2 8011675: adding compilation level to replay data
iignatyev
parents: 10195
diff changeset
440 }
7b23cb975cf2 8011675: adding compilation level to replay data
iignatyev
parents: 10195
diff changeset
441 if (msg != NULL) {
7b23cb975cf2 8011675: adding compilation level to replay data
iignatyev
parents: 10195
diff changeset
442 report_error(msg);
7b23cb975cf2 8011675: adding compilation level to replay data
iignatyev
parents: 10195
diff changeset
443 return false;
7b23cb975cf2 8011675: adding compilation level to replay data
iignatyev
parents: 10195
diff changeset
444 }
7b23cb975cf2 8011675: adding compilation level to replay data
iignatyev
parents: 10195
diff changeset
445 return true;
7b23cb975cf2 8011675: adding compilation level to replay data
iignatyev
parents: 10195
diff changeset
446 }
7b23cb975cf2 8011675: adding compilation level to replay data
iignatyev
parents: 10195
diff changeset
447
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
448 // compile <klass> <name> <signature> <entry_bci> <comp_level> inline <count> <depth> <bci> <klass> <name> <signature> ...
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
449 void* process_inline(ciMethod* imethod, Method* m, int entry_bci, int comp_level, TRAPS) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
450 _imethod = m;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
451 _iklass = imethod->holder();
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
452 _entry_bci = entry_bci;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
453 _comp_level = comp_level;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
454 int line_no = 1;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
455 int c = getc(_stream);
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
456 while(c != EOF) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
457 c = get_line(c);
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
458 // Expecting only lines with "compile" command in inline replay file.
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
459 char* cmd = parse_string();
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
460 if (cmd == NULL || strcmp("compile", cmd) != 0) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
461 return NULL;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
462 }
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
463 process_compile(CHECK_NULL);
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
464 if (had_error()) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
465 tty->print_cr("Error while parsing line %d: %s\n", line_no, _error_message);
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
466 tty->print_cr("%s", _buffer);
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
467 return NULL;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
468 }
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
469 if (_ci_inline_records != NULL && _ci_inline_records->length() > 0) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
470 // Found inlining record for the requested method.
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
471 return _ci_inline_records;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
472 }
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
473 line_no++;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
474 }
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
475 return NULL;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
476 }
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
477
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
478 // compile <klass> <name> <signature> <entry_bci> <comp_level> inline <count> <depth> <bci> <klass> <name> <signature> ...
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
479 void process_compile(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
480 Method* method = parse_method(CHECK);
11963
1b6395189726 8012263: ciReplay: gracefully exit & report meaningful error when replay data parsing fails
minqi
parents: 10271
diff changeset
481 if (had_error()) return;
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
482 int entry_bci = parse_int("entry_bci");
10197
7b23cb975cf2 8011675: adding compilation level to replay data
iignatyev
parents: 10195
diff changeset
483 const char* comp_level_label = "comp_level";
7b23cb975cf2 8011675: adding compilation level to replay data
iignatyev
parents: 10195
diff changeset
484 int comp_level = parse_int(comp_level_label);
7b23cb975cf2 8011675: adding compilation level to replay data
iignatyev
parents: 10195
diff changeset
485 // old version w/o comp_level
7b23cb975cf2 8011675: adding compilation level to replay data
iignatyev
parents: 10195
diff changeset
486 if (had_error() && (error_message() == comp_level_label)) {
7b23cb975cf2 8011675: adding compilation level to replay data
iignatyev
parents: 10195
diff changeset
487 comp_level = CompLevel_full_optimization;
7b23cb975cf2 8011675: adding compilation level to replay data
iignatyev
parents: 10195
diff changeset
488 }
7b23cb975cf2 8011675: adding compilation level to replay data
iignatyev
parents: 10195
diff changeset
489 if (!is_valid_comp_level(comp_level)) {
7b23cb975cf2 8011675: adding compilation level to replay data
iignatyev
parents: 10195
diff changeset
490 return;
7b23cb975cf2 8011675: adding compilation level to replay data
iignatyev
parents: 10195
diff changeset
491 }
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
492 if (_imethod != NULL) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
493 // Replay Inlining
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
494 if (entry_bci != _entry_bci || comp_level != _comp_level) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
495 return;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
496 }
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
497 const char* iklass_name = _imethod->method_holder()->name()->as_utf8();
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
498 const char* imethod_name = _imethod->name()->as_utf8();
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
499 const char* isignature = _imethod->signature()->as_utf8();
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
500 const char* klass_name = method->method_holder()->name()->as_utf8();
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
501 const char* method_name = method->name()->as_utf8();
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
502 const char* signature = method->signature()->as_utf8();
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
503 if (strcmp(iklass_name, klass_name) != 0 ||
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
504 strcmp(imethod_name, method_name) != 0 ||
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
505 strcmp(isignature, signature) != 0) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
506 return;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
507 }
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
508 }
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
509 int inline_count = 0;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
510 if (parse_tag_and_count("inline", inline_count)) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
511 // Record inlining data
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
512 _ci_inline_records = new GrowableArray<ciInlineRecord*>();
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
513 for (int i = 0; i < inline_count; i++) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
514 int depth = parse_int("inline_depth");
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
515 int bci = parse_int("inline_bci");
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
516 if (had_error()) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
517 break;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
518 }
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
519 Method* inl_method = parse_method(CHECK);
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
520 if (had_error()) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
521 break;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
522 }
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
523 new_ciInlineRecord(inl_method, bci, depth);
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
524 }
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
525 }
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
526 if (_imethod != NULL) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
527 return; // Replay Inlining
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
528 }
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
529 Klass* k = method->method_holder();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
530 ((InstanceKlass*)k)->initialize(THREAD);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
531 if (HAS_PENDING_EXCEPTION) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
532 oop throwable = PENDING_EXCEPTION;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
533 java_lang_Throwable::print(throwable, tty);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
534 tty->cr();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
535 if (ReplayIgnoreInitErrors) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
536 CLEAR_PENDING_EXCEPTION;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
537 ((InstanceKlass*)k)->set_init_state(InstanceKlass::fully_initialized);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
538 } else {
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 // 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
543 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
544 if (nm != NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
545 nm->make_not_entrant();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
546 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
547 replay_state = this;
10197
7b23cb975cf2 8011675: adding compilation level to replay data
iignatyev
parents: 10195
diff changeset
548 CompileBroker::compile_method(method, entry_bci, comp_level,
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
549 methodHandle(), 0, "replay", THREAD);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
550 replay_state = NULL;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
551 reset();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
552 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
553
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
554 // 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
555 //
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
556 //
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
557 void process_ciMethod(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
558 Method* method = parse_method(CHECK);
11963
1b6395189726 8012263: ciReplay: gracefully exit & report meaningful error when replay data parsing fails
minqi
parents: 10271
diff changeset
559 if (had_error()) return;
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
560 ciMethodRecord* rec = new_ciMethod(method);
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
561 rec->_invocation_counter = parse_int("invocation_counter");
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
562 rec->_backedge_counter = parse_int("backedge_counter");
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
563 rec->_interpreter_invocation_count = parse_int("interpreter_invocation_count");
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
564 rec->_interpreter_throwout_count = parse_int("interpreter_throwout_count");
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
565 rec->_instructions_size = parse_int("instructions_size");
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
566 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
567
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
568 // 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
569 void process_ciMethodData(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
570 Method* method = parse_method(CHECK);
11963
1b6395189726 8012263: ciReplay: gracefully exit & report meaningful error when replay data parsing fails
minqi
parents: 10271
diff changeset
571 if (had_error()) return;
17912
653e11c86c5a 8041959: Skip replay parsing errors with ReplayIgnoreInitErrors
kvn
parents: 17622
diff changeset
572 /* just copied from Method, to build interpret data*/
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
573 if (InstanceRefKlass::owns_pending_list_lock((JavaThread*)THREAD)) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
574 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
575 }
17912
653e11c86c5a 8041959: Skip replay parsing errors with ReplayIgnoreInitErrors
kvn
parents: 17622
diff changeset
576 // To be properly initialized, some profiling in the MDO needs the
653e11c86c5a 8041959: Skip replay parsing errors with ReplayIgnoreInitErrors
kvn
parents: 17622
diff changeset
577 // method to be rewritten (number of arguments at a call for
653e11c86c5a 8041959: Skip replay parsing errors with ReplayIgnoreInitErrors
kvn
parents: 17622
diff changeset
578 // instance)
653e11c86c5a 8041959: Skip replay parsing errors with ReplayIgnoreInitErrors
kvn
parents: 17622
diff changeset
579 method->method_holder()->link_class(CHECK);
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
580 // methodOopDesc::build_interpreter_method_data(method, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
581 {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
582 // Grab a lock here to prevent multiple
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
583 // MethodData*s from being created.
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
584 MutexLocker ml(MethodData_lock, THREAD);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
585 if (method->method_data() == NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
586 ClassLoaderData* loader_data = method->method_holder()->class_loader_data();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
587 MethodData* method_data = MethodData::allocate(loader_data, method, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
588 method->set_method_data(method_data);
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 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
591
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
592 // collect and record all the needed information for later
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
593 ciMethodDataRecord* rec = new_ciMethodData(method);
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
594 rec->_state = parse_int("state");
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
595 rec->_current_mileage = parse_int("current_mileage");
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
596
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
597 rec->_orig_data = parse_data("orig", rec->_orig_data_length);
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
598 if (rec->_orig_data == NULL) {
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
599 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
600 }
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
601 rec->_data = parse_intptr_data("data", rec->_data_length);
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
602 if (rec->_data == NULL) {
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
603 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
604 }
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
605 if (!parse_tag_and_count("oops", rec->_oops_length)) {
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
606 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
607 }
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
608 rec->_oops_handles = NEW_RESOURCE_ARRAY(jobject, rec->_oops_length);
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
609 rec->_oops_offsets = NEW_RESOURCE_ARRAY(int, rec->_oops_length);
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
610 for (int i = 0; i < rec->_oops_length; i++) {
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
611 int offset = parse_int("offset");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
612 if (had_error()) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
613 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
614 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
615 Klass* k = parse_klass(CHECK);
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
616 rec->_oops_offsets[i] = offset;
10271
f9be75d21404 8012902: remove use of global operator new - take 2
minqi
parents: 10197
diff changeset
617 KlassHandle *kh = NEW_C_HEAP_OBJ(KlassHandle, mtCompiler);
f9be75d21404 8012902: remove use of global operator new - take 2
minqi
parents: 10197
diff changeset
618 ::new ((void*)kh) KlassHandle(THREAD, k);
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
619 rec->_oops_handles[i] = (jobject)kh;
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
620 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
621 }
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 // instanceKlass <name>
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
624 //
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
625 // Loads and initializes the klass 'name'. This can be used to
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
626 // create particular class loading environments
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
627 void process_instanceKlass(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
628 // just load the referenced class
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
629 Klass* k = parse_klass(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
630 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
631
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
632 // ciInstanceKlass <name> <is_linked> <is_initialized> <length> tag # # # ...
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
633 //
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
634 // 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
635 // 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
636 // constant pool tags are in the same state.
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
637 void process_ciInstanceKlass(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
638 InstanceKlass* k = (InstanceKlass *)parse_klass(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
639 int is_linked = parse_int("is_linked");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
640 int is_initialized = parse_int("is_initialized");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
641 int length = parse_int("length");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
642 if (is_initialized) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
643 k->initialize(THREAD);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
644 if (HAS_PENDING_EXCEPTION) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
645 oop throwable = PENDING_EXCEPTION;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
646 java_lang_Throwable::print(throwable, tty);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
647 tty->cr();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
648 if (ReplayIgnoreInitErrors) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
649 CLEAR_PENDING_EXCEPTION;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
650 k->set_init_state(InstanceKlass::fully_initialized);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
651 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
652 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
653 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
654 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
655 } else if (is_linked) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
656 k->link_class(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
657 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
658 ConstantPool* cp = k->constants();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
659 if (length != cp->length()) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
660 report_error("constant pool length mismatch: wrong class files?");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
661 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
662 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
663
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
664 int parsed_two_word = 0;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
665 for (int i = 1; i < length; i++) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
666 int tag = parse_int("tag");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
667 if (had_error()) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
668 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
669 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
670 switch (cp->tag_at(i).value()) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
671 case JVM_CONSTANT_UnresolvedClass: {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
672 if (tag == JVM_CONSTANT_Class) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
673 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
674 Klass* k = cp->klass_at(i, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
675 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
676 break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
677 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
678 case JVM_CONSTANT_Long:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
679 case JVM_CONSTANT_Double:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
680 parsed_two_word = i + 1;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
681
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
682 case JVM_CONSTANT_ClassIndex:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
683 case JVM_CONSTANT_StringIndex:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
684 case JVM_CONSTANT_String:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
685 case JVM_CONSTANT_UnresolvedClassInError:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
686 case JVM_CONSTANT_Fieldref:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
687 case JVM_CONSTANT_Methodref:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
688 case JVM_CONSTANT_InterfaceMethodref:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
689 case JVM_CONSTANT_NameAndType:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
690 case JVM_CONSTANT_Utf8:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
691 case JVM_CONSTANT_Integer:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
692 case JVM_CONSTANT_Float:
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
693 case JVM_CONSTANT_MethodHandle:
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
694 case JVM_CONSTANT_MethodType:
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
695 case JVM_CONSTANT_InvokeDynamic:
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
696 if (tag != cp->tag_at(i).value()) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
697 report_error("tag mismatch: wrong class files?");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
698 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
699 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
700 break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
701
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
702 case JVM_CONSTANT_Class:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
703 if (tag == JVM_CONSTANT_Class) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
704 } else if (tag == JVM_CONSTANT_UnresolvedClass) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
705 tty->print_cr("Warning: entry was unresolved in the replay data");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
706 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
707 report_error("Unexpected tag");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
708 return;
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 break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
711
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
712 case 0:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
713 if (parsed_two_word == i) continue;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
714
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
715 default:
10195
e12c9b3740db 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 10105
diff changeset
716 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
717 break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
718 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
719
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
720 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
721 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
722
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
723 // 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
724 // 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
725 // static fields but it's impossible to properly rerun the static
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
726 // initiailizer.
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
727 void process_staticfield(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
728 InstanceKlass* k = (InstanceKlass *)parse_klass(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
729
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
730 if (ReplaySuppressInitializers == 0 ||
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
731 ReplaySuppressInitializers == 2 && k->class_loader() == NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
732 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
733 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
734
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
735 assert(k->is_initialized(), "must be");
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 const char* field_name = parse_escaped_string();;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
738 const char* field_signature = parse_string();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
739 fieldDescriptor fd;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
740 Symbol* name = SymbolTable::lookup(field_name, (int)strlen(field_name), CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
741 Symbol* sig = SymbolTable::lookup(field_signature, (int)strlen(field_signature), CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
742 if (!k->find_local_field(name, sig, &fd) ||
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
743 !fd.is_static() ||
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
744 fd.has_initial_value()) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
745 report_error(field_name);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
746 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
747 }
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 oop java_mirror = k->java_mirror();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
750 if (field_signature[0] == '[') {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
751 int length = parse_int("array length");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
752 oop value = NULL;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
753
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
754 if (field_signature[1] == '[') {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
755 // multi dimensional array
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
756 ArrayKlass* kelem = (ArrayKlass *)parse_klass(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
757 int rank = 0;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
758 while (field_signature[rank] == '[') {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
759 rank++;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
760 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
761 int* dims = NEW_RESOURCE_ARRAY(int, rank);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
762 dims[0] = length;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
763 for (int i = 1; i < rank; i++) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
764 dims[i] = 1; // These aren't relevant to the compiler
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
765 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
766 value = kelem->multi_allocate(rank, dims, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
767 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
768 if (strcmp(field_signature, "[B") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
769 value = oopFactory::new_byteArray(length, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
770 } else if (strcmp(field_signature, "[Z") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
771 value = oopFactory::new_boolArray(length, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
772 } else if (strcmp(field_signature, "[C") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
773 value = oopFactory::new_charArray(length, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
774 } else if (strcmp(field_signature, "[S") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
775 value = oopFactory::new_shortArray(length, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
776 } else if (strcmp(field_signature, "[F") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
777 value = oopFactory::new_singleArray(length, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
778 } else if (strcmp(field_signature, "[D") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
779 value = oopFactory::new_doubleArray(length, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
780 } else if (strcmp(field_signature, "[I") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
781 value = oopFactory::new_intArray(length, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
782 } else if (strcmp(field_signature, "[J") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
783 value = oopFactory::new_longArray(length, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
784 } else if (field_signature[0] == '[' && field_signature[1] == 'L') {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
785 KlassHandle kelem = resolve_klass(field_signature + 1, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
786 value = oopFactory::new_objArray(kelem(), length, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
787 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
788 report_error("unhandled array staticfield");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
789 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
790 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
791 java_mirror->obj_field_put(fd.offset(), value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
792 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
793 const char* string_value = parse_escaped_string();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
794 if (strcmp(field_signature, "I") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
795 int value = atoi(string_value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
796 java_mirror->int_field_put(fd.offset(), value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
797 } else if (strcmp(field_signature, "B") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
798 int value = atoi(string_value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
799 java_mirror->byte_field_put(fd.offset(), value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
800 } else if (strcmp(field_signature, "C") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
801 int value = atoi(string_value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
802 java_mirror->char_field_put(fd.offset(), value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
803 } else if (strcmp(field_signature, "S") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
804 int value = atoi(string_value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
805 java_mirror->short_field_put(fd.offset(), value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
806 } else if (strcmp(field_signature, "Z") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
807 int value = atol(string_value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
808 java_mirror->bool_field_put(fd.offset(), value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
809 } else if (strcmp(field_signature, "J") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
810 jlong value;
7623
203f64878aab 7102489: RFE: cleanup jlong typedef on __APPLE__and _LLP64 systems.
hseigel
parents: 7185
diff changeset
811 if (sscanf(string_value, JLONG_FORMAT, &value) != 1) {
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
812 fprintf(stderr, "Error parsing long: %s\n", string_value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
813 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
814 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
815 java_mirror->long_field_put(fd.offset(), value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
816 } else if (strcmp(field_signature, "F") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
817 float value = atof(string_value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
818 java_mirror->float_field_put(fd.offset(), value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
819 } else if (strcmp(field_signature, "D") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
820 double value = atof(string_value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
821 java_mirror->double_field_put(fd.offset(), value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
822 } else if (strcmp(field_signature, "Ljava/lang/String;") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
823 Handle value = java_lang_String::create_from_str(string_value, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
824 java_mirror->obj_field_put(fd.offset(), value());
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
825 } else if (field_signature[0] == 'L') {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
826 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
827 KlassHandle kelem = resolve_klass(field_signature, CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
828 oop value = ((InstanceKlass*)kelem())->allocate_instance(CHECK);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
829 java_mirror->obj_field_put(fd.offset(), value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
830 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
831 report_error("unhandled staticfield");
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 }
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 #if INCLUDE_JVMTI
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
837 void process_JvmtiExport(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
838 const char* field = parse_string();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
839 bool value = parse_int("JvmtiExport flag") != 0;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
840 if (strcmp(field, "can_access_local_variables") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
841 JvmtiExport::set_can_access_local_variables(value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
842 } else if (strcmp(field, "can_hotswap_or_post_breakpoint") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
843 JvmtiExport::set_can_hotswap_or_post_breakpoint(value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
844 } else if (strcmp(field, "can_post_on_exceptions") == 0) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
845 JvmtiExport::set_can_post_on_exceptions(value);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
846 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
847 report_error("Unrecognized JvmtiExport directive");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
848 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
849 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
850 #endif // INCLUDE_JVMTI
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 // Create and initialize a record for a ciMethod
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
853 ciMethodRecord* new_ciMethod(Method* method) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
854 ciMethodRecord* rec = NEW_RESOURCE_OBJ(ciMethodRecord);
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
855 rec->_klass_name = method->method_holder()->name()->as_utf8();
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
856 rec->_method_name = method->name()->as_utf8();
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
857 rec->_signature = method->signature()->as_utf8();
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
858 _ci_method_records.append(rec);
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
859 return rec;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
860 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
861
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
862 // Lookup data for a ciMethod
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
863 ciMethodRecord* find_ciMethodRecord(Method* method) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
864 const char* klass_name = method->method_holder()->name()->as_utf8();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
865 const char* method_name = method->name()->as_utf8();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
866 const char* signature = method->signature()->as_utf8();
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
867 for (int i = 0; i < _ci_method_records.length(); i++) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
868 ciMethodRecord* rec = _ci_method_records.at(i);
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
869 if (strcmp(rec->_klass_name, klass_name) == 0 &&
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
870 strcmp(rec->_method_name, method_name) == 0 &&
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
871 strcmp(rec->_signature, signature) == 0) {
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
872 return rec;
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 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
875 return NULL;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
876 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
877
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
878 // Create and initialize a record for a ciMethodData
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
879 ciMethodDataRecord* new_ciMethodData(Method* method) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
880 ciMethodDataRecord* rec = NEW_RESOURCE_OBJ(ciMethodDataRecord);
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
881 rec->_klass_name = method->method_holder()->name()->as_utf8();
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
882 rec->_method_name = method->name()->as_utf8();
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
883 rec->_signature = method->signature()->as_utf8();
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
884 _ci_method_data_records.append(rec);
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
885 return rec;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
886 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
887
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
888 // Lookup data for a ciMethodData
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
889 ciMethodDataRecord* find_ciMethodDataRecord(Method* method) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
890 const char* klass_name = method->method_holder()->name()->as_utf8();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
891 const char* method_name = method->name()->as_utf8();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
892 const char* signature = method->signature()->as_utf8();
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
893 for (int i = 0; i < _ci_method_data_records.length(); i++) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
894 ciMethodDataRecord* rec = _ci_method_data_records.at(i);
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
895 if (strcmp(rec->_klass_name, klass_name) == 0 &&
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
896 strcmp(rec->_method_name, method_name) == 0 &&
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
897 strcmp(rec->_signature, signature) == 0) {
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
898 return rec;
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 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
901 return NULL;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
902 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
903
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
904 // Create and initialize a record for a ciInlineRecord
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
905 ciInlineRecord* new_ciInlineRecord(Method* method, int bci, int depth) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
906 ciInlineRecord* rec = NEW_RESOURCE_OBJ(ciInlineRecord);
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
907 rec->_klass_name = method->method_holder()->name()->as_utf8();
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
908 rec->_method_name = method->name()->as_utf8();
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
909 rec->_signature = method->signature()->as_utf8();
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
910 rec->_inline_bci = bci;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
911 rec->_inline_depth = depth;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
912 _ci_inline_records->append(rec);
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
913 return rec;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
914 }
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
915
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
916 // Lookup inlining data for a ciMethod
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
917 ciInlineRecord* find_ciInlineRecord(Method* method, int bci, int depth) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
918 if (_ci_inline_records != NULL) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
919 return find_ciInlineRecord(_ci_inline_records, method, bci, depth);
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
920 }
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
921 return NULL;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
922 }
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
923
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
924 static ciInlineRecord* find_ciInlineRecord(GrowableArray<ciInlineRecord*>* records,
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
925 Method* method, int bci, int depth) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
926 if (records != NULL) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
927 const char* klass_name = method->method_holder()->name()->as_utf8();
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
928 const char* method_name = method->name()->as_utf8();
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
929 const char* signature = method->signature()->as_utf8();
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
930 for (int i = 0; i < records->length(); i++) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
931 ciInlineRecord* rec = records->at(i);
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
932 if ((rec->_inline_bci == bci) &&
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
933 (rec->_inline_depth == depth) &&
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
934 (strcmp(rec->_klass_name, klass_name) == 0) &&
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
935 (strcmp(rec->_method_name, method_name) == 0) &&
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
936 (strcmp(rec->_signature, signature) == 0)) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
937 return rec;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
938 }
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
939 }
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
940 }
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
941 return NULL;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
942 }
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
943
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
944 const char* error_message() {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
945 return _error_message;
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
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
948 void reset() {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
949 _error_message = NULL;
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
950 _ci_method_records.clear();
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
951 _ci_method_data_records.clear();
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
952 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
953
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
954 // 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
955 // in place.
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
956 static void unescape_string(char* value) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
957 char* from = value;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
958 char* to = value;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
959 while (*from != '\0') {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
960 if (*from != '\\') {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
961 *from++ = *to++;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
962 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
963 switch (from[1]) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
964 case 'u': {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
965 from += 2;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
966 jchar value=0;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
967 for (int i=0; i<4; i++) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
968 char c = *from++;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
969 switch (c) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
970 case '0': case '1': case '2': case '3': case '4':
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
971 case '5': case '6': case '7': case '8': case '9':
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
972 value = (value << 4) + c - '0';
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
973 break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
974 case 'a': case 'b': case 'c':
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
975 case 'd': case 'e': case 'f':
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
976 value = (value << 4) + 10 + c - 'a';
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
977 break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
978 case 'A': case 'B': case 'C':
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
979 case 'D': case 'E': case 'F':
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
980 value = (value << 4) + 10 + c - 'A';
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
981 break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
982 default:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
983 ShouldNotReachHere();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
984 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
985 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
986 UNICODE::convert_to_utf8(&value, 1, to);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
987 to++;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
988 break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
989 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
990 case 't': *to++ = '\t'; from += 2; break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
991 case 'n': *to++ = '\n'; from += 2; break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
992 case 'r': *to++ = '\r'; from += 2; break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
993 case 'f': *to++ = '\f'; from += 2; break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
994 default:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
995 ShouldNotReachHere();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
996 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
997 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
998 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
999 *from = *to;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1000 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1001 };
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1002
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1003 void ciReplay::replay(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1004 int exit_code = replay_impl(THREAD);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1005
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1006 Threads::destroy_vm();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1007
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1008 vm_exit(exit_code);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1009 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1010
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1011 void* ciReplay::load_inline_data(ciMethod* method, int entry_bci, int comp_level) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1012 if (FLAG_IS_DEFAULT(InlineDataFile)) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1013 tty->print_cr("ERROR: no inline replay data file specified (use -XX:InlineDataFile=inline_pid12345.txt).");
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1014 return NULL;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1015 }
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1016
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1017 VM_ENTRY_MARK;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1018 // Load and parse the replay data
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1019 CompileReplay rp(InlineDataFile, THREAD);
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1020 if (!rp.can_replay()) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1021 tty->print_cr("ciReplay: !rp.can_replay()");
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1022 return NULL;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1023 }
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1024 void* data = rp.process_inline(method, method->get_Method(), entry_bci, comp_level, THREAD);
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1025 if (HAS_PENDING_EXCEPTION) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1026 oop throwable = PENDING_EXCEPTION;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1027 CLEAR_PENDING_EXCEPTION;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1028 java_lang_Throwable::print(throwable, tty);
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1029 tty->cr();
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1030 java_lang_Throwable::print_stack_trace(throwable, tty);
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1031 tty->cr();
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1032 return NULL;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1033 }
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1034
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1035 if (rp.had_error()) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1036 tty->print_cr("ciReplay: Failed on %s", rp.error_message());
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1037 return NULL;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1038 }
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1039 return data;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1040 }
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1041
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1042 int ciReplay::replay_impl(TRAPS) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1043 HandleMark hm;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1044 ResourceMark rm;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1045 // Make sure we don't run with background compilation
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1046 BackgroundCompilation = false;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1047
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1048 if (ReplaySuppressInitializers > 2) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1049 // ReplaySuppressInitializers > 2 means that we want to allow
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1050 // normal VM bootstrap but once we get into the replay itself
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1051 // don't allow any intializers to be run.
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1052 ReplaySuppressInitializers = 1;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1053 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1054
10195
e12c9b3740db 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 10105
diff changeset
1055 if (FLAG_IS_DEFAULT(ReplayDataFile)) {
e12c9b3740db 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 10105
diff changeset
1056 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
1057 return 1;
e12c9b3740db 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 10105
diff changeset
1058 }
e12c9b3740db 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 10105
diff changeset
1059
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1060 // Load and parse the replay data
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1061 CompileReplay rp(ReplayDataFile, THREAD);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1062 int exit_code = 0;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1063 if (rp.can_replay()) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1064 rp.process(THREAD);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1065 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1066 exit_code = 1;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1067 return exit_code;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1068 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1069
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1070 if (HAS_PENDING_EXCEPTION) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1071 oop throwable = PENDING_EXCEPTION;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1072 CLEAR_PENDING_EXCEPTION;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1073 java_lang_Throwable::print(throwable, tty);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1074 tty->cr();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1075 java_lang_Throwable::print_stack_trace(throwable, tty);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1076 tty->cr();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1077 exit_code = 2;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1078 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1079
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1080 if (rp.had_error()) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1081 tty->print_cr("Failed on %s", rp.error_message());
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1082 exit_code = 1;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1083 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1084 return exit_code;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1085 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1086
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1087 void ciReplay::initialize(ciMethodData* m) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1088 if (replay_state == NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1089 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1090 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1091
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1092 ASSERT_IN_VM;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1093 ResourceMark rm;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1094
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1095 Method* method = m->get_MethodData()->method();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1096 ciMethodDataRecord* rec = replay_state->find_ciMethodDataRecord(method);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1097 if (rec == NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1098 // This indicates some mismatch with the original environment and
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1099 // the replay environment though it's not always enough to
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1100 // interfere with reproducing a bug
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1101 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
1102 method->print_name(tty);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1103 tty->cr();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1104 } else {
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1105 m->_state = rec->_state;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1106 m->_current_mileage = rec->_current_mileage;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1107 if (rec->_data_length != 0) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1108 assert(m->_data_size == rec->_data_length * (int)sizeof(rec->_data[0]), "must agree");
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1109
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1110 // Write the correct ciObjects back into the profile data
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1111 ciEnv* env = ciEnv::current();
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1112 for (int i = 0; i < rec->_oops_length; i++) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1113 KlassHandle *h = (KlassHandle *)rec->_oops_handles[i];
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1114 *(ciMetadata**)(rec->_data + rec->_oops_offsets[i]) =
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1115 env->get_metadata((*h)());
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1116 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1117 // Copy the updated profile data into place as intptr_ts
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1118 #ifdef _LP64
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1119 Copy::conjoint_jlongs_atomic((jlong *)rec->_data, (jlong *)m->_data, rec->_data_length);
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1120 #else
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1121 Copy::conjoint_jints_atomic((jint *)rec->_data, (jint *)m->_data, rec->_data_length);
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1122 #endif
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1123 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1124
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1125 // copy in the original header
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1126 Copy::conjoint_jbytes(rec->_orig_data, (char*)&m->_orig, rec->_orig_data_length);
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1127 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1128 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1129
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1130
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1131 bool ciReplay::should_not_inline(ciMethod* method) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1132 if (replay_state == NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1133 return false;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1134 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1135 VM_ENTRY_MARK;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1136 // ciMethod without a record shouldn't be inlined.
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1137 return replay_state->find_ciMethodRecord(method->get_Method()) == NULL;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1138 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1139
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1140 bool ciReplay::should_inline(void* data, ciMethod* method, int bci, int inline_depth) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1141 if (data != NULL) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1142 GrowableArray<ciInlineRecord*>* records = (GrowableArray<ciInlineRecord*>*)data;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1143 VM_ENTRY_MARK;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1144 // Inline record are ordered by bci and depth.
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1145 return CompileReplay::find_ciInlineRecord(records, method->get_Method(), bci, inline_depth) != NULL;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1146 } else if (replay_state != NULL) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1147 VM_ENTRY_MARK;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1148 // Inline record are ordered by bci and depth.
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1149 return replay_state->find_ciInlineRecord(method->get_Method(), bci, inline_depth) != NULL;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1150 }
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1151 return false;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1152 }
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1153
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1154 bool ciReplay::should_not_inline(void* data, ciMethod* method, int bci, int inline_depth) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1155 if (data != NULL) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1156 GrowableArray<ciInlineRecord*>* records = (GrowableArray<ciInlineRecord*>*)data;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1157 VM_ENTRY_MARK;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1158 // Inline record are ordered by bci and depth.
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1159 return CompileReplay::find_ciInlineRecord(records, method->get_Method(), bci, inline_depth) == NULL;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1160 } else if (replay_state != NULL) {
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1161 VM_ENTRY_MARK;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1162 // Inline record are ordered by bci and depth.
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1163 return replay_state->find_ciInlineRecord(method->get_Method(), bci, inline_depth) == NULL;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1164 }
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1165 return false;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1166 }
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1167
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1168 void ciReplay::initialize(ciMethod* m) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1169 if (replay_state == NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1170 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1171 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1172
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1173 ASSERT_IN_VM;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1174 ResourceMark rm;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1175
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1176 Method* method = m->get_Method();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1177 ciMethodRecord* rec = replay_state->find_ciMethodRecord(method);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1178 if (rec == NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1179 // This indicates some mismatch with the original environment and
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1180 // the replay environment though it's not always enough to
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1181 // interfere with reproducing a bug
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1182 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
1183 method->print_name(tty);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1184 tty->cr();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1185 } else {
10105
aeaca88565e6 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 8002
diff changeset
1186 EXCEPTION_CONTEXT;
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1187 // m->_instructions_size = rec->_instructions_size;
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1188 m->_instructions_size = -1;
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1189 m->_interpreter_invocation_count = rec->_interpreter_invocation_count;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1190 m->_interpreter_throwout_count = rec->_interpreter_throwout_count;
12868
c775af091fe9 8025566: EXCEPTION_ACCESS_VIOLATION in compiled by C1 String.valueOf method
twisti
parents: 11963
diff changeset
1191 MethodCounters* mcs = method->get_method_counters(CHECK_AND_CLEAR);
c775af091fe9 8025566: EXCEPTION_ACCESS_VIOLATION in compiled by C1 String.valueOf method
twisti
parents: 11963
diff changeset
1192 guarantee(mcs != NULL, "method counters allocation failed");
17622
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1193 mcs->invocation_counter()->_counter = rec->_invocation_counter;
849eb7bfceac 8028468: Add inlining information into ciReplay
kvn
parents: 12868
diff changeset
1194 mcs->backedge_counter()->_counter = rec->_backedge_counter;
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1195 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1196 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1197
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1198 bool ciReplay::is_loaded(Method* method) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1199 if (replay_state == NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1200 return true;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1201 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1202
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1203 ASSERT_IN_VM;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1204 ResourceMark rm;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1205
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1206 ciMethodRecord* rec = replay_state->find_ciMethodRecord(method);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1207 return rec != NULL;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
1208 }
7185
90273fc0a981 8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents: 6972
diff changeset
1209 #endif // PRODUCT