14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_CI_CIENV_HPP
26 #define SHARE_VM_CI_CIENV_HPP
27
28 #include "ci/ciClassList.hpp"
29 #include "ci/ciObjectFactory.hpp"
30 #include "classfile/systemDictionary.hpp"
31 #include "code/debugInfoRec.hpp"
32 #include "code/dependencies.hpp"
33 #include "code/exceptionHandlerTable.hpp"
34 #include "compiler/oopMap.hpp"
35 #include "runtime/thread.hpp"
36
37 class CompileTask;
38
39 // ciEnv
40 //
41 // This class is the top level broker for requests from the compiler
42 // to the VM.
43 class ciEnv : StackObj {
44 CI_PACKAGE_ACCESS_TO
45
46 friend class CompileBroker;
47 friend class Dependencies; // for get_object, during logging
48
49 private:
50 Arena* _arena; // Alias for _ciEnv_arena except in init_shared_objects()
51 Arena _ciEnv_arena;
52 int _system_dictionary_modification_counter;
53 ciObjectFactory* _factory;
54 OopRecorder* _oop_recorder;
55 DebugInformationRecorder* _debug_info;
56 Dependencies* _dependencies;
57 const char* _failure_reason;
58 int _compilable;
59 bool _break_at_compile;
60 int _num_inlined_bytecodes;
61 CompileTask* _task; // faster access to CompilerThread::task
62 CompileLog* _log; // faster access to CompilerThread::log
63 void* _compiler_data; // compiler-specific stuff, if any
64
65 char* _name_buffer;
66 int _name_buffer_len;
67
68 // Cache Jvmti state
69 bool _jvmti_can_hotswap_or_post_breakpoint;
70 bool _jvmti_can_access_local_variables;
71 bool _jvmti_can_post_on_exceptions;
72 bool _jvmti_can_pop_frame;
73
74 // Cache DTrace flags
75 bool _dtrace_extended_probes;
76 bool _dtrace_monitor_probes;
77 bool _dtrace_method_probes;
78 bool _dtrace_alloc_probes;
79
80 // Distinguished instances of certain ciObjects..
81 static ciObject* _null_object_instance;
82
83 #define WK_KLASS_DECL(name, ignore_s, ignore_o) static ciInstanceKlass* _##name;
277 }
278
279 // General utility : get a buffer of some required length.
280 // Used in symbol creation.
281 char* name_buffer(int req_len);
282
283 // Is this thread currently in the VM state?
284 static bool is_in_vm();
285
286 // Helper routine for determining the validity of a compilation with
287 // respect to method dependencies (e.g. concurrent class loading).
288 void validate_compile_task_dependencies(ciMethod* target);
289
290 public:
291 enum {
292 MethodCompilable,
293 MethodCompilable_not_at_tier,
294 MethodCompilable_never
295 };
296
297 ciEnv(CompileTask* task, int system_dictionary_modification_counter);
298 // Used only during initialization of the ci
299 ciEnv(Arena* arena);
300 ~ciEnv();
301
302 OopRecorder* oop_recorder() { return _oop_recorder; }
303 void set_oop_recorder(OopRecorder* r) { _oop_recorder = r; }
304
305 DebugInformationRecorder* debug_info() { return _debug_info; }
306 void set_debug_info(DebugInformationRecorder* i) { _debug_info = i; }
307
308 Dependencies* dependencies() { return _dependencies; }
309 void set_dependencies(Dependencies* d) { _dependencies = d; }
310
311 // This is true if the compilation is not going to produce code.
312 // (It is reasonable to retry failed compilations.)
313 bool failing() { return _failure_reason != NULL; }
314
315 // Reason this compilation is failing, such as "too many basic blocks".
316 const char* failure_reason() { return _failure_reason; }
317
335 bool break_at_compile() { return _break_at_compile; }
336 void set_break_at_compile(bool z) { _break_at_compile = z; }
337
338 // Cache Jvmti state
339 void cache_jvmti_state();
340 bool jvmti_state_changed() const;
341 bool should_retain_local_variables() const;
342 bool jvmti_can_hotswap_or_post_breakpoint() const { return _jvmti_can_hotswap_or_post_breakpoint; }
343 bool jvmti_can_post_on_exceptions() const { return _jvmti_can_post_on_exceptions; }
344
345 // Cache DTrace flags
346 void cache_dtrace_flags();
347 bool dtrace_extended_probes() const { return _dtrace_extended_probes; }
348 bool dtrace_monitor_probes() const { return _dtrace_monitor_probes; }
349 bool dtrace_method_probes() const { return _dtrace_method_probes; }
350 bool dtrace_alloc_probes() const { return _dtrace_alloc_probes; }
351
352 // The compiler task which has created this env.
353 // May be useful to find out compile_id, comp_level, etc.
354 CompileTask* task() { return _task; }
355
356 // Handy forwards to the task:
357 int comp_level(); // task()->comp_level()
358 uint compile_id(); // task()->compile_id()
359
360 // Register the result of a compilation.
361 void register_method(ciMethod* target,
362 int entry_bci,
363 CodeOffsets* offsets,
364 int orig_pc_offset,
365 CodeBuffer* code_buffer,
366 int frame_words,
367 OopMapSet* oop_map_set,
368 ExceptionHandlerTable* handler_table,
369 ImplicitExceptionTable* inc_table,
370 AbstractCompiler* compiler,
371 bool has_unsafe_access,
372 bool has_wide_vectors,
373 RTMState rtm_state = NoRTM);
374
|
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_CI_CIENV_HPP
26 #define SHARE_VM_CI_CIENV_HPP
27
28 #include "ci/ciClassList.hpp"
29 #include "ci/ciObjectFactory.hpp"
30 #include "classfile/systemDictionary.hpp"
31 #include "code/debugInfoRec.hpp"
32 #include "code/dependencies.hpp"
33 #include "code/exceptionHandlerTable.hpp"
34 #include "compiler/compilerDirectives.hpp"
35 #include "compiler/oopMap.hpp"
36 #include "runtime/thread.hpp"
37
38 class CompileTask;
39
40 // ciEnv
41 //
42 // This class is the top level broker for requests from the compiler
43 // to the VM.
44 class ciEnv : StackObj {
45 CI_PACKAGE_ACCESS_TO
46
47 friend class CompileBroker;
48 friend class Dependencies; // for get_object, during logging
49
50 private:
51 Arena* _arena; // Alias for _ciEnv_arena except in init_shared_objects()
52 Arena _ciEnv_arena;
53 int _system_dictionary_modification_counter;
54 ciObjectFactory* _factory;
55 OopRecorder* _oop_recorder;
56 DebugInformationRecorder* _debug_info;
57 Dependencies* _dependencies;
58 const char* _failure_reason;
59 int _compilable;
60 bool _break_at_compile;
61 int _num_inlined_bytecodes;
62 CompileTask* _task; // faster access to CompilerThread::task
63 CompileLog* _log; // faster access to CompilerThread::log
64 void* _compiler_data; // compiler-specific stuff, if any
65 DirectiveSet* _directive;
66
67 char* _name_buffer;
68 int _name_buffer_len;
69
70 // Cache Jvmti state
71 bool _jvmti_can_hotswap_or_post_breakpoint;
72 bool _jvmti_can_access_local_variables;
73 bool _jvmti_can_post_on_exceptions;
74 bool _jvmti_can_pop_frame;
75
76 // Cache DTrace flags
77 bool _dtrace_extended_probes;
78 bool _dtrace_monitor_probes;
79 bool _dtrace_method_probes;
80 bool _dtrace_alloc_probes;
81
82 // Distinguished instances of certain ciObjects..
83 static ciObject* _null_object_instance;
84
85 #define WK_KLASS_DECL(name, ignore_s, ignore_o) static ciInstanceKlass* _##name;
279 }
280
281 // General utility : get a buffer of some required length.
282 // Used in symbol creation.
283 char* name_buffer(int req_len);
284
285 // Is this thread currently in the VM state?
286 static bool is_in_vm();
287
288 // Helper routine for determining the validity of a compilation with
289 // respect to method dependencies (e.g. concurrent class loading).
290 void validate_compile_task_dependencies(ciMethod* target);
291
292 public:
293 enum {
294 MethodCompilable,
295 MethodCompilable_not_at_tier,
296 MethodCompilable_never
297 };
298
299 ciEnv(CompileTask* task, int system_dictionary_modification_counter, DirectiveSet* set);
300 // Used only during initialization of the ci
301 ciEnv(Arena* arena);
302 ~ciEnv();
303
304 OopRecorder* oop_recorder() { return _oop_recorder; }
305 void set_oop_recorder(OopRecorder* r) { _oop_recorder = r; }
306
307 DebugInformationRecorder* debug_info() { return _debug_info; }
308 void set_debug_info(DebugInformationRecorder* i) { _debug_info = i; }
309
310 Dependencies* dependencies() { return _dependencies; }
311 void set_dependencies(Dependencies* d) { _dependencies = d; }
312
313 // This is true if the compilation is not going to produce code.
314 // (It is reasonable to retry failed compilations.)
315 bool failing() { return _failure_reason != NULL; }
316
317 // Reason this compilation is failing, such as "too many basic blocks".
318 const char* failure_reason() { return _failure_reason; }
319
337 bool break_at_compile() { return _break_at_compile; }
338 void set_break_at_compile(bool z) { _break_at_compile = z; }
339
340 // Cache Jvmti state
341 void cache_jvmti_state();
342 bool jvmti_state_changed() const;
343 bool should_retain_local_variables() const;
344 bool jvmti_can_hotswap_or_post_breakpoint() const { return _jvmti_can_hotswap_or_post_breakpoint; }
345 bool jvmti_can_post_on_exceptions() const { return _jvmti_can_post_on_exceptions; }
346
347 // Cache DTrace flags
348 void cache_dtrace_flags();
349 bool dtrace_extended_probes() const { return _dtrace_extended_probes; }
350 bool dtrace_monitor_probes() const { return _dtrace_monitor_probes; }
351 bool dtrace_method_probes() const { return _dtrace_method_probes; }
352 bool dtrace_alloc_probes() const { return _dtrace_alloc_probes; }
353
354 // The compiler task which has created this env.
355 // May be useful to find out compile_id, comp_level, etc.
356 CompileTask* task() { return _task; }
357 DirectiveSet* directive() { return _directive; }
358
359 // Handy forwards to the task:
360 int comp_level(); // task()->comp_level()
361 uint compile_id(); // task()->compile_id()
362
363 // Register the result of a compilation.
364 void register_method(ciMethod* target,
365 int entry_bci,
366 CodeOffsets* offsets,
367 int orig_pc_offset,
368 CodeBuffer* code_buffer,
369 int frame_words,
370 OopMapSet* oop_map_set,
371 ExceptionHandlerTable* handler_table,
372 ImplicitExceptionTable* inc_table,
373 AbstractCompiler* compiler,
374 bool has_unsafe_access,
375 bool has_wide_vectors,
376 RTMState rtm_state = NoRTM);
377
|