< prev index next >

src/hotspot/share/ci/ciEnv.hpp

Print this page




  34 #include "compiler/oopMap.hpp"
  35 #include "oops/methodData.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   friend class PrepareExtraDataClosure;
  50 
  51 private:
  52   Arena*           _arena;       // Alias for _ciEnv_arena except in init_shared_objects()
  53   Arena            _ciEnv_arena;

  54   ciObjectFactory* _factory;
  55   OopRecorder*     _oop_recorder;
  56   DebugInformationRecorder* _debug_info;
  57   Dependencies*    _dependencies;
  58   const char*      _failure_reason;
  59   bool             _inc_decompile_count_on_failure;
  60   int              _compilable;
  61   bool             _break_at_compile;
  62   int              _num_inlined_bytecodes;
  63   CompileTask*     _task;           // faster access to CompilerThread::task
  64   CompileLog*      _log;            // faster access to CompilerThread::log
  65   void*            _compiler_data;  // compiler-specific stuff, if any
  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;


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



 293 public:
 294   enum {
 295     MethodCompilable,
 296     MethodCompilable_not_at_tier,
 297     MethodCompilable_never
 298   };
 299 
 300   ciEnv(CompileTask* task);
 301   // Used only during initialization of the ci
 302   ciEnv(Arena* arena);
 303   ~ciEnv();
 304 
 305   OopRecorder* oop_recorder() { return _oop_recorder; }
 306   void set_oop_recorder(OopRecorder* r) { _oop_recorder = r; }
 307 
 308   DebugInformationRecorder* debug_info() { return _debug_info; }
 309   void set_debug_info(DebugInformationRecorder* i) { _debug_info = i; }
 310 
 311   Dependencies* dependencies() { return _dependencies; }
 312   void set_dependencies(Dependencies* d) { _dependencies = d; }
 313 
 314   // This is true if the compilation is not going to produce code.
 315   // (It is reasonable to retry failed compilations.)
 316   bool failing() { return _failure_reason != NULL; }
 317 
 318   // Reason this compilation is failing, such as "too many basic blocks".
 319   const char* failure_reason() { return _failure_reason; }
 320 


 434   // What is the current compilation environment?
 435   static ciEnv* current() { return CompilerThread::current()->env(); }
 436 
 437   // Overload with current thread argument
 438   static ciEnv* current(CompilerThread *thread) { return thread->env(); }
 439 
 440   // Per-compiler data.  (Used by C2 to publish the Compile* pointer.)
 441   void* compiler_data() { return _compiler_data; }
 442   void set_compiler_data(void* x) { _compiler_data = x; }
 443 
 444   // Notice that a method has been inlined in the current compile;
 445   // used only for statistics.
 446   void notice_inlined_method(ciMethod* method);
 447 
 448   // Total number of bytecodes in inlined methods in this compile
 449   int num_inlined_bytecodes() const;
 450 
 451   // Output stream for logging compilation info.
 452   CompileLog* log() { return _log; }
 453   void set_log(CompileLog* log) { _log = log; }



 454 
 455   void record_failure(const char* reason);      // Record failure and report later
 456   void report_failure(const char* reason);      // Report failure immediately
 457   void record_method_not_compilable(const char* reason, bool all_tiers = true);
 458   void record_out_of_memory_failure();
 459 
 460   // RedefineClasses support
 461   void metadata_do(MetadataClosure* f) { _factory->metadata_do(f); }
 462 
 463   // Dump the compilation replay data for the ciEnv to the stream.
 464   void dump_replay_data(int compile_id);
 465   void dump_inline_data(int compile_id);
 466   void dump_replay_data(outputStream* out);
 467   void dump_replay_data_unsafe(outputStream* out);
 468   void dump_compile_data(outputStream* out);
 469 };
 470 
 471 #endif // SHARE_CI_CIENV_HPP


  34 #include "compiler/oopMap.hpp"
  35 #include "oops/methodData.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   friend class PrepareExtraDataClosure;
  50 
  51 private:
  52   Arena*           _arena;       // Alias for _ciEnv_arena except in init_shared_objects()
  53   Arena            _ciEnv_arena;
  54   int              _system_dictionary_modification_counter;
  55   ciObjectFactory* _factory;
  56   OopRecorder*     _oop_recorder;
  57   DebugInformationRecorder* _debug_info;
  58   Dependencies*    _dependencies;
  59   const char*      _failure_reason;
  60   bool             _inc_decompile_count_on_failure;
  61   int              _compilable;
  62   bool             _break_at_compile;
  63   int              _num_inlined_bytecodes;
  64   CompileTask*     _task;           // faster access to CompilerThread::task
  65   CompileLog*      _log;            // faster access to CompilerThread::log
  66   void*            _compiler_data;  // compiler-specific stuff, if any
  67 
  68   char* _name_buffer;
  69   int   _name_buffer_len;
  70 
  71   // Cache Jvmti state
  72   bool  _jvmti_can_hotswap_or_post_breakpoint;
  73   bool  _jvmti_can_access_local_variables;
  74   bool  _jvmti_can_post_on_exceptions;


 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 
 295   // Call internally when Compile_lock is already held.
 296   bool system_dictionary_modification_counter_changed_locked();
 297 public:
 298   enum {
 299     MethodCompilable,
 300     MethodCompilable_not_at_tier,
 301     MethodCompilable_never
 302   };
 303 
 304   ciEnv(CompileTask* task, int system_dictionary_modification_counter);
 305   // Used only during initialization of the ci
 306   ciEnv(Arena* arena);
 307   ~ciEnv();
 308 
 309   OopRecorder* oop_recorder() { return _oop_recorder; }
 310   void set_oop_recorder(OopRecorder* r) { _oop_recorder = r; }
 311 
 312   DebugInformationRecorder* debug_info() { return _debug_info; }
 313   void set_debug_info(DebugInformationRecorder* i) { _debug_info = i; }
 314 
 315   Dependencies* dependencies() { return _dependencies; }
 316   void set_dependencies(Dependencies* d) { _dependencies = d; }
 317 
 318   // This is true if the compilation is not going to produce code.
 319   // (It is reasonable to retry failed compilations.)
 320   bool failing() { return _failure_reason != NULL; }
 321 
 322   // Reason this compilation is failing, such as "too many basic blocks".
 323   const char* failure_reason() { return _failure_reason; }
 324 


 438   // What is the current compilation environment?
 439   static ciEnv* current() { return CompilerThread::current()->env(); }
 440 
 441   // Overload with current thread argument
 442   static ciEnv* current(CompilerThread *thread) { return thread->env(); }
 443 
 444   // Per-compiler data.  (Used by C2 to publish the Compile* pointer.)
 445   void* compiler_data() { return _compiler_data; }
 446   void set_compiler_data(void* x) { _compiler_data = x; }
 447 
 448   // Notice that a method has been inlined in the current compile;
 449   // used only for statistics.
 450   void notice_inlined_method(ciMethod* method);
 451 
 452   // Total number of bytecodes in inlined methods in this compile
 453   int num_inlined_bytecodes() const;
 454 
 455   // Output stream for logging compilation info.
 456   CompileLog* log() { return _log; }
 457   void set_log(CompileLog* log) { _log = log; }
 458 
 459   // Check for changes to the system dictionary during compilation
 460   bool system_dictionary_modification_counter_changed();
 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 = true);
 465   void record_out_of_memory_failure();
 466 
 467   // RedefineClasses support
 468   void metadata_do(MetadataClosure* f) { _factory->metadata_do(f); }
 469 
 470   // Dump the compilation replay data for the ciEnv to the stream.
 471   void dump_replay_data(int compile_id);
 472   void dump_inline_data(int compile_id);
 473   void dump_replay_data(outputStream* out);
 474   void dump_replay_data_unsafe(outputStream* out);
 475   void dump_compile_data(outputStream* out);
 476 };
 477 
 478 #endif // SHARE_CI_CIENV_HPP
< prev index next >