#include "src/profiler/cpu-profiler.h"
#include <unordered_map>
#include <utility>
#include "include/v8-locker.h"
#include "src/base/lazy-instance.h"
#include "src/base/template-utils.h"
#include "src/debug/debug.h"
#include "src/execution/frames-inl.h"
#include "src/execution/v8threads.h"
#include "src/execution/vm-state-inl.h"
#include "src/libsampler/sampler.h"
#include "src/logging/counters.h"
#include "src/logging/log.h"
#include "src/profiler/cpu-profiler-inl.h"
#include "src/profiler/profiler-stats.h"
#include "src/profiler/symbolizer.h"
#include "src/utils/locked-queue-inl.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/wasm-engine.h"
#endif
namespace v8 {
namespace internal {
static const int kProfilerStackSize = …;
class CpuSampler : public sampler::Sampler { … };
ProfilingScope::ProfilingScope(Isolate* isolate, ProfilerListener* listener)
: … { … }
ProfilingScope::~ProfilingScope() { … }
ProfilerEventsProcessor::ProfilerEventsProcessor(
Isolate* isolate, Symbolizer* symbolizer,
ProfilerCodeObserver* code_observer, CpuProfilesCollection* profiles)
: … { … }
SamplingEventsProcessor::SamplingEventsProcessor(
Isolate* isolate, Symbolizer* symbolizer,
ProfilerCodeObserver* code_observer, CpuProfilesCollection* profiles,
base::TimeDelta period, bool use_precise_sampling)
: … { … }
SamplingEventsProcessor::~SamplingEventsProcessor() { … }
ProfilerEventsProcessor::~ProfilerEventsProcessor() { … }
void ProfilerEventsProcessor::Enqueue(const CodeEventsContainer& event) { … }
void ProfilerEventsProcessor::AddDeoptStack(Address from, int fp_to_sp_delta) { … }
void ProfilerEventsProcessor::AddCurrentStack(bool update_stats) { … }
void ProfilerEventsProcessor::AddSample(TickSample sample) { … }
void ProfilerEventsProcessor::StopSynchronously() { … }
bool ProfilerEventsProcessor::ProcessCodeEvent() { … }
void ProfilerEventsProcessor::CodeEventHandler(
const CodeEventsContainer& evt_rec) { … }
void SamplingEventsProcessor::SymbolizeAndAddToProfiles(
const TickSampleEventRecord* record) { … }
ProfilerEventsProcessor::SampleProcessingResult
SamplingEventsProcessor::ProcessOneSample() { … }
void SamplingEventsProcessor::Run() { … }
void SamplingEventsProcessor::SetSamplingInterval(base::TimeDelta period) { … }
void* SamplingEventsProcessor::operator new(size_t size) { … }
void SamplingEventsProcessor::operator delete(void* ptr) { … }
ProfilerCodeObserver::ProfilerCodeObserver(Isolate* isolate,
CodeEntryStorage& storage)
: … { … }
void ProfilerCodeObserver::ClearCodeMap() { … }
void ProfilerCodeObserver::CodeEventHandler(
const CodeEventsContainer& evt_rec) { … }
size_t ProfilerCodeObserver::GetEstimatedMemoryUsage() const { … }
void ProfilerCodeObserver::CodeEventHandlerInternal(
const CodeEventsContainer& evt_rec) { … }
void ProfilerCodeObserver::CreateEntriesForRuntimeCallStats() { … }
void ProfilerCodeObserver::LogBuiltins() { … }
int CpuProfiler::GetProfilesCount() { … }
CpuProfile* CpuProfiler::GetProfile(int index) { … }
void CpuProfiler::DeleteAllProfiles() { … }
void CpuProfiler::DeleteProfile(CpuProfile* profile) { … }
namespace {
class CpuProfilersManager { … };
DEFINE_LAZY_LEAKY_OBJECT_GETTER(…)
}
CpuProfiler::CpuProfiler(Isolate* isolate, CpuProfilingNamingMode naming_mode,
CpuProfilingLoggingMode logging_mode)
: … { … }
CpuProfiler::CpuProfiler(Isolate* isolate, CpuProfilingNamingMode naming_mode,
CpuProfilingLoggingMode logging_mode,
CpuProfilesCollection* test_profiles,
Symbolizer* test_symbolizer,
ProfilerEventsProcessor* test_processor,
ProfilerCodeObserver* test_code_observer)
: … { … }
CpuProfiler::~CpuProfiler() { … }
void CpuProfiler::set_sampling_interval(base::TimeDelta value) { … }
void CpuProfiler::set_use_precise_sampling(bool value) { … }
void CpuProfiler::ResetProfiles() { … }
void CpuProfiler::EnableLogging() { … }
void CpuProfiler::DisableLogging() { … }
base::TimeDelta CpuProfiler::ComputeSamplingInterval() { … }
void CpuProfiler::AdjustSamplingInterval() { … }
void CpuProfiler::CollectSample(Isolate* isolate) { … }
void CpuProfiler::CollectSample() { … }
size_t CpuProfiler::GetAllProfilersMemorySize(Isolate* isolate) { … }
size_t CpuProfiler::GetEstimatedMemoryUsage() const { … }
CpuProfilingResult CpuProfiler::StartProfiling(
CpuProfilingOptions options,
std::unique_ptr<DiscardedSamplesDelegate> delegate) { … }
CpuProfilingResult CpuProfiler::StartProfiling(
const char* title, CpuProfilingOptions options,
std::unique_ptr<DiscardedSamplesDelegate> delegate) { … }
CpuProfilingResult CpuProfiler::StartProfiling(
Tagged<String> title, CpuProfilingOptions options,
std::unique_ptr<DiscardedSamplesDelegate> delegate) { … }
void CpuProfiler::StartProcessorIfNotStarted() { … }
CpuProfile* CpuProfiler::StopProfiling(const char* title) { … }
CpuProfile* CpuProfiler::StopProfiling(ProfilerId id) { … }
CpuProfile* CpuProfiler::StopProfiling(Tagged<String> title) { … }
void CpuProfiler::StopProcessor() { … }
}
}