< prev index next >

src/hotspot/share/code/compiledMethod.hpp

Print this page

139 
140 
141 class CompiledMethod : public CodeBlob {
142   friend class VMStructs;
143   friend class NMethodSweeper;
144 
145   void init_defaults();
146 protected:
147   enum MarkForDeoptimizationStatus {
148     not_marked,
149     deoptimize,
150     deoptimize_noupdate
151   };
152 
153   MarkForDeoptimizationStatus _mark_for_deoptimization_status; // Used for stack deoptimization
154 
155   // set during construction
156   unsigned int _has_unsafe_access:1;         // May fault due to unsafe access.
157   unsigned int _has_method_handle_invokes:1; // Has this method MethodHandle invokes?
158   unsigned int _has_wide_vectors:1;          // Preserve wide vectors at safepoints

159 
160   Method*   _method;
161   address _scopes_data_begin;
162   // All deoptee's will resume execution at this location described by
163   // this address.
164   address _deopt_handler_begin;
165   // All deoptee's at a MethodHandle call site will resume execution
166   // at this location described by this offset.
167   address _deopt_mh_handler_begin;
168 
169   PcDescContainer _pc_desc_container;
170   ExceptionCache * volatile _exception_cache;
171 
172   void* _gc_data;
173 
174   virtual void flush() = 0;

175 protected:
176   CompiledMethod(Method* method, const char* name, CompilerType type, const CodeBlobLayout& layout, int frame_complete_offset, int frame_size, ImmutableOopMapSet* oop_maps, bool caller_must_gc_arguments);
177   CompiledMethod(Method* method, const char* name, CompilerType type, int size, int header_size, CodeBuffer* cb, int frame_complete_offset, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments);
178 
179 public:
180   // Only used by unit test.
181   CompiledMethod() {}
182 
183   virtual bool is_compiled() const                { return true; }
184 
185   template<typename T>
186   T* gc_data() const                              { return reinterpret_cast<T*>(_gc_data); }
187   template<typename T>
188   void set_gc_data(T* gc_data)                    { _gc_data = reinterpret_cast<void*>(gc_data); }
189 
190   bool  has_unsafe_access() const                 { return _has_unsafe_access; }
191   void  set_has_unsafe_access(bool z)             { _has_unsafe_access = z; }
192 



193   bool  has_method_handle_invokes() const         { return _has_method_handle_invokes; }
194   void  set_has_method_handle_invokes(bool z)     { _has_method_handle_invokes = z; }
195 
196   bool  has_wide_vectors() const                  { return _has_wide_vectors; }
197   void  set_has_wide_vectors(bool z)              { _has_wide_vectors = z; }
198 
199   enum { not_installed = -1, // in construction, only the owner doing the construction is
200                              // allowed to advance state
201          in_use        = 0,  // executable nmethod
202          not_used      = 1,  // not entrant, but revivable
203          not_entrant   = 2,  // marked for deoptimization but activations may still exist,
204                              // will be transformed to zombie when all activations are gone
205          unloaded      = 3,  // there should be no activations, should not be called, will be
206                              // transformed to zombie by the sweeper, when not "locked in vm".
207          zombie        = 4   // no activations exist, nmethod is ready for purge
208   };
209 
210   virtual bool  is_in_use() const = 0;
211   virtual int   comp_level() const = 0;
212   virtual int   compile_id() const = 0;

224   Method* method() const                          { return _method; }
225   virtual void print_pcs() = 0;
226   bool is_native_method() const { return _method != NULL && _method->is_native(); }
227   bool is_java_method() const { return _method != NULL && !_method->is_native(); }
228 
229   // ScopeDesc retrieval operation
230   PcDesc* pc_desc_at(address pc)   { return find_pc_desc(pc, false); }
231   // pc_desc_near returns the first PcDesc at or after the given pc.
232   PcDesc* pc_desc_near(address pc) { return find_pc_desc(pc, true); }
233 
234   // ScopeDesc for an instruction
235   ScopeDesc* scope_desc_at(address pc);
236   ScopeDesc* scope_desc_near(address pc);
237 
238   bool is_at_poll_return(address pc);
239   bool is_at_poll_or_poll_return(address pc);
240 
241   bool  is_marked_for_deoptimization() const { return _mark_for_deoptimization_status != not_marked; }
242   void  mark_for_deoptimization(bool inc_recompile_counts = true);
243 


244   bool update_recompile_counts() const {
245     // Update recompile counts when either the update is explicitly requested (deoptimize)
246     // or the nmethod is not marked for deoptimization at all (not_marked).
247     // The latter happens during uncommon traps when deoptimized nmethod is made not entrant.
248     return _mark_for_deoptimization_status != deoptimize_noupdate;
249   }
250 
251   // tells whether frames described by this nmethod can be deoptimized
252   // note: native wrappers cannot be deoptimized.
253   bool can_be_deoptimized() const { return is_java_method(); }
254 
255   virtual oop oop_at(int index) const = 0;
256   virtual Metadata* metadata_at(int index) const = 0;
257 
258   address scopes_data_begin() const { return _scopes_data_begin; }
259   virtual address scopes_data_end() const = 0;
260   int scopes_data_size() const { return scopes_data_end() - scopes_data_begin(); }
261 
262   virtual PcDesc* scopes_pcs_begin() const = 0;
263   virtual PcDesc* scopes_pcs_end() const = 0;

279 
280   virtual address stub_begin() const = 0;
281   virtual address stub_end() const = 0;
282   bool stub_contains(address addr) const { return stub_begin() <= addr && addr < stub_end(); }
283   int stub_size() const { return stub_end() - stub_begin(); }
284 
285   virtual address handler_table_begin() const = 0;
286   virtual address handler_table_end() const = 0;
287   bool handler_table_contains(address addr) const { return handler_table_begin() <= addr && addr < handler_table_end(); }
288   int handler_table_size() const { return handler_table_end() - handler_table_begin(); }
289 
290   virtual address exception_begin() const = 0;
291 
292   virtual address nul_chk_table_begin() const = 0;
293   virtual address nul_chk_table_end() const = 0;
294   bool nul_chk_table_contains(address addr) const { return nul_chk_table_begin() <= addr && addr < nul_chk_table_end(); }
295   int nul_chk_table_size() const { return nul_chk_table_end() - nul_chk_table_begin(); }
296 
297   virtual oop* oop_addr_at(int index) const = 0;
298   virtual Metadata** metadata_addr_at(int index) const = 0;
299   virtual void    set_original_pc(const frame* fr, address pc) = 0;
300 
301 protected:
302   // Exception cache support
303   // Note: _exception_cache may be read and cleaned concurrently.
304   ExceptionCache* exception_cache() const         { return _exception_cache; }
305   ExceptionCache* exception_cache_acquire() const;
306   void set_exception_cache(ExceptionCache *ec)    { _exception_cache = ec; }
307 
308 public:
309   address handler_for_exception_and_pc(Handle exception, address pc);
310   void add_handler_for_exception_and_pc(Handle exception, address pc, address handler);
311   void clean_exception_cache();
312 
313   void add_exception_cache_entry(ExceptionCache* new_entry);
314   ExceptionCache* exception_cache_entry_for_exception(Handle exception);
315 
316   // MethodHandle
317   bool is_method_handle_return(address return_pc);
318   address deopt_mh_handler_begin() const  { return _deopt_mh_handler_begin; }
319 
320   address deopt_handler_begin() const { return _deopt_handler_begin; }
321   virtual address get_original_pc(const frame* fr) = 0;
322   // Deopt
323   // Return true is the PC is one would expect if the frame is being deopted.
324   inline bool is_deopt_pc(address pc);
325   inline bool is_deopt_mh_entry(address pc);
326   inline bool is_deopt_entry(address pc);
327 









328   virtual bool can_convert_to_zombie() = 0;
329   virtual const char* compile_kind() const = 0;
330   virtual int get_state() const = 0;
331 
332   const char* state() const;
333 
334   bool inlinecache_check_contains(address addr) const {
335     return (addr >= code_begin() && addr < verified_entry_point());
336   }
337 
338   void preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f);
339 
340   // implicit exceptions support
341   address continuation_for_implicit_div0_exception(address pc) { return continuation_for_implicit_exception(pc, true); }
342   address continuation_for_implicit_null_exception(address pc) { return continuation_for_implicit_exception(pc, false); }
343 
344   static address get_deopt_original_pc(const frame* fr);
345 
346   // Inline cache support for class unloading and nmethod unloading
347  private:

139 
140 
141 class CompiledMethod : public CodeBlob {
142   friend class VMStructs;
143   friend class NMethodSweeper;
144 
145   void init_defaults();
146 protected:
147   enum MarkForDeoptimizationStatus {
148     not_marked,
149     deoptimize,
150     deoptimize_noupdate
151   };
152 
153   MarkForDeoptimizationStatus _mark_for_deoptimization_status; // Used for stack deoptimization
154 
155   // set during construction
156   unsigned int _has_unsafe_access:1;         // May fault due to unsafe access.
157   unsigned int _has_method_handle_invokes:1; // Has this method MethodHandle invokes?
158   unsigned int _has_wide_vectors:1;          // Preserve wide vectors at safepoints
159   unsigned int _has_monitors:1;              // Fastpath monitor detection for continuations
160 
161   Method*   _method;
162   address _scopes_data_begin;
163   // All deoptee's will resume execution at this location described by
164   // this address.
165   address _deopt_handler_begin;
166   // All deoptee's at a MethodHandle call site will resume execution
167   // at this location described by this offset.
168   address _deopt_mh_handler_begin;
169 
170   PcDescContainer _pc_desc_container;
171   ExceptionCache * volatile _exception_cache;
172 
173   void* _gc_data;
174 
175   virtual void flush() = 0;
176 
177 protected:
178   CompiledMethod(Method* method, const char* name, CompilerType type, const CodeBlobLayout& layout, int frame_complete_offset, int frame_size, ImmutableOopMapSet* oop_maps, bool caller_must_gc_arguments, bool compiled);
179   CompiledMethod(Method* method, const char* name, CompilerType type, int size, int header_size, CodeBuffer* cb, int frame_complete_offset, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments, bool compiled);
180 
181 public:
182   // Only used by unit test.
183   CompiledMethod() {}
184 


185   template<typename T>
186   T* gc_data() const                              { return reinterpret_cast<T*>(_gc_data); }
187   template<typename T>
188   void set_gc_data(T* gc_data)                    { _gc_data = reinterpret_cast<void*>(gc_data); }
189 
190   bool  has_unsafe_access() const                 { return _has_unsafe_access; }
191   void  set_has_unsafe_access(bool z)             { _has_unsafe_access = z; }
192 
193   bool  has_monitors() const                      { return _has_monitors; }
194   void  set_has_monitors(bool z)                  { _has_monitors = z; }
195 
196   bool  has_method_handle_invokes() const         { return _has_method_handle_invokes; }
197   void  set_has_method_handle_invokes(bool z)     { _has_method_handle_invokes = z; }
198 
199   bool  has_wide_vectors() const                  { return _has_wide_vectors; }
200   void  set_has_wide_vectors(bool z)              { _has_wide_vectors = z; }
201 
202   enum { not_installed = -1, // in construction, only the owner doing the construction is
203                              // allowed to advance state
204          in_use        = 0,  // executable nmethod
205          not_used      = 1,  // not entrant, but revivable
206          not_entrant   = 2,  // marked for deoptimization but activations may still exist,
207                              // will be transformed to zombie when all activations are gone
208          unloaded      = 3,  // there should be no activations, should not be called, will be
209                              // transformed to zombie by the sweeper, when not "locked in vm".
210          zombie        = 4   // no activations exist, nmethod is ready for purge
211   };
212 
213   virtual bool  is_in_use() const = 0;
214   virtual int   comp_level() const = 0;
215   virtual int   compile_id() const = 0;

227   Method* method() const                          { return _method; }
228   virtual void print_pcs() = 0;
229   bool is_native_method() const { return _method != NULL && _method->is_native(); }
230   bool is_java_method() const { return _method != NULL && !_method->is_native(); }
231 
232   // ScopeDesc retrieval operation
233   PcDesc* pc_desc_at(address pc)   { return find_pc_desc(pc, false); }
234   // pc_desc_near returns the first PcDesc at or after the given pc.
235   PcDesc* pc_desc_near(address pc) { return find_pc_desc(pc, true); }
236 
237   // ScopeDesc for an instruction
238   ScopeDesc* scope_desc_at(address pc);
239   ScopeDesc* scope_desc_near(address pc);
240 
241   bool is_at_poll_return(address pc);
242   bool is_at_poll_or_poll_return(address pc);
243 
244   bool  is_marked_for_deoptimization() const { return _mark_for_deoptimization_status != not_marked; }
245   void  mark_for_deoptimization(bool inc_recompile_counts = true);
246 
247   virtual void  make_deoptimized() { assert(false, "not supported"); };
248 
249   bool update_recompile_counts() const {
250     // Update recompile counts when either the update is explicitly requested (deoptimize)
251     // or the nmethod is not marked for deoptimization at all (not_marked).
252     // The latter happens during uncommon traps when deoptimized nmethod is made not entrant.
253     return _mark_for_deoptimization_status != deoptimize_noupdate;
254   }
255 
256   // tells whether frames described by this nmethod can be deoptimized
257   // note: native wrappers cannot be deoptimized.
258   bool can_be_deoptimized() const { return is_java_method(); }
259 
260   virtual oop oop_at(int index) const = 0;
261   virtual Metadata* metadata_at(int index) const = 0;
262 
263   address scopes_data_begin() const { return _scopes_data_begin; }
264   virtual address scopes_data_end() const = 0;
265   int scopes_data_size() const { return scopes_data_end() - scopes_data_begin(); }
266 
267   virtual PcDesc* scopes_pcs_begin() const = 0;
268   virtual PcDesc* scopes_pcs_end() const = 0;

284 
285   virtual address stub_begin() const = 0;
286   virtual address stub_end() const = 0;
287   bool stub_contains(address addr) const { return stub_begin() <= addr && addr < stub_end(); }
288   int stub_size() const { return stub_end() - stub_begin(); }
289 
290   virtual address handler_table_begin() const = 0;
291   virtual address handler_table_end() const = 0;
292   bool handler_table_contains(address addr) const { return handler_table_begin() <= addr && addr < handler_table_end(); }
293   int handler_table_size() const { return handler_table_end() - handler_table_begin(); }
294 
295   virtual address exception_begin() const = 0;
296 
297   virtual address nul_chk_table_begin() const = 0;
298   virtual address nul_chk_table_end() const = 0;
299   bool nul_chk_table_contains(address addr) const { return nul_chk_table_begin() <= addr && addr < nul_chk_table_end(); }
300   int nul_chk_table_size() const { return nul_chk_table_end() - nul_chk_table_begin(); }
301 
302   virtual oop* oop_addr_at(int index) const = 0;
303   virtual Metadata** metadata_addr_at(int index) const = 0;

304 
305 protected:
306   // Exception cache support
307   // Note: _exception_cache may be read and cleaned concurrently.
308   ExceptionCache* exception_cache() const         { return _exception_cache; }
309   ExceptionCache* exception_cache_acquire() const;
310   void set_exception_cache(ExceptionCache *ec)    { _exception_cache = ec; }
311 
312 public:
313   address handler_for_exception_and_pc(Handle exception, address pc);
314   void add_handler_for_exception_and_pc(Handle exception, address pc, address handler);
315   void clean_exception_cache();
316 
317   void add_exception_cache_entry(ExceptionCache* new_entry);
318   ExceptionCache* exception_cache_entry_for_exception(Handle exception);
319 
320   // MethodHandle
321   bool is_method_handle_return(address return_pc);
322   address deopt_mh_handler_begin() const  { return _deopt_mh_handler_begin; }
323 
324   address deopt_handler_begin() const { return _deopt_handler_begin; }
325   address* deopt_handler_begin_addr()        { return &_deopt_handler_begin; }
326   // Deopt
327   // Return true is the PC is one would expect if the frame is being deopted.
328   inline bool is_deopt_pc(address pc);
329   inline bool is_deopt_mh_entry(address pc);
330   inline bool is_deopt_entry(address pc);
331 
332   // Accessor/mutator for the original pc of a frame before a frame was deopted.
333   address get_original_pc(const frame* fr) { return *orig_pc_addr(fr); }
334   void    set_original_pc(const frame* fr, address pc) { *orig_pc_addr(fr) = pc; }
335 
336   virtual int orig_pc_offset() = 0;
337 private:
338   address* orig_pc_addr(const frame* fr);
339 
340 public:
341   virtual bool can_convert_to_zombie() = 0;
342   virtual const char* compile_kind() const = 0;
343   virtual int get_state() const = 0;
344 
345   const char* state() const;
346 
347   bool inlinecache_check_contains(address addr) const {
348     return (addr >= code_begin() && addr < verified_entry_point());
349   }
350 
351   void preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f);
352 
353   // implicit exceptions support
354   address continuation_for_implicit_div0_exception(address pc) { return continuation_for_implicit_exception(pc, true); }
355   address continuation_for_implicit_null_exception(address pc) { return continuation_for_implicit_exception(pc, false); }
356 
357   static address get_deopt_original_pc(const frame* fr);
358 
359   // Inline cache support for class unloading and nmethod unloading
360  private:
< prev index next >