< prev index next >

src/hotspot/share/jfr/recorder/stacktrace/jfrStackTraceRepository.cpp

Print this page
*** 144,33 ***
    repo._entries = 0;
    repo._last_entries = 0;
    return processed;
  }
  
! traceid JfrStackTraceRepository::record(Thread* thread, int skip /* 0 */) {
!   assert(thread == Thread::current(), "invariant");
!   JfrThreadLocal* const tl = thread->jfr_thread_local();
    assert(tl != NULL, "invariant");
    if (tl->has_cached_stack_trace()) {
      return tl->cached_stack_trace_id();
    }
!   if (!thread->is_Java_thread() || thread->is_hidden_from_external_view() || tl->is_excluded()) {
      return 0;
    }
    JfrStackFrame* frames = tl->stackframes();
    if (frames == NULL) {
      // pending oom
      return 0;
    }
    assert(frames != NULL, "invariant");
    assert(tl->stackframes() == frames, "invariant");
!   return instance().record_for(JavaThread::cast(thread), skip, frames, tl->stackdepth());
  }
  
! traceid JfrStackTraceRepository::record_for(JavaThread* thread, int skip, JfrStackFrame *frames, u4 max_frames) {
    JfrStackTrace stacktrace(frames, max_frames);
!   return stacktrace.record_safe(thread, skip) ? add(instance(), stacktrace) : 0;
  }
  traceid JfrStackTraceRepository::add(JfrStackTraceRepository& repo, const JfrStackTrace& stacktrace) {
    traceid tid = repo.add_trace(stacktrace);
    if (tid == 0) {
      stacktrace.resolve_linenos();
--- 144,33 ---
    repo._entries = 0;
    repo._last_entries = 0;
    return processed;
  }
  
! traceid JfrStackTraceRepository::record(Thread* current_thread, int skip /* 0 */) {
!   assert(current_thread == Thread::current(), "invariant");
!   JfrThreadLocal* const tl = current_thread->jfr_thread_local();
    assert(tl != NULL, "invariant");
    if (tl->has_cached_stack_trace()) {
      return tl->cached_stack_trace_id();
    }
!   if (!current_thread->is_Java_thread() || current_thread->is_hidden_from_external_view() || tl->is_excluded()) {
      return 0;
    }
    JfrStackFrame* frames = tl->stackframes();
    if (frames == NULL) {
      // pending oom
      return 0;
    }
    assert(frames != NULL, "invariant");
    assert(tl->stackframes() == frames, "invariant");
!   return instance().record(JavaThread::cast(current_thread), skip, frames, tl->stackdepth());
  }
  
! traceid JfrStackTraceRepository::record(JavaThread* current_thread, int skip, JfrStackFrame *frames, u4 max_frames) {
    JfrStackTrace stacktrace(frames, max_frames);
!   return stacktrace.record(current_thread, skip) ? add(instance(), stacktrace) : 0;
  }
  traceid JfrStackTraceRepository::add(JfrStackTraceRepository& repo, const JfrStackTrace& stacktrace) {
    traceid tid = repo.add_trace(stacktrace);
    if (tid == 0) {
      stacktrace.resolve_linenos();

*** 182,25 ***
  
  traceid JfrStackTraceRepository::add(const JfrStackTrace& stacktrace) {
    return add(instance(), stacktrace);
  }
  
! void JfrStackTraceRepository::record_for_leak_profiler(JavaThread* thread, int skip /* 0 */) {
!   assert(thread != NULL, "invariant");
!   JfrThreadLocal* const tl = thread->jfr_thread_local();
    assert(tl != NULL, "invariant");
    assert(!tl->has_cached_stack_trace(), "invariant");
    JfrStackTrace stacktrace(tl->stackframes(), tl->stackdepth());
!   stacktrace.record_safe(thread, skip);
    const unsigned int hash = stacktrace.hash();
    if (hash != 0) {
      tl->set_cached_stack_trace_id(add(leak_profiler_instance(), stacktrace), hash);
    }
  }
  
  traceid JfrStackTraceRepository::add_trace(const JfrStackTrace& stacktrace) {
    MutexLocker lock(JfrStacktrace_lock, Mutex::_no_safepoint_check_flag);
    const size_t index = stacktrace._hash % TABLE_SIZE;
    const JfrStackTrace* table_entry = _table[index];
  
    while (table_entry != NULL) {
      if (table_entry->equals(stacktrace)) {
--- 182,27 ---
  
  traceid JfrStackTraceRepository::add(const JfrStackTrace& stacktrace) {
    return add(instance(), stacktrace);
  }
  
! void JfrStackTraceRepository::record_for_leak_profiler(JavaThread* current_thread, int skip /* 0 */) {
!   assert(current_thread != NULL, "invariant");
!   assert(current_thread == Thread::current(), "invariant");
+   JfrThreadLocal* const tl = current_thread->jfr_thread_local();
    assert(tl != NULL, "invariant");
    assert(!tl->has_cached_stack_trace(), "invariant");
    JfrStackTrace stacktrace(tl->stackframes(), tl->stackdepth());
!   stacktrace.record(current_thread, skip);
    const unsigned int hash = stacktrace.hash();
    if (hash != 0) {
      tl->set_cached_stack_trace_id(add(leak_profiler_instance(), stacktrace), hash);
    }
  }
  
  traceid JfrStackTraceRepository::add_trace(const JfrStackTrace& stacktrace) {
    MutexLocker lock(JfrStacktrace_lock, Mutex::_no_safepoint_check_flag);
+   assert(stacktrace._nr_of_frames > 0, "invariant");
    const size_t index = stacktrace._hash % TABLE_SIZE;
    const JfrStackTrace* table_entry = _table[index];
  
    while (table_entry != NULL) {
      if (table_entry->equals(stacktrace)) {
< prev index next >