< prev index next >

src/hotspot/share/prims/stackwalk.cpp

Print this page
rev 49275 : [mq]: JDK-8199781.patch


  31 #include "memory/oopFactory.hpp"
  32 #include "oops/oop.inline.hpp"
  33 #include "oops/objArrayOop.inline.hpp"
  34 #include "prims/stackwalk.hpp"
  35 #include "runtime/globals.hpp"
  36 #include "runtime/handles.inline.hpp"
  37 #include "runtime/javaCalls.hpp"
  38 #include "runtime/vframe.hpp"
  39 #include "utilities/globalDefinitions.hpp"
  40 
  41 // setup and cleanup actions
  42 void BaseFrameStream::setup_magic_on_entry(objArrayHandle frames_array) {
  43   frames_array->obj_at_put(magic_pos, _thread->threadObj());
  44   _anchor = address_value();
  45   assert(check_magic(frames_array), "invalid magic");
  46 }
  47 
  48 bool BaseFrameStream::check_magic(objArrayHandle frames_array) {
  49   oop   m1 = frames_array->obj_at(magic_pos);
  50   jlong m2 = _anchor;
  51   if (m1 == _thread->threadObj() && m2 == address_value())  return true;
  52   return false;
  53 }
  54 
  55 bool BaseFrameStream::cleanup_magic_on_exit(objArrayHandle frames_array) {
  56   bool ok = check_magic(frames_array);
  57   frames_array->obj_at_put(magic_pos, NULL);
  58   _anchor = 0L;
  59   return ok;
  60 }
  61 
  62 JavaFrameStream::JavaFrameStream(JavaThread* thread, int mode)
  63   : BaseFrameStream(thread), _vfst(thread) {
  64   _need_method_info = StackWalk::need_method_info(mode);
  65 }
  66 
  67 // Returns the BaseFrameStream for the current stack being traversed.
  68 //
  69 // Parameters:
  70 //  thread         Current Java thread.
  71 //  magic          Magic value used for each stack walking
  72 //  frames_array   User-supplied buffers.  The 0th element is reserved
  73 //                 for this BaseFrameStream to use
  74 //
  75 BaseFrameStream* BaseFrameStream::from_current(JavaThread* thread, jlong magic,
  76                                                objArrayHandle frames_array)
  77 {
  78   assert(thread != NULL && thread->is_Java_thread(), "");
  79   oop m1 = frames_array->obj_at(magic_pos);
  80   if (m1 != thread->threadObj())      return NULL;
  81   if (magic == 0L)                    return NULL;
  82   BaseFrameStream* stream = (BaseFrameStream*) (intptr_t) magic;
  83   if (!stream->is_valid_in(thread, frames_array))   return NULL;
  84   return stream;
  85 }
  86 
  87 // Unpacks one or more frames into user-supplied buffers.
  88 // Updates the end index, and returns the number of unpacked frames.
  89 // Always start with the existing vfst.method and bci.
  90 // Do not call vfst.next to advance over the last returned value.
  91 // In other words, do not leave any stale data in the vfst.
  92 //
  93 // Parameters:
  94 //   mode             Restrict which frames to be decoded.
  95 //   BaseFrameStream  stream of frames
  96 //   max_nframes      Maximum number of frames to be filled.
  97 //   start_index      Start index to the user-supplied buffers.
  98 //   frames_array     Buffer to store Class or StackFrame in, starting at start_index.
  99 //                    frames array is a Class<?>[] array when only getting caller
 100 //                    reference, and a StackFrameInfo[] array (or derivative)




  31 #include "memory/oopFactory.hpp"
  32 #include "oops/oop.inline.hpp"
  33 #include "oops/objArrayOop.inline.hpp"
  34 #include "prims/stackwalk.hpp"
  35 #include "runtime/globals.hpp"
  36 #include "runtime/handles.inline.hpp"
  37 #include "runtime/javaCalls.hpp"
  38 #include "runtime/vframe.hpp"
  39 #include "utilities/globalDefinitions.hpp"
  40 
  41 // setup and cleanup actions
  42 void BaseFrameStream::setup_magic_on_entry(objArrayHandle frames_array) {
  43   frames_array->obj_at_put(magic_pos, _thread->threadObj());
  44   _anchor = address_value();
  45   assert(check_magic(frames_array), "invalid magic");
  46 }
  47 
  48 bool BaseFrameStream::check_magic(objArrayHandle frames_array) {
  49   oop   m1 = frames_array->obj_at(magic_pos);
  50   jlong m2 = _anchor;
  51   if (oopDesc::equals(m1, _thread->threadObj()) && m2 == address_value())  return true;
  52   return false;
  53 }
  54 
  55 bool BaseFrameStream::cleanup_magic_on_exit(objArrayHandle frames_array) {
  56   bool ok = check_magic(frames_array);
  57   frames_array->obj_at_put(magic_pos, NULL);
  58   _anchor = 0L;
  59   return ok;
  60 }
  61 
  62 JavaFrameStream::JavaFrameStream(JavaThread* thread, int mode)
  63   : BaseFrameStream(thread), _vfst(thread) {
  64   _need_method_info = StackWalk::need_method_info(mode);
  65 }
  66 
  67 // Returns the BaseFrameStream for the current stack being traversed.
  68 //
  69 // Parameters:
  70 //  thread         Current Java thread.
  71 //  magic          Magic value used for each stack walking
  72 //  frames_array   User-supplied buffers.  The 0th element is reserved
  73 //                 for this BaseFrameStream to use
  74 //
  75 BaseFrameStream* BaseFrameStream::from_current(JavaThread* thread, jlong magic,
  76                                                objArrayHandle frames_array)
  77 {
  78   assert(thread != NULL && thread->is_Java_thread(), "");
  79   oop m1 = frames_array->obj_at(magic_pos);
  80   if (!oopDesc::equals(m1, thread->threadObj())) return NULL;
  81   if (magic == 0L)                    return NULL;
  82   BaseFrameStream* stream = (BaseFrameStream*) (intptr_t) magic;
  83   if (!stream->is_valid_in(thread, frames_array))   return NULL;
  84   return stream;
  85 }
  86 
  87 // Unpacks one or more frames into user-supplied buffers.
  88 // Updates the end index, and returns the number of unpacked frames.
  89 // Always start with the existing vfst.method and bci.
  90 // Do not call vfst.next to advance over the last returned value.
  91 // In other words, do not leave any stale data in the vfst.
  92 //
  93 // Parameters:
  94 //   mode             Restrict which frames to be decoded.
  95 //   BaseFrameStream  stream of frames
  96 //   max_nframes      Maximum number of frames to be filled.
  97 //   start_index      Start index to the user-supplied buffers.
  98 //   frames_array     Buffer to store Class or StackFrame in, starting at start_index.
  99 //                    frames array is a Class<?>[] array when only getting caller
 100 //                    reference, and a StackFrameInfo[] array (or derivative)


< prev index next >