< prev index next >

src/hotspot/share/runtime/vframe.hpp

Print this page




  33 #include "runtime/stackValue.hpp"
  34 #include "runtime/stackValueCollection.hpp"
  35 #include "utilities/growableArray.hpp"
  36 
  37 // vframes are virtual stack frames representing source level activations.
  38 // A single frame may hold several source level activations in the case of
  39 // optimized code. The debugging stored with the optimized code enables
  40 // us to unfold a frame as a stack of vframes.
  41 // A cVFrame represents an activation of a non-java method.
  42 
  43 // The vframe inheritance hierarchy:
  44 // - vframe
  45 //   - javaVFrame
  46 //     - interpretedVFrame
  47 //     - compiledVFrame     ; (used for both compiled Java methods and native stubs)
  48 //   - externalVFrame
  49 //     - entryVFrame        ; special frame created when calling Java from C
  50 
  51 // - BasicLock
  52 


  53 class vframe: public ResourceObj {
  54  protected:
  55   frame        _fr;      // Raw frame behind the virtual frame.
  56   RegisterMap  _reg_map; // Register map for the raw frame (used to handle callee-saved registers).
  57   JavaThread*  _thread;  // The thread owning the raw frame.
  58 
  59   vframe(const frame* fr, const RegisterMap* reg_map, JavaThread* thread);
  60   vframe(const frame* fr, JavaThread* thread);
  61  public:
  62   // Factory method for creating vframes
  63   static vframe* new_vframe(const frame* f, const RegisterMap *reg_map, JavaThread* thread);
  64 
  65   // Accessors
  66   frame              fr()           const { return _fr;       }
  67   CodeBlob*          cb()         const { return _fr.cb();  }
  68   CompiledMethod*   nm()         const {
  69       assert( cb() != NULL && cb()->is_compiled(), "usage");
  70       return (CompiledMethod*) cb();
  71   }
  72 
  73 // ???? Does this need to be a copy?
  74   frame*             frame_pointer() { return &_fr;       }
  75   const RegisterMap* register_map() const { return &_reg_map; }
  76   JavaThread*        thread()       const { return _thread;   }

  77 
  78   // Returns the sender vframe
  79   virtual vframe* sender() const;
  80 
  81   // Returns the next javaVFrame on the stack (skipping all other kinds of frame)
  82   javaVFrame *java_sender() const;
  83 
  84   // Answers if the this is the top vframe in the frame, i.e., if the sender vframe
  85   // is in the caller frame
  86   virtual bool is_top() const { return true; }
  87 
  88   // Returns top vframe within same frame (see is_top())
  89   virtual vframe* top() const;
  90 
  91   // Type testing operations
  92   virtual bool is_entry_frame()       const { return false; }
  93   virtual bool is_java_frame()        const { return false; }
  94   virtual bool is_interpreted_frame() const { return false; }
  95   virtual bool is_compiled_frame()    const { return false; }
  96 
  97 #ifndef PRODUCT
  98   // printing operations
  99   virtual void print_value() const;
 100   virtual void print();
 101 #endif
 102 };
 103 

 104 
 105 class javaVFrame: public vframe {
 106  public:
 107   // JVM state
 108   virtual Method*                      method()         const = 0;
 109   virtual int                          bci()            const = 0;
 110   virtual StackValueCollection*        locals()         const = 0;
 111   virtual StackValueCollection*        expressions()    const = 0;
 112   // the order returned by monitors() is from oldest -> youngest#4418568
 113   virtual GrowableArray<MonitorInfo*>* monitors()       const = 0;
 114 
 115   // Debugging support via JVMTI.
 116   // NOTE that this is not guaranteed to give correct results for compiled vframes.
 117   // Deoptimize first if necessary.
 118   virtual void set_locals(StackValueCollection* values) const = 0;
 119 
 120   // Test operation
 121   bool is_java_frame() const { return true; }
 122 
 123  protected:


 275   bool owner_is_scalar_replaced()  const { return _owner_is_scalar_replaced; }
 276 };
 277 
 278 class vframeStreamCommon : StackObj {
 279  protected:
 280   // common
 281   frame        _prev_frame;
 282   frame        _frame;
 283   JavaThread*  _thread;
 284   RegisterMap  _reg_map;
 285   enum { interpreted_mode, compiled_mode, at_end_mode } _mode;
 286 
 287   // For compiled_mode
 288   int _decode_offset;
 289   int _sender_decode_offset;
 290   int _vframe_id;
 291 
 292   // Cached information
 293   Method* _method;
 294   int       _bci;

 295 
 296   // Should VM activations be ignored or not
 297   bool _stop_at_java_call_stub;

 298 
 299   bool fill_in_compiled_inlined_sender();
 300   void fill_from_compiled_frame(int decode_offset);
 301   void fill_from_compiled_native_frame();
 302 
 303   void fill_from_interpreter_frame();
 304   bool fill_from_frame();
 305 
 306   // Helper routine for security_get_caller_frame
 307   void skip_prefixed_method_and_wrappers();
 308 
 309   DEBUG_ONLY(void found_bad_method_frame() const;)
 310 
 311  public:
 312   // Constructor
 313   inline vframeStreamCommon(JavaThread* thread);

 314 
 315   // Accessors
 316   Method* method() const { return _method; }
 317   int bci() const { return _bci; }
 318   inline intptr_t* frame_id() const;
 319   address frame_pc() const { return _frame.pc(); }

 320 
 321   CodeBlob*          cb()         const { return _frame.cb();  }
 322   CompiledMethod*   nm()         const {
 323       assert( cb() != NULL && cb()->is_compiled(), "usage");
 324       return (CompiledMethod*) cb();
 325   }
 326 
 327   javaVFrame* asJavaVFrame();
 328 
 329   // Frame type
 330   inline bool is_interpreted_frame() const;
 331   inline bool is_entry_frame() const;
 332 
 333   // Iteration
 334   inline void next();
 335   void security_next();
 336 
 337   bool at_end() const { return _mode == at_end_mode; }
 338 
 339   // Implements security traversal. Skips depth no. of frame including
 340   // special security frames and prefixed native methods
 341   void security_get_caller_frame(int depth);
 342 
 343   // Helper routine for JVM_LatestUserDefinedLoader -- needed for 1.4
 344   // reflection implementation
 345   void skip_reflection_related_frames();
 346 };
 347 
 348 class vframeStream : public vframeStreamCommon {
 349  public:
 350   // Constructors
 351   vframeStream(JavaThread* thread, bool stop_at_java_call_stub = false);
 352 


 353   // top_frame may not be at safepoint, start with sender
 354   vframeStream(JavaThread* thread, frame top_frame, bool stop_at_java_call_stub = false);


 355 };
 356 
 357 #endif // SHARE_RUNTIME_VFRAME_HPP


  33 #include "runtime/stackValue.hpp"
  34 #include "runtime/stackValueCollection.hpp"
  35 #include "utilities/growableArray.hpp"
  36 
  37 // vframes are virtual stack frames representing source level activations.
  38 // A single frame may hold several source level activations in the case of
  39 // optimized code. The debugging stored with the optimized code enables
  40 // us to unfold a frame as a stack of vframes.
  41 // A cVFrame represents an activation of a non-java method.
  42 
  43 // The vframe inheritance hierarchy:
  44 // - vframe
  45 //   - javaVFrame
  46 //     - interpretedVFrame
  47 //     - compiledVFrame     ; (used for both compiled Java methods and native stubs)
  48 //   - externalVFrame
  49 //     - entryVFrame        ; special frame created when calling Java from C
  50 
  51 // - BasicLock
  52 
  53 class javaVFrame;
  54 
  55 class vframe: public ResourceObj {
  56  protected:
  57   frame        _fr;      // Raw frame behind the virtual frame.
  58   RegisterMap  _reg_map; // Register map for the raw frame (used to handle callee-saved registers).
  59   JavaThread*  _thread;  // The thread owning the raw frame.
  60 
  61   vframe(const frame* fr, const RegisterMap* reg_map, JavaThread* thread);
  62   vframe(const frame* fr, JavaThread* thread);
  63  public:
  64   // Factory method for creating vframes
  65   static vframe* new_vframe(const frame* f, const RegisterMap *reg_map, JavaThread* thread);
  66 
  67   // Accessors
  68   frame              fr()           const { return _fr;       }
  69   CodeBlob*          cb()         const { return _fr.cb();  }
  70   CompiledMethod*   nm()         const {
  71       assert( cb() != NULL && cb()->is_compiled(), "usage");
  72       return (CompiledMethod*) cb();
  73   }
  74 
  75 // ???? Does this need to be a copy?
  76   frame*             frame_pointer() { return &_fr;       }
  77   const RegisterMap* register_map() const { return &_reg_map; }
  78   JavaThread*        thread()       const { return _thread;   }
  79   oop                continuation() const { return _reg_map.cont(); }
  80 
  81   // Returns the sender vframe
  82   virtual vframe* sender() const;
  83 
  84   // Returns the next javaVFrame on the stack (skipping all other kinds of frame)
  85   javaVFrame *java_sender() const;
  86 
  87   // Answers if the this is the top vframe in the frame, i.e., if the sender vframe
  88   // is in the caller frame
  89   virtual bool is_top() const { return true; }
  90 
  91   // Returns top vframe within same frame (see is_top())
  92   virtual vframe* top() const;
  93 
  94   // Type testing operations
  95   virtual bool is_entry_frame()       const { return false; }
  96   virtual bool is_java_frame()        const { return false; }
  97   virtual bool is_interpreted_frame() const { return false; }
  98   virtual bool is_compiled_frame()    const { return false; }
  99 
 100 #ifndef PRODUCT
 101   // printing operations
 102   virtual void print_value() const;
 103   virtual void print();
 104 #endif
 105 };
 106 
 107 class MonitorInfo;
 108 
 109 class javaVFrame: public vframe {
 110  public:
 111   // JVM state
 112   virtual Method*                      method()         const = 0;
 113   virtual int                          bci()            const = 0;
 114   virtual StackValueCollection*        locals()         const = 0;
 115   virtual StackValueCollection*        expressions()    const = 0;
 116   // the order returned by monitors() is from oldest -> youngest#4418568
 117   virtual GrowableArray<MonitorInfo*>* monitors()       const = 0;
 118 
 119   // Debugging support via JVMTI.
 120   // NOTE that this is not guaranteed to give correct results for compiled vframes.
 121   // Deoptimize first if necessary.
 122   virtual void set_locals(StackValueCollection* values) const = 0;
 123 
 124   // Test operation
 125   bool is_java_frame() const { return true; }
 126 
 127  protected:


 279   bool owner_is_scalar_replaced()  const { return _owner_is_scalar_replaced; }
 280 };
 281 
 282 class vframeStreamCommon : StackObj {
 283  protected:
 284   // common
 285   frame        _prev_frame;
 286   frame        _frame;
 287   JavaThread*  _thread;
 288   RegisterMap  _reg_map;
 289   enum { interpreted_mode, compiled_mode, at_end_mode } _mode;
 290 
 291   // For compiled_mode
 292   int _decode_offset;
 293   int _sender_decode_offset;
 294   int _vframe_id;
 295 
 296   // Cached information
 297   Method* _method;
 298   int       _bci;
 299   Handle   _cont; // the current frame's continuation
 300 
 301   // Should VM activations be ignored or not
 302   bool _stop_at_java_call_stub;
 303   Handle _continuation_scope; // stop at bottom of continuation with this scope
 304 
 305   bool fill_in_compiled_inlined_sender();
 306   void fill_from_compiled_frame(int decode_offset);
 307   void fill_from_compiled_native_frame();
 308 
 309   void fill_from_interpreter_frame();
 310   bool fill_from_frame();
 311 
 312   // Helper routine for security_get_caller_frame
 313   void skip_prefixed_method_and_wrappers();
 314 
 315   DEBUG_ONLY(void found_bad_method_frame() const;)
 316 
 317  public:
 318   // Constructor
 319   inline vframeStreamCommon(JavaThread* thread);
 320   inline vframeStreamCommon(RegisterMap reg_map);
 321 
 322   // Accessors
 323   Method* method() const { return _method; }
 324   int bci() const { return _bci; }
 325   inline intptr_t* frame_id() const;
 326   address frame_pc() const { return _frame.pc(); }
 327   oop continuation() const { return _cont(); }
 328 
 329   CodeBlob*          cb()         const { return _frame.cb();  }
 330   CompiledMethod*   nm()         const {
 331       assert( cb() != NULL && cb()->is_compiled(), "usage");
 332       return (CompiledMethod*) cb();
 333   }
 334 
 335   javaVFrame* asJavaVFrame();
 336 
 337   // Frame type
 338   inline bool is_interpreted_frame() const;
 339   inline bool is_entry_frame() const;
 340 
 341   // Iteration
 342   inline void next();
 343   void security_next();
 344 
 345   bool at_end() const { return _mode == at_end_mode; }
 346 
 347   // Implements security traversal. Skips depth no. of frame including
 348   // special security frames and prefixed native methods
 349   void security_get_caller_frame(int depth);
 350 
 351   // Helper routine for JVM_LatestUserDefinedLoader -- needed for 1.4
 352   // reflection implementation
 353   void skip_reflection_related_frames();
 354 };
 355 
 356 class vframeStream : public vframeStreamCommon {
 357  public:
 358   // Constructors
 359   vframeStream(JavaThread* thread, bool stop_at_java_call_stub = false);
 360 
 361   vframeStream(JavaThread* thread, Handle continuation_scope, bool stop_at_java_call_stub = false);
 362 
 363   // top_frame may not be at safepoint, start with sender
 364   vframeStream(JavaThread* thread, frame top_frame, bool stop_at_java_call_stub = false);
 365 
 366   vframeStream(Handle continuation);
 367 };
 368 
 369 #endif // SHARE_RUNTIME_VFRAME_HPP
< prev index next >