Commit 4a2e91b8 authored by Peter Marshall's avatar Peter Marshall Committed by Commit Bot

[cleanup] Remove unused TickSample class from the public API

We have internal::TickSample which inherits from this, but we never
use the public version in the API despite defining it there.

Change-Id: I6f0ce7ee663ef821be57cfbad540c1660484a525
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1745472
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Reviewed-by: 's avatarAlexei Filippov <alph@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63329}
parent d0e718a7
......@@ -52,82 +52,6 @@ template class V8_EXPORT std::vector<v8::CpuProfileDeoptInfo>;
namespace v8 {
// TickSample captures the information collected for each sample.
struct V8_EXPORT TickSample {
// Internal profiling (with --prof + tools/$OS-tick-processor) wants to
// include the runtime function we're calling. Externally exposed tick
// samples don't care.
enum RecordCEntryFrame { kIncludeCEntryFrame, kSkipCEntryFrame };
TickSample()
: state(OTHER),
pc(nullptr),
external_callback_entry(nullptr),
frames_count(0),
has_external_callback(false),
update_stats(true) {}
/**
* Initialize a tick sample from the isolate.
* \param isolate The isolate.
* \param state Execution state.
* \param record_c_entry_frame Include or skip the runtime function.
* \param update_stats Whether update the sample to the aggregated stats.
* \param use_simulator_reg_state When set to true and V8 is running under a
* simulator, the method will use the simulator
* register state rather than the one provided
* with |state| argument. Otherwise the method
* will use provided register |state| as is.
*/
void Init(Isolate* isolate, const v8::RegisterState& state,
RecordCEntryFrame record_c_entry_frame, bool update_stats,
bool use_simulator_reg_state = true);
/**
* Get a call stack sample from the isolate.
* \param isolate The isolate.
* \param state Register state.
* \param record_c_entry_frame Include or skip the runtime function.
* \param frames Caller allocated buffer to store stack frames.
* \param frames_limit Maximum number of frames to capture. The buffer must
* be large enough to hold the number of frames.
* \param sample_info The sample info is filled up by the function
* provides number of actual captured stack frames and
* the current VM state.
* \param use_simulator_reg_state When set to true and V8 is running under a
* simulator, the method will use the simulator
* register state rather than the one provided
* with |state| argument. Otherwise the method
* will use provided register |state| as is.
* \param contexts If set, contexts[i] will be set to the address of the
* incumbent native context associated with frames[i]. It
* should be large enough to hold |frames_limit| frame
* contexts.
* \note GetStackSample is thread and signal safe and should only be called
* when the JS thread is paused or interrupted.
* Otherwise the behavior is undefined.
*/
static bool GetStackSample(Isolate* isolate, v8::RegisterState* state,
RecordCEntryFrame record_c_entry_frame,
void** frames, size_t frames_limit,
v8::SampleInfo* sample_info,
bool use_simulator_reg_state = true,
void** contexts = nullptr);
StateTag state; // The state of the VM.
void* pc; // Instruction pointer.
union {
void* tos; // Top stack value (*sp).
void* external_callback_entry;
};
static const unsigned kMaxFramesCountLog2 = 8;
static const unsigned kMaxFramesCount = (1 << kMaxFramesCountLog2) - 1;
void* stack[kMaxFramesCount]; // Call stack.
void* contexts[kMaxFramesCount]; // Stack of associated native contexts.
void* top_context = nullptr; // Address of the incumbent native context.
unsigned frames_count : kMaxFramesCountLog2; // Number of captured frames.
bool has_external_callback : 1;
bool update_stats : 1; // Whether the sample should update aggregated stats.
};
/**
* CpuProfileNode represents a node in a call graph.
*/
......
......@@ -8199,8 +8199,10 @@ bool Isolate::GetHeapCodeAndMetadataStatistics(
void Isolate::GetStackSample(const RegisterState& state, void** frames,
size_t frames_limit, SampleInfo* sample_info) {
RegisterState regs = state;
if (TickSample::GetStackSample(this, &regs, TickSample::kSkipCEntryFrame,
frames, frames_limit, sample_info)) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
if (i::TickSample::GetStackSample(isolate, &regs,
i::TickSample::kSkipCEntryFrame, frames,
frames_limit, sample_info)) {
return;
}
sample_info->frames_count = 0;
......
......@@ -765,7 +765,7 @@ class Profiler : public base::Thread {
void Disengage();
// Inserts collected profiling data into buffer.
void Insert(v8::TickSample* sample) {
void Insert(TickSample* sample) {
if (Succ(head_) == static_cast<int>(base::Relaxed_Load(&tail_))) {
overflow_ = true;
} else {
......@@ -779,7 +779,7 @@ class Profiler : public base::Thread {
private:
// Waits for a signal and removes profiling data.
bool Remove(v8::TickSample* sample) {
bool Remove(TickSample* sample) {
buffer_semaphore_.Wait(); // Wait for an element.
*sample = buffer_[base::Relaxed_Load(&tail_)];
bool result = overflow_;
......@@ -796,7 +796,7 @@ class Profiler : public base::Thread {
// Cyclic buffer for communicating profiling samples
// between the signal handler and the worker thread.
static const int kBufferSize = 128;
v8::TickSample buffer_[kBufferSize]; // Buffer storage.
TickSample buffer_[kBufferSize]; // Buffer storage.
int head_; // Index to the buffer head.
base::Atomic32 tail_; // Index to the buffer tail.
bool overflow_; // Tell whether a buffer overflow has occurred.
......@@ -888,7 +888,7 @@ void Profiler::Disengage() {
// inserting a fake element in the queue and then wait for
// the thread to terminate.
base::Relaxed_Store(&running_, 0);
v8::TickSample sample;
TickSample sample;
Insert(&sample);
Join();
......@@ -896,7 +896,7 @@ void Profiler::Disengage() {
}
void Profiler::Run() {
v8::TickSample sample;
TickSample sample;
bool overflow = Remove(&sample);
while (base::Relaxed_Load(&running_)) {
LOG(isolate_, TickEvent(&sample, overflow));
......@@ -1549,7 +1549,7 @@ void Logger::RuntimeCallTimerEvent() {
msg.WriteToLogFile();
}
void Logger::TickEvent(v8::TickSample* sample, bool overflow) {
void Logger::TickEvent(TickSample* sample, bool overflow) {
if (!log_->IsEnabled() || !FLAG_prof_cpp) return;
if (V8_UNLIKELY(TracingFlags::runtime_stats.load(std::memory_order_relaxed) ==
v8::tracing::TracingCategoryObserver::ENABLED_BY_NATIVE)) {
......
......@@ -15,14 +15,14 @@
namespace v8 {
struct TickSample;
namespace sampler {
class Sampler;
}
namespace internal {
struct TickSample;
// Logger is used for collecting logging information from V8 during
// execution. The result is dumped to a file.
//
......
......@@ -16,6 +16,7 @@
#include "src/sanitizer/msan.h"
namespace v8 {
namespace internal {
namespace {
bool IsSamePage(i::Address ptr1, i::Address ptr2) {
......@@ -78,11 +79,6 @@ bool IsNoFrameRegion(i::Address address) {
return false;
}
} // namespace
namespace internal {
namespace {
#if defined(USE_SIMULATOR)
class SimulatorHelper {
public:
......@@ -184,16 +180,13 @@ Address ScrapeNativeContextAddress(Heap* heap, Address context_address) {
}
} // namespace
} // namespace internal
//
// StackTracer implementation
//
DISABLE_ASAN void TickSample::Init(Isolate* v8_isolate,
const RegisterState& reg_state,
RecordCEntryFrame record_c_entry_frame,
bool update_stats,
bool use_simulator_reg_state) {
bool use_simulator_reg_state,
base::TimeDelta sampling_interval) {
this->update_stats = update_stats;
SampleInfo info;
RegisterState regs = reg_state;
......@@ -229,6 +222,8 @@ DISABLE_ASAN void TickSample::Init(Isolate* v8_isolate,
} else {
tos = nullptr;
}
this->sampling_interval = sampling_interval;
timestamp = base::TimeTicks::HighResolutionNow();
}
bool TickSample::GetStackSample(Isolate* v8_isolate, RegisterState* regs,
......@@ -368,20 +363,6 @@ bool TickSample::GetStackSample(Isolate* v8_isolate, RegisterState* regs,
return true;
}
namespace internal {
void TickSample::Init(Isolate* isolate, const v8::RegisterState& state,
RecordCEntryFrame record_c_entry_frame, bool update_stats,
bool use_simulator_reg_state,
base::TimeDelta sampling_interval) {
v8::TickSample::Init(reinterpret_cast<v8::Isolate*>(isolate), state,
record_c_entry_frame, update_stats,
use_simulator_reg_state);
this->sampling_interval = sampling_interval;
if (pc == nullptr) return;
timestamp = base::TimeTicks::HighResolutionNow();
}
void TickSample::print() const {
PrintF("TickSample: at %p\n", this);
PrintF(" - state: %s\n", StateToString(state));
......
......@@ -5,7 +5,7 @@
#ifndef V8_PROFILER_TICK_SAMPLE_H_
#define V8_PROFILER_TICK_SAMPLE_H_
#include "include/v8-profiler.h"
#include "include/v8.h"
#include "src/base/platform/time.h"
#include "src/common/globals.h"
......@@ -14,15 +14,83 @@ namespace internal {
class Isolate;
struct TickSample : public v8::TickSample {
// TickSample captures the information collected for each sample.
struct V8_EXPORT TickSample {
// Internal profiling (with --prof + tools/$OS-tick-processor) wants to
// include the runtime function we're calling. Externally exposed tick
// samples don't care.
enum RecordCEntryFrame { kIncludeCEntryFrame, kSkipCEntryFrame };
TickSample()
: state(OTHER),
pc(nullptr),
external_callback_entry(nullptr),
frames_count(0),
has_external_callback(false),
update_stats(true) {}
/**
* Initialize a tick sample from the isolate.
* \param isolate The isolate.
* \param state Execution state.
* \param record_c_entry_frame Include or skip the runtime function.
* \param update_stats Whether update the sample to the aggregated stats.
* \param use_simulator_reg_state When set to true and V8 is running under a
* simulator, the method will use the simulator
* register state rather than the one provided
* with |state| argument. Otherwise the method
* will use provided register |state| as is.
*/
void Init(Isolate* isolate, const v8::RegisterState& state,
RecordCEntryFrame record_c_entry_frame, bool update_stats,
bool use_simulator_reg_state = true,
base::TimeDelta sampling_interval = base::TimeDelta());
base::TimeTicks timestamp;
base::TimeDelta sampling_interval; // Sampling interval used to capture.
/**
* Get a call stack sample from the isolate.
* \param isolate The isolate.
* \param state Register state.
* \param record_c_entry_frame Include or skip the runtime function.
* \param frames Caller allocated buffer to store stack frames.
* \param frames_limit Maximum number of frames to capture. The buffer must
* be large enough to hold the number of frames.
* \param sample_info The sample info is filled up by the function
* provides number of actual captured stack frames and
* the current VM state.
* \param use_simulator_reg_state When set to true and V8 is running under a
* simulator, the method will use the simulator
* register state rather than the one provided
* with |state| argument. Otherwise the method
* will use provided register |state| as is.
* \note GetStackSample is thread and signal safe and should only be called
* when the JS thread is paused or interrupted.
* Otherwise the behavior is undefined.
*/
static bool GetStackSample(Isolate* isolate, v8::RegisterState* state,
RecordCEntryFrame record_c_entry_frame,
void** frames, size_t frames_limit,
v8::SampleInfo* sample_info,
bool use_simulator_reg_state = true,
void** contexts = nullptr);
void print() const;
StateTag state; // The state of the VM.
void* pc; // Instruction pointer.
union {
void* tos; // Top stack value (*sp).
void* external_callback_entry;
};
static const unsigned kMaxFramesCountLog2 = 8;
static const unsigned kMaxFramesCount = (1 << kMaxFramesCountLog2) - 1;
void* stack[kMaxFramesCount]; // Call stack.
void* contexts[kMaxFramesCount]; // Stack of associated native contexts.
void* top_context = nullptr; // Address of the incumbent native context.
unsigned frames_count : kMaxFramesCountLog2; // Number of captured frames.
bool has_external_callback : 1;
bool update_stats : 1; // Whether the sample should update aggregated stats.
base::TimeTicks timestamp;
base::TimeDelta sampling_interval; // Sampling interval used to capture.
};
} // namespace internal
......
......@@ -323,7 +323,7 @@ TEST(Issue1398) {
v8::internal::TickSample sample;
sample.pc = reinterpret_cast<void*>(code.InstructionStart());
sample.tos = nullptr;
sample.frames_count = v8::TickSample::kMaxFramesCount;
sample.frames_count = TickSample::kMaxFramesCount;
for (unsigned i = 0; i < sample.frames_count; ++i) {
sample.stack[i] = reinterpret_cast<void*>(code.InstructionStart());
}
......@@ -341,7 +341,7 @@ TEST(Issue1398) {
++actual_depth;
}
CHECK_EQ(1 + v8::TickSample::kMaxFramesCount, actual_depth); // +1 for PC.
CHECK_EQ(1 + TickSample::kMaxFramesCount, actual_depth); // +1 for PC.
}
TEST(DeleteAllCpuProfiles) {
......
......@@ -37,6 +37,7 @@
#include "src/execution/vm-state-inl.h"
#include "src/init/v8.h"
#include "src/objects/objects-inl.h"
#include "src/profiler/tick-sample.h"
#include "test/cctest/cctest.h"
#include "test/cctest/trace-extension.h"
......
......@@ -30,6 +30,7 @@
#include "include/v8-profiler.h"
#include "src/execution/vm-state-inl.h"
#include "src/objects/smi.h"
#include "src/profiler/tick-sample.h"
#include "test/cctest/cctest.h"
namespace v8 {
......@@ -89,21 +90,20 @@ Address TraceExtension::GetFP(const v8::FunctionCallbackInfo<v8::Value>& args) {
return fp;
}
static struct { v8::TickSample* sample; } trace_env = {nullptr};
static struct { TickSample* sample; } trace_env = {nullptr};
void TraceExtension::InitTraceEnv(v8::TickSample* sample) {
void TraceExtension::InitTraceEnv(TickSample* sample) {
trace_env.sample = sample;
}
void TraceExtension::DoTrace(Address fp) {
RegisterState regs;
regs.fp = reinterpret_cast<void*>(fp);
// sp is only used to define stack high bound
regs.sp = reinterpret_cast<void*>(
reinterpret_cast<Address>(trace_env.sample) - 10240);
trace_env.sample->Init(CcTest::isolate(), regs,
v8::TickSample::kSkipCEntryFrame, true);
trace_env.sample->Init(CcTest::i_isolate(), regs,
TickSample::kSkipCEntryFrame, true);
}
......
......@@ -32,9 +32,10 @@
#include "src/common/globals.h"
namespace v8 {
struct TickSample;
namespace internal {
struct TickSample;
class TraceExtension : public v8::Extension {
public:
TraceExtension() : v8::Extension("v8/trace", kSource) { }
......@@ -45,7 +46,7 @@ class TraceExtension : public v8::Extension {
static void JSEntrySP(const v8::FunctionCallbackInfo<v8::Value>& args);
static void JSEntrySPLevel2(const v8::FunctionCallbackInfo<v8::Value>& args);
static Address GetJsEntrySp();
static void InitTraceEnv(v8::TickSample* sample);
static void InitTraceEnv(TickSample* sample);
static void DoTrace(Address fp);
private:
static Address GetFP(const v8::FunctionCallbackInfo<v8::Value>& args);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment