Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Revert "[XDK] Add in-depth allocation tracker"
Browse files Browse the repository at this point in the history
This reverts commit 283ac1d.

The v8-crosswalk side of this patch was reverted in
crosswalk-project/v8-crosswalk#157, so the chromium-crosswalk side needs
to be reverted accordingly.
  • Loading branch information
Raphael Kubo da Costa authored and Maksim Sisov committed Jun 27, 2016
1 parent 7241dea commit d3001c4
Show file tree
Hide file tree
Showing 8 changed files with 1 addition and 258 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,6 @@ class InspectorHeapProfilerAgent::HeapStatsUpdateTask final {
Timer<HeapStatsUpdateTask> m_timer;
};

class InspectorHeapProfilerAgent::HeapXDKUpdateTask final {
public:
explicit HeapXDKUpdateTask(V8HeapProfilerAgent*);
void startTimer(float sav);
void resetTimer() { m_timer.stop(); }
void onTimer(Timer<HeapXDKUpdateTask>*);

private:
V8HeapProfilerAgent* m_heapProfilerAgent;
Timer<HeapXDKUpdateTask> m_timer;
};

InspectorHeapProfilerAgent::HeapStatsUpdateTask::HeapStatsUpdateTask(V8HeapProfilerAgent* heapProfilerAgent)
: m_heapProfilerAgent(heapProfilerAgent)
, m_timer(this, &HeapStatsUpdateTask::onTimer)
Expand Down Expand Up @@ -243,46 +231,4 @@ void InspectorHeapProfilerAgent::stopSampling(ErrorString* errorString, OwnPtr<p
m_v8HeapProfilerAgent->stopSampling(errorString, profile);
}

InspectorHeapProfilerAgent::HeapXDKUpdateTask::HeapXDKUpdateTask(V8HeapProfilerAgent* heapProfilerAgent)
: m_heapProfilerAgent(heapProfilerAgent)
, m_timer(this, &HeapXDKUpdateTask::onTimer)
{
}

void InspectorHeapProfilerAgent::HeapXDKUpdateTask::onTimer(Timer<HeapXDKUpdateTask>*)
{
// The timer is stopped on m_heapProfilerAgent destruction,
// so this method will never be called after m_heapProfilerAgent has been destroyed.
m_heapProfilerAgent->requestHeapXDKUpdate();
}

void InspectorHeapProfilerAgent::HeapXDKUpdateTask::startTimer(float sav)
{
ASSERT(!m_timer.isActive());
m_timer.startRepeating(sav, BLINK_FROM_HERE);
}

void InspectorHeapProfilerAgent::startTrackingHeapXDK(ErrorString* error, const protocol::Maybe<int>& depth, const protocol::Maybe<int>& sav, const protocol::Maybe<bool>& retentions)
{
if (m_heapXDKUpdateTask)
return;

m_v8HeapProfilerAgent->startTrackingHeapXDK(error, depth, sav, retentions);
float savTimer = (float) sav.fromMaybe(1000) / 1000.;
m_heapXDKUpdateTask = adoptPtr(new HeapXDKUpdateTask(m_v8HeapProfilerAgent));
m_heapXDKUpdateTask->startTimer(savTimer);
}

void InspectorHeapProfilerAgent::stopTrackingHeapXDK(ErrorString* error, OwnPtr<protocol::HeapProfiler::HeapEventXDK>* profile)
{
if (!m_heapXDKUpdateTask) {
*error = "Heap object tracking is not started.";
return;
}

m_v8HeapProfilerAgent->stopTrackingHeapXDK(error, profile);
m_heapXDKUpdateTask->resetTimer();
m_heapXDKUpdateTask.clear();
}

} // namespace blink
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#include "wtf/Noncopyable.h"
#include "wtf/OwnPtr.h"
#include "wtf/PassOwnPtr.h"
#include <v8-profiler.h>

