inline Object* function_slot_object() const;
friend class StackFrameIterator;
- friend class StackTracer;
};
}
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_;
}
//
-// 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;
-}
-
-
-//
// Ticker used to provide ticks to the profiler and the sliding state
// window.
//
friend class LogMessageBuilder;
friend class TimeLog;
friend class Profiler;
- friend class StackTracer;
friend class VMState;
friend class LoggerTestHelper;
};
-// Class that extracts stack trace, used for profiling.
-class StackTracer : public AllStatic {
- public:
- static void Trace(Isolate* isolate, TickSample* sample);
-};
-
} } // namespace v8::internal
#include "v8.h"
+#include "frames-inl.h"
#include "log.h"
#include "platform.h"
#include "simulator.h"
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() {
SamplerThread::SetUp();
}
}
void Sampler::SampleStack(TickSample* sample) {
- StackTracer::Trace(isolate_, sample);
+ sample->Trace(isolate_);
if (++samples_taken_ < 0) samples_taken_ = 0;
}
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.
using v8::internal::Handle;
using v8::internal::Isolate;
using v8::internal::JSFunction;
-using v8::internal::StackTracer;
using v8::internal::TickSample;
// 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());
}
// 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.
// 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);
// 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
// JSFuncDoTrace() [JS]
// js_trace(EBP) [native (extension)]
// DoTraceHideCEntryFPAddress(EBP) [native]
- // StackTracer::Trace
+ // TickSample::Trace
//
CHECK(sample.external_callback);
// 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;