annotate src/share/vm/compiler/compilerOracle.cpp @ 1994:6cd6d394f280

7001033: assert(gch->gc_cause() == GCCause::_scavenge_alot || !gch->incremental_collection_failed()) 7002546: regression on SpecJbb2005 on 7b118 comparing to 7b117 on small heaps Summary: Relaxed assertion checking related to incremental_collection_failed flag to allow for ExplicitGCInvokesConcurrent behaviour where we do not want a failing scavenge to bail to a stop-world collection. Parameterized incremental_collection_will_fail() so we can selectively use, or not use, as appropriate, the statistical prediction at specific use sites. This essentially reverts the scavenge bail-out logic to what it was prior to some recent changes that had inadvertently started using the statistical prediction which can be noisy in the presence of bursty loads. Added some associated verbose non-product debugging messages. Reviewed-by: johnc, tonyp
author ysr
date Tue, 07 Dec 2010 21:55:53 -0800
parents f95d63e2154a
children 781072b12368
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
2 * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1155
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1155
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1155
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #include "compiler/compilerOracle.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27 #include "memory/allocation.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "memory/oopFactory.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "memory/resourceArea.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "oops/klass.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #include "oops/methodOop.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32 #include "oops/oop.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
33 #include "oops/symbolOop.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
34 #include "runtime/handles.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
35 #include "runtime/jniHandles.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 class MethodMatcher : public CHeapObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
38 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
39 enum Mode {
a61af66fc99e Initial load
duke
parents:
diff changeset
40 Exact,
a61af66fc99e Initial load
duke
parents:
diff changeset
41 Prefix = 1,
a61af66fc99e Initial load
duke
parents:
diff changeset
42 Suffix = 2,
a61af66fc99e Initial load
duke
parents:
diff changeset
43 Substring = Prefix | Suffix,
a61af66fc99e Initial load
duke
parents:
diff changeset
44 Any,
a61af66fc99e Initial load
duke
parents:
diff changeset
45 Unknown = -1
a61af66fc99e Initial load
duke
parents:
diff changeset
46 };
a61af66fc99e Initial load
duke
parents:
diff changeset
47
a61af66fc99e Initial load
duke
parents:
diff changeset
48 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
49 jobject _class_name;
a61af66fc99e Initial load
duke
parents:
diff changeset
50 Mode _class_mode;
a61af66fc99e Initial load
duke
parents:
diff changeset
51 jobject _method_name;
a61af66fc99e Initial load
duke
parents:
diff changeset
52 Mode _method_mode;
a61af66fc99e Initial load
duke
parents:
diff changeset
53 jobject _signature;
a61af66fc99e Initial load
duke
parents:
diff changeset
54 MethodMatcher* _next;
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 static bool match(symbolHandle candidate, symbolHandle match, Mode match_mode);
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 symbolHandle class_name() const { return (symbolOop)JNIHandles::resolve_non_null(_class_name); }
a61af66fc99e Initial load
duke
parents:
diff changeset
59 symbolHandle method_name() const { return (symbolOop)JNIHandles::resolve_non_null(_method_name); }
a61af66fc99e Initial load
duke
parents:
diff changeset
60 symbolHandle signature() const { return (symbolOop)JNIHandles::resolve(_signature); }
a61af66fc99e Initial load
duke
parents:
diff changeset
61
a61af66fc99e Initial load
duke
parents:
diff changeset
62 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
63 MethodMatcher(symbolHandle class_name, Mode class_mode,
a61af66fc99e Initial load
duke
parents:
diff changeset
64 symbolHandle method_name, Mode method_mode,
a61af66fc99e Initial load
duke
parents:
diff changeset
65 symbolHandle signature, MethodMatcher* next);
a61af66fc99e Initial load
duke
parents:
diff changeset
66 MethodMatcher(symbolHandle class_name, symbolHandle method_name, MethodMatcher* next);
a61af66fc99e Initial load
duke
parents:
diff changeset
67
a61af66fc99e Initial load
duke
parents:
diff changeset
68 // utility method
a61af66fc99e Initial load
duke
parents:
diff changeset
69 MethodMatcher* find(methodHandle method) {
a61af66fc99e Initial load
duke
parents:
diff changeset
70 symbolHandle class_name = Klass::cast(method->method_holder())->name();
a61af66fc99e Initial load
duke
parents:
diff changeset
71 symbolHandle method_name = method->name();
a61af66fc99e Initial load
duke
parents:
diff changeset
72 for (MethodMatcher* current = this; current != NULL; current = current->_next) {
a61af66fc99e Initial load
duke
parents:
diff changeset
73 if (match(class_name, current->class_name(), current->_class_mode) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
74 match(method_name, current->method_name(), current->_method_mode) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
75 (current->signature().is_null() || current->signature()() == method->signature())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
76 return current;
a61af66fc99e Initial load
duke
parents:
diff changeset
77 }
a61af66fc99e Initial load
duke
parents:
diff changeset
78 }
a61af66fc99e Initial load
duke
parents:
diff changeset
79 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
80 }
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 bool match(methodHandle method) {
a61af66fc99e Initial load
duke
parents:
diff changeset
83 return find(method) != NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
84 }
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 MethodMatcher* next() const { return _next; }
a61af66fc99e Initial load
duke
parents:
diff changeset
87
a61af66fc99e Initial load
duke
parents:
diff changeset
88 static void print_symbol(symbolHandle h, Mode mode) {
a61af66fc99e Initial load
duke
parents:
diff changeset
89 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 if (mode == Suffix || mode == Substring || mode == Any) {
a61af66fc99e Initial load
duke
parents:
diff changeset
92 tty->print("*");
a61af66fc99e Initial load
duke
parents:
diff changeset
93 }
a61af66fc99e Initial load
duke
parents:
diff changeset
94 if (mode != Any) {
a61af66fc99e Initial load
duke
parents:
diff changeset
95 h()->print_symbol_on(tty);
a61af66fc99e Initial load
duke
parents:
diff changeset
96 }
a61af66fc99e Initial load
duke
parents:
diff changeset
97 if (mode == Prefix || mode == Substring) {
a61af66fc99e Initial load
duke
parents:
diff changeset
98 tty->print("*");
a61af66fc99e Initial load
duke
parents:
diff changeset
99 }
a61af66fc99e Initial load
duke
parents:
diff changeset
100 }
a61af66fc99e Initial load
duke
parents:
diff changeset
101
a61af66fc99e Initial load
duke
parents:
diff changeset
102 void print_base() {
a61af66fc99e Initial load
duke
parents:
diff changeset
103 print_symbol(class_name(), _class_mode);
a61af66fc99e Initial load
duke
parents:
diff changeset
104 tty->print(".");
a61af66fc99e Initial load
duke
parents:
diff changeset
105 print_symbol(method_name(), _method_mode);
a61af66fc99e Initial load
duke
parents:
diff changeset
106 if (!signature().is_null()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
107 tty->print(" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
108 signature()->print_symbol_on(tty);
a61af66fc99e Initial load
duke
parents:
diff changeset
109 }
a61af66fc99e Initial load
duke
parents:
diff changeset
110 }
a61af66fc99e Initial load
duke
parents:
diff changeset
111
a61af66fc99e Initial load
duke
parents:
diff changeset
112 virtual void print() {
a61af66fc99e Initial load
duke
parents:
diff changeset
113 print_base();
a61af66fc99e Initial load
duke
parents:
diff changeset
114 tty->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
115 }
a61af66fc99e Initial load
duke
parents:
diff changeset
116 };
a61af66fc99e Initial load
duke
parents:
diff changeset
117
a61af66fc99e Initial load
duke
parents:
diff changeset
118 MethodMatcher::MethodMatcher(symbolHandle class_name, symbolHandle method_name, MethodMatcher* next) {
a61af66fc99e Initial load
duke
parents:
diff changeset
119 _class_name = JNIHandles::make_global(class_name);
a61af66fc99e Initial load
duke
parents:
diff changeset
120 _method_name = JNIHandles::make_global(method_name);
a61af66fc99e Initial load
duke
parents:
diff changeset
121 _next = next;
a61af66fc99e Initial load
duke
parents:
diff changeset
122 _class_mode = MethodMatcher::Exact;
a61af66fc99e Initial load
duke
parents:
diff changeset
123 _method_mode = MethodMatcher::Exact;
a61af66fc99e Initial load
duke
parents:
diff changeset
124 _signature = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
125 }
a61af66fc99e Initial load
duke
parents:
diff changeset
126
a61af66fc99e Initial load
duke
parents:
diff changeset
127
a61af66fc99e Initial load
duke
parents:
diff changeset
128 MethodMatcher::MethodMatcher(symbolHandle class_name, Mode class_mode,
a61af66fc99e Initial load
duke
parents:
diff changeset
129 symbolHandle method_name, Mode method_mode,
a61af66fc99e Initial load
duke
parents:
diff changeset
130 symbolHandle signature, MethodMatcher* next):
a61af66fc99e Initial load
duke
parents:
diff changeset
131 _class_mode(class_mode)
a61af66fc99e Initial load
duke
parents:
diff changeset
132 , _method_mode(method_mode)
a61af66fc99e Initial load
duke
parents:
diff changeset
133 , _next(next)
a61af66fc99e Initial load
duke
parents:
diff changeset
134 , _class_name(JNIHandles::make_global(class_name()))
a61af66fc99e Initial load
duke
parents:
diff changeset
135 , _method_name(JNIHandles::make_global(method_name()))
a61af66fc99e Initial load
duke
parents:
diff changeset
136 , _signature(JNIHandles::make_global(signature())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
137 }
a61af66fc99e Initial load
duke
parents:
diff changeset
138
a61af66fc99e Initial load
duke
parents:
diff changeset
139 bool MethodMatcher::match(symbolHandle candidate, symbolHandle match, Mode match_mode) {
a61af66fc99e Initial load
duke
parents:
diff changeset
140 if (match_mode == Any) {
a61af66fc99e Initial load
duke
parents:
diff changeset
141 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
142 }
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 if (match_mode == Exact) {
a61af66fc99e Initial load
duke
parents:
diff changeset
145 return candidate() == match();
a61af66fc99e Initial load
duke
parents:
diff changeset
146 }
a61af66fc99e Initial load
duke
parents:
diff changeset
147
a61af66fc99e Initial load
duke
parents:
diff changeset
148 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
149 const char * candidate_string = candidate->as_C_string();
a61af66fc99e Initial load
duke
parents:
diff changeset
150 const char * match_string = match->as_C_string();
a61af66fc99e Initial load
duke
parents:
diff changeset
151
a61af66fc99e Initial load
duke
parents:
diff changeset
152 switch (match_mode) {
a61af66fc99e Initial load
duke
parents:
diff changeset
153 case Prefix:
a61af66fc99e Initial load
duke
parents:
diff changeset
154 return strstr(candidate_string, match_string) == candidate_string;
a61af66fc99e Initial load
duke
parents:
diff changeset
155
a61af66fc99e Initial load
duke
parents:
diff changeset
156 case Suffix: {
a61af66fc99e Initial load
duke
parents:
diff changeset
157 size_t clen = strlen(candidate_string);
a61af66fc99e Initial load
duke
parents:
diff changeset
158 size_t mlen = strlen(match_string);
a61af66fc99e Initial load
duke
parents:
diff changeset
159 return clen >= mlen && strcmp(candidate_string + clen - mlen, match_string) == 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
160 }
a61af66fc99e Initial load
duke
parents:
diff changeset
161
a61af66fc99e Initial load
duke
parents:
diff changeset
162 case Substring:
a61af66fc99e Initial load
duke
parents:
diff changeset
163 return strstr(candidate_string, match_string) != NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
164
a61af66fc99e Initial load
duke
parents:
diff changeset
165 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
166 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
167 }
a61af66fc99e Initial load
duke
parents:
diff changeset
168 }
a61af66fc99e Initial load
duke
parents:
diff changeset
169
a61af66fc99e Initial load
duke
parents:
diff changeset
170
a61af66fc99e Initial load
duke
parents:
diff changeset
171 class MethodOptionMatcher: public MethodMatcher {
a61af66fc99e Initial load
duke
parents:
diff changeset
172 const char * option;
a61af66fc99e Initial load
duke
parents:
diff changeset
173 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
174 MethodOptionMatcher(symbolHandle class_name, Mode class_mode,
a61af66fc99e Initial load
duke
parents:
diff changeset
175 symbolHandle method_name, Mode method_mode,
a61af66fc99e Initial load
duke
parents:
diff changeset
176 symbolHandle signature, const char * opt, MethodMatcher* next):
a61af66fc99e Initial load
duke
parents:
diff changeset
177 MethodMatcher(class_name, class_mode, method_name, method_mode, signature, next) {
a61af66fc99e Initial load
duke
parents:
diff changeset
178 option = opt;
a61af66fc99e Initial load
duke
parents:
diff changeset
179 }
a61af66fc99e Initial load
duke
parents:
diff changeset
180
a61af66fc99e Initial load
duke
parents:
diff changeset
181 bool match(methodHandle method, const char* opt) {
a61af66fc99e Initial load
duke
parents:
diff changeset
182 MethodOptionMatcher* current = this;
a61af66fc99e Initial load
duke
parents:
diff changeset
183 while (current != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
184 current = (MethodOptionMatcher*)current->find(method);
a61af66fc99e Initial load
duke
parents:
diff changeset
185 if (current == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
186 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
187 }
a61af66fc99e Initial load
duke
parents:
diff changeset
188 if (strcmp(current->option, opt) == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
189 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
190 }
a61af66fc99e Initial load
duke
parents:
diff changeset
191 current = current->next();
a61af66fc99e Initial load
duke
parents:
diff changeset
192 }
a61af66fc99e Initial load
duke
parents:
diff changeset
193 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
194 }
a61af66fc99e Initial load
duke
parents:
diff changeset
195
a61af66fc99e Initial load
duke
parents:
diff changeset
196 MethodOptionMatcher* next() {
a61af66fc99e Initial load
duke
parents:
diff changeset
197 return (MethodOptionMatcher*)_next;
a61af66fc99e Initial load
duke
parents:
diff changeset
198 }
a61af66fc99e Initial load
duke
parents:
diff changeset
199
a61af66fc99e Initial load
duke
parents:
diff changeset
200 virtual void print() {
a61af66fc99e Initial load
duke
parents:
diff changeset
201 print_base();
a61af66fc99e Initial load
duke
parents:
diff changeset
202 tty->print(" %s", option);
a61af66fc99e Initial load
duke
parents:
diff changeset
203 tty->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
204 }
a61af66fc99e Initial load
duke
parents:
diff changeset
205 };
a61af66fc99e Initial load
duke
parents:
diff changeset
206
a61af66fc99e Initial load
duke
parents:
diff changeset
207
a61af66fc99e Initial load
duke
parents:
diff changeset
208
a61af66fc99e Initial load
duke
parents:
diff changeset
209 // this must parallel the command_names below
a61af66fc99e Initial load
duke
parents:
diff changeset
210 enum OracleCommand {
a61af66fc99e Initial load
duke
parents:
diff changeset
211 UnknownCommand = -1,
a61af66fc99e Initial load
duke
parents:
diff changeset
212 OracleFirstCommand = 0,
a61af66fc99e Initial load
duke
parents:
diff changeset
213 BreakCommand = OracleFirstCommand,
a61af66fc99e Initial load
duke
parents:
diff changeset
214 PrintCommand,
a61af66fc99e Initial load
duke
parents:
diff changeset
215 ExcludeCommand,
a61af66fc99e Initial load
duke
parents:
diff changeset
216 InlineCommand,
a61af66fc99e Initial load
duke
parents:
diff changeset
217 DontInlineCommand,
a61af66fc99e Initial load
duke
parents:
diff changeset
218 CompileOnlyCommand,
a61af66fc99e Initial load
duke
parents:
diff changeset
219 LogCommand,
a61af66fc99e Initial load
duke
parents:
diff changeset
220 OptionCommand,
a61af66fc99e Initial load
duke
parents:
diff changeset
221 QuietCommand,
a61af66fc99e Initial load
duke
parents:
diff changeset
222 HelpCommand,
a61af66fc99e Initial load
duke
parents:
diff changeset
223 OracleCommandCount
a61af66fc99e Initial load
duke
parents:
diff changeset
224 };
a61af66fc99e Initial load
duke
parents:
diff changeset
225
a61af66fc99e Initial load
duke
parents:
diff changeset
226 // this must parallel the enum OracleCommand
a61af66fc99e Initial load
duke
parents:
diff changeset
227 static const char * command_names[] = {
a61af66fc99e Initial load
duke
parents:
diff changeset
228 "break",
a61af66fc99e Initial load
duke
parents:
diff changeset
229 "print",
a61af66fc99e Initial load
duke
parents:
diff changeset
230 "exclude",
a61af66fc99e Initial load
duke
parents:
diff changeset
231 "inline",
a61af66fc99e Initial load
duke
parents:
diff changeset
232 "dontinline",
a61af66fc99e Initial load
duke
parents:
diff changeset
233 "compileonly",
a61af66fc99e Initial load
duke
parents:
diff changeset
234 "log",
a61af66fc99e Initial load
duke
parents:
diff changeset
235 "option",
a61af66fc99e Initial load
duke
parents:
diff changeset
236 "quiet",
a61af66fc99e Initial load
duke
parents:
diff changeset
237 "help"
a61af66fc99e Initial load
duke
parents:
diff changeset
238 };
a61af66fc99e Initial load
duke
parents:
diff changeset
239
a61af66fc99e Initial load
duke
parents:
diff changeset
240 static const char * command_name(OracleCommand command) {
a61af66fc99e Initial load
duke
parents:
diff changeset
241 if (command < OracleFirstCommand || command >= OracleCommandCount) {
a61af66fc99e Initial load
duke
parents:
diff changeset
242 return "unknown command";
a61af66fc99e Initial load
duke
parents:
diff changeset
243 }
a61af66fc99e Initial load
duke
parents:
diff changeset
244 return command_names[command];
a61af66fc99e Initial load
duke
parents:
diff changeset
245 }
a61af66fc99e Initial load
duke
parents:
diff changeset
246
a61af66fc99e Initial load
duke
parents:
diff changeset
247 class MethodMatcher;
a61af66fc99e Initial load
duke
parents:
diff changeset
248 static MethodMatcher* lists[OracleCommandCount] = { 0, };
a61af66fc99e Initial load
duke
parents:
diff changeset
249
a61af66fc99e Initial load
duke
parents:
diff changeset
250
a61af66fc99e Initial load
duke
parents:
diff changeset
251 static bool check_predicate(OracleCommand command, methodHandle method) {
a61af66fc99e Initial load
duke
parents:
diff changeset
252 return ((lists[command] != NULL) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
253 !method.is_null() &&
a61af66fc99e Initial load
duke
parents:
diff changeset
254 lists[command]->match(method));
a61af66fc99e Initial load
duke
parents:
diff changeset
255 }
a61af66fc99e Initial load
duke
parents:
diff changeset
256
a61af66fc99e Initial load
duke
parents:
diff changeset
257
a61af66fc99e Initial load
duke
parents:
diff changeset
258 static MethodMatcher* add_predicate(OracleCommand command,
a61af66fc99e Initial load
duke
parents:
diff changeset
259 symbolHandle class_name, MethodMatcher::Mode c_mode,
a61af66fc99e Initial load
duke
parents:
diff changeset
260 symbolHandle method_name, MethodMatcher::Mode m_mode,
a61af66fc99e Initial load
duke
parents:
diff changeset
261 symbolHandle signature) {
a61af66fc99e Initial load
duke
parents:
diff changeset
262 assert(command != OptionCommand, "must use add_option_string");
a61af66fc99e Initial load
duke
parents:
diff changeset
263 if (command == LogCommand && !LogCompilation && lists[LogCommand] == NULL)
a61af66fc99e Initial load
duke
parents:
diff changeset
264 tty->print_cr("Warning: +LogCompilation must be enabled in order for individual methods to be logged.");
a61af66fc99e Initial load
duke
parents:
diff changeset
265 lists[command] = new MethodMatcher(class_name, c_mode, method_name, m_mode, signature, lists[command]);
a61af66fc99e Initial load
duke
parents:
diff changeset
266 return lists[command];
a61af66fc99e Initial load
duke
parents:
diff changeset
267 }
a61af66fc99e Initial load
duke
parents:
diff changeset
268
a61af66fc99e Initial load
duke
parents:
diff changeset
269
a61af66fc99e Initial load
duke
parents:
diff changeset
270
a61af66fc99e Initial load
duke
parents:
diff changeset
271 static MethodMatcher* add_option_string(symbolHandle class_name, MethodMatcher::Mode c_mode,
a61af66fc99e Initial load
duke
parents:
diff changeset
272 symbolHandle method_name, MethodMatcher::Mode m_mode,
a61af66fc99e Initial load
duke
parents:
diff changeset
273 symbolHandle signature,
a61af66fc99e Initial load
duke
parents:
diff changeset
274 const char* option) {
a61af66fc99e Initial load
duke
parents:
diff changeset
275 lists[OptionCommand] = new MethodOptionMatcher(class_name, c_mode, method_name, m_mode,
a61af66fc99e Initial load
duke
parents:
diff changeset
276 signature, option, lists[OptionCommand]);
a61af66fc99e Initial load
duke
parents:
diff changeset
277 return lists[OptionCommand];
a61af66fc99e Initial load
duke
parents:
diff changeset
278 }
a61af66fc99e Initial load
duke
parents:
diff changeset
279
a61af66fc99e Initial load
duke
parents:
diff changeset
280
a61af66fc99e Initial load
duke
parents:
diff changeset
281 bool CompilerOracle::has_option_string(methodHandle method, const char* option) {
a61af66fc99e Initial load
duke
parents:
diff changeset
282 return lists[OptionCommand] != NULL &&
a61af66fc99e Initial load
duke
parents:
diff changeset
283 ((MethodOptionMatcher*)lists[OptionCommand])->match(method, option);
a61af66fc99e Initial load
duke
parents:
diff changeset
284 }
a61af66fc99e Initial load
duke
parents:
diff changeset
285
a61af66fc99e Initial load
duke
parents:
diff changeset
286
a61af66fc99e Initial load
duke
parents:
diff changeset
287 bool CompilerOracle::should_exclude(methodHandle method, bool& quietly) {
a61af66fc99e Initial load
duke
parents:
diff changeset
288 quietly = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
289 if (lists[ExcludeCommand] != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
290 if (lists[ExcludeCommand]->match(method)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
291 quietly = _quiet;
a61af66fc99e Initial load
duke
parents:
diff changeset
292 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
293 }
a61af66fc99e Initial load
duke
parents:
diff changeset
294 }
a61af66fc99e Initial load
duke
parents:
diff changeset
295
a61af66fc99e Initial load
duke
parents:
diff changeset
296 if (lists[CompileOnlyCommand] != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
297 return !lists[CompileOnlyCommand]->match(method);
a61af66fc99e Initial load
duke
parents:
diff changeset
298 }
a61af66fc99e Initial load
duke
parents:
diff changeset
299 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
300 }
a61af66fc99e Initial load
duke
parents:
diff changeset
301
a61af66fc99e Initial load
duke
parents:
diff changeset
302
a61af66fc99e Initial load
duke
parents:
diff changeset
303 bool CompilerOracle::should_inline(methodHandle method) {
a61af66fc99e Initial load
duke
parents:
diff changeset
304 return (check_predicate(InlineCommand, method));
a61af66fc99e Initial load
duke
parents:
diff changeset
305 }
a61af66fc99e Initial load
duke
parents:
diff changeset
306
a61af66fc99e Initial load
duke
parents:
diff changeset
307
a61af66fc99e Initial load
duke
parents:
diff changeset
308 bool CompilerOracle::should_not_inline(methodHandle method) {
a61af66fc99e Initial load
duke
parents:
diff changeset
309 return (check_predicate(DontInlineCommand, method));
a61af66fc99e Initial load
duke
parents:
diff changeset
310 }
a61af66fc99e Initial load
duke
parents:
diff changeset
311
a61af66fc99e Initial load
duke
parents:
diff changeset
312
a61af66fc99e Initial load
duke
parents:
diff changeset
313 bool CompilerOracle::should_print(methodHandle method) {
a61af66fc99e Initial load
duke
parents:
diff changeset
314 return (check_predicate(PrintCommand, method));
a61af66fc99e Initial load
duke
parents:
diff changeset
315 }
a61af66fc99e Initial load
duke
parents:
diff changeset
316
a61af66fc99e Initial load
duke
parents:
diff changeset
317
a61af66fc99e Initial load
duke
parents:
diff changeset
318 bool CompilerOracle::should_log(methodHandle method) {
a61af66fc99e Initial load
duke
parents:
diff changeset
319 if (!LogCompilation) return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
320 if (lists[LogCommand] == NULL) return true; // by default, log all
a61af66fc99e Initial load
duke
parents:
diff changeset
321 return (check_predicate(LogCommand, method));
a61af66fc99e Initial load
duke
parents:
diff changeset
322 }
a61af66fc99e Initial load
duke
parents:
diff changeset
323
a61af66fc99e Initial load
duke
parents:
diff changeset
324
a61af66fc99e Initial load
duke
parents:
diff changeset
325 bool CompilerOracle::should_break_at(methodHandle method) {
a61af66fc99e Initial load
duke
parents:
diff changeset
326 return check_predicate(BreakCommand, method);
a61af66fc99e Initial load
duke
parents:
diff changeset
327 }
a61af66fc99e Initial load
duke
parents:
diff changeset
328
a61af66fc99e Initial load
duke
parents:
diff changeset
329
a61af66fc99e Initial load
duke
parents:
diff changeset
330 static OracleCommand parse_command_name(const char * line, int* bytes_read) {
a61af66fc99e Initial load
duke
parents:
diff changeset
331 assert(ARRAY_SIZE(command_names) == OracleCommandCount,
a61af66fc99e Initial load
duke
parents:
diff changeset
332 "command_names size mismatch");
a61af66fc99e Initial load
duke
parents:
diff changeset
333
a61af66fc99e Initial load
duke
parents:
diff changeset
334 *bytes_read = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
335 char command[32];
a61af66fc99e Initial load
duke
parents:
diff changeset
336 int result = sscanf(line, "%32[a-z]%n", command, bytes_read);
a61af66fc99e Initial load
duke
parents:
diff changeset
337 for (uint i = 0; i < ARRAY_SIZE(command_names); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
338 if (strcmp(command, command_names[i]) == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
339 return (OracleCommand)i;
a61af66fc99e Initial load
duke
parents:
diff changeset
340 }
a61af66fc99e Initial load
duke
parents:
diff changeset
341 }
a61af66fc99e Initial load
duke
parents:
diff changeset
342 return UnknownCommand;
a61af66fc99e Initial load
duke
parents:
diff changeset
343 }
a61af66fc99e Initial load
duke
parents:
diff changeset
344
a61af66fc99e Initial load
duke
parents:
diff changeset
345
a61af66fc99e Initial load
duke
parents:
diff changeset
346 static void usage() {
a61af66fc99e Initial load
duke
parents:
diff changeset
347 tty->print_cr(" CompileCommand and the CompilerOracle allows simple control over");
a61af66fc99e Initial load
duke
parents:
diff changeset
348 tty->print_cr(" what's allowed to be compiled. The standard supported directives");
a61af66fc99e Initial load
duke
parents:
diff changeset
349 tty->print_cr(" are exclude and compileonly. The exclude directive stops a method");
a61af66fc99e Initial load
duke
parents:
diff changeset
350 tty->print_cr(" from being compiled and compileonly excludes all methods except for");
a61af66fc99e Initial load
duke
parents:
diff changeset
351 tty->print_cr(" the ones mentioned by compileonly directives. The basic form of");
a61af66fc99e Initial load
duke
parents:
diff changeset
352 tty->print_cr(" all commands is a command name followed by the name of the method");
a61af66fc99e Initial load
duke
parents:
diff changeset
353 tty->print_cr(" in one of two forms: the standard class file format as in");
a61af66fc99e Initial load
duke
parents:
diff changeset
354 tty->print_cr(" class/name.methodName or the PrintCompilation format");
a61af66fc99e Initial load
duke
parents:
diff changeset
355 tty->print_cr(" class.name::methodName. The method name can optionally be followed");
a61af66fc99e Initial load
duke
parents:
diff changeset
356 tty->print_cr(" by a space then the signature of the method in the class file");
a61af66fc99e Initial load
duke
parents:
diff changeset
357 tty->print_cr(" format. Otherwise the directive applies to all methods with the");
a61af66fc99e Initial load
duke
parents:
diff changeset
358 tty->print_cr(" same name and class regardless of signature. Leading and trailing");
a61af66fc99e Initial load
duke
parents:
diff changeset
359 tty->print_cr(" *'s in the class and/or method name allows a small amount of");
a61af66fc99e Initial load
duke
parents:
diff changeset
360 tty->print_cr(" wildcarding. ");
a61af66fc99e Initial load
duke
parents:
diff changeset
361 tty->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
362 tty->print_cr(" Examples:");
a61af66fc99e Initial load
duke
parents:
diff changeset
363 tty->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
364 tty->print_cr(" exclude java/lang/StringBuffer.append");
a61af66fc99e Initial load
duke
parents:
diff changeset
365 tty->print_cr(" compileonly java/lang/StringBuffer.toString ()Ljava/lang/String;");
a61af66fc99e Initial load
duke
parents:
diff changeset
366 tty->print_cr(" exclude java/lang/String*.*");
a61af66fc99e Initial load
duke
parents:
diff changeset
367 tty->print_cr(" exclude *.toString");
a61af66fc99e Initial load
duke
parents:
diff changeset
368 }
a61af66fc99e Initial load
duke
parents:
diff changeset
369
a61af66fc99e Initial load
duke
parents:
diff changeset
370
a61af66fc99e Initial load
duke
parents:
diff changeset
371 // The characters allowed in a class or method name. All characters > 0x7f
a61af66fc99e Initial load
duke
parents:
diff changeset
372 // are allowed in order to handle obfuscated class files (e.g. Volano)
a61af66fc99e Initial load
duke
parents:
diff changeset
373 #define RANGEBASE "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789$_<>" \
a61af66fc99e Initial load
duke
parents:
diff changeset
374 "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f" \
a61af66fc99e Initial load
duke
parents:
diff changeset
375 "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f" \
a61af66fc99e Initial load
duke
parents:
diff changeset
376 "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf" \
a61af66fc99e Initial load
duke
parents:
diff changeset
377 "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf" \
a61af66fc99e Initial load
duke
parents:
diff changeset
378 "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf" \
a61af66fc99e Initial load
duke
parents:
diff changeset
379 "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" \
a61af66fc99e Initial load
duke
parents:
diff changeset
380 "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef" \
a61af66fc99e Initial load
duke
parents:
diff changeset
381 "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
a61af66fc99e Initial load
duke
parents:
diff changeset
382
a61af66fc99e Initial load
duke
parents:
diff changeset
383 #define RANGE0 "[*" RANGEBASE "]"
a61af66fc99e Initial load
duke
parents:
diff changeset
384 #define RANGEDOT "[*" RANGEBASE ".]"
a61af66fc99e Initial load
duke
parents:
diff changeset
385 #define RANGESLASH "[*" RANGEBASE "/]"
a61af66fc99e Initial load
duke
parents:
diff changeset
386
a61af66fc99e Initial load
duke
parents:
diff changeset
387
a61af66fc99e Initial load
duke
parents:
diff changeset
388 // Accept several syntaxes for these patterns
a61af66fc99e Initial load
duke
parents:
diff changeset
389 // original syntax
a61af66fc99e Initial load
duke
parents:
diff changeset
390 // cmd java.lang.String foo
a61af66fc99e Initial load
duke
parents:
diff changeset
391 // PrintCompilation syntax
a61af66fc99e Initial load
duke
parents:
diff changeset
392 // cmd java.lang.String::foo
a61af66fc99e Initial load
duke
parents:
diff changeset
393 // VM syntax
a61af66fc99e Initial load
duke
parents:
diff changeset
394 // cmd java/lang/String[. ]foo
a61af66fc99e Initial load
duke
parents:
diff changeset
395 //
a61af66fc99e Initial load
duke
parents:
diff changeset
396
a61af66fc99e Initial load
duke
parents:
diff changeset
397 static const char* patterns[] = {
a61af66fc99e Initial load
duke
parents:
diff changeset
398 "%*[ \t]%255" RANGEDOT " " "%255" RANGE0 "%n",
a61af66fc99e Initial load
duke
parents:
diff changeset
399 "%*[ \t]%255" RANGEDOT "::" "%255" RANGE0 "%n",
a61af66fc99e Initial load
duke
parents:
diff changeset
400 "%*[ \t]%255" RANGESLASH "%*[ .]" "%255" RANGE0 "%n",
a61af66fc99e Initial load
duke
parents:
diff changeset
401 };
a61af66fc99e Initial load
duke
parents:
diff changeset
402
a61af66fc99e Initial load
duke
parents:
diff changeset
403 static MethodMatcher::Mode check_mode(char name[], const char*& error_msg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
404 int match = MethodMatcher::Exact;
1155
4e6abf09f540 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 0
diff changeset
405 while (name[0] == '*') {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
406 match |= MethodMatcher::Suffix;
a61af66fc99e Initial load
duke
parents:
diff changeset
407 strcpy(name, name + 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
408 }
a61af66fc99e Initial load
duke
parents:
diff changeset
409
1155
4e6abf09f540 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 0
diff changeset
410 if (strcmp(name, "*") == 0) return MethodMatcher::Any;
4e6abf09f540 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 0
diff changeset
411
0
a61af66fc99e Initial load
duke
parents:
diff changeset
412 size_t len = strlen(name);
1155
4e6abf09f540 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 0
diff changeset
413 while (len > 0 && name[len - 1] == '*') {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
414 match |= MethodMatcher::Prefix;
1155
4e6abf09f540 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 0
diff changeset
415 name[--len] = '\0';
0
a61af66fc99e Initial load
duke
parents:
diff changeset
416 }
a61af66fc99e Initial load
duke
parents:
diff changeset
417
a61af66fc99e Initial load
duke
parents:
diff changeset
418 if (strstr(name, "*") != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
419 error_msg = " Embedded * not allowed";
a61af66fc99e Initial load
duke
parents:
diff changeset
420 return MethodMatcher::Unknown;
a61af66fc99e Initial load
duke
parents:
diff changeset
421 }
a61af66fc99e Initial load
duke
parents:
diff changeset
422 return (MethodMatcher::Mode)match;
a61af66fc99e Initial load
duke
parents:
diff changeset
423 }
a61af66fc99e Initial load
duke
parents:
diff changeset
424
a61af66fc99e Initial load
duke
parents:
diff changeset
425 static bool scan_line(const char * line,
a61af66fc99e Initial load
duke
parents:
diff changeset
426 char class_name[], MethodMatcher::Mode* c_mode,
a61af66fc99e Initial load
duke
parents:
diff changeset
427 char method_name[], MethodMatcher::Mode* m_mode,
a61af66fc99e Initial load
duke
parents:
diff changeset
428 int* bytes_read, const char*& error_msg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
429 *bytes_read = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
430 error_msg = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
431 for (uint i = 0; i < ARRAY_SIZE(patterns); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
432 if (2 == sscanf(line, patterns[i], class_name, method_name, bytes_read)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
433 *c_mode = check_mode(class_name, error_msg);
a61af66fc99e Initial load
duke
parents:
diff changeset
434 *m_mode = check_mode(method_name, error_msg);
a61af66fc99e Initial load
duke
parents:
diff changeset
435 return *c_mode != MethodMatcher::Unknown && *m_mode != MethodMatcher::Unknown;
a61af66fc99e Initial load
duke
parents:
diff changeset
436 }
a61af66fc99e Initial load
duke
parents:
diff changeset
437 }
a61af66fc99e Initial load
duke
parents:
diff changeset
438 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
439 }
a61af66fc99e Initial load
duke
parents:
diff changeset
440
a61af66fc99e Initial load
duke
parents:
diff changeset
441
a61af66fc99e Initial load
duke
parents:
diff changeset
442
a61af66fc99e Initial load
duke
parents:
diff changeset
443 void CompilerOracle::parse_from_line(char* line) {
a61af66fc99e Initial load
duke
parents:
diff changeset
444 if (line[0] == '\0') return;
a61af66fc99e Initial load
duke
parents:
diff changeset
445 if (line[0] == '#') return;
a61af66fc99e Initial load
duke
parents:
diff changeset
446
a61af66fc99e Initial load
duke
parents:
diff changeset
447 bool have_colon = (strstr(line, "::") != NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
448 for (char* lp = line; *lp != '\0'; lp++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
449 // Allow '.' to separate the class name from the method name.
a61af66fc99e Initial load
duke
parents:
diff changeset
450 // This is the preferred spelling of methods:
a61af66fc99e Initial load
duke
parents:
diff changeset
451 // exclude java/lang/String.indexOf(I)I
a61af66fc99e Initial load
duke
parents:
diff changeset
452 // Allow ',' for spaces (eases command line quoting).
a61af66fc99e Initial load
duke
parents:
diff changeset
453 // exclude,java/lang/String.indexOf
a61af66fc99e Initial load
duke
parents:
diff changeset
454 // For backward compatibility, allow space as separator also.
a61af66fc99e Initial load
duke
parents:
diff changeset
455 // exclude java/lang/String indexOf
a61af66fc99e Initial load
duke
parents:
diff changeset
456 // exclude,java/lang/String,indexOf
a61af66fc99e Initial load
duke
parents:
diff changeset
457 // For easy cut-and-paste of method names, allow VM output format
a61af66fc99e Initial load
duke
parents:
diff changeset
458 // as produced by methodOopDesc::print_short_name:
a61af66fc99e Initial load
duke
parents:
diff changeset
459 // exclude java.lang.String::indexOf
a61af66fc99e Initial load
duke
parents:
diff changeset
460 // For simple implementation convenience here, convert them all to space.
a61af66fc99e Initial load
duke
parents:
diff changeset
461 if (have_colon) {
a61af66fc99e Initial load
duke
parents:
diff changeset
462 if (*lp == '.') *lp = '/'; // dots build the package prefix
a61af66fc99e Initial load
duke
parents:
diff changeset
463 if (*lp == ':') *lp = ' ';
a61af66fc99e Initial load
duke
parents:
diff changeset
464 }
a61af66fc99e Initial load
duke
parents:
diff changeset
465 if (*lp == ',' || *lp == '.') *lp = ' ';
a61af66fc99e Initial load
duke
parents:
diff changeset
466 }
a61af66fc99e Initial load
duke
parents:
diff changeset
467
a61af66fc99e Initial load
duke
parents:
diff changeset
468 char* original_line = line;
a61af66fc99e Initial load
duke
parents:
diff changeset
469 int bytes_read;
a61af66fc99e Initial load
duke
parents:
diff changeset
470 OracleCommand command = parse_command_name(line, &bytes_read);
a61af66fc99e Initial load
duke
parents:
diff changeset
471 line += bytes_read;
a61af66fc99e Initial load
duke
parents:
diff changeset
472
a61af66fc99e Initial load
duke
parents:
diff changeset
473 if (command == QuietCommand) {
a61af66fc99e Initial load
duke
parents:
diff changeset
474 _quiet = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
475 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
476 }
a61af66fc99e Initial load
duke
parents:
diff changeset
477
a61af66fc99e Initial load
duke
parents:
diff changeset
478 if (command == HelpCommand) {
a61af66fc99e Initial load
duke
parents:
diff changeset
479 usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
480 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
481 }
a61af66fc99e Initial load
duke
parents:
diff changeset
482
a61af66fc99e Initial load
duke
parents:
diff changeset
483 MethodMatcher::Mode c_match = MethodMatcher::Exact;
a61af66fc99e Initial load
duke
parents:
diff changeset
484 MethodMatcher::Mode m_match = MethodMatcher::Exact;
a61af66fc99e Initial load
duke
parents:
diff changeset
485 char class_name[256];
a61af66fc99e Initial load
duke
parents:
diff changeset
486 char method_name[256];
a61af66fc99e Initial load
duke
parents:
diff changeset
487 char sig[1024];
a61af66fc99e Initial load
duke
parents:
diff changeset
488 char errorbuf[1024];
a61af66fc99e Initial load
duke
parents:
diff changeset
489 const char* error_msg = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
490 MethodMatcher* match = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
491
a61af66fc99e Initial load
duke
parents:
diff changeset
492 if (scan_line(line, class_name, &c_match, method_name, &m_match, &bytes_read, error_msg)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
493 EXCEPTION_MARK;
a61af66fc99e Initial load
duke
parents:
diff changeset
494 symbolHandle c_name = oopFactory::new_symbol_handle(class_name, CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
495 symbolHandle m_name = oopFactory::new_symbol_handle(method_name, CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
496 symbolHandle signature;
a61af66fc99e Initial load
duke
parents:
diff changeset
497
a61af66fc99e Initial load
duke
parents:
diff changeset
498 line += bytes_read;
a61af66fc99e Initial load
duke
parents:
diff changeset
499 // there might be a signature following the method.
a61af66fc99e Initial load
duke
parents:
diff changeset
500 // signatures always begin with ( so match that by hand
a61af66fc99e Initial load
duke
parents:
diff changeset
501 if (1 == sscanf(line, "%*[ \t](%254[);/" RANGEBASE "]%n", sig + 1, &bytes_read)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
502 sig[0] = '(';
a61af66fc99e Initial load
duke
parents:
diff changeset
503 line += bytes_read;
a61af66fc99e Initial load
duke
parents:
diff changeset
504 signature = oopFactory::new_symbol_handle(sig, CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
505 }
a61af66fc99e Initial load
duke
parents:
diff changeset
506
a61af66fc99e Initial load
duke
parents:
diff changeset
507 if (command == OptionCommand) {
a61af66fc99e Initial load
duke
parents:
diff changeset
508 // Look for trailing options to support
a61af66fc99e Initial load
duke
parents:
diff changeset
509 // ciMethod::has_option("string") to control features in the
a61af66fc99e Initial load
duke
parents:
diff changeset
510 // compiler. Multiple options may follow the method name.
a61af66fc99e Initial load
duke
parents:
diff changeset
511 char option[256];
a61af66fc99e Initial load
duke
parents:
diff changeset
512 while (sscanf(line, "%*[ \t]%255[a-zA-Z0-9]%n", option, &bytes_read) == 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
513 if (match != NULL && !_quiet) {
a61af66fc99e Initial load
duke
parents:
diff changeset
514 // Print out the last match added
a61af66fc99e Initial load
duke
parents:
diff changeset
515 tty->print("CompilerOracle: %s ", command_names[command]);
a61af66fc99e Initial load
duke
parents:
diff changeset
516 match->print();
a61af66fc99e Initial load
duke
parents:
diff changeset
517 }
a61af66fc99e Initial load
duke
parents:
diff changeset
518 match = add_option_string(c_name, c_match, m_name, m_match, signature, strdup(option));
a61af66fc99e Initial load
duke
parents:
diff changeset
519 line += bytes_read;
a61af66fc99e Initial load
duke
parents:
diff changeset
520 }
a61af66fc99e Initial load
duke
parents:
diff changeset
521 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
522 bytes_read = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
523 sscanf(line, "%*[ \t]%n", &bytes_read);
a61af66fc99e Initial load
duke
parents:
diff changeset
524 if (line[bytes_read] != '\0') {
a61af66fc99e Initial load
duke
parents:
diff changeset
525 jio_snprintf(errorbuf, sizeof(errorbuf), " Unrecognized text after command: %s", line);
a61af66fc99e Initial load
duke
parents:
diff changeset
526 error_msg = errorbuf;
a61af66fc99e Initial load
duke
parents:
diff changeset
527 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
528 match = add_predicate(command, c_name, c_match, m_name, m_match, signature);
a61af66fc99e Initial load
duke
parents:
diff changeset
529 }
a61af66fc99e Initial load
duke
parents:
diff changeset
530 }
a61af66fc99e Initial load
duke
parents:
diff changeset
531 }
a61af66fc99e Initial load
duke
parents:
diff changeset
532
a61af66fc99e Initial load
duke
parents:
diff changeset
533 if (match != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
534 if (!_quiet) {
a61af66fc99e Initial load
duke
parents:
diff changeset
535 tty->print("CompilerOracle: %s ", command_names[command]);
a61af66fc99e Initial load
duke
parents:
diff changeset
536 match->print();
a61af66fc99e Initial load
duke
parents:
diff changeset
537 }
a61af66fc99e Initial load
duke
parents:
diff changeset
538 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
539 tty->print_cr("CompilerOracle: unrecognized line");
a61af66fc99e Initial load
duke
parents:
diff changeset
540 tty->print_cr(" \"%s\"", original_line);
a61af66fc99e Initial load
duke
parents:
diff changeset
541 if (error_msg != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
542 tty->print_cr(error_msg);
a61af66fc99e Initial load
duke
parents:
diff changeset
543 }
a61af66fc99e Initial load
duke
parents:
diff changeset
544 }
a61af66fc99e Initial load
duke
parents:
diff changeset
545 }
a61af66fc99e Initial load
duke
parents:
diff changeset
546
a61af66fc99e Initial load
duke
parents:
diff changeset
547 static const char* cc_file() {
a61af66fc99e Initial load
duke
parents:
diff changeset
548 if (CompileCommandFile == NULL)
a61af66fc99e Initial load
duke
parents:
diff changeset
549 return ".hotspot_compiler";
a61af66fc99e Initial load
duke
parents:
diff changeset
550 return CompileCommandFile;
a61af66fc99e Initial load
duke
parents:
diff changeset
551 }
a61af66fc99e Initial load
duke
parents:
diff changeset
552 bool CompilerOracle::_quiet = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
553
a61af66fc99e Initial load
duke
parents:
diff changeset
554 void CompilerOracle::parse_from_file() {
a61af66fc99e Initial load
duke
parents:
diff changeset
555 FILE* stream = fopen(cc_file(), "rt");
a61af66fc99e Initial load
duke
parents:
diff changeset
556 if (stream == NULL) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
557
a61af66fc99e Initial load
duke
parents:
diff changeset
558 char token[1024];
a61af66fc99e Initial load
duke
parents:
diff changeset
559 int pos = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
560 int c = getc(stream);
a61af66fc99e Initial load
duke
parents:
diff changeset
561 while(c != EOF) {
a61af66fc99e Initial load
duke
parents:
diff changeset
562 if (c == '\n') {
a61af66fc99e Initial load
duke
parents:
diff changeset
563 token[pos++] = '\0';
a61af66fc99e Initial load
duke
parents:
diff changeset
564 parse_from_line(token);
a61af66fc99e Initial load
duke
parents:
diff changeset
565 pos = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
566 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
567 token[pos++] = c;
a61af66fc99e Initial load
duke
parents:
diff changeset
568 }
a61af66fc99e Initial load
duke
parents:
diff changeset
569 c = getc(stream);
a61af66fc99e Initial load
duke
parents:
diff changeset
570 }
a61af66fc99e Initial load
duke
parents:
diff changeset
571 token[pos++] = '\0';
a61af66fc99e Initial load
duke
parents:
diff changeset
572 parse_from_line(token);
a61af66fc99e Initial load
duke
parents:
diff changeset
573
a61af66fc99e Initial load
duke
parents:
diff changeset
574 fclose(stream);
a61af66fc99e Initial load
duke
parents:
diff changeset
575 }
a61af66fc99e Initial load
duke
parents:
diff changeset
576
a61af66fc99e Initial load
duke
parents:
diff changeset
577 void CompilerOracle::parse_from_string(const char* str, void (*parse_line)(char*)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
578 char token[1024];
a61af66fc99e Initial load
duke
parents:
diff changeset
579 int pos = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
580 const char* sp = str;
a61af66fc99e Initial load
duke
parents:
diff changeset
581 int c = *sp++;
a61af66fc99e Initial load
duke
parents:
diff changeset
582 while (c != '\0') {
a61af66fc99e Initial load
duke
parents:
diff changeset
583 if (c == '\n') {
a61af66fc99e Initial load
duke
parents:
diff changeset
584 token[pos++] = '\0';
a61af66fc99e Initial load
duke
parents:
diff changeset
585 parse_line(token);
a61af66fc99e Initial load
duke
parents:
diff changeset
586 pos = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
587 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
588 token[pos++] = c;
a61af66fc99e Initial load
duke
parents:
diff changeset
589 }
a61af66fc99e Initial load
duke
parents:
diff changeset
590 c = *sp++;
a61af66fc99e Initial load
duke
parents:
diff changeset
591 }
a61af66fc99e Initial load
duke
parents:
diff changeset
592 token[pos++] = '\0';
a61af66fc99e Initial load
duke
parents:
diff changeset
593 parse_line(token);
a61af66fc99e Initial load
duke
parents:
diff changeset
594 }
a61af66fc99e Initial load
duke
parents:
diff changeset
595
a61af66fc99e Initial load
duke
parents:
diff changeset
596 void CompilerOracle::append_comment_to_file(const char* message) {
a61af66fc99e Initial load
duke
parents:
diff changeset
597 fileStream stream(fopen(cc_file(), "at"));
a61af66fc99e Initial load
duke
parents:
diff changeset
598 stream.print("# ");
a61af66fc99e Initial load
duke
parents:
diff changeset
599 for (int index = 0; message[index] != '\0'; index++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
600 stream.put(message[index]);
a61af66fc99e Initial load
duke
parents:
diff changeset
601 if (message[index] == '\n') stream.print("# ");
a61af66fc99e Initial load
duke
parents:
diff changeset
602 }
a61af66fc99e Initial load
duke
parents:
diff changeset
603 stream.cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
604 }
a61af66fc99e Initial load
duke
parents:
diff changeset
605
a61af66fc99e Initial load
duke
parents:
diff changeset
606 void CompilerOracle::append_exclude_to_file(methodHandle method) {
a61af66fc99e Initial load
duke
parents:
diff changeset
607 fileStream stream(fopen(cc_file(), "at"));
a61af66fc99e Initial load
duke
parents:
diff changeset
608 stream.print("exclude ");
a61af66fc99e Initial load
duke
parents:
diff changeset
609 Klass::cast(method->method_holder())->name()->print_symbol_on(&stream);
a61af66fc99e Initial load
duke
parents:
diff changeset
610 stream.print(".");
a61af66fc99e Initial load
duke
parents:
diff changeset
611 method->name()->print_symbol_on(&stream);
a61af66fc99e Initial load
duke
parents:
diff changeset
612 method->signature()->print_symbol_on(&stream);
a61af66fc99e Initial load
duke
parents:
diff changeset
613 stream.cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
614 stream.cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
615 }
a61af66fc99e Initial load
duke
parents:
diff changeset
616
a61af66fc99e Initial load
duke
parents:
diff changeset
617
a61af66fc99e Initial load
duke
parents:
diff changeset
618 void compilerOracle_init() {
a61af66fc99e Initial load
duke
parents:
diff changeset
619 CompilerOracle::parse_from_string(CompileCommand, CompilerOracle::parse_from_line);
a61af66fc99e Initial load
duke
parents:
diff changeset
620 CompilerOracle::parse_from_string(CompileOnly, CompilerOracle::parse_compile_only);
a61af66fc99e Initial load
duke
parents:
diff changeset
621 CompilerOracle::parse_from_file();
1155
4e6abf09f540 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 0
diff changeset
622 if (lists[PrintCommand] != NULL) {
4e6abf09f540 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 0
diff changeset
623 if (PrintAssembly) {
4e6abf09f540 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 0
diff changeset
624 warning("CompileCommand and/or .hotspot_compiler file contains 'print' commands, but PrintAssembly is also enabled");
4e6abf09f540 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 0
diff changeset
625 } else if (FLAG_IS_DEFAULT(DebugNonSafepoints)) {
4e6abf09f540 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 0
diff changeset
626 warning("printing of assembly code is enabled; turning on DebugNonSafepoints to gain additional output");
4e6abf09f540 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 0
diff changeset
627 DebugNonSafepoints = true;
4e6abf09f540 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 0
diff changeset
628 }
4e6abf09f540 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 0
diff changeset
629 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
630 }
a61af66fc99e Initial load
duke
parents:
diff changeset
631
a61af66fc99e Initial load
duke
parents:
diff changeset
632
a61af66fc99e Initial load
duke
parents:
diff changeset
633 void CompilerOracle::parse_compile_only(char * line) {
a61af66fc99e Initial load
duke
parents:
diff changeset
634 int i;
a61af66fc99e Initial load
duke
parents:
diff changeset
635 char name[1024];
a61af66fc99e Initial load
duke
parents:
diff changeset
636 const char* className = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
637 const char* methodName = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
638
a61af66fc99e Initial load
duke
parents:
diff changeset
639 bool have_colon = (strstr(line, "::") != NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
640 char method_sep = have_colon ? ':' : '.';
a61af66fc99e Initial load
duke
parents:
diff changeset
641
a61af66fc99e Initial load
duke
parents:
diff changeset
642 if (Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
643 tty->print_cr(line);
a61af66fc99e Initial load
duke
parents:
diff changeset
644 }
a61af66fc99e Initial load
duke
parents:
diff changeset
645
a61af66fc99e Initial load
duke
parents:
diff changeset
646 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
647 while (*line != '\0') {
a61af66fc99e Initial load
duke
parents:
diff changeset
648 MethodMatcher::Mode c_match = MethodMatcher::Exact;
a61af66fc99e Initial load
duke
parents:
diff changeset
649 MethodMatcher::Mode m_match = MethodMatcher::Exact;
a61af66fc99e Initial load
duke
parents:
diff changeset
650
a61af66fc99e Initial load
duke
parents:
diff changeset
651 for (i = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
652 i < 1024 && *line != '\0' && *line != method_sep && *line != ',' && !isspace(*line);
a61af66fc99e Initial load
duke
parents:
diff changeset
653 line++, i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
654 name[i] = *line;
a61af66fc99e Initial load
duke
parents:
diff changeset
655 if (name[i] == '.') name[i] = '/'; // package prefix uses '/'
a61af66fc99e Initial load
duke
parents:
diff changeset
656 }
a61af66fc99e Initial load
duke
parents:
diff changeset
657
a61af66fc99e Initial load
duke
parents:
diff changeset
658 if (i > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
659 char* newName = NEW_RESOURCE_ARRAY( char, i + 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
660 if (newName == NULL)
a61af66fc99e Initial load
duke
parents:
diff changeset
661 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
662 strncpy(newName, name, i);
a61af66fc99e Initial load
duke
parents:
diff changeset
663 newName[i] = '\0';
a61af66fc99e Initial load
duke
parents:
diff changeset
664
a61af66fc99e Initial load
duke
parents:
diff changeset
665 if (className == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
666 className = newName;
a61af66fc99e Initial load
duke
parents:
diff changeset
667 c_match = MethodMatcher::Prefix;
a61af66fc99e Initial load
duke
parents:
diff changeset
668 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
669 methodName = newName;
a61af66fc99e Initial load
duke
parents:
diff changeset
670 }
a61af66fc99e Initial load
duke
parents:
diff changeset
671 }
a61af66fc99e Initial load
duke
parents:
diff changeset
672
a61af66fc99e Initial load
duke
parents:
diff changeset
673 if (*line == method_sep) {
a61af66fc99e Initial load
duke
parents:
diff changeset
674 if (className == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
675 className = "";
a61af66fc99e Initial load
duke
parents:
diff changeset
676 c_match = MethodMatcher::Any;
a61af66fc99e Initial load
duke
parents:
diff changeset
677 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
678 // foo/bar.blah is an exact match on foo/bar, bar.blah is a suffix match on bar
a61af66fc99e Initial load
duke
parents:
diff changeset
679 if (strchr(className, '/') != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
680 c_match = MethodMatcher::Exact;
a61af66fc99e Initial load
duke
parents:
diff changeset
681 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
682 c_match = MethodMatcher::Suffix;
a61af66fc99e Initial load
duke
parents:
diff changeset
683 }
a61af66fc99e Initial load
duke
parents:
diff changeset
684 }
a61af66fc99e Initial load
duke
parents:
diff changeset
685 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
686 // got foo or foo/bar
a61af66fc99e Initial load
duke
parents:
diff changeset
687 if (className == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
688 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
689 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
690 // got foo or foo/bar
a61af66fc99e Initial load
duke
parents:
diff changeset
691 if (strchr(className, '/') != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
692 c_match = MethodMatcher::Prefix;
a61af66fc99e Initial load
duke
parents:
diff changeset
693 } else if (className[0] == '\0') {
a61af66fc99e Initial load
duke
parents:
diff changeset
694 c_match = MethodMatcher::Any;
a61af66fc99e Initial load
duke
parents:
diff changeset
695 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
696 c_match = MethodMatcher::Substring;
a61af66fc99e Initial load
duke
parents:
diff changeset
697 }
a61af66fc99e Initial load
duke
parents:
diff changeset
698 }
a61af66fc99e Initial load
duke
parents:
diff changeset
699 }
a61af66fc99e Initial load
duke
parents:
diff changeset
700
a61af66fc99e Initial load
duke
parents:
diff changeset
701 // each directive is terminated by , or NUL or . followed by NUL
a61af66fc99e Initial load
duke
parents:
diff changeset
702 if (*line == ',' || *line == '\0' || (line[0] == '.' && line[1] == '\0')) {
a61af66fc99e Initial load
duke
parents:
diff changeset
703 if (methodName == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
704 methodName = "";
a61af66fc99e Initial load
duke
parents:
diff changeset
705 if (*line != method_sep) {
a61af66fc99e Initial load
duke
parents:
diff changeset
706 m_match = MethodMatcher::Any;
a61af66fc99e Initial load
duke
parents:
diff changeset
707 }
a61af66fc99e Initial load
duke
parents:
diff changeset
708 }
a61af66fc99e Initial load
duke
parents:
diff changeset
709
a61af66fc99e Initial load
duke
parents:
diff changeset
710 EXCEPTION_MARK;
a61af66fc99e Initial load
duke
parents:
diff changeset
711 symbolHandle c_name = oopFactory::new_symbol_handle(className, CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
712 symbolHandle m_name = oopFactory::new_symbol_handle(methodName, CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
713 symbolHandle signature;
a61af66fc99e Initial load
duke
parents:
diff changeset
714
a61af66fc99e Initial load
duke
parents:
diff changeset
715 add_predicate(CompileOnlyCommand, c_name, c_match, m_name, m_match, signature);
a61af66fc99e Initial load
duke
parents:
diff changeset
716 if (PrintVMOptions) {
a61af66fc99e Initial load
duke
parents:
diff changeset
717 tty->print("CompileOnly: compileonly ");
a61af66fc99e Initial load
duke
parents:
diff changeset
718 lists[CompileOnlyCommand]->print();
a61af66fc99e Initial load
duke
parents:
diff changeset
719 }
a61af66fc99e Initial load
duke
parents:
diff changeset
720
a61af66fc99e Initial load
duke
parents:
diff changeset
721 className = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
722 methodName = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
723 }
a61af66fc99e Initial load
duke
parents:
diff changeset
724
a61af66fc99e Initial load
duke
parents:
diff changeset
725 line = *line == '\0' ? line : line + 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
726 }
a61af66fc99e Initial load
duke
parents:
diff changeset
727 }