hotspot/src/share/vm/c1/c1_IR.hpp
changeset 6745 a34ef8968a84
parent 5707 6c66849ed24e
child 7397 5b173b4ca846
equal deleted inserted replaced
6743:ef1795cd50a7 6745:a34ef8968a84
   130 class IRScope: public CompilationResourceObj {
   130 class IRScope: public CompilationResourceObj {
   131  private:
   131  private:
   132   // hierarchy
   132   // hierarchy
   133   Compilation*  _compilation;                    // the current compilation
   133   Compilation*  _compilation;                    // the current compilation
   134   IRScope*      _caller;                         // the caller scope, or NULL
   134   IRScope*      _caller;                         // the caller scope, or NULL
   135   int           _caller_bci;                     // the caller bci of the corresponding (inlined) invoke, or < 0
       
   136   ValueStack*   _caller_state;                   // the caller state, or NULL
       
   137   int           _level;                          // the inlining level
   135   int           _level;                          // the inlining level
   138   ciMethod*     _method;                         // the corresponding method
   136   ciMethod*     _method;                         // the corresponding method
   139   IRScopeList   _callees;                        // the inlined method scopes
   137   IRScopeList   _callees;                        // the inlined method scopes
   140 
   138 
   141   // graph
   139   // graph
   142   XHandlers*    _xhandlers;                      // the exception handlers
   140   XHandlers*    _xhandlers;                      // the exception handlers
   143   int           _number_of_locks;                // the number of monitor lock slots needed
   141   int           _number_of_locks;                // the number of monitor lock slots needed
   144   bool          _monitor_pairing_ok;             // the monitor pairing info
   142   bool          _monitor_pairing_ok;             // the monitor pairing info
   145   BlockBegin*   _start;                          // the start block, successsors are method entries
   143   BlockBegin*   _start;                          // the start block, successsors are method entries
   146 
   144 
   147   // lock stack management
       
   148   int           _lock_stack_size;                // number of expression stack elements which, if present,
       
   149                                                  // must be spilled to the stack because of exception
       
   150                                                  // handling inside inlined methods
       
   151 
       
   152   BitMap        _requires_phi_function;          // bit is set if phi functions at loop headers are necessary for a local variable
   145   BitMap        _requires_phi_function;          // bit is set if phi functions at loop headers are necessary for a local variable
   153 
   146 
   154   // helper functions
   147   // helper functions
   155   BlockBegin* header_block(BlockBegin* entry, BlockBegin::Flag f, ValueStack* state);
       
   156   BlockBegin* build_graph(Compilation* compilation, int osr_bci);
   148   BlockBegin* build_graph(Compilation* compilation, int osr_bci);
   157 
   149 
   158  public:
   150  public:
   159   // creation
   151   // creation
   160   IRScope(Compilation* compilation, IRScope* caller, int caller_bci, ciMethod* method, int osr_bci, bool create_graph = false);
   152   IRScope(Compilation* compilation, IRScope* caller, int caller_bci, ciMethod* method, int osr_bci, bool create_graph = false);
   161 
   153 
   162   // accessors
   154   // accessors
   163   Compilation*  compilation() const              { return _compilation; }
   155   Compilation*  compilation() const              { return _compilation; }
   164   IRScope*      caller() const                   { return _caller; }
   156   IRScope*      caller() const                   { return _caller; }
   165   int           caller_bci() const               { return _caller_bci; }
       
   166   ValueStack*   caller_state() const             { return _caller_state; }
       
   167   int           level() const                    { return _level; }
   157   int           level() const                    { return _level; }
   168   ciMethod*     method() const                   { return _method; }
   158   ciMethod*     method() const                   { return _method; }
   169   int           max_stack() const;               // NOTE: expensive
   159   int           max_stack() const;               // NOTE: expensive
   170   int           lock_stack_size() const          {
       
   171     assert(_lock_stack_size != -1, "uninitialized");
       
   172     return _lock_stack_size;
       
   173   }
       
   174   BitMap&       requires_phi_function()          { return _requires_phi_function; }
   160   BitMap&       requires_phi_function()          { return _requires_phi_function; }
   175 
       
   176   // mutators
       
   177   // Needed because caller state is not ready at time of IRScope construction
       
   178   void          set_caller_state(ValueStack* state) { _caller_state = state; }
       
   179   // Needed because caller state changes after IRScope construction.
       
   180   // Computes number of expression stack elements whose state must be
       
   181   // preserved in the case of an exception; these may be seen by
       
   182   // caller scopes. Zero when inlining of methods containing exception
       
   183   // handlers is disabled, otherwise a conservative approximation.
       
   184   void          compute_lock_stack_size();
       
   185 
   161 
   186   // hierarchy
   162   // hierarchy
   187   bool          is_top_scope() const             { return _caller == NULL; }
   163   bool          is_top_scope() const             { return _caller == NULL; }
   188   void          add_callee(IRScope* callee)      { _callees.append(callee); }
   164   void          add_callee(IRScope* callee)      { _callees.append(callee); }
   189   int           number_of_callees() const        { return _callees.length(); }
   165   int           number_of_callees() const        { return _callees.length(); }
   190   IRScope*      callee_no(int i) const           { return _callees.at(i); }
   166   IRScope*      callee_no(int i) const           { return _callees.at(i); }
   191   int           top_scope_bci() const;
       
   192 
   167 
   193   // accessors, graph
   168   // accessors, graph
   194   bool          is_valid() const                 { return start() != NULL; }
   169   bool          is_valid() const                 { return start() != NULL; }
   195   XHandlers*    xhandlers() const                { return _xhandlers; }
   170   XHandlers*    xhandlers() const                { return _xhandlers; }
   196   int           number_of_locks() const          { return _number_of_locks; }
   171   int           number_of_locks() const          { return _number_of_locks; }
   264   IRScopeDebugInfo* _scope_debug_info;
   239   IRScopeDebugInfo* _scope_debug_info;
   265   IRScope*          _scope;
   240   IRScope*          _scope;
   266   XHandlers*        _exception_handlers;
   241   XHandlers*        _exception_handlers;
   267   OopMap*           _oop_map;
   242   OopMap*           _oop_map;
   268   ValueStack*       _stack;                      // used by deoptimization (contains also monitors
   243   ValueStack*       _stack;                      // used by deoptimization (contains also monitors
   269   int               _bci;
       
   270   CodeEmitInfo*     _next;
       
   271   int               _id;
       
   272   bool              _is_method_handle_invoke;    // true if the associated call site is a MethodHandle call site.
   244   bool              _is_method_handle_invoke;    // true if the associated call site is a MethodHandle call site.
   273 
   245 
   274   FrameMap*     frame_map() const                { return scope()->compilation()->frame_map(); }
   246   FrameMap*     frame_map() const                { return scope()->compilation()->frame_map(); }
   275   Compilation*  compilation() const              { return scope()->compilation(); }
   247   Compilation*  compilation() const              { return scope()->compilation(); }
   276 
   248 
   277  public:
   249  public:
   278 
   250 
   279   // use scope from ValueStack
   251   // use scope from ValueStack
   280   CodeEmitInfo(int bci, ValueStack* stack, XHandlers* exception_handlers);
   252   CodeEmitInfo(ValueStack* stack, XHandlers* exception_handlers);
   281 
       
   282   // used by natives
       
   283   CodeEmitInfo(IRScope* scope, int bci)
       
   284     : _scope(scope)
       
   285     , _bci(bci)
       
   286     , _oop_map(NULL)
       
   287     , _scope_debug_info(NULL)
       
   288     , _stack(NULL)
       
   289     , _exception_handlers(NULL)
       
   290     , _next(NULL)
       
   291     , _id(-1)
       
   292     , _is_method_handle_invoke(false) {
       
   293   }
       
   294 
   253 
   295   // make a copy
   254   // make a copy
   296   CodeEmitInfo(CodeEmitInfo* info, bool lock_stack_only = false);
   255   CodeEmitInfo(CodeEmitInfo* info, ValueStack* stack = NULL);
   297 
   256 
   298   // accessors
   257   // accessors
   299   OopMap* oop_map()                              { return _oop_map; }
   258   OopMap* oop_map()                              { return _oop_map; }
   300   ciMethod* method() const                       { return _scope->method(); }
   259   ciMethod* method() const                       { return _scope->method(); }
   301   IRScope* scope() const                         { return _scope; }
   260   IRScope* scope() const                         { return _scope; }
   302   XHandlers* exception_handlers() const          { return _exception_handlers; }
   261   XHandlers* exception_handlers() const          { return _exception_handlers; }
   303   ValueStack* stack() const                      { return _stack; }
   262   ValueStack* stack() const                      { return _stack; }
   304   int bci() const                                { return _bci; }
       
   305 
   263 
   306   void add_register_oop(LIR_Opr opr);
   264   void add_register_oop(LIR_Opr opr);
   307   void record_debug_info(DebugInformationRecorder* recorder, int pc_offset);
   265   void record_debug_info(DebugInformationRecorder* recorder, int pc_offset);
   308 
       
   309   CodeEmitInfo* next() const        { return _next; }
       
   310   void set_next(CodeEmitInfo* next) { _next = next; }
       
   311 
       
   312   int id() const      { return _id; }
       
   313   void set_id(int id) { _id = id; }
       
   314 
   266 
   315   bool     is_method_handle_invoke() const { return _is_method_handle_invoke;     }
   267   bool     is_method_handle_invoke() const { return _is_method_handle_invoke;     }
   316   void set_is_method_handle_invoke(bool x) {        _is_method_handle_invoke = x; }
   268   void set_is_method_handle_invoke(bool x) {        _is_method_handle_invoke = x; }
   317 };
   269 };
   318 
   270