< prev index next >

src/hotspot/share/ci/ciEnv.hpp

Print this page

 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/compiler_globals.hpp"
 35 #include "compiler/compilerThread.hpp"
 36 #include "oops/methodData.hpp"
 37 #include "runtime/javaThread.hpp"
 38 
 39 class CompileTask;
 40 class OopMapSet;

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

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 
230   ciMethod* get_method_from_handle(Method* method);
231 
232   ciInstance* get_or_create_exception(jobject& handle, Symbol* name);
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_unsafe_access,
383                        bool                      has_wide_vectors,
384                        bool                      has_monitors,
385                        int                       immediate_oops_patched,
386                        RTMState                  rtm_state = NoRTM);


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

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







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

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




513 };
514 
515 #endif // SHARE_CI_CIENV_HPP

 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/compiler_globals.hpp"
 35 #include "compiler/compilerThread.hpp"
 36 #include "oops/methodData.hpp"
 37 #include "runtime/javaThread.hpp"
 38 
 39 class CompileTask;
 40 class OopMapSet;
 41 class SCCEntry;
 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   const char*      _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   // Get a ciMethod representing either an unfound method or
234   // a method with an unloaded holder.  Ensures uniqueness of
235   // the result.
236   ciMethod* get_unloaded_method(ciKlass*         holder,
237                                 ciSymbol*        name,
238                                 ciSymbol*        signature,
239                                 ciInstanceKlass* accessor) {
240     ciInstanceKlass* declared_holder = get_instance_klass_for_declared_method_holder(holder);
241     return _factory->get_unloaded_method(declared_holder, name, signature, accessor);
242   }
243 
244   // Get a ciKlass representing an unloaded klass.
245   // Ensures uniqueness of the result.
246   ciKlass* get_unloaded_klass(ciKlass*  accessing_klass,
247                               ciSymbol* name) {
248     return _factory->get_unloaded_klass(accessing_klass, name, true);
249   }
250 
251   // Get a ciKlass representing an unloaded klass mirror.
252   // Result is not necessarily unique, but will be unloaded.

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

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

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