< prev index next >

src/hotspot/share/ci/ciEnv.hpp

Print this page

 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_CI_CIENV_HPP
 26 #define SHARE_CI_CIENV_HPP
 27 
 28 #include "ci/ciClassList.hpp"
 29 #include "ci/ciObjectFactory.hpp"
 30 #include "classfile/vmClassMacros.hpp"
 31 #include "code/debugInfoRec.hpp"
 32 #include "code/dependencies.hpp"
 33 #include "code/exceptionHandlerTable.hpp"
 34 #include "compiler/cHeapStringHolder.hpp"
 35 #include "compiler/compiler_globals.hpp"
 36 #include "compiler/compilerThread.hpp"

 37 #include "oops/methodData.hpp"
 38 #include "runtime/javaThread.hpp"
 39 
 40 class CompileTask;
 41 class OopMapSet;


 42 
 43 // ciEnv
 44 //
 45 // This class is the top level broker for requests from the compiler
 46 // to the VM.
 47 class ciEnv : StackObj {
 48   CI_PACKAGE_ACCESS_TO
 49   friend class CompileBroker;
 50   friend class Dependencies;  // for get_object, during logging
 51   friend class RecordLocation;
 52   friend class PrepareExtraDataClosure;
 53 
 54 private:
 55   Arena*           _arena;       // Alias for _ciEnv_arena except in init_shared_objects()
 56   Arena            _ciEnv_arena;
 57   ciObjectFactory* _factory;
 58   OopRecorder*     _oop_recorder;
 59   DebugInformationRecorder* _debug_info;
 60   Dependencies*    _dependencies;
 61   CHeapStringHolder _failure_reason;

206   ciTypeArrayKlass* get_type_array_klass(Klass* o) {
207     if (o == nullptr) return nullptr;
208     return get_metadata(o)->as_type_array_klass();
209   }
210   ciKlass* get_klass(Klass* o) {
211     if (o == nullptr) return nullptr;
212     return get_metadata(o)->as_klass();
213   }
214   ciInstanceKlass* get_instance_klass(Klass* o) {
215     if (o == nullptr) return nullptr;
216     return get_metadata(o)->as_instance_klass();
217   }
218   ciMethod* get_method(Method* o) {
219     if (o == nullptr) return nullptr;
220     return get_metadata(o)->as_method();
221   }
222   ciMethodData* get_method_data(MethodData* o) {
223     if (o == nullptr) return nullptr;
224     return get_metadata(o)->as_method_data();
225   }




226 
227   ciMethod* get_method_from_handle(Method* method);
228 
229   // Get a ciMethod representing either an unfound method or
230   // a method with an unloaded holder.  Ensures uniqueness of
231   // the result.
232   ciMethod* get_unloaded_method(ciKlass*         holder,
233                                 ciSymbol*        name,
234                                 ciSymbol*        signature,
235                                 ciInstanceKlass* accessor) {
236     ciInstanceKlass* declared_holder = get_instance_klass_for_declared_method_holder(holder);
237     return _factory->get_unloaded_method(declared_holder, name, signature, accessor);
238   }
239 
240   // Get a ciKlass representing an unloaded klass.
241   // Ensures uniqueness of the result.
242   ciKlass* get_unloaded_klass(ciKlass*  accessing_klass,
243                               ciSymbol* name) {
244     return _factory->get_unloaded_klass(accessing_klass, name, true);
245   }

274   ciReturnAddress* get_return_address(int bci) {
275     return _factory->get_return_address(bci);
276   }
277 
278   // Get a ciMethodData representing the methodData for a method
279   // with none.
280   ciMethodData* get_empty_methodData() {
281     return _factory->get_empty_methodData();
282   }
283 
284   // General utility : get a buffer of some required length.
285   // Used in symbol creation.
286   char* name_buffer(int req_len);
287 
288   // Is this thread currently in the VM state?
289   static bool is_in_vm();
290 
291   // Helper routine for determining the validity of a compilation with
292   // respect to method dependencies (e.g. concurrent class loading).
293   void validate_compile_task_dependencies(ciMethod* target);






294 public:
295   enum {
296     MethodCompilable,
297     MethodCompilable_not_at_tier,
298     MethodCompilable_never
299   };
300 
301   ciEnv(CompileTask* task);
302   // Used only during initialization of the ci
303   ciEnv(Arena* arena);
304   ~ciEnv();
305 
306   OopRecorder* oop_recorder() { return _oop_recorder; }
307   void set_oop_recorder(OopRecorder* r) { _oop_recorder = r; }
308 
309   DebugInformationRecorder* debug_info() { return _debug_info; }
310   void set_debug_info(DebugInformationRecorder* i) { _debug_info = i; }
311 
312   Dependencies* dependencies() { return _dependencies; }
313   void set_dependencies(Dependencies* d) { _dependencies = d; }

346     return _jvmti_can_access_local_variables || _jvmti_can_pop_frame;
347   }
348   bool  jvmti_can_hotswap_or_post_breakpoint() const { return _jvmti_can_hotswap_or_post_breakpoint; }
349   bool  jvmti_can_post_on_exceptions()         const { return _jvmti_can_post_on_exceptions; }
350   bool  jvmti_can_get_owned_monitor_info()     const { return _jvmti_can_get_owned_monitor_info; }
351   bool  jvmti_can_walk_any_space()             const { return _jvmti_can_walk_any_space; }
352 
353   // Cache DTrace flags
354   void  cache_dtrace_flags();
355   bool  dtrace_method_probes()   const { return _dtrace_method_probes; }
356   bool  dtrace_alloc_probes()    const { return _dtrace_alloc_probes; }
357 
358   // The compiler task which has created this env.
359   // May be useful to find out compile_id, comp_level, etc.
360   CompileTask* task() const { return _task; }
361 
362   // Handy forwards to the task:
363   int comp_level();   // task()->comp_level()
364   int compile_id();  // task()->compile_id()
365 














