< prev index next >

src/hotspot/share/ci/ciEnv.hpp

Print this page

 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/compiler_globals.hpp"
 35 #include "compiler/compilerThread.hpp"
 36 #include "compiler/cHeapStringHolder.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;

213   }
214   ciKlass* get_klass(Klass* o) {
215     if (o == nullptr) return nullptr;
216     return get_metadata(o)->as_klass();
217   }
218   ciInstanceKlass* get_instance_klass(Klass* o) {
219     if (o == nullptr) return nullptr;
220     return get_metadata(o)->as_instance_klass();
221   }
222   ciMethod* get_method(Method* o) {
223     if (o == nullptr) return nullptr;
224     return get_metadata(o)->as_method();
225   }
226   ciMethodData* get_method_data(MethodData* o) {
227     if (o == nullptr) return nullptr;
228     return get_metadata(o)->as_method_data();
229   }
230 
231   ciMethod* get_method_from_handle(Method* method);
232 
233   ciInstance* get_or_create_exception(jobject& handle, Symbol* name);
234 
235   // Get a ciMethod representing either an unfound method or
236   // a method with an unloaded holder.  Ensures uniqueness of
237   // the result.
238   ciMethod* get_unloaded_method(ciKlass*         holder,
239                                 ciSymbol*        name,
240                                 ciSymbol*        signature,
241                                 ciInstanceKlass* accessor) {
242     ciInstanceKlass* declared_holder = get_instance_klass_for_declared_method_holder(holder);
243     return _factory->get_unloaded_method(declared_holder, name, signature, accessor);
244   }
245 
246   // Get a ciKlass representing an unloaded klass.
247   // Ensures uniqueness of the result.
248   ciKlass* get_unloaded_klass(ciKlass*  accessing_klass,
249                               ciSymbol* name) {
250     return _factory->get_unloaded_klass(accessing_klass, name, true);
251   }
252 
253   // Get a ciKlass representing an unloaded klass mirror.
254   // Result is not necessarily unique, but will be unloaded.

363 
364   // The compiler task which has created this env.
365   // May be useful to find out compile_id, comp_level, etc.
366   CompileTask* task() const { return _task; }
367 
368   // Handy forwards to the task:
369   int comp_level();   // task()->comp_level()
370   int compile_id();  // task()->compile_id()
371 
372   // Register the result of a compilation.
373   void register_method(ciMethod*                 target,
374                        int                       entry_bci,
375                        CodeOffsets*              offsets,
376                        int                       orig_pc_offset,
377                        CodeBuffer*               code_buffer,
378                        int                       frame_words,
379                        OopMapSet*                oop_map_set,
380                        ExceptionHandlerTable*    handler_table,
381                        ImplicitExceptionTable*   inc_table,
382                        AbstractCompiler*         compiler,


383                        bool                      has_unsafe_access,
384                        bool                      has_wide_vectors,
385                        bool                      has_monitors,
386                        int                       immediate_oops_patched,
387                        RTMState                  rtm_state = NoRTM);


388 
389   // Access to certain well known ciObjects.
390 #define VM_CLASS_FUNC(name, ignore_s) \
391   ciInstanceKlass* name() { \
392     return _##name;\
393   }
394   VM_CLASSES_DO(VM_CLASS_FUNC)
395 #undef VM_CLASS_FUNC
396 
397   ciInstance* NullPointerException_instance() {
398     assert(_NullPointerException_instance != nullptr, "initialization problem");
399     return _NullPointerException_instance;
400   }
401   ciInstance* ArithmeticException_instance() {
402     assert(_ArithmeticException_instance != nullptr, "initialization problem");
403     return _ArithmeticException_instance;
404   }
405 
406   // Lazy constructors:
407   ciInstance* ArrayIndexOutOfBoundsException_instance();

450 
451   // Notice that a method has been inlined in the current compile;
452   // used only for statistics.
453   void notice_inlined_method(ciMethod* method);
454 
455   // Total number of bytecodes in inlined methods in this compile
456   int num_inlined_bytecodes() const;
457 
458   // Output stream for logging compilation info.
459   CompileLog* log() { return _log; }
460   void set_log(CompileLog* log) { _log = log; }
461 
462   void record_failure(const char* reason);      // Record failure and report later
463   void report_failure(const char* reason);      // Report failure immediately
464   void record_method_not_compilable(const char* reason, bool all_tiers = false);
465   void record_out_of_memory_failure();
466 
467   // RedefineClasses support
468   void metadata_do(MetadataClosure* f) { _factory->metadata_do(f); }
469 







