< prev index next >

src/hotspot/share/prims/stackwalk.hpp

Print this page
*** 26,10 ***
--- 26,11 ---
  #ifndef SHARE_PRIMS_STACKWALK_HPP
  #define SHARE_PRIMS_STACKWALK_HPP
  
  #include "jvm.h"
  #include "oops/oop.hpp"
+ #include "runtime/continuation.hpp"
  #include "runtime/vframe.hpp"
  
  // BaseFrameStream is an abstract base class for encapsulating the VM-side
  // implementation of the StackWalker API.  There are two concrete subclasses:
  // - JavaFrameStream:

*** 42,24 ***
    enum {
      magic_pos = 0
    };
  
    JavaThread*           _thread;
    jlong                 _anchor;
  protected:
    void fill_stackframe(Handle stackFrame, const methodHandle& method, TRAPS);
  public:
!   BaseFrameStream(JavaThread* thread) : _thread(thread), _anchor(0L) {}
  
    virtual void    next()=0;
    virtual bool    at_end()=0;
  
    virtual Method* method()=0;
    virtual int     bci()=0;
  
    virtual void    fill_frame(int index, objArrayHandle  frames_array,
                               const methodHandle& method, TRAPS)=0;
  
    void setup_magic_on_entry(objArrayHandle frames_array);
    bool check_magic(objArrayHandle frames_array);
    bool cleanup_magic_on_exit(objArrayHandle frames_array);
  
--- 43,32 ---
    enum {
      magic_pos = 0
    };
  
    JavaThread*           _thread;
+   Handle                _continuation;
    jlong                 _anchor;
+ 
  protected:
    void fill_stackframe(Handle stackFrame, const methodHandle& method, TRAPS);
  public:
!   BaseFrameStream(JavaThread* thread, Handle continuation);
  
    virtual void    next()=0;
    virtual bool    at_end()=0;
  
    virtual Method* method()=0;
    virtual int     bci()=0;
+   virtual oop     cont()=0; // returns the current continuation (even when walking a thread)
+ 
+   virtual const RegisterMap* reg_map()=0;
  
    virtual void    fill_frame(int index, objArrayHandle  frames_array,
                               const methodHandle& method, TRAPS)=0;
+   
+   oop continuation() { return _continuation(); }
+   void set_continuation(Handle cont);
  
    void setup_magic_on_entry(objArrayHandle frames_array);
    bool check_magic(objArrayHandle frames_array);
    bool cleanup_magic_on_exit(objArrayHandle frames_array);
  