366   // Register the result of a compilation.
367   void register_method(ciMethod*                 target,
368                        int                       entry_bci,
369                        CodeOffsets*              offsets,
370                        int                       orig_pc_offset,
371                        CodeBuffer*               code_buffer,
372                        int                       frame_words,
373                        OopMapSet*                oop_map_set,
374                        ExceptionHandlerTable*    handler_table,
375                        ImplicitExceptionTable*   inc_table,
376                        AbstractCompiler*         compiler,


377                        bool                      has_unsafe_access,
378                        bool                      has_wide_vectors,
379                        bool                      has_monitors,
380                        bool                      has_scoped_access,
381                        int                       immediate_oops_patched);

382 
383   // Access to certain well known ciObjects.
384 #define VM_CLASS_FUNC(name, ignore_s) \
385   ciInstanceKlass* name() { \
386     return _##name;\
387   }
388   VM_CLASSES_DO(VM_CLASS_FUNC)
389 #undef VM_CLASS_FUNC
390 
391   ciInstance* NullPointerException_instance() {
392     assert(_NullPointerException_instance != nullptr, "initialization problem");
393     return _NullPointerException_instance;
394   }
395   ciInstance* ArithmeticException_instance() {
396     assert(_ArithmeticException_instance != nullptr, "initialization problem");
397     return _ArithmeticException_instance;
398   }
399   ciInstance* ArrayIndexOutOfBoundsException_instance() {
400     assert(_ArrayIndexOutOfBoundsException_instance != nullptr, "initialization problem");
401     return _ArrayIndexOutOfBoundsException_instance;

495   void dump_replay_data(int compile_id);
496   void dump_inline_data(int compile_id);
497   void dump_replay_data(outputStream* out);
498   void dump_replay_data_unsafe(outputStream* out);
499   void dump_replay_data_helper(outputStream* out);
500   void dump_compile_data(outputStream* out);
501   void dump_replay_data_version(outputStream* out);
502 
503   const char *dyno_name(const InstanceKlass* ik) const;
504   const char *replay_name(const InstanceKlass* ik) const;
505   const char *replay_name(ciKlass* i) const;
506 
507   void record_lambdaform(Thread* thread, oop obj);
508   void record_member(Thread* thread, oop obj);
509   void record_mh(Thread* thread, oop obj);
510   void record_call_site_obj(Thread* thread, oop obj);
511   void record_call_site_method(Thread* thread, Method* adapter);
512   void process_invokedynamic(const constantPoolHandle &cp, int index, JavaThread* thread);
513   void process_invokehandle(const constantPoolHandle &cp, int index, JavaThread* thread);
514   void find_dynamic_call_sites();



515 };
516 
517 #endif // SHARE_CI_CIENV_HPP

 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_CI_CIENV_HPP
 26 #define SHARE_CI_CIENV_HPP
 27 
 28 #include "ci/ciClassList.hpp"
 29 #include "ci/ciObjectFactory.hpp"
 30 #include "classfile/vmClassMacros.hpp"
 31 #include "code/debugInfoRec.hpp"
 32 #include "code/dependencies.hpp"
 33 #include "code/exceptionHandlerTable.hpp"
 34 #include "compiler/cHeapStringHolder.hpp"
 35 #include "compiler/compiler_globals.hpp"
 36 #include "compiler/compilerThread.hpp"
 37 #include "oops/methodCounters.hpp"
 38 #include "oops/methodData.hpp"
 39 #include "runtime/javaThread.hpp"
 40 
 41 class CompileTask;
 42 class OopMapSet;
 43 class AOTCodeEntry;
 44 class AOTCodeReader;
 45 
 46 // ciEnv
 47 //
 48 // This class is the top level broker for requests from the compiler
 49 // to the VM.
 50 class ciEnv : StackObj {
 51   CI_PACKAGE_ACCESS_TO
 52   friend class CompileBroker;
 53   friend class Dependencies;  // for get_object, during logging
 54   friend class RecordLocation;
 55   friend class PrepareExtraDataClosure;
 56 
 57 private:
 58   Arena*           _arena;       // Alias for _ciEnv_arena except in init_shared_objects()
 59   Arena            _ciEnv_arena;
 60   ciObjectFactory* _factory;
 61   OopRecorder*     _oop_recorder;
 62   DebugInformationRecorder* _debug_info;
 63   Dependencies*    _dependencies;
 64   CHeapStringHolder _failure_reason;

209   ciTypeArrayKlass* get_type_array_klass(Klass* o) {
210     if (o == nullptr) return nullptr;
211     return get_metadata(o)->as_type_array_klass();
212   }
213   ciKlass* get_klass(Klass* o) {
214     if (o == nullptr) return nullptr;
215     return get_metadata(o)->as_klass();
216   }
217   ciInstanceKlass* get_instance_klass(Klass* o) {
218     if (o == nullptr) return nullptr;
219     return get_metadata(o)->as_instance_klass();
220   }
221   ciMethod* get_method(Method* o) {
222     if (o == nullptr) return nullptr;
223     return get_metadata(o)->as_method();
224   }
225   ciMethodData* get_method_data(MethodData* o) {
226     if (o == nullptr) return nullptr;
227     return get_metadata(o)->as_method_data();
228   }
229   ciMetadata* get_method_counters(MethodCounters* o) {
230     if (o == nullptr) return nullptr;
231     return get_metadata((Metadata*)o);
232   }
233 
234   ciMethod* get_method_from_handle(Method* method);
235 
236   // Get a ciMethod representing either an unfound method or
237   // a method with an unloaded holder.  Ensures uniqueness of
238   // the result.
239   ciMethod* get_unloaded_method(ciKlass*         holder,
240                                 ciSymbol*        name,
241                                 ciSymbol*        signature,
242                                 ciInstanceKlass* accessor) {
243     ciInstanceKlass* declared_holder = get_instance_klass_for_declared_method_holder(holder);
244     return _factory->get_unloaded_method(declared_holder, name, signature, accessor);
245   }
246 
247   // Get a ciKlass representing an unloaded klass.
248   // Ensures uniqueness of the result.
249   ciKlass* get_unloaded_klass(ciKlass*  accessing_klass,
250                               ciSymbol* name) {
251     return _factory->get_unloaded_klass(accessing_klass, name, true);
252   }

281   ciReturnAddress* get_return_address(int bci) {
282     return _factory->get_return_address(bci);
283   }
284 
285   // Get a ciMethodData representing the methodData for a method
286   // with none.
287   ciMethodData* get_empty_methodData() {
288     return _factory->get_empty_methodData();
289   }
290 
291   // General utility : get a buffer of some required length.
292   // Used in symbol creation.
293   char* name_buffer(int req_len);
294 
295   // Is this thread currently in the VM state?
296   static bool is_in_vm();
297 
298   // Helper routine for determining the validity of a compilation with
299   // respect to method dependencies (e.g. concurrent class loading).
300   void validate_compile_task_dependencies(ciMethod* target);
301 
302   // Helper rountimes to factor out common code used by routines that register a method
303   // i.e. register_aot_method() and register_method()
304   bool is_compilation_valid(JavaThread* thread, ciMethod* target, bool install_code, bool is_loading_aot_code, bool preload);
305   void make_code_usable(JavaThread* thread, ciMethod* target, bool preload, int entry_bci, AOTCodeEntry* aot_code_entry, nmethod* nm);
306 
307 public:
308   enum {
309     MethodCompilable,
310     MethodCompilable_not_at_tier,
311     MethodCompilable_never
312   };
313 
314   ciEnv(CompileTask* task);
315   // Used only during initialization of the ci
316   ciEnv(Arena* arena);
317   ~ciEnv();
318 
319   OopRecorder* oop_recorder() { return _oop_recorder; }
320   void set_oop_recorder(OopRecorder* r) { _oop_recorder = r; }
321 
322   DebugInformationRecorder* debug_info() { return _debug_info; }
323   void set_debug_info(DebugInformationRecorder* i) { _debug_info = i; }
324 
325   Dependencies* dependencies() { return _dependencies; }
326   void set_dependencies(Dependencies* d) { _dependencies = d; }

359     return _jvmti_can_access_local_variables || _jvmti_can_pop_frame;
360   }
361   bool  jvmti_can_hotswap_or_post_breakpoint() const { return _jvmti_can_hotswap_or_post_breakpoint; }
362   bool  jvmti_can_post_on_exceptions()         const { return _jvmti_can_post_on_exceptions; }
363   bool  jvmti_can_get_owned_monitor_info()     const { return _jvmti_can_get_owned_monitor_info; }
364   bool  jvmti_can_walk_any_space()             const { return _jvmti_can_walk_any_space; }
365 
366   // Cache DTrace flags
367   void  cache_dtrace_flags();
368   bool  dtrace_method_probes()   const { return _dtrace_method_probes; }
369   bool  dtrace_alloc_probes()    const { return _dtrace_alloc_probes; }
370 
371   // The compiler task which has created this env.
372   // May be useful to find out compile_id, comp_level, etc.
373   CompileTask* task() const { return _task; }
374 
375   // Handy forwards to the task:
376   int comp_level();   // task()->comp_level()
377   int compile_id();  // task()->compile_id()
378 
379   // Register method loaded from AOT code cache
380   nmethod* register_aot_method(JavaThread* thread,
381                                ciMethod* target,
382                                AbstractCompiler* compiler,
383                                nmethod* archived_nm,
384                                address reloc_data,
385                                GrowableArray<Handle>& oop_list,
386                                GrowableArray<Metadata*>& metadata_list,
387                                ImmutableOopMapSet* oopmaps,
388                                address immutable_data,
389                                GrowableArray<Handle>& reloc_imm_oop_list,
390                                GrowableArray<Metadata*>& reloc_imm_metadata_list,
391                                AOTCodeReader* aot_code_reader);
392 
393   // Register the result of a compilation.
394   void register_method(ciMethod*                 target,
395                        int                       entry_bci,
396                        CodeOffsets*              offsets,
397                        int                       orig_pc_offset,
398                        CodeBuffer*               code_buffer,
399                        int                       frame_words,
400                        OopMapSet*                oop_map_set,
401                        ExceptionHandlerTable*    handler_table,
402                        ImplicitExceptionTable*   inc_table,
403                        AbstractCompiler*         compiler,
404                        bool                      has_clinit_barriers,
405                        bool                      for_preload,
406                        bool                      has_unsafe_access,
407                        bool                      has_wide_vectors,
408                        bool                      has_monitors,
409                        bool                      has_scoped_access,
410                        int                       immediate_oops_patched,
411                        bool                      install_code);
412 
413   // Access to certain well known ciObjects.
414 #define VM_CLASS_FUNC(name, ignore_s) \
415   ciInstanceKlass* name() { \
416     return _##name;\
417   }
418   VM_CLASSES_DO(VM_CLASS_FUNC)
419 #undef VM_CLASS_FUNC
420 
421   ciInstance* NullPointerException_instance() {
422     assert(_NullPointerException_instance != nullptr, "initialization problem");
423     return _NullPointerException_instance;
424   }
425   ciInstance* ArithmeticException_instance() {
426     assert(_ArithmeticException_instance != nullptr, "initialization problem");
427     return _ArithmeticException_instance;
428   }
429   ciInstance* ArrayIndexOutOfBoundsException_instance() {
430     assert(_ArrayIndexOutOfBoundsException_instance != nullptr, "initialization problem");
431     return _ArrayIndexOutOfBoundsException_instance;

525   void dump_replay_data(int compile_id);
526   void dump_inline_data(int compile_id);
527   void dump_replay_data(outputStream* out);
528   void dump_replay_data_unsafe(outputStream* out);
529   void dump_replay_data_helper(outputStream* out);
530   void dump_compile_data(outputStream* out);
531   void dump_replay_data_version(outputStream* out);
532 
533   const char *dyno_name(const InstanceKlass* ik) const;
534   const char *replay_name(const InstanceKlass* ik) const;
535   const char *replay_name(ciKlass* i) const;
536 
537   void record_lambdaform(Thread* thread, oop obj);
538   void record_member(Thread* thread, oop obj);
539   void record_mh(Thread* thread, oop obj);
540   void record_call_site_obj(Thread* thread, oop obj);
541   void record_call_site_method(Thread* thread, Method* adapter);
542   void process_invokedynamic(const constantPoolHandle &cp, int index, JavaThread* thread);
543   void process_invokehandle(const constantPoolHandle &cp, int index, JavaThread* thread);
544   void find_dynamic_call_sites();
545 
546   bool is_precompile();
547   InstanceKlass::ClassState compute_init_state_for_precompiled(InstanceKlass* ik);
548 };
549 
550 #endif // SHARE_CI_CIENV_HPP
< prev index next >