470   // Replay support
471 private:
472   static int klass_compare(const InstanceKlass* const &ik1, const InstanceKlass* const &ik2) {
473     if (ik1 > ik2) {
474       return 1;
475     } else if (ik1 < ik2) {
476       return -1;
477     } else {
478       return 0;
479     }
480   }
481   bool dyno_loc(const InstanceKlass* ik, const char *&loc) const;
482   void set_dyno_loc(const InstanceKlass* ik);
483   void record_best_dyno_loc(const InstanceKlass* ik);
484   bool print_dyno_loc(outputStream* out, const InstanceKlass* ik) const;
485 
486   GrowableArray<const InstanceKlass*>* _dyno_klasses;
487   GrowableArray<const char *>*         _dyno_locs;
488 
489 #define MAX_DYNO_NAME_LENGTH 1024

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




514 };
515 
516 #endif // SHARE_CI_CIENV_HPP

 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/compiler_globals.hpp"
 35 #include "compiler/compilerThread.hpp"
 36 #include "compiler/cHeapStringHolder.hpp"
 37 #include "oops/methodData.hpp"
 38 #include "runtime/javaThread.hpp"
 39 
 40 class CompileTask;
 41 class OopMapSet;
 42 class SCCEntry;
 43 
 44 // ciEnv
 45 //
 46 // This class is the top level broker for requests from the compiler
 47 // to the VM.
 48 class ciEnv : StackObj {
 49   CI_PACKAGE_ACCESS_TO
 50   friend class CompileBroker;
 51   friend class Dependencies;  // for get_object, during logging
 52   friend class RecordLocation;
 53   friend class PrepareExtraDataClosure;
 54 
 55 private:
 56   Arena*           _arena;       // Alias for _ciEnv_arena except in init_shared_objects()
 57   Arena            _ciEnv_arena;
 58   ciObjectFactory* _factory;
 59   OopRecorder*     _oop_recorder;
 60   DebugInformationRecorder* _debug_info;
 61   Dependencies*    _dependencies;
 62   CHeapStringHolder _failure_reason;

214   }
215   ciKlass* get_klass(Klass* o) {
216     if (o == nullptr) return nullptr;
217     return get_metadata(o)->as_klass();
218   }
219   ciInstanceKlass* get_instance_klass(Klass* o) {
220     if (o == nullptr) return nullptr;
221     return get_metadata(o)->as_instance_klass();
222   }
223   ciMethod* get_method(Method* o) {
224     if (o == nullptr) return nullptr;
225     return get_metadata(o)->as_method();
226   }
227   ciMethodData* get_method_data(MethodData* o) {
228     if (o == nullptr) return nullptr;
229     return get_metadata(o)->as_method_data();
230   }
231 
232   ciMethod* get_method_from_handle(Method* method);
233 


234   // Get a ciMethod representing either an unfound method or
235   // a method with an unloaded holder.  Ensures uniqueness of
236   // the result.
237   ciMethod* get_unloaded_method(ciKlass*         holder,
238                                 ciSymbol*        name,
239                                 ciSymbol*        signature,
240                                 ciInstanceKlass* accessor) {
241     ciInstanceKlass* declared_holder = get_instance_klass_for_declared_method_holder(holder);
242     return _factory->get_unloaded_method(declared_holder, name, signature, accessor);
243   }
244 
245   // Get a ciKlass representing an unloaded klass.
246   // Ensures uniqueness of the result.
247   ciKlass* get_unloaded_klass(ciKlass*  accessing_klass,
248                               ciSymbol* name) {
249     return _factory->get_unloaded_klass(accessing_klass, name, true);
250   }
251 
252   // Get a ciKlass representing an unloaded klass mirror.
253   // Result is not necessarily unique, but will be unloaded.

