void ClassLoaderData::Dependencies::locked_add(objArrayHandle last_handle,
                                               objArrayHandle new_dependency,
                                               Thread* THREAD) {

  // Have to lock and put the new dependency on the end of the dependency
  // array so the card mark for CMS sees that this dependency is new.
  // Can probably do this lock free with some effort.
  ObjectLocker ol(Handle(THREAD, _list_head), THREAD);

  oop loader_or_mirror = new_dependency->obj_at(0);

  // Since the dependencies are only added, add to the end.
  objArrayOop end = last_handle();
  objArrayOop last = NULL;
  while (end != NULL) {
    last = end;
    // check again if another thread added it to the end.
    if (end->obj_at(0) == loader_or_mirror) {
      // Don't need to add it
      return;
    }
    end = (objArrayOop)end->obj_at(1);
  }
  assert (last != NULL, "dependencies should be initialized");
  // fill in the first element with the oop in new_dependency.
  if (last->obj_at(0) == NULL) {
    last->obj_at_put(0, new_dependency->obj_at(0));
  } else {
    last->obj_at_put(1, new_dependency());
  }
}
示例#2
0
void Rewriter::relocate_and_link(instanceKlassHandle this_oop,
                                 objArrayHandle methods, TRAPS) {
  int len = methods->length();
  for (int i = len-1; i >= 0; i--) {
    methodHandle m(THREAD, (methodOop)methods->obj_at(i));

    if (m->has_jsrs()) {
      m = rewrite_jsrs(m, CHECK);
      // Method might have gotten rewritten.
      methods->obj_at_put(i, m());
    }

    // Set up method entry points for compiler and interpreter    .
    m->link_method(m, CHECK);

    // This is for JVMTI and unrelated to relocator but the last thing we do
#ifdef ASSERT
    if (StressMethodComparator) {
      static int nmc = 0;
      for (int j = i; j >= 0 && j >= i-4; j--) {
        if ((++nmc % 1000) == 0)  tty->print_cr("Have run MethodComparator %d times...", nmc);
        bool z = MethodComparator::methods_EMCP(m(),
                   (methodOop)methods->obj_at(j));
        if (j == i && !z) {
          tty->print("MethodComparator FAIL: "); m->print(); m->print_codes();
          assert(z, "method must compare equal to itself");
        }
      }
    }
#endif //ASSERT
  }
}
示例#3
0
// Fill in the StackFrameInfo at the given index in frames_array
void JavaFrameStream::fill_frame(int index, objArrayHandle  frames_array,
                                 const methodHandle& method, TRAPS) {
    if (_need_method_info) {
        Handle stackFrame(THREAD, frames_array->obj_at(index));
        fill_stackframe(stackFrame, method);
    } else {
        frames_array->obj_at_put(index, method->method_holder()->java_mirror());
    }
}
示例#4
0
// Unpacks one or more frames into user-supplied buffers.
// Updates the end index, and returns the number of unpacked frames.
// Always start with the existing vfst.method and bci.
// Do not call vfst.next to advance over the last returned value.
// In other words, do not leave any stale data in the vfst.
//
// Parameters:
//   mode             Restrict which frames to be decoded.
//   BaseFrameStream  stream of frames
//   max_nframes      Maximum number of frames to be filled.
//   start_index      Start index to the user-supplied buffers.
//   frames_array     Buffer to store Class or StackFrame in, starting at start_index.
//                    frames array is a Class<?>[] array when only getting caller
//                    reference, and a StackFrameInfo[] array (or derivative)
//                    otherwise. It should never be null.
//   end_index        End index to the user-supplied buffers with unpacked frames.
//
// Returns the number of frames whose information was transferred into the buffers.
//
int StackWalk::fill_in_frames(jlong mode, BaseFrameStream& stream,
                              int max_nframes, int start_index,
                              objArrayHandle  frames_array,
                              int& end_index, TRAPS) {
    log_debug(stackwalk)("fill_in_frames limit=%d start=%d frames length=%d",
                         max_nframes, start_index, frames_array->length());
    assert(max_nframes > 0, "invalid max_nframes");
    assert(start_index + max_nframes <= frames_array->length(), "oob");

    int frames_decoded = 0;
    for (; !stream.at_end(); stream.next()) {
        Method* method = stream.method();

        if (method == NULL) continue;

        // skip hidden frames for default StackWalker option (i.e. SHOW_HIDDEN_FRAMES
        // not set) and when StackWalker::getCallerClass is called
        if (!ShowHiddenFrames && (skip_hidden_frames(mode) || get_caller_class(mode))) {
            if (method->is_hidden()) {
                if (log_is_enabled(Debug, stackwalk)) {
                    ResourceMark rm(THREAD);
                    outputStream* st = Log(stackwalk)::debug_stream();
                    st->print("  hidden method: ");
                    method->print_short_name(st);
                    st->cr();
                }
                continue;
            }
        }

        int index = end_index++;
        if (log_is_enabled(Debug, stackwalk)) {
            ResourceMark rm(THREAD);
            outputStream* st = Log(stackwalk)::debug_stream();
            st->print("  %d: frame method: ", index);
            method->print_short_name(st);
            st->print_cr(" bci=%d", stream.bci());
        }

        if (!need_method_info(mode) && get_caller_class(mode) &&
                index == start_index && method->caller_sensitive()) {
            ResourceMark rm(THREAD);
            THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(),
                        err_msg("StackWalker::getCallerClass called from @CallerSensitive %s method",
                                method->name_and_sig_as_C_string()));
        }
        // fill in StackFrameInfo and initialize MemberName
        stream.fill_frame(index, frames_array, method, CHECK_0);
        if (++frames_decoded >= max_nframes)  break;
    }
    return frames_decoded;
}
示例#5
0
// Unpacks one or more frames into user-supplied buffers.
// Updates the end index, and returns the number of unpacked frames.
// Always start with the existing vfst.method and bci.
// Do not call vfst.next to advance over the last returned value.
// In other words, do not leave any stale data in the vfst.
//
// Parameters:
//   mode             Restrict which frames to be decoded.
//   JavaFrameStream  stream of javaVFrames
//   max_nframes      Maximum number of frames to be filled.
//   start_index      Start index to the user-supplied buffers.
//   frames_array     Buffer to store Class or StackFrame in, starting at start_index.
//                    frames array is a Class<?>[] array when only getting caller
//                    reference, and a StackFrameInfo[] array (or derivative)
//                    otherwise. It should never be null.
//   end_index        End index to the user-supplied buffers with unpacked frames.
//
// Returns the number of frames whose information was transferred into the buffers.
//
int StackWalk::fill_in_frames(jlong mode, JavaFrameStream& stream,
                              int max_nframes, int start_index,
                              objArrayHandle  frames_array,
                              int& end_index, TRAPS) {
  if (TraceStackWalk) {
    tty->print_cr("fill_in_frames limit=%d start=%d frames length=%d",
                  max_nframes, start_index, frames_array->length());
  }
  assert(max_nframes > 0, "invalid max_nframes");
  assert(start_index + max_nframes <= frames_array->length(), "oob");

  int frames_decoded = 0;
  for (; !stream.at_end(); stream.next()) {
    Method* method = stream.method();
    int bci = stream.bci();

    if (method == NULL) continue;
    if (!ShowHiddenFrames && StackWalk::skip_hidden_frames(mode)) {
      if (method->is_hidden()) {
        if (TraceStackWalk) {
          tty->print("  hidden method: "); method->print_short_name();
          tty->print("\n");
        }
        continue;
      }
    }

    int index = end_index++;
    if (TraceStackWalk) {
      tty->print("  %d: frame method: ", index); method->print_short_name();
      tty->print_cr(" bci=%d", bci);
    }

    // fill in StackFrameInfo and initialize MemberName
    if (live_frame_info(mode)) {
      assert (use_frames_array(mode), "Bad mode for get live frame");
      Handle stackFrame(frames_array->obj_at(index));
      fill_live_stackframe(stackFrame, method, bci, stream.java_frame(), CHECK_0);
    } else if (need_method_info(mode)) {
      assert (use_frames_array(mode), "Bad mode for get stack frame");
      Handle stackFrame(frames_array->obj_at(index));
      fill_stackframe(stackFrame, method, bci);
    } else {
      assert (use_frames_array(mode) == false, "Bad mode for get caller class");
      frames_array->obj_at_put(index, method->method_holder()->java_mirror());
    }
    if (++frames_decoded >= max_nframes)  break;
  }
  return frames_decoded;
}
示例#6
0
// Begins stack walking.
//
// Parameters:
//   stackStream    StackStream object
//   mode           Stack walking mode.
//   skip_frames    Number of frames to be skipped.
//   frame_count    Number of frames to be traversed.
//   start_index    Start index to the user-supplied buffers.
//   frames_array   Buffer to store StackFrame in, starting at start_index.
//                  frames array is a Class<?>[] array when only getting caller
//                  reference, and a StackFrameInfo[] array (or derivative)
//                  otherwise. It should never be null.
//
// Returns Object returned from AbstractStackWalker::doStackWalk call.
//
oop StackWalk::walk(Handle stackStream, jlong mode,
                    int skip_frames, int frame_count, int start_index,
                    objArrayHandle frames_array,
                    TRAPS) {
    ResourceMark rm(THREAD);
    JavaThread* jt = (JavaThread*)THREAD;
    log_debug(stackwalk)("Start walking: mode " JLONG_FORMAT " skip %d frames batch size %d",
                         mode, skip_frames, frame_count);

    if (frames_array.is_null()) {
        THROW_MSG_(vmSymbols::java_lang_NullPointerException(), "frames_array is NULL", NULL);
    }

    // Setup traversal onto my stack.
    if (live_frame_info(mode)) {
        assert (use_frames_array(mode), "Bad mode for get live frame");
        RegisterMap regMap(jt, true);
        LiveFrameStream stream(jt, &regMap);
        return fetchFirstBatch(stream, stackStream, mode, skip_frames, frame_count,
                               start_index, frames_array, THREAD);
    } else {
        JavaFrameStream stream(jt, mode);
        return fetchFirstBatch(stream, stackStream, mode, skip_frames, frame_count,
                               start_index, frames_array, THREAD);
    }
}
示例#7
0
// Walk the next batch of stack frames
//
// Parameters:
//   stackStream    StackStream object
//   mode           Stack walking mode.
//   magic          Must be valid value to continue the stack walk
//   frame_count    Number of frames to be decoded.
//   start_index    Start index to the user-supplied buffers.
//   classes_array  Buffer to store classes in, starting at start_index.
//   frames_array   Buffer to store StackFrame in, starting at start_index.
//                  NULL if not used.
//
// Returns the end index of frame filled in the buffer.
//
jint StackWalk::moreFrames(Handle stackStream, jlong mode, jlong magic,
                           int frame_count, int start_index,
                           objArrayHandle classes_array,
                           objArrayHandle frames_array,
                           TRAPS)
{
  JavaThread* jt = (JavaThread*)THREAD;
  StackWalkAnchor* existing_anchor = StackWalkAnchor::from_current(jt, magic, classes_array);
  if (existing_anchor == NULL) {
    THROW_MSG_(vmSymbols::java_lang_InternalError(), "doStackWalk: corrupted buffers", 0L);
  }

  if ((need_method_info(mode) || live_frame_info(mode)) && frames_array.is_null()) {
    THROW_MSG_(vmSymbols::java_lang_NullPointerException(), "frames_array is NULL", 0L);
  }

  if (TraceStackWalk) {
    tty->print_cr("StackWalk::moreFrames frame_count %d existing_anchor " PTR_FORMAT " start %d frames %d",
                  frame_count, p2i(existing_anchor), start_index, classes_array->length());
  }
  int end_index = start_index;
  if (frame_count <= 0) {
    return end_index;        // No operation.
  }

  int count = frame_count + start_index;
  assert (classes_array->length() >= count, "not enough space in buffers");

  StackWalkAnchor& anchor = (*existing_anchor);
  vframeStream& vfst = anchor.vframe_stream();
  if (!vfst.at_end()) {
    vfst.next();  // this was the last frame decoded in the previous batch
    if (!vfst.at_end()) {
      int n = fill_in_frames(mode, vfst, frame_count, start_index, classes_array,
                             frames_array, end_index, CHECK_0);
      if (n < 1) {
        THROW_MSG_(vmSymbols::java_lang_InternalError(), "doStackWalk: later decode failed", 0L);
      }
      return end_index;
    }
  }
  return end_index;
}
示例#8
0
// Walk the next batch of stack frames
//
// Parameters:
//   stackStream    StackStream object
//   mode           Stack walking mode.
//   magic          Must be valid value to continue the stack walk
//   frame_count    Number of frames to be decoded.
//   start_index    Start index to the user-supplied buffers.
//   frames_array   Buffer to store StackFrame in, starting at start_index.
//
// Returns the end index of frame filled in the buffer.
//
jint StackWalk::moreFrames(Handle stackStream, jlong mode, jlong magic,
                           int frame_count, int start_index,
                           objArrayHandle frames_array,
                           TRAPS)
{
  JavaThread* jt = (JavaThread*)THREAD;
  JavaFrameStream* existing_stream = JavaFrameStream::from_current(jt, magic, frames_array);
  if (existing_stream == NULL) {
    THROW_MSG_(vmSymbols::java_lang_InternalError(), "doStackWalk: corrupted buffers", 0L);
  }

  if (frames_array.is_null()) {
    THROW_MSG_(vmSymbols::java_lang_NullPointerException(), "frames_array is NULL", 0L);
  }

  if (TraceStackWalk) {
    tty->print_cr("StackWalk::moreFrames frame_count %d existing_stream " PTR_FORMAT " start %d frames %d",
                  frame_count, p2i(existing_stream), start_index, frames_array->length());
  }
  int end_index = start_index;
  if (frame_count <= 0) {
    return end_index;        // No operation.
  }

  int count = frame_count + start_index;
  assert (frames_array->length() >= count, "not enough space in buffers");

  JavaFrameStream& stream = (*existing_stream);
  if (!stream.at_end()) {
    stream.next(); // advance past the last frame decoded in previous batch
    if (!stream.at_end()) {
      int n = fill_in_frames(mode, stream, frame_count, start_index,
                             frames_array, end_index, CHECK_0);
      if (n < 1) {
        THROW_MSG_(vmSymbols::java_lang_InternalError(), "doStackWalk: later decode failed", 0L);
      }
      return end_index;
    }
  }
  return end_index;
}
void JavaAssertions::fillJavaArrays(const OptionList* p, int len,
objArrayHandle names, typeArrayHandle enabled, TRAPS) {
  // Fill in the parallel names and enabled (boolean) arrays.  Start at the end
  // of the array and work backwards, so the order of items in the arrays
  // matches the order on the command line (the list is in reverse order, since
  // it was created by prepending successive items from the command line).
  int index;
  for (index = len - 1; p != 0; p = p->next(), --index) {
    assert(index >= 0, "length does not match list");
    Handle s = java_lang_String::create_from_str(p->name(), CHECK);
    s = java_lang_String::char_converter(s, '/', '.', CHECK);
    names->obj_at_put(index, s());
    enabled->bool_at_put(index, p->enabled());
  }
  assert(index == -1, "length does not match list");
}
示例#10
0
// setup and cleanup actions
void BaseFrameStream::setup_magic_on_entry(objArrayHandle frames_array) {
    frames_array->obj_at_put(magic_pos, _thread->threadObj());
    _anchor = address_value();
    assert(check_magic(frames_array), "invalid magic");
}
示例#11
0
// Fill in the LiveStackFrameInfo at the given index in frames_array
void LiveFrameStream::fill_frame(int index, objArrayHandle  frames_array,
                                 const methodHandle& method, TRAPS) {
    Handle stackFrame(THREAD, frames_array->obj_at(index));
    fill_live_stackframe(stackFrame, method, CHECK);
}
示例#12
0
bool StackWalkAnchor::cleanup_magic_on_exit(objArrayHandle classes_array) {
  bool ok = check_magic(classes_array);
  classes_array->obj_at_put(magic_pos, NULL);
  _anchor = 0L;
  return ok;
}
示例#13
0
// setup and cleanup actions
void StackWalkAnchor::setup_magic_on_entry(objArrayHandle classes_array) {
  classes_array->obj_at_put(magic_pos, _thread->threadObj());
  _anchor = address_value();
  assert(check_magic(classes_array), "invalid magic");
}
示例#14
0
// Begins stack walking.
//
// Parameters:
//   stackStream    StackStream object
//   mode           Stack walking mode.
//   skip_frames    Number of frames to be skipped.
//   frame_count    Number of frames to be traversed.
//   start_index    Start index to the user-supplied buffers.
//   classes_array  Buffer to store classes in, starting at start_index.
//   frames_array   Buffer to store StackFrame in, starting at start_index.
//                  NULL if not used.
//
// Returns Object returned from AbstractStackWalker::doStackWalk call.
//
oop StackWalk::walk(Handle stackStream, jlong mode,
                    int skip_frames, int frame_count, int start_index,
                    objArrayHandle classes_array,
                    objArrayHandle frames_array,
                    TRAPS) {
  JavaThread* jt = (JavaThread*)THREAD;
  if (TraceStackWalk) {
    tty->print_cr("Start walking: mode " JLONG_FORMAT " skip %d frames batch size %d",
                  mode, skip_frames, frame_count);
  }

  if (need_method_info(mode)) {
    if (frames_array.is_null()) {
      THROW_MSG_(vmSymbols::java_lang_NullPointerException(), "frames_array is NULL", NULL);
    }
  }

  Klass* stackWalker_klass = SystemDictionary::StackWalker_klass();
  Klass* abstractStackWalker_klass = SystemDictionary::AbstractStackWalker_klass();

  methodHandle m_doStackWalk(THREAD, Universe::do_stack_walk_method());

  // Open up a traversable stream onto my stack.
  // This stream will be made available by *reference* to the inner Java call.
  StackWalkAnchor anchor(jt);
  vframeStream& vfst = anchor.vframe_stream();

  {
    // Skip all methods from AbstractStackWalker and StackWalk (enclosing method)
    if (!fill_in_stacktrace(mode)) {
      while (!vfst.at_end()) {
        InstanceKlass* ik = vfst.method()->method_holder();
        if (ik != stackWalker_klass &&
              ik != abstractStackWalker_klass && ik->super() != abstractStackWalker_klass)  {
          break;
        }

        if (TraceStackWalk) {
          tty->print("  skip "); vfst.method()->print_short_name(); tty->print("\n");
        }
        vfst.next();
      }
    }

    // For exceptions, skip Throwable::fillInStackTrace and <init> methods
    // of the exception class and superclasses
    if (fill_in_stacktrace(mode)) {
      bool skip_to_fillInStackTrace = false;
      bool skip_throwableInit_check = false;
      while (!vfst.at_end() && !skip_throwableInit_check) {
        InstanceKlass* ik = vfst.method()->method_holder();
        Method* method = vfst.method();
        if (!skip_to_fillInStackTrace) {
          if (ik == SystemDictionary::Throwable_klass() &&
              method->name() == vmSymbols::fillInStackTrace_name()) {
              // this frame will be skipped
              skip_to_fillInStackTrace = true;
          }
        } else if (!(ik->is_subclass_of(SystemDictionary::Throwable_klass()) &&
                     method->name() == vmSymbols::object_initializer_name())) {
            // there are none or we've seen them all - either way stop checking
            skip_throwableInit_check = true;
            break;
        }

        if (TraceStackWalk) {
          tty->print("stack walk: skip "); vfst.method()->print_short_name(); tty->print("\n");
        }
        vfst.next();
      }
    }

    // stack frame has been traversed individually and resume stack walk
    // from the stack frame at depth == skip_frames.
    for (int n=0; n < skip_frames && !vfst.at_end(); vfst.next(), n++) {
      if (TraceStackWalk) {
        tty->print("  skip "); vfst.method()->print_short_name();
        tty->print_cr(" frame id: " PTR_FORMAT " pc: " PTR_FORMAT,
                      p2i(vfst.frame_id()), p2i(vfst.frame_pc()));
      }
    }
  }

  // The Method* pointer in the vfst has a very short shelf life.  Grab it now.
  int end_index = start_index;
  int numFrames = 0;
  if (!vfst.at_end()) {
    numFrames = fill_in_frames(mode, vfst, frame_count, start_index, classes_array,
                               frames_array, end_index, CHECK_NULL);
    if (numFrames < 1) {
      THROW_MSG_(vmSymbols::java_lang_InternalError(), "stack walk: decode failed", NULL);
    }
  }

  // JVM_CallStackWalk walks the stack and fills in stack frames, then calls to
  // Java method java.lang.StackStreamFactory.AbstractStackWalker::doStackWalk
  // which calls the implementation to consume the stack frames.
  // When JVM_CallStackWalk returns, it invalidates the stack stream.
  JavaValue result(T_OBJECT);
  JavaCallArguments args(stackStream);
  args.push_long(anchor.address_value());
  args.push_int(skip_frames);
  args.push_int(frame_count);
  args.push_int(start_index);
  args.push_int(end_index);

  // Link the thread and vframe stream into the callee-visible object
  anchor.setup_magic_on_entry(classes_array);

  JavaCalls::call(&result, m_doStackWalk, &args, THREAD);

  // Do this before anything else happens, to disable any lingering stream objects
  bool ok = anchor.cleanup_magic_on_exit(classes_array);

  // Throw pending exception if we must
  (void) (CHECK_NULL);

  if (!ok) {
    THROW_MSG_(vmSymbols::java_lang_InternalError(), "doStackWalk: corrupted buffers on exit", NULL);
  }

  // Return normally
  return (oop)result.get_jobject();

}
示例#15
0
// Begins stack walking.
//
// Parameters:
//   stackStream    StackStream object
//   mode           Stack walking mode.
//   skip_frames    Number of frames to be skipped.
//   frame_count    Number of frames to be traversed.
//   start_index    Start index to the user-supplied buffers.
//   frames_array   Buffer to store StackFrame in, starting at start_index.
//                  frames array is a Class<?>[] array when only getting caller
//                  reference, and a StackFrameInfo[] array (or derivative)
//                  otherwise. It should never be null.
//
// Returns Object returned from AbstractStackWalker::doStackWalk call.
//
oop StackWalk::walk(Handle stackStream, jlong mode,
                    int skip_frames, int frame_count, int start_index,
                    objArrayHandle frames_array,
                    TRAPS) {
  ResourceMark rm(THREAD);
  JavaThread* jt = (JavaThread*)THREAD;
  if (TraceStackWalk) {
    tty->print_cr("Start walking: mode " JLONG_FORMAT " skip %d frames batch size %d",
                  mode, skip_frames, frame_count);
  }

  if (frames_array.is_null()) {
    THROW_MSG_(vmSymbols::java_lang_NullPointerException(), "frames_array is NULL", NULL);
  }

  Klass* stackWalker_klass = SystemDictionary::StackWalker_klass();
  Klass* abstractStackWalker_klass = SystemDictionary::AbstractStackWalker_klass();

  methodHandle m_doStackWalk(THREAD, Universe::do_stack_walk_method());

  // Setup traversal onto my stack.
  RegisterMap regMap(jt, true);
  JavaFrameStream stream(jt, &regMap);
  {
    while (!stream.at_end()) {
      InstanceKlass* ik = stream.method()->method_holder();
      if (ik != stackWalker_klass &&
            ik != abstractStackWalker_klass && ik->super() != abstractStackWalker_klass)  {
        break;
      }

      if (TraceStackWalk) {
        tty->print("  skip "); stream.method()->print_short_name(); tty->print("\n");
      }
      stream.next();
    }

    // stack frame has been traversed individually and resume stack walk
    // from the stack frame at depth == skip_frames.
    for (int n=0; n < skip_frames && !stream.at_end(); stream.next(), n++) {
      if (TraceStackWalk) {
        tty->print("  skip "); stream.method()->print_short_name();
        tty->print_cr(" frame id: " PTR_FORMAT " pc: " PTR_FORMAT,
                      p2i(stream.java_frame()->fr().id()),
                      p2i(stream.java_frame()->fr().pc()));
      }
    }
  }

  int end_index = start_index;
  int numFrames = 0;
  if (!stream.at_end()) {
    numFrames = fill_in_frames(mode, stream, frame_count, start_index,
                               frames_array, end_index, CHECK_NULL);
    if (numFrames < 1) {
      THROW_MSG_(vmSymbols::java_lang_InternalError(), "stack walk: decode failed", NULL);
    }
  }

  // JVM_CallStackWalk walks the stack and fills in stack frames, then calls to
  // Java method java.lang.StackStreamFactory.AbstractStackWalker::doStackWalk
  // which calls the implementation to consume the stack frames.
  // When JVM_CallStackWalk returns, it invalidates the stack stream.
  JavaValue result(T_OBJECT);
  JavaCallArguments args(stackStream);
  args.push_long(stream.address_value());
  args.push_int(skip_frames);
  args.push_int(frame_count);
  args.push_int(start_index);
  args.push_int(end_index);

  // Link the thread and vframe stream into the callee-visible object
  stream.setup_magic_on_entry(frames_array);

  JavaCalls::call(&result, m_doStackWalk, &args, THREAD);

  // Do this before anything else happens, to disable any lingering stream objects
  bool ok = stream.cleanup_magic_on_exit(frames_array);

  // Throw pending exception if we must
  (void) (CHECK_NULL);

  if (!ok) {
    THROW_MSG_(vmSymbols::java_lang_InternalError(), "doStackWalk: corrupted buffers on exit", NULL);
  }

  // Return normally
  return (oop)result.get_jobject();
}
示例#16
0
bool BaseFrameStream::check_magic(objArrayHandle frames_array) {
    oop   m1 = frames_array->obj_at(magic_pos);
    jlong m2 = _anchor;
    if (m1 == _thread->threadObj() && m2 == address_value())  return true;
    return false;
}
示例#17
0
bool BaseFrameStream::cleanup_magic_on_exit(objArrayHandle frames_array) {
    bool ok = check_magic(frames_array);
    frames_array->obj_at_put(magic_pos, NULL);
    _anchor = 0L;
    return ok;
}
示例#18
0
bool StackWalkAnchor::check_magic(objArrayHandle classes_array) {
  oop   m1 = classes_array->obj_at(magic_pos);
  jlong m2 = _anchor;
  if (m1 == _thread->threadObj() && m2 == address_value())  return true;
  return false;
}