Commit bb0b8b2d authored by alph's avatar alph Committed by Commit bot

[inspector] Drop V8_VERSION checks.

BUG=chromium:635948

Review-Url: https://codereview.chromium.org/2323273002
Cr-Commit-Position: refs/heads/master@{#39314}
parent 5465c25c
......@@ -23,11 +23,9 @@ namespace HeapProfilerAgentState {
static const char heapProfilerEnabled[] = "heapProfilerEnabled";
static const char heapObjectsTrackingEnabled[] = "heapObjectsTrackingEnabled";
static const char allocationTrackingEnabled[] = "allocationTrackingEnabled";
#if V8_MAJOR_VERSION >= 5
static const char samplingHeapProfilerEnabled[] = "samplingHeapProfilerEnabled";
static const char samplingHeapProfilerInterval[] =
"samplingHeapProfilerInterval";
#endif
}
class HeapSnapshotProgress final : public v8::ActivityControl {
......@@ -164,7 +162,6 @@ void V8HeapProfilerAgentImpl::restore() {
HeapProfilerAgentState::heapObjectsTrackingEnabled, false))
startTrackingHeapObjectsInternal(m_state->booleanProperty(
HeapProfilerAgentState::allocationTrackingEnabled, false));
#if V8_MAJOR_VERSION >= 5
if (m_state->booleanProperty(
HeapProfilerAgentState::samplingHeapProfilerEnabled, false)) {
ErrorString error;
......@@ -173,7 +170,6 @@ void V8HeapProfilerAgentImpl::restore() {
DCHECK_GE(samplingInterval, 0);
startSampling(&error, Maybe<double>(samplingInterval));
}
#endif
}
void V8HeapProfilerAgentImpl::collectGarbage(ErrorString*) {
......@@ -202,13 +198,11 @@ void V8HeapProfilerAgentImpl::enable(ErrorString*) {
void V8HeapProfilerAgentImpl::disable(ErrorString* error) {
stopTrackingHeapObjectsInternal();
#if V8_MAJOR_VERSION >= 5
if (m_state->booleanProperty(
HeapProfilerAgentState::samplingHeapProfilerEnabled, false)) {
v8::HeapProfiler* profiler = m_isolate->GetHeapProfiler();
if (profiler) profiler->StopSamplingHeapProfiler();
}
#endif
m_isolate->GetHeapProfiler()->ClearObjectIds();
m_state->setBoolean(HeapProfilerAgentState::heapProfilerEnabled, false);
}
......@@ -340,7 +334,6 @@ void V8HeapProfilerAgentImpl::stopTrackingHeapObjectsInternal() {
void V8HeapProfilerAgentImpl::startSampling(
ErrorString* errorString, const Maybe<double>& samplingInterval) {
#if V8_MAJOR_VERSION >= 5
v8::HeapProfiler* profiler = m_isolate->GetHeapProfiler();
if (!profiler) {
*errorString = "Cannot access v8 heap profiler";
......@@ -353,18 +346,11 @@ void V8HeapProfilerAgentImpl::startSampling(
samplingIntervalValue);
m_state->setBoolean(HeapProfilerAgentState::samplingHeapProfilerEnabled,
true);
#if V8_MAJOR_VERSION * 1000 + V8_MINOR_VERSION >= 5002
profiler->StartSamplingHeapProfiler(
static_cast<uint64_t>(samplingIntervalValue), 128,
v8::HeapProfiler::kSamplingForceGC);
#else
profiler->StartSamplingHeapProfiler(
static_cast<uint64_t>(samplingIntervalValue), 128);
#endif
#endif
}
#if V8_MAJOR_VERSION >= 5
namespace {
std::unique_ptr<protocol::HeapProfiler::SamplingHeapProfileNode>
buildSampingHeapProfileNode(const v8::AllocationProfile::Node* node) {
......@@ -392,12 +378,10 @@ buildSampingHeapProfileNode(const v8::AllocationProfile::Node* node) {
return result;
}
} // namespace
#endif
void V8HeapProfilerAgentImpl::stopSampling(
ErrorString* errorString,
std::unique_ptr<protocol::HeapProfiler::SamplingHeapProfile>* profile) {
#if V8_MAJOR_VERSION >= 5
v8::HeapProfiler* profiler = m_isolate->GetHeapProfiler();
if (!profiler) {
*errorString = "Cannot access v8 heap profiler";
......@@ -418,7 +402,6 @@ void V8HeapProfilerAgentImpl::stopSampling(
*profile = protocol::HeapProfiler::SamplingHeapProfile::create()
.setHead(buildSampingHeapProfileNode(root))
.build();
#endif
}
} // namespace v8_inspector
......@@ -16,9 +16,6 @@
#include <vector>
#define ENSURE_V8_VERSION(major, minor) \
(V8_MAJOR_VERSION * 1000 + V8_MINOR_VERSION >= (major)*1000 + (minor))
namespace v8_inspector {
namespace ProfilerAgentState {
......@@ -162,9 +159,7 @@ V8ProfilerAgentImpl::V8ProfilerAgentImpl(
m_recordingCPUProfile(false) {}
V8ProfilerAgentImpl::~V8ProfilerAgentImpl() {
#if ENSURE_V8_VERSION(5, 4)
if (m_profiler) m_profiler->Dispose();
#endif
}
void V8ProfilerAgentImpl::consoleProfile(const String16& title) {
......@@ -209,10 +204,8 @@ void V8ProfilerAgentImpl::consoleProfileEnd(const String16& title) {
void V8ProfilerAgentImpl::enable(ErrorString*) {
if (m_enabled) return;
m_enabled = true;
#if ENSURE_V8_VERSION(5, 4)
DCHECK(!m_profiler);
m_profiler = v8::CpuProfiler::New(m_isolate);
#endif
m_state->setBoolean(ProfilerAgentState::profilerEnabled, true);
}
......@@ -222,10 +215,8 @@ void V8ProfilerAgentImpl::disable(ErrorString* errorString) {
stopProfiling(m_startedProfiles[i - 1].m_id, false);
m_startedProfiles.clear();
stop(nullptr, nullptr);
#if ENSURE_V8_VERSION(5, 4)
m_profiler->Dispose();
m_profiler = nullptr;
#endif
m_enabled = false;
m_state->setBoolean(ProfilerAgentState::profilerEnabled, false);
}
......@@ -237,7 +228,7 @@ void V8ProfilerAgentImpl::setSamplingInterval(ErrorString* error,
return;
}
m_state->setInteger(ProfilerAgentState::samplingInterval, interval);
profiler()->SetSamplingInterval(interval);
m_profiler->SetSamplingInterval(interval);
}
void V8ProfilerAgentImpl::restore() {
......@@ -245,13 +236,11 @@ void V8ProfilerAgentImpl::restore() {
if (!m_state->booleanProperty(ProfilerAgentState::profilerEnabled, false))
return;
m_enabled = true;
#if ENSURE_V8_VERSION(5, 4)
DCHECK(!m_profiler);
m_profiler = v8::CpuProfiler::New(m_isolate);
#endif
int interval = 0;
m_state->getInteger(ProfilerAgentState::samplingInterval, &interval);
if (interval) profiler()->SetSamplingInterval(interval);
if (interval) m_profiler->SetSamplingInterval(interval);
if (m_state->booleanProperty(ProfilerAgentState::userInitiatedProfiling,
false)) {
ErrorString error;
......@@ -295,14 +284,14 @@ String16 V8ProfilerAgentImpl::nextProfileId() {
void V8ProfilerAgentImpl::startProfiling(const String16& title) {
v8::HandleScope handleScope(m_isolate);
profiler()->StartProfiling(toV8String(m_isolate, title), true);
m_profiler->StartProfiling(toV8String(m_isolate, title), true);
}
std::unique_ptr<protocol::Profiler::Profile> V8ProfilerAgentImpl::stopProfiling(
const String16& title, bool serialize) {
v8::HandleScope handleScope(m_isolate);
v8::CpuProfile* profile =
profiler()->StopProfiling(toV8String(m_isolate, title));
m_profiler->StopProfiling(toV8String(m_isolate, title));
if (!profile) return nullptr;
std::unique_ptr<protocol::Profiler::Profile> result;
if (serialize) result = createCPUProfile(m_isolate, profile);
......@@ -314,12 +303,4 @@ bool V8ProfilerAgentImpl::isRecording() const {
return m_recordingCPUProfile || !m_startedProfiles.empty();
}
v8::CpuProfiler* V8ProfilerAgentImpl::profiler() {
#if ENSURE_V8_VERSION(5, 4)
return m_profiler;
#else
return m_isolate->GetCpuProfiler();
#endif
}
} // namespace v8_inspector
......@@ -45,7 +45,6 @@ class V8ProfilerAgentImpl : public protocol::Profiler::Backend {
private:
String16 nextProfileId();
v8::CpuProfiler* profiler();
void startProfiling(const String16& title);
std::unique_ptr<protocol::Profiler::Profile> stopProfiling(
......
......@@ -158,9 +158,7 @@ std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::capture(
v8::HandleScope handleScope(isolate);
v8::Local<v8::StackTrace> stackTrace;
if (isolate->InContext()) {
#if V8_MAJOR_VERSION >= 5
isolate->GetCpuProfiler()->CollectSample();
#endif
stackTrace = v8::StackTrace::CurrentStackTrace(isolate, maxStackSize,
stackTraceOptions);
}
......
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