362 
363   // The compiler task which has created this env.
364   // May be useful to find out compile_id, comp_level, etc.
365   CompileTask* task() const { return _task; }
366 
367   // Handy forwards to the task:
368   int comp_level();   // task()->comp_level()
369   int compile_id();  // task()->compile_id()
370 
371   // Register the result of a compilation.
372   void register_method(ciMethod*                 target,
373                        int                       entry_bci,
374                        CodeOffsets*              offsets,
375                        int                       orig_pc_offset,
376                        CodeBuffer*               code_buffer,
377                        int                       frame_words,
378                        OopMapSet*                oop_map_set,
379                        ExceptionHandlerTable*    handler_table,
380                        ImplicitExceptionTable*   inc_table,
381                        AbstractCompiler*         compiler,
382                        bool                      has_clinit_barriers,
383                        bool                      for_preload,
384                        bool                      has_unsafe_access,
385                        bool                      has_wide_vectors,
386                        bool                      has_monitors,
387                        int                       immediate_oops_patched,
388                        bool                      install_code,
389                        RTMState                  rtm_state = NoRTM,
390                        SCCEntry*                 entry = nullptr);
391 
392   // Access to certain well known ciObjects.
393 #define VM_CLASS_FUNC(name, ignore_s) \
394   ciInstanceKlass* name() { \
395     return _##name;\
396   }
397   VM_CLASSES_DO(VM_CLASS_FUNC)
398 #undef VM_CLASS_FUNC
399 
400   ciInstance* NullPointerException_instance() {
401     assert(_NullPointerException_instance != nullptr, "initialization problem");
402     return _NullPointerException_instance;
403   }
404   ciInstance* ArithmeticException_instance() {
405     assert(_ArithmeticException_instance != nullptr, "initialization problem");
406     return _ArithmeticException_instance;
407   }
408 
409   // Lazy constructors:
410   ciInstance* ArrayIndexOutOfBoundsException_instance();

453 
454   // Notice that a method has been inlined in the current compile;
455   // used only for statistics.
456   void notice_inlined_method(ciMethod* method);
457 
458   // Total number of bytecodes in inlined methods in this compile
459   int num_inlined_bytecodes() const;
460 
461   // Output stream for logging compilation info.
462   CompileLog* log() { return _log; }
463   void set_log(CompileLog* log) { _log = log; }
464 
465   void record_failure(const char* reason);      // Record failure and report later
466   void report_failure(const char* reason);      // Report failure immediately
467   void record_method_not_compilable(const char* reason, bool all_tiers = false);
468   void record_out_of_memory_failure();
469 
470   // RedefineClasses support
471   void metadata_do(MetadataClosure* f) { _factory->metadata_do(f); }
472 
473 private:
474   SCCEntry* _scc_clinit_barriers_entry;
475 
476 public:
477   void  set_scc_clinit_barriers_entry(SCCEntry* entry) { _scc_clinit_barriers_entry = entry; }
478   SCCEntry* scc_clinit_barriers_entry()          const { return _scc_clinit_barriers_entry; }
479 
480   // Replay support
481 private:
482   static int klass_compare(const InstanceKlass* const &ik1, const InstanceKlass* const &ik2) {
483     if (ik1 > ik2) {
484       return 1;
485     } else if (ik1 < ik2) {
486       return -1;
487     } else {
488       return 0;
489     }
490   }
491   bool dyno_loc(const InstanceKlass* ik, const char *&loc) const;
492   void set_dyno_loc(const InstanceKlass* ik);
493   void record_best_dyno_loc(const InstanceKlass* ik);
494   bool print_dyno_loc(outputStream* out, const InstanceKlass* ik) const;
495 
496   GrowableArray<const InstanceKlass*>* _dyno_klasses;
497   GrowableArray<const char *>*         _dyno_locs;
498 
499 #define MAX_DYNO_NAME_LENGTH 1024

504   void dump_replay_data(int compile_id);
505   void dump_inline_data(int compile_id);
506   void dump_replay_data(outputStream* out);
507   void dump_replay_data_unsafe(outputStream* out);
508   void dump_replay_data_helper(outputStream* out);
509   void dump_compile_data(outputStream* out);
510   void dump_replay_data_version(outputStream* out);
511 
512   const char *dyno_name(const InstanceKlass* ik) const;
513   const char *replay_name(const InstanceKlass* ik) const;
514   const char *replay_name(ciKlass* i) const;
515 
516   void record_lambdaform(Thread* thread, oop obj);
517   void record_member(Thread* thread, oop obj);
518   void record_mh(Thread* thread, oop obj);
519   void record_call_site_obj(Thread* thread, oop obj);
520   void record_call_site_method(Thread* thread, Method* adapter);
521   void process_invokedynamic(const constantPoolHandle &cp, int index, JavaThread* thread);
522   void process_invokehandle(const constantPoolHandle &cp, int index, JavaThread* thread);
523   void find_dynamic_call_sites();
524 
525   bool is_precompiled();
526   bool is_fully_initialized(InstanceKlass* ik);
527   InstanceKlass::ClassState compute_init_state_for_precompiled(InstanceKlass* ik);
528 };
529 
530 #endif // SHARE_CI_CIENV_HPP
< prev index next >