Revision: 14298
Author:   [email protected]
Date:     Wed Apr 17 00:53:12 2013
Log:      Move StackTracer to sampler.h

Apart from tests Sampler is the only client of StackTracer so it is logical to move it into sampler.h

BUG=None

Review URL: https://codereview.chromium.org/14208012
http://code.google.com/p/v8/source/detail?r=14298

Modified:
 /branches/bleeding_edge/src/frames.h
 /branches/bleeding_edge/src/isolate.h
 /branches/bleeding_edge/src/log.cc
 /branches/bleeding_edge/src/log.h
 /branches/bleeding_edge/src/sampler.cc
 /branches/bleeding_edge/src/sampler.h
 /branches/bleeding_edge/test/cctest/test-log-stack-tracer.cc

=======================================
--- /branches/bleeding_edge/src/frames.h        Mon Apr  8 04:17:32 2013
+++ /branches/bleeding_edge/src/frames.h        Wed Apr 17 00:53:12 2013
@@ -593,7 +593,6 @@
   inline Object* function_slot_object() const;

   friend class StackFrameIterator;
-  friend class StackTracer;
 };


=======================================
--- /branches/bleeding_edge/src/isolate.h       Thu Apr 11 07:22:04 2013
+++ /branches/bleeding_edge/src/isolate.h       Wed Apr 17 00:53:12 2013
@@ -649,7 +649,7 @@
   }
   inline Address* handler_address() { return &thread_local_top_.handler_; }

-  // Bottom JS entry (see StackTracer::Trace in log.cc).
+  // Bottom JS entry (see StackTracer::Trace in sampler.cc).
   static Address js_entry_sp(ThreadLocalTop* thread) {
     return thread->js_entry_sp_;
   }
=======================================
--- /branches/bleeding_edge/src/log.cc  Wed Apr 17 00:20:24 2013
+++ /branches/bleeding_edge/src/log.cc  Wed Apr 17 00:53:12 2013
@@ -109,36 +109,6 @@
   // Tells whether we are currently recording tick samples.
   bool paused_;
 };
-
-
-//
-// StackTracer implementation
-//
-DISABLE_ASAN void StackTracer::Trace(Isolate* isolate, TickSample* sample) {
-  ASSERT(isolate->IsInitialized());
-
-  // Avoid collecting traces while doing GC.
-  if (sample->state == GC) return;
-
-  const Address js_entry_sp =
-      Isolate::js_entry_sp(isolate->thread_local_top());
-  if (js_entry_sp == 0) {
-    // Not executing JS now.
-    return;
-  }
-
-  sample->external_callback = isolate->external_callback();
-
-  SafeStackTraceFrameIterator it(isolate,
-                                 sample->fp, sample->sp,
-                                 sample->sp, js_entry_sp);
-  int i = 0;
-  while (!it.done() && i < TickSample::kMaxFramesCount) {
-    sample->stack[i++] = it.frame()->pc();
-    it.Advance();
-  }
-  sample->frames_count = i;
-}


 //
=======================================
--- /branches/bleeding_edge/src/log.h   Wed Apr 17 00:20:24 2013
+++ /branches/bleeding_edge/src/log.h   Wed Apr 17 00:53:12 2013
@@ -466,7 +466,6 @@
   friend class LogMessageBuilder;
   friend class TimeLog;
   friend class Profiler;
-  friend class StackTracer;
   friend class VMState;

   friend class LoggerTestHelper;
@@ -505,12 +504,6 @@
 };


-// Class that extracts stack trace, used for profiling.
-class StackTracer : public AllStatic {
- public:
-  static void Trace(Isolate* isolate, TickSample* sample);
-};
-
 } }  // namespace v8::internal


=======================================
--- /branches/bleeding_edge/src/sampler.cc      Wed Apr 17 00:20:24 2013
+++ /branches/bleeding_edge/src/sampler.cc      Wed Apr 17 00:53:12 2013
@@ -59,6 +59,7 @@

 #include "v8.h"

+#include "frames-inl.h"
 #include "log.h"
 #include "platform.h"
 #include "simulator.h"
@@ -617,6 +618,34 @@

 Mutex* SamplerThread::mutex_ = NULL;
 SamplerThread* SamplerThread::instance_ = NULL;
