Clean up sampling tracing.
- Moved maps to fields within thread.
- Created temp trace field to lessen amount of traces allocated and freed.
Change-Id: I23fe25a85ad2894cc6917f87d4046cdececf0739
diff --git a/runtime/trace.h b/runtime/trace.h
index 5733929..9fe2cc6 100644
--- a/runtime/trace.h
+++ b/runtime/trace.h
@@ -83,6 +83,11 @@
mirror::Throwable* exception_object)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
+ // Reuse an old stack trace if it exists, otherwise allocate a new one.
+ static std::vector<mirror::ArtMethod*>* AllocStackTrace();
+ // Clear and store an old stack trace for later use.
+ static void FreeStackTrace(std::vector<mirror::ArtMethod*>* stack_trace);
+
~Trace();
private:
@@ -116,11 +121,8 @@
// Sampling thread, non-zero when sampling.
static pthread_t sampling_pthread_;
- // Maps a thread to its most recent stack trace sample.
- SafeMap<Thread*, std::vector<mirror::ArtMethod*>*> thread_stack_trace_map_;
-
- // Maps a thread to its clock base.
- SafeMap<Thread*, uint64_t> thread_clock_base_map_;
+ // Used to remember an unused stack trace to avoid re-allocation during sampling.
+ static UniquePtr<std::vector<mirror::ArtMethod*> > temp_stack_trace_;
// File to write trace data out to, NULL if direct to ddms.
UniquePtr<File> trace_file_;