< prev index next >

src/hotspot/share/jfr/leakprofiler/checkpoint/eventEmitter.cpp

Print this page
@@ -42,17 +42,16 @@
  
  EventEmitter::EventEmitter(const JfrTicks& start_time, const JfrTicks& end_time) :
    _start_time(start_time),
    _end_time(end_time),
    _thread(Thread::current()),
-   _jfr_thread_local(_thread->jfr_thread_local()),
-   _thread_id(_thread->jfr_thread_local()->thread_id()) {}
+   _jfr_thread_local(_thread->jfr_thread_local()) {}
  
  EventEmitter::~EventEmitter() {
    // restore / reset thread local stack trace and thread id
-   _jfr_thread_local->set_thread_id(_thread_id);
    _jfr_thread_local->clear_cached_stack_trace();
+   JfrThreadLocal::stop_impersonating(_thread);
  }
  
  void EventEmitter::emit(ObjectSampler* sampler, int64_t cutoff_ticks, bool emit_all, bool skip_bfs) {
    assert(sampler != NULL, "invariant");
    ResourceMark rm;

@@ -173,8 +172,8 @@
    // the event generation mechanism by injecting externally provided id's.
    // At this particular location, it allows us to emit an old object event
    // supplying information from where the actual sampling occurred.
    _jfr_thread_local->set_cached_stack_trace_id(sample->stack_trace_id());
    assert(sample->has_thread(), "invariant");
-   _jfr_thread_local->set_thread_id(sample->thread_id());
+   JfrThreadLocal::impersonate(_thread, sample->thread_id());
    e.commit();
  }
< prev index next >