+
+
+//
+// StackTracer implementation
+//
+DISABLE_ASAN void TickSample::Trace(Isolate* isolate) {
+  ASSERT(isolate->IsInitialized());
+
+  // Avoid collecting traces while doing GC.
+  if (state == GC) return;
+
+  const Address js_entry_sp =
+      Isolate::js_entry_sp(isolate->thread_local_top());
+  if (js_entry_sp == 0) {
+    // Not executing JS now.
+    return;
+  }
+
+  external_callback = isolate->external_callback();
+
+  SafeStackTraceFrameIterator it(isolate, fp, sp, sp, js_entry_sp);
+  int i = 0;
+  while (!it.done() && i < TickSample::kMaxFramesCount) {
+    stack[i++] = it.frame()->pc();
+    it.Advance();
+  }
+  frames_count = i;
+}


 void Sampler::SetUp() {
@@ -658,7 +687,7 @@
 }

 void Sampler::SampleStack(TickSample* sample) {
-  StackTracer::Trace(isolate_, sample);
+  sample->Trace(isolate_);
   if (++samples_taken_ < 0) samples_taken_ = 0;
 }

=======================================
--- /branches/bleeding_edge/src/sampler.h       Mon Apr 15 06:57:41 2013
+++ /branches/bleeding_edge/src/sampler.h       Wed Apr 17 00:53:12 2013
@@ -52,6 +52,7 @@
         fp(NULL),
         external_callback(NULL),
         frames_count(0) {}
+  void Trace(Isolate* isolate);
   StateTag state;  // The state of the VM.
   Address pc;      // Instruction pointer.
   Address sp;      // Stack pointer.
=======================================
--- /branches/bleeding_edge/test/cctest/test-log-stack-tracer.cc Fri Apr 12 04:20:22 2013 +++ /branches/bleeding_edge/test/cctest/test-log-stack-tracer.cc Wed Apr 17 00:53:12 2013
@@ -51,7 +51,6 @@
 using v8::internal::Handle;
 using v8::internal::Isolate;
 using v8::internal::JSFunction;
-using v8::internal::StackTracer;
 using v8::internal::TickSample;


@@ -70,7 +69,7 @@
   // sp is only used to define stack high bound
   trace_env.sample->sp =
       reinterpret_cast<Address>(trace_env.sample) - 10240;
-  StackTracer::Trace(Isolate::Current(), trace_env.sample);
+  trace_env.sample->Trace(Isolate::Current());
 }


@@ -258,7 +257,7 @@

 // This test verifies that stack tracing works when called during
 // execution of a native function called from JS code. In this case,
-// StackTracer uses Isolate::c_entry_fp as a starting point for stack
+// TickSample::Trace uses Isolate::c_entry_fp as a starting point for stack
 // walking.
 TEST(CFromJSStackTrace) {
// BUG(1303) Inlining of JSFuncDoTrace() in JSTrace below breaks this test.
@@ -285,7 +284,7 @@
   //     JSFuncDoTrace() [JS] [captures EBP value and encodes it as Smi]
   //       trace(EBP) [native (extension)]
   //         DoTrace(EBP) [native]
-  //           StackTracer::Trace
+  //           TickSample::Trace

   CHECK(sample.external_callback);
   CHECK_EQ(FUNCTION_ADDR(TraceExtension::Trace), sample.external_callback);
@@ -300,9 +299,9 @@


 // This test verifies that stack tracing works when called during
-// execution of JS code. However, as calling StackTracer requires
+// execution of JS code. However, as calling TickSample::Trace requires
 // entering native code, we can only emulate pure JS by erasing
-// Isolate::c_entry_fp value. In this case, StackTracer uses passed frame
+// Isolate::c_entry_fp value. In this case, TickSample::Trace uses passed frame
 // pointer value as a starting point for stack walking.
 TEST(PureJSStackTrace) {
   // This test does not pass with inlining enabled since inlined functions
@@ -334,7 +333,7 @@
   //       JSFuncDoTrace() [JS]
   //         js_trace(EBP) [native (extension)]
   //           DoTraceHideCEntryFPAddress(EBP) [native]
-  //             StackTracer::Trace
+  //             TickSample::Trace
   //

   CHECK(sample.external_callback);
@@ -374,7 +373,7 @@


 // This test verifies that stack tracing doesn't crash when called on
-// pure native code. StackTracer only unrolls JS code, so we can't
+// pure native code. TickSample::Trace only unrolls JS code, so we can't
 // get any meaningful info here.
 TEST(PureCStackTrace) {
   TickSample sample;

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to