namespace v8 {
class Isolate;
Expand Down Expand Up @@ -70,13 +69,9 @@ class CORE_EXPORT InspectorHeapProfilerAgent final : public InspectorBaseAgent<I
void getHeapObjectId(ErrorString*, const String16& objectId, String16* heapSnapshotObjectId) override;
void startSampling(ErrorString*) override;
void stopSampling(ErrorString*, OwnPtr<protocol::HeapProfiler::SamplingHeapProfile>*) override;
void startTrackingHeapXDK(ErrorString*, const Maybe<int>& stack_depth, const Maybe<int>& sav, const Maybe<bool>& retentions) override;
void stopTrackingHeapXDK(ErrorString*, OwnPtr<protocol::HeapProfiler::HeapEventXDK>*) override;

private:
class HeapStatsUpdateTask;
class HeapXDKStream;
class HeapXDKUpdateTask;

InspectorHeapProfilerAgent(v8::Isolate*, V8HeapProfilerAgent*);

Expand All @@ -86,7 +81,6 @@ class CORE_EXPORT InspectorHeapProfilerAgent final : public InspectorBaseAgent<I

V8HeapProfilerAgent* m_v8HeapProfilerAgent;
OwnPtr<HeapStatsUpdateTask> m_heapStatsUpdateTask;
OwnPtr<HeapXDKUpdateTask> m_heapXDKUpdateTask;
v8::Isolate* m_isolate;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ WebInspector.HeapProfilerModel.Events = {
LastSeenObjectId: "LastSeenObjectId",
AddHeapSnapshotChunk: "AddHeapSnapshotChunk",
ReportHeapSnapshotProgress: "ReportHeapSnapshotProgress",
ResetProfiles: "ResetProfiles",
HeapXDKUpdate: "HeapXDKUpdate"
ResetProfiles: "ResetProfiles"
}

WebInspector.HeapProfilerModel.prototype = {
Expand Down Expand Up @@ -71,14 +70,6 @@ WebInspector.HeapProfilerModel.prototype = {
this.dispatchEventToListeners(WebInspector.HeapProfilerModel.Events.ResetProfiles);
},

/**
* @param {string} message
*/
heapXDKUpdate: function (message)
{
this.dispatchEventToListeners(WebInspector.HeapProfilerModel.Events.HeapXDKUpdate, message);
},

__proto__: WebInspector.SDKModel.prototype
}

Expand Down Expand Up @@ -138,14 +129,5 @@ WebInspector.HeapProfilerDispatcher.prototype = {
resetProfiles: function()
{
this._heapProfilerModel.resetProfiles();
},

/**
* @override
* @param {string} message
*/
heapXDKUpdate: function(message)
{
this._heapProfilerModel.heapXDKUpdate(message);
}
}
38 changes: 0 additions & 38 deletions third_party/WebKit/Source/devtools/protocol.json
Original file line number Diff line number Diff line change
Expand Up @@ -3886,7 +3886,6 @@
{ "name": "columnNumber", "type": "integer", "description": "1-based column number of the function start position." },
{ "name": "hitCount", "type": "integer", "description": "Number of samples where this node was on top of the call stack." },
{ "name": "callUID", "type": "number", "description": "Call UID." },
{ "name": "stackEntryLine", "type": "integer", "description": "Hit line for entry in stack." },
{ "name": "children", "type": "array", "items": { "$ref": "CPUProfileNode" }, "description": "Child nodes." },
{ "name": "deoptReason", "type": "string", "description": "The reason of being not optimized. The function may be deoptimized or marked as don't optimize."},
{ "name": "id", "type": "integer", "description": "Unique id of the node." },
Expand Down Expand Up @@ -3991,19 +3990,6 @@
"properties": [
{ "name": "head", "$ref": "SamplingHeapProfileNode" }
]
},
{
"id": "HeapEventXDK",
"type": "object",
"description": "",
"properties": [
{ "name": "duration", "type": "integer" },
{ "name": "symbols", "type": "string" },
{ "name": "frames", "type": "string" },
{ "name": "types", "type": "string" },
{ "name": "chunks", "type": "string" },
{ "name": "retentions", "type": "string" }
]
}
],
"commands": [
Expand All @@ -4026,20 +4012,6 @@
]

},
{
"name": "startTrackingHeapXDK",
"parameters": [
{ "name": "stack_depth", "type": "integer", "optional": true },
{ "name": "sav", "type": "integer", "optional": true },
{ "name": "retentions", "type": "boolean", "optional": true }
]
},
{
"name": "stopTrackingHeapXDK",
"returns": [
{ "name": "profileXDK", "$ref": "HeapEventXDK", "description": "Recorded profile." }
]
},
{
"name": "takeHeapSnapshot",
"parameters": [
Expand Down Expand Up @@ -4117,16 +4089,6 @@
"parameters": [
{ "name": "statsUpdate", "type": "array", "items": { "type": "integer" }, "description": "An array of triplets. Each triplet describes a fragment. The first integer is the fragment index, the second integer is a total count of objects for the fragment, the third integer is a total size of the objects for the fragment."}
]
},
{
"name": "heapXDKUpdate",
"parameters": [
{ "name": "symbols", "type": "string" },
{ "name": "frames", "type": "string" },
{ "name": "types", "type": "string" },
{ "name": "chunks", "type": "string" },
{ "name": "retentions", "type": "string" }
]
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,113 +362,4 @@ void V8HeapProfilerAgentImpl::stopSampling(ErrorString* errorString, OwnPtr<prot
#endif
}

class HeapXDKStream : public v8::OutputStream {
public:
HeapXDKStream(protocol::Frontend::HeapProfiler* frontend)
: m_frontend(frontend)
{
}
void EndOfStream() override { }

WriteResult WriteAsciiChunk(char* data, int size) override
{
ASSERT(false);
return kAbort;
}

WriteResult WriteHeapXDKChunk(const char* symbols, size_t symbolsSize, const char* frames, size_t framesSize, const char* types, size_t typesSize,
const char* chunks, size_t chunksSize, const char* retentions, size_t retentionSize) override
{
m_frontend->heapXDKUpdate(String(symbols, symbolsSize), String(frames, framesSize), String(types, typesSize), String(chunks, chunksSize), String(retentions, retentionSize));
return kContinue;
}

private:
protocol::Frontend::HeapProfiler* m_frontend;
};

static PassOwnPtr<protocol::HeapProfiler::HeapEventXDK> createHeapProfileXDK(const HeapProfileXDK& heapProfileXDK)
{
OwnPtr<protocol::HeapProfiler::HeapEventXDK> profile = protocol::HeapProfiler::HeapEventXDK::create()
.setDuration(heapProfileXDK.getDuration())
.setSymbols(heapProfileXDK.getSymbols())
.setFrames(heapProfileXDK.getFrames())
.setTypes(heapProfileXDK.getTypes())
.setChunks(heapProfileXDK.getChunks())
.setRetentions(heapProfileXDK.getRetentions()).build();
return profile.release();
}

void V8HeapProfilerAgentImpl::startTrackingHeapXDK(ErrorString* error, const protocol::Maybe<int>& depth, const protocol::Maybe<int>& sav, const protocol::Maybe<bool>& retentions)
{
v8::HeapProfiler* profiler = m_isolate->GetHeapProfiler();
if (!profiler) {
*error = "Cannot access v8 heap profiler";
return;
}

m_state->setBoolean(HeapProfilerAgentState::heapObjectsTrackingEnabled, true);
int stackDepth = depth.fromMaybe(8);
bool needRetentions = retentions.fromMaybe(false);
profiler->StartTrackingHeapObjectsXDK(stackDepth, needRetentions);
}

void V8HeapProfilerAgentImpl::stopTrackingHeapXDK(ErrorString* error, OwnPtr<protocol::HeapProfiler::HeapEventXDK>* profile)
{
v8::HeapProfiler* profiler = m_isolate->GetHeapProfiler();
if (!profiler) {
*error = "Cannot access v8 heap profiler";
return;
}

OwnPtr<HeapProfileXDK> heapProfileXDK = HeapProfileXDK::create(
profiler->StopTrackingHeapObjectsXDK(), m_isolate);
*profile = createHeapProfileXDK(*heapProfileXDK);
m_state->setBoolean(HeapProfilerAgentState::heapObjectsTrackingEnabled, false);
}

void V8HeapProfilerAgentImpl::requestHeapXDKUpdate()
{
if (!m_frontend)
return;
HeapXDKStream heapXDKStream(m_frontend);
m_isolate->GetHeapProfiler()->GetHeapXDKStats(
&heapXDKStream);
}

String HeapProfileXDK::getSymbols() const
{
v8::HandleScope handleScope(m_isolate);
return String(m_event->getSymbols());
}

String HeapProfileXDK::getFrames() const
{
v8::HandleScope handleScope(m_isolate);
return String(m_event->getFrames());
}

String HeapProfileXDK::getTypes() const
{
v8::HandleScope handleScope(m_isolate);
return String(m_event->getTypes());
}

String HeapProfileXDK::getChunks() const
{
v8::HandleScope handleScope(m_isolate);
return String(m_event->getChunks());
}

int HeapProfileXDK::getDuration() const
{
return (int)m_event->getDuration();
}

String HeapProfileXDK::getRetentions() const
{
v8::HandleScope handleScope(m_isolate);
return String(m_event->getRetentions());
}

} // namespace blink
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,13 @@

#include "platform/inspector_protocol/Allocator.h"
#include "platform/v8_inspector/public/V8HeapProfilerAgent.h"
#include <v8-profiler.h>

namespace blink {

class V8InspectorSessionImpl;

using protocol::Maybe;

class HeapProfileXDK final {
public:
static PassOwnPtr<HeapProfileXDK> create(v8::HeapEventXDK* event, v8::Isolate* isolate)
{
return adoptPtr(new HeapProfileXDK(event, isolate));
}

String getSymbols() const;
String getFrames() const;
String getTypes() const;
String getChunks() const;
String getRetentions() const;
int getDuration() const;

private:
HeapProfileXDK(v8::HeapEventXDK* event, v8::Isolate* isolate)
: m_event(event),
m_isolate(isolate)
{
}

v8::HeapEventXDK* m_event;
v8::Isolate* m_isolate;
};

class V8HeapProfilerAgentImpl : public V8HeapProfilerAgent {
PROTOCOL_DISALLOW_COPY(V8HeapProfilerAgentImpl);
public:
Expand All @@ -65,14 +39,10 @@ class V8HeapProfilerAgentImpl : public V8HeapProfilerAgent {
void addInspectedHeapObject(ErrorString*, const String16& inspectedHeapObjectId) override;
void getHeapObjectId(ErrorString*, const String16& objectId, String16* heapSnapshotObjectId) override;

void startTrackingHeapXDK(ErrorString*, const Maybe<int>& depth, const Maybe<int>& sav, const Maybe<bool>& retentions) override;
void stopTrackingHeapXDK(ErrorString*, OwnPtr<protocol::HeapProfiler::HeapEventXDK>*) override;

void startSampling(ErrorString*) override;
void stopSampling(ErrorString*, OwnPtr<protocol::HeapProfiler::SamplingHeapProfile>*) override;

void requestHeapStatsUpdate() override;
void requestHeapXDKUpdate() override;

private:
void startTrackingHeapObjectsInternal(bool trackAllocations);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ PassOwnPtr<protocol::Profiler::CPUProfileNode> buildInspectorObjectFor(v8::Isola
.setColumnNumber(node->GetColumnNumber())
.setHitCount(node->GetHitCount())
.setCallUID(node->GetCallUid())
.setStackEntryLine(node->GetSrcLine())
.setChildren(children.release())
.setPositionTicks(positionTicks.release())
.setDeoptReason(node->GetBailoutReason())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class PLATFORM_EXPORT V8HeapProfilerAgent : public protocol::Backend::HeapProfil
virtual ~V8HeapProfilerAgent() { }

virtual void requestHeapStatsUpdate() = 0;
virtual void requestHeapXDKUpdate() = 0;
};

} // namespace blink
Expand Down

0 comments on commit d3001c4

Please sign in to comment.