*** 76,51 ***
  
  class JavaFrameStream : public BaseFrameStream {
  private:
    vframeStream          _vfst;
    bool                  _need_method_info;
  public:
!   JavaFrameStream(JavaThread* thread, int mode);
  
!   void next();
!   bool at_end()    { return _vfst.at_end(); }
  
!   Method* method() { return _vfst.method(); }
!   int bci()        { return _vfst.bci(); }
  
    void fill_frame(int index, objArrayHandle  frames_array,
!                   const methodHandle& method, TRAPS);
  };
  
  class LiveFrameStream : public BaseFrameStream {
  private:
    enum {
      MODE_INTERPRETED = 0x01,
      MODE_COMPILED    = 0x02
    };
  
!   javaVFrame*           _jvf;
  
    void fill_live_stackframe(Handle stackFrame, const methodHandle& method, TRAPS);
    static oop create_primitive_slot_instance(StackValueCollection* values,
                                              int i, BasicType type, TRAPS);
    static objArrayHandle monitors_to_object_array(GrowableArray<MonitorInfo*>* monitors,
                                                   TRAPS);
    static objArrayHandle values_to_object_array(StackValueCollection* values, TRAPS);
  public:
!   LiveFrameStream(JavaThread* thread, RegisterMap* rm) : BaseFrameStream(thread) {
-     _jvf = thread->last_java_vframe(rm);
-   }
  
!   void next()      { _jvf = _jvf->java_sender(); }
-   bool at_end()    { return _jvf == NULL; }
  
!   Method* method() { return _jvf->method(); }
!   int bci()        { return _jvf->bci(); }
  
    void fill_frame(int index, objArrayHandle  frames_array,
!                   const methodHandle& method, TRAPS);
  };
  
  class StackWalk : public AllStatic {
  private:
    static int fill_in_frames(jlong mode, BaseFrameStream& stream,
--- 85,60 ---
  
  class JavaFrameStream : public BaseFrameStream {
  private:
    vframeStream          _vfst;
    bool                  _need_method_info;
+ 
  public:
!   JavaFrameStream(JavaThread* thread, int mode, Handle cont_scope, Handle cont);
+ 
+   const RegisterMap* reg_map() override { return _vfst.reg_map(); };
  
!   void next()   override;
!   bool at_end() override { return _vfst.at_end(); }
  
!   Method* method() override { return _vfst.method(); }
!   int bci()        override { return _vfst.bci(); }
+   oop cont()       override { return _vfst.continuation(); }
  
    void fill_frame(int index, objArrayHandle  frames_array,
!                   const methodHandle& method, TRAPS) override;
  };
  
  class LiveFrameStream : public BaseFrameStream {
  private:
    enum {
      MODE_INTERPRETED = 0x01,
      MODE_COMPILED    = 0x02
    };
  
!   Handle              _cont_scope;  // the delimitation of this walk
+ 
+   RegisterMap*        _map;
+   javaVFrame*         _jvf;
+   ContinuationEntry* _cont;
  
    void fill_live_stackframe(Handle stackFrame, const methodHandle& method, TRAPS);
    static oop create_primitive_slot_instance(StackValueCollection* values,
                                              int i, BasicType type, TRAPS);
    static objArrayHandle monitors_to_object_array(GrowableArray<MonitorInfo*>* monitors,
                                                   TRAPS);
    static objArrayHandle values_to_object_array(StackValueCollection* values, TRAPS);
  public:
!   LiveFrameStream(JavaThread* thread, RegisterMap* rm, Handle cont_scope, Handle cont);
  
!   const RegisterMap* reg_map() override { return _map; };
  
!   void next()   override;
!   bool at_end() override { return _jvf == NULL; }
+ 
+   Method* method() override { return _jvf->method(); }
+   int bci()        override { return _jvf->bci(); }
+   oop cont() override { return continuation() != NULL ? continuation(): _cont->cont_oop(); }
  
    void fill_frame(int index, objArrayHandle  frames_array,
!                   const methodHandle& method, TRAPS) override;
  };
  
  class StackWalk : public AllStatic {
  private:
    static int fill_in_frames(jlong mode, BaseFrameStream& stream,

*** 143,19 ***
      return (mode & JVM_STACKWALK_FILL_CLASS_REFS_ONLY) == 0;
    }
    static inline bool use_frames_array(int mode) {
      return (mode & JVM_STACKWALK_FILL_CLASS_REFS_ONLY) == 0;
    }
!   static oop walk(Handle stackStream, jlong mode,
!                   int skip_frames, int frame_count, int start_index,
-                   objArrayHandle frames_array,
                    TRAPS);
  
    static oop fetchFirstBatch(BaseFrameStream& stream, Handle stackStream,
                               jlong mode, int skip_frames, int frame_count,
                               int start_index, objArrayHandle frames_array, TRAPS);
  
    static jint fetchNextBatch(Handle stackStream, jlong mode, jlong magic,
                               int frame_count, int start_index,
                               objArrayHandle frames_array, TRAPS);
  };
  #endif // SHARE_PRIMS_STACKWALK_HPP
--- 161,21 ---
      return (mode & JVM_STACKWALK_FILL_CLASS_REFS_ONLY) == 0;
    }
    static inline bool use_frames_array(int mode) {
      return (mode & JVM_STACKWALK_FILL_CLASS_REFS_ONLY) == 0;
    }
!   static oop walk(Handle stackStream, jlong mode, int skip_frames, Handle cont_scope, Handle cont,
!                   int frame_count, int start_index, objArrayHandle frames_array,
                    TRAPS);
  
    static oop fetchFirstBatch(BaseFrameStream& stream, Handle stackStream,
                               jlong mode, int skip_frames, int frame_count,
                               int start_index, objArrayHandle frames_array, TRAPS);
  
    static jint fetchNextBatch(Handle stackStream, jlong mode, jlong magic,
                               int frame_count, int start_index,
                               objArrayHandle frames_array, TRAPS);
+ 
+   static void setContinuation(Handle stackStream, jlong magic, objArrayHandle frames_array, 
+                               Handle cont, TRAPS);
  };
  #endif // SHARE_PRIMS_STACKWALK_HPP
< prev index next >