Print this page
rev 1082 : imported patch indy.compiler.patch
rev 1083 : [mq]: indy.compiler.inline.patch
Split |
Close |
Expand all |
Collapse all |
--- old/src/share/vm/ci/ciEnv.hpp
+++ new/src/share/vm/ci/ciEnv.hpp
1 1 /*
2 2 * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation.
8 8 *
9 9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 12 * version 2 for more details (a copy is included in the LICENSE file that
13 13 * accompanied this code).
14 14 *
15 15 * You should have received a copy of the GNU General Public License version
16 16 * 2 along with this work; if not, write to the Free Software Foundation,
17 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 18 *
19 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 21 * have any questions.
22 22 *
23 23 */
24 24
25 25 class CompileTask;
26 26
27 27 // ciEnv
28 28 //
29 29 // This class is the top level broker for requests from the compiler
30 30 // to the VM.
31 31 class ciEnv : StackObj {
32 32 CI_PACKAGE_ACCESS_TO
33 33
34 34 friend class CompileBroker;
35 35 friend class Dependencies; // for get_object, during logging
36 36
37 37 private:
38 38 Arena* _arena; // Alias for _ciEnv_arena except in init_shared_objects()
39 39 Arena _ciEnv_arena;
40 40 int _system_dictionary_modification_counter;
41 41 ciObjectFactory* _factory;
42 42 OopRecorder* _oop_recorder;
43 43 DebugInformationRecorder* _debug_info;
44 44 Dependencies* _dependencies;
45 45 const char* _failure_reason;
46 46 int _compilable;
47 47 bool _break_at_compile;
48 48 int _num_inlined_bytecodes;
49 49 CompileTask* _task; // faster access to CompilerThread::task
50 50 CompileLog* _log; // faster access to CompilerThread::log
51 51 void* _compiler_data; // compiler-specific stuff, if any
52 52
53 53 char* _name_buffer;
54 54 int _name_buffer_len;
55 55
56 56 // Cache Jvmti state
57 57 bool _jvmti_can_hotswap_or_post_breakpoint;
58 58 bool _jvmti_can_examine_or_deopt_anywhere;
59 59 bool _jvmti_can_access_local_variables;
60 60 bool _jvmti_can_post_exceptions;
61 61
62 62 // Cache DTrace flags
63 63 bool _dtrace_extended_probes;
64 64 bool _dtrace_monitor_probes;
65 65 bool _dtrace_method_probes;
66 66 bool _dtrace_alloc_probes;
67 67
68 68 // Distinguished instances of certain ciObjects..
69 69 static ciObject* _null_object_instance;
70 70 static ciMethodKlass* _method_klass_instance;
71 71 static ciSymbolKlass* _symbol_klass_instance;
72 72 static ciKlassKlass* _klass_klass_instance;
73 73 static ciInstanceKlassKlass* _instance_klass_klass_instance;
74 74 static ciTypeArrayKlassKlass* _type_array_klass_klass_instance;
75 75 static ciObjArrayKlassKlass* _obj_array_klass_klass_instance;
76 76
77 77 static ciInstanceKlass* _ArrayStoreException;
78 78 static ciInstanceKlass* _Class;
79 79 static ciInstanceKlass* _ClassCastException;
80 80 static ciInstanceKlass* _InvokeDynamic;
81 81 static ciInstanceKlass* _Object;
82 82 static ciInstanceKlass* _Throwable;
83 83 static ciInstanceKlass* _Thread;
84 84 static ciInstanceKlass* _OutOfMemoryError;
85 85 static ciInstanceKlass* _String;
86 86 static ciInstanceKlass* _StringBuffer;
87 87 static ciInstanceKlass* _StringBuilder;
88 88 static ciInstanceKlass* _Integer;
89 89
90 90 static ciSymbol* _unloaded_cisymbol;
91 91 static ciInstanceKlass* _unloaded_ciinstance_klass;
92 92 static ciObjArrayKlass* _unloaded_ciobjarrayklass;
93 93
94 94 static jobject _ArrayIndexOutOfBoundsException_handle;
95 95 static jobject _ArrayStoreException_handle;
96 96 static jobject _ClassCastException_handle;
97 97
98 98 ciInstance* _NullPointerException_instance;
99 99 ciInstance* _ArithmeticException_instance;
100 100 ciInstance* _ArrayIndexOutOfBoundsException_instance;
101 101 ciInstance* _ArrayStoreException_instance;
102 102 ciInstance* _ClassCastException_instance;
103 103
104 104 ciInstance* _the_null_string; // The Java string "null"
105 105 ciInstance* _the_min_jint_string; // The Java string "-2147483648"
106 106
107 107 // Look up a klass by name from a particular class loader (the accessor's).
108 108 // If require_local, result must be defined in that class loader, or NULL.
109 109 // If !require_local, a result from remote class loader may be reported,
110 110 // if sufficient class loader constraints exist such that initiating
111 111 // a class loading request from the given loader is bound to return
112 112 // the class defined in the remote loader (or throw an error).
113 113 //
↓ open down ↓ |
113 lines elided |
↑ open up ↑ |
114 114 // Return an unloaded klass if !require_local and no class at all is found.
115 115 //
116 116 // The CI treats a klass as loaded if it is consistently defined in
117 117 // another loader, even if it hasn't yet been loaded in all loaders
118 118 // that could potentially see it via delegation.
119 119 ciKlass* get_klass_by_name(ciKlass* accessing_klass,
120 120 ciSymbol* klass_name,
121 121 bool require_local);
122 122
123 123 // Constant pool access.
124 - ciKlass* get_klass_by_index(ciInstanceKlass* loading_klass,
124 + ciKlass* get_klass_by_index(constantPoolHandle cpool,
125 125 int klass_index,
126 - bool& is_accessible);
127 - ciConstant get_constant_by_index(ciInstanceKlass* loading_klass,
128 - int constant_index);
126 + bool& is_accessible,
127 + ciInstanceKlass* loading_klass);
128 + ciConstant get_constant_by_index(constantPoolHandle cpool,
129 + int constant_index,
130 + ciInstanceKlass* accessor);
129 131 bool is_unresolved_string(ciInstanceKlass* loading_klass,
130 132 int constant_index) const;
131 133 bool is_unresolved_klass(ciInstanceKlass* loading_klass,
132 134 int constant_index) const;
133 135 ciField* get_field_by_index(ciInstanceKlass* loading_klass,
134 136 int field_index);
135 - ciMethod* get_method_by_index(ciInstanceKlass* loading_klass,
136 - int method_index, Bytecodes::Code bc);
137 + ciMethod* get_method_by_index(constantPoolHandle cpool,
138 + int method_index, Bytecodes::Code bc,
139 + ciInstanceKlass* loading_klass);
137 140
138 141 // Implementation methods for loading and constant pool access.
139 142 ciKlass* get_klass_by_name_impl(ciKlass* accessing_klass,
140 143 ciSymbol* klass_name,
141 144 bool require_local);
142 - ciKlass* get_klass_by_index_impl(ciInstanceKlass* loading_klass,
145 + ciKlass* get_klass_by_index_impl(constantPoolHandle cpool,
143 146 int klass_index,
144 - bool& is_accessible);
145 - ciConstant get_constant_by_index_impl(ciInstanceKlass* loading_klass,
146 - int constant_index);
147 + bool& is_accessible,
148 + ciInstanceKlass* loading_klass);
149 + ciConstant get_constant_by_index_impl(constantPoolHandle cpool,
150 + int constant_index,
151 + ciInstanceKlass* loading_klass);
147 152 bool is_unresolved_string_impl (instanceKlass* loading_klass,
148 153 int constant_index) const;
149 154 bool is_unresolved_klass_impl (instanceKlass* loading_klass,
150 155 int constant_index) const;
151 156 ciField* get_field_by_index_impl(ciInstanceKlass* loading_klass,
152 157 int field_index);
153 - ciMethod* get_method_by_index_impl(ciInstanceKlass* loading_klass,
154 - int method_index, Bytecodes::Code bc);
155 - ciMethod* get_fake_invokedynamic_method_impl(ciInstanceKlass* accessor,
158 + ciMethod* get_method_by_index_impl(constantPoolHandle cpool,
159 + int method_index, Bytecodes::Code bc,
160 + ciInstanceKlass* loading_klass);
161 + ciMethod* get_fake_invokedynamic_method_impl(constantPoolHandle cpool,
156 162 int index, Bytecodes::Code bc);
157 163
158 164 // Helper methods
159 165 bool check_klass_accessibility(ciKlass* accessing_klass,
160 166 klassOop resolved_klassOop);
161 167 methodOop lookup_method(instanceKlass* accessor,
162 168 instanceKlass* holder,
163 169 symbolOop name,
164 170 symbolOop sig,
165 171 Bytecodes::Code bc);
166 172
167 173 // Get a ciObject from the object factory. Ensures uniqueness
168 174 // of ciObjects.
169 175 ciObject* get_object(oop o) {
170 176 if (o == NULL) {
171 177 return _null_object_instance;
172 178 } else {
173 179 return _factory->get(o);
174 180 }
175 181 }
176 182
177 183 ciMethod* get_method_from_handle(jobject method);
178 184
179 185 ciInstance* get_or_create_exception(jobject& handle, symbolHandle name);
180 186
181 187 // Get a ciMethod representing either an unfound method or
182 188 // a method with an unloaded holder. Ensures uniqueness of
183 189 // the result.
184 190 ciMethod* get_unloaded_method(ciInstanceKlass* holder,
185 191 ciSymbol* name,
186 192 ciSymbol* signature) {
187 193 return _factory->get_unloaded_method(holder, name, signature);
188 194 }
189 195
190 196 // Get a ciKlass representing an unloaded klass.
191 197 // Ensures uniqueness of the result.
192 198 ciKlass* get_unloaded_klass(ciKlass* accessing_klass,
193 199 ciSymbol* name) {
194 200 return _factory->get_unloaded_klass(accessing_klass, name, true);
195 201 }
196 202
197 203 // See if we already have an unloaded klass for the given name
198 204 // or return NULL if not.
199 205 ciKlass *check_get_unloaded_klass(ciKlass* accessing_klass, ciSymbol* name) {
200 206 return _factory->get_unloaded_klass(accessing_klass, name, false);
201 207 }
202 208
203 209 // Get a ciReturnAddress corresponding to the given bci.
204 210 // Ensures uniqueness of the result.
205 211 ciReturnAddress* get_return_address(int bci) {
206 212 return _factory->get_return_address(bci);
207 213 }
208 214
209 215 // Get a ciMethodData representing the methodData for a method
210 216 // with none.
211 217 ciMethodData* get_empty_methodData() {
212 218 return _factory->get_empty_methodData();
213 219 }
214 220
215 221 // General utility : get a buffer of some required length.
216 222 // Used in symbol creation.
217 223 char* name_buffer(int req_len);
218 224
219 225 // Is this thread currently in the VM state?
220 226 static bool is_in_vm();
221 227
222 228 // Helper routine for determining the validity of a compilation
223 229 // with respect to concurrent class loading.
224 230 void check_for_system_dictionary_modification(ciMethod* target);
225 231
226 232 public:
227 233 enum {
228 234 MethodCompilable,
229 235 MethodCompilable_not_at_tier,
230 236 MethodCompilable_never
231 237 };
232 238
233 239 ciEnv(CompileTask* task, int system_dictionary_modification_counter);
234 240 // Used only during initialization of the ci
235 241 ciEnv(Arena* arena);
236 242 ~ciEnv();
237 243
238 244 OopRecorder* oop_recorder() { return _oop_recorder; }
239 245 void set_oop_recorder(OopRecorder* r) { _oop_recorder = r; }
240 246
241 247 DebugInformationRecorder* debug_info() { return _debug_info; }
242 248 void set_debug_info(DebugInformationRecorder* i) { _debug_info = i; }
243 249
244 250 Dependencies* dependencies() { return _dependencies; }
245 251 void set_dependencies(Dependencies* d) { _dependencies = d; }
246 252
247 253 // This is true if the compilation is not going to produce code.
248 254 // (It is reasonable to retry failed compilations.)
249 255 bool failing() { return _failure_reason != NULL; }
250 256
251 257 // Reason this compilation is failing, such as "too many basic blocks".
252 258 const char* failure_reason() { return _failure_reason; }
253 259
254 260 // Return state of appropriate compilability
255 261 int compilable() { return _compilable; }
256 262
257 263 bool break_at_compile() { return _break_at_compile; }
258 264 void set_break_at_compile(bool z) { _break_at_compile = z; }
259 265
260 266 // Cache Jvmti state
261 267 void cache_jvmti_state();
262 268 bool jvmti_can_hotswap_or_post_breakpoint() const { return _jvmti_can_hotswap_or_post_breakpoint; }
263 269 bool jvmti_can_examine_or_deopt_anywhere() const { return _jvmti_can_examine_or_deopt_anywhere; }
264 270 bool jvmti_can_access_local_variables() const { return _jvmti_can_access_local_variables; }
265 271 bool jvmti_can_post_exceptions() const { return _jvmti_can_post_exceptions; }
266 272
267 273 // Cache DTrace flags
268 274 void cache_dtrace_flags();
269 275 bool dtrace_extended_probes() const { return _dtrace_extended_probes; }
270 276 bool dtrace_monitor_probes() const { return _dtrace_monitor_probes; }
271 277 bool dtrace_method_probes() const { return _dtrace_method_probes; }
272 278 bool dtrace_alloc_probes() const { return _dtrace_alloc_probes; }
273 279
274 280 // The compiler task which has created this env.
275 281 // May be useful to find out compile_id, comp_level, etc.
276 282 CompileTask* task() { return _task; }
277 283 // Handy forwards to the task:
278 284 int comp_level(); // task()->comp_level()
279 285 uint compile_id(); // task()->compile_id()
280 286
281 287 // Register the result of a compilation.
282 288 void register_method(ciMethod* target,
283 289 int entry_bci,
284 290 CodeOffsets* offsets,
285 291 int orig_pc_offset,
286 292 CodeBuffer* code_buffer,
287 293 int frame_words,
288 294 OopMapSet* oop_map_set,
289 295 ExceptionHandlerTable* handler_table,
290 296 ImplicitExceptionTable* inc_table,
291 297 AbstractCompiler* compiler,
292 298 int comp_level,
293 299 bool has_debug_info = true,
294 300 bool has_unsafe_access = false);
295 301
296 302
297 303 // Access to certain well known ciObjects.
298 304 ciInstanceKlass* ArrayStoreException_klass() {
299 305 return _ArrayStoreException;
300 306 }
301 307 ciInstanceKlass* Class_klass() {
302 308 return _Class;
303 309 }
304 310 ciInstanceKlass* ClassCastException_klass() {
305 311 return _ClassCastException;
306 312 }
307 313 ciInstanceKlass* InvokeDynamic_klass() {
308 314 return _InvokeDynamic;
309 315 }
310 316 ciInstanceKlass* Object_klass() {
311 317 return _Object;
312 318 }
313 319 ciInstanceKlass* Throwable_klass() {
314 320 return _Throwable;
315 321 }
316 322 ciInstanceKlass* Thread_klass() {
317 323 return _Thread;
318 324 }
319 325 ciInstanceKlass* OutOfMemoryError_klass() {
320 326 return _OutOfMemoryError;
321 327 }
322 328 ciInstanceKlass* String_klass() {
323 329 return _String;
324 330 }
325 331 ciInstanceKlass* StringBuilder_klass() {
326 332 return _StringBuilder;
327 333 }
328 334 ciInstanceKlass* StringBuffer_klass() {
329 335 return _StringBuffer;
330 336 }
331 337 ciInstanceKlass* Integer_klass() {
332 338 return _Integer;
333 339 }
334 340 ciInstance* NullPointerException_instance() {
335 341 assert(_NullPointerException_instance != NULL, "initialization problem");
336 342 return _NullPointerException_instance;
337 343 }
338 344 ciInstance* ArithmeticException_instance() {
339 345 assert(_ArithmeticException_instance != NULL, "initialization problem");
340 346 return _ArithmeticException_instance;
341 347 }
342 348
343 349 // Lazy constructors:
344 350 ciInstance* ArrayIndexOutOfBoundsException_instance();
345 351 ciInstance* ArrayStoreException_instance();
346 352 ciInstance* ClassCastException_instance();
347 353
348 354 ciInstance* the_null_string();
349 355 ciInstance* the_min_jint_string();
350 356
351 357 static ciSymbol* unloaded_cisymbol() {
352 358 return _unloaded_cisymbol;
353 359 }
354 360 static ciObjArrayKlass* unloaded_ciobjarrayklass() {
355 361 return _unloaded_ciobjarrayklass;
356 362 }
357 363 static ciInstanceKlass* unloaded_ciinstance_klass() {
358 364 return _unloaded_ciinstance_klass;
359 365 }
360 366
361 367 ciKlass* find_system_klass(ciSymbol* klass_name);
362 368 // Note: To find a class from its name string, use ciSymbol::make,
363 369 // but consider adding to vmSymbols.hpp instead.
364 370
365 371 // Use this to make a holder for non-perm compile time constants.
366 372 // The resulting array is guaranteed to satisfy "can_be_constant".
367 373 ciArray* make_system_array(GrowableArray<ciObject*>* objects);
368 374
369 375 // converts the ciKlass* representing the holder of a method into a
370 376 // ciInstanceKlass*. This is needed since the holder of a method in
371 377 // the bytecodes could be an array type. Basically this converts
372 378 // array types into java/lang/Object and other types stay as they are.
373 379 static ciInstanceKlass* get_instance_klass_for_declared_method_holder(ciKlass* klass);
374 380
375 381 // Return the machine-level offset of o, which must be an element of a.
376 382 // This may be used to form constant-loading expressions in lieu of simpler encodings.
377 383 int array_element_offset_in_bytes(ciArray* a, ciObject* o);
378 384
379 385 // Access to the compile-lifetime allocation arena.
380 386 Arena* arena() { return _arena; }
381 387
382 388 // What is the current compilation environment?
383 389 static ciEnv* current() { return CompilerThread::current()->env(); }
384 390
385 391 // Overload with current thread argument
386 392 static ciEnv* current(CompilerThread *thread) { return thread->env(); }
387 393
388 394 // Per-compiler data. (Used by C2 to publish the Compile* pointer.)
389 395 void* compiler_data() { return _compiler_data; }
390 396 void set_compiler_data(void* x) { _compiler_data = x; }
391 397
392 398 // Notice that a method has been inlined in the current compile;
393 399 // used only for statistics.
394 400 void notice_inlined_method(ciMethod* method);
395 401
396 402 // Total number of bytecodes in inlined methods in this compile
397 403 int num_inlined_bytecodes() const;
398 404
399 405 // Output stream for logging compilation info.
400 406 CompileLog* log() { return _log; }
401 407 void set_log(CompileLog* log) { _log = log; }
402 408
403 409 // Check for changes to the system dictionary during compilation
404 410 bool system_dictionary_modification_counter_changed();
405 411
406 412 void record_failure(const char* reason);
407 413 void record_method_not_compilable(const char* reason, bool all_tiers = true);
408 414 void record_out_of_memory_failure();
409 415 };
↓ open down ↓ |
244 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX