| Index: tools/tickprocessor.js
|
| ===================================================================
|
| --- tools/tickprocessor.js (revision 7006)
|
| +++ tools/tickprocessor.js (working copy)
|
| @@ -26,16 +26,21 @@
|
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
| -function Profile(separateIc) {
|
| - devtools.profiler.Profile.call(this);
|
| +function inherits(childCtor, parentCtor) {
|
| + childCtor.prototype.__proto__ = parentCtor.prototype;
|
| +};
|
| +
|
| +
|
| +function V8Profile(separateIc) {
|
| + Profile.call(this);
|
| if (!separateIc) {
|
| - this.skipThisFunction = function(name) { return Profile.IC_RE.test(name); };
|
| + this.skipThisFunction = function(name) { return V8Profile.IC_RE.test(name); };
|
| }
|
| };
|
| -Profile.prototype = devtools.profiler.Profile.prototype;
|
| +inherits(V8Profile, Profile);
|
|
|
|
|
| -Profile.IC_RE =
|
| +V8Profile.IC_RE =
|
| /^(?:CallIC|LoadIC|StoreIC)|(?:Builtin: (?:Keyed)?(?:Call|Load|Store)IC_)/;
|
|
|
|
|
| @@ -52,15 +57,23 @@
|
| }
|
|
|
|
|
| -function inherits(childCtor, parentCtor) {
|
| - childCtor.prototype.__proto__ = parentCtor.prototype;
|
| -};
|
| +/**
|
| + * Parser for dynamic code optimization state.
|
| + */
|
| +function parseState(s) {
|
| + switch (s) {
|
| + case "": return Profile.CodeState.COMPILED;
|
| + case "~": return Profile.CodeState.OPTIMIZABLE;
|
| + case "*": return Profile.CodeState.OPTIMIZED;
|
| + }
|
| + throw new Error("unknown code state: " + s);
|
| +}
|
|
|
|
|
| function SnapshotLogProcessor() {
|
| - devtools.profiler.LogReader.call(this, {
|
| + LogReader.call(this, {
|
| 'code-creation': {
|
| - parsers: [null, parseInt, parseInt, null],
|
| + parsers: [null, parseInt, parseInt, null, 'var-args'],
|
| processor: this.processCodeCreation },
|
| 'code-move': { parsers: [parseInt, parseInt],
|
| processor: this.processCodeMove },
|
| @@ -69,11 +82,12 @@
|
| 'function-creation': null,
|
| 'function-move': null,
|
| 'function-delete': null,
|
| + 'sfi-move': null,
|
| 'snapshot-pos': { parsers: [parseInt, parseInt],
|
| processor: this.processSnapshotPosition }});
|
|
|
| - Profile.prototype.handleUnknownCode = function(operation, addr) {
|
| - var op = devtools.profiler.Profile.Operation;
|
| + V8Profile.prototype.handleUnknownCode = function(operation, addr) {
|
| + var op = Profile.Operation;
|
| switch (operation) {
|
| case op.MOVE:
|
| print('Snapshot: Code move event for unknown code: 0x' +
|
| @@ -86,15 +100,21 @@
|
| }
|
| };
|
|
|
| - this.profile_ = new Profile();
|
| + this.profile_ = new V8Profile();
|
| this.serializedEntries_ = [];
|
| }
|
| -inherits(SnapshotLogProcessor, devtools.profiler.LogReader);
|
| +inherits(SnapshotLogProcessor, LogReader);
|
|
|
|
|
| SnapshotLogProcessor.prototype.processCodeCreation = function(
|
| - type, start, size, name) {
|
| - var entry = this.profile_.addCode(type, name, start, size);
|
| + type, start, size, name, maybe_func) {
|
| + if (maybe_func.length) {
|
| + var funcAddr = parseInt(maybe_func[0]);
|
| + var state = parseState(maybe_func[1]);
|
| + this.profile_.addFuncCode(type, name, start, size, funcAddr, state);
|
| + } else {
|
| + this.profile_.addCode(type, name, start, size);
|
| + }
|
| };
|
|
|
|
|
| @@ -127,22 +147,18 @@
|
|
|
| function TickProcessor(
|
| cppEntriesProvider, separateIc, ignoreUnknown, stateFilter, snapshotLogProcessor) {
|
| - devtools.profiler.LogReader.call(this, {
|
| + LogReader.call(this, {
|
| 'shared-library': { parsers: [null, parseInt, parseInt],
|
| processor: this.processSharedLibrary },
|
| 'code-creation': {
|
| - parsers: [null, parseInt, parseInt, null],
|
| + parsers: [null, parseInt, parseInt, null, 'var-args'],
|
| processor: this.processCodeCreation },
|
| 'code-move': { parsers: [parseInt, parseInt],
|
| processor: this.processCodeMove },
|
| 'code-delete': { parsers: [parseInt],
|
| processor: this.processCodeDelete },
|
| - 'function-creation': { parsers: [parseInt, parseInt],
|
| - processor: this.processFunctionCreation },
|
| - 'function-move': { parsers: [parseInt, parseInt],
|
| + 'sfi-move': { parsers: [parseInt, parseInt],
|
| processor: this.processFunctionMove },
|
| - 'function-delete': { parsers: [parseInt],
|
| - processor: this.processFunctionDelete },
|
| 'snapshot-pos': { parsers: [parseInt, parseInt],
|
| processor: this.processSnapshotPosition },
|
| 'tick': { parsers: [parseInt, parseInt, parseInt, parseInt, 'var-args'],
|
| @@ -155,6 +171,9 @@
|
| processor: this.processJSProducer },
|
| // Ignored events.
|
| 'profiler': null,
|
| + 'function-creation': null,
|
| + 'function-move': null,
|
| + 'function-delete': null,
|
| 'heap-sample-stats': null,
|
| 'heap-sample-item': null,
|
| 'heap-js-cons-item': null,
|
| @@ -172,9 +191,9 @@
|
| var ticks = this.ticks_ =
|
| { total: 0, unaccounted: 0, excluded: 0, gc: 0 };
|
|
|
| - Profile.prototype.handleUnknownCode = function(
|
| + V8Profile.prototype.handleUnknownCode = function(
|
| operation, addr, opt_stackPos) {
|
| - var op = devtools.profiler.Profile.Operation;
|
| + var op = Profile.Operation;
|
| switch (operation) {
|
| case op.MOVE:
|
| print('Code move event for unknown code: 0x' + addr.toString(16));
|
| @@ -193,16 +212,16 @@
|
| }
|
| };
|
|
|
| - this.profile_ = new Profile(separateIc);
|
| + this.profile_ = new V8Profile(separateIc);
|
| this.codeTypes_ = {};
|
| // Count each tick as a time unit.
|
| - this.viewBuilder_ = new devtools.profiler.ViewBuilder(1);
|
| + this.viewBuilder_ = new ViewBuilder(1);
|
| this.lastLogFileName_ = null;
|
|
|
| this.generation_ = 1;
|
| this.currentProducerProfile_ = null;
|
| };
|
| -inherits(TickProcessor, devtools.profiler.LogReader);
|
| +inherits(TickProcessor, LogReader);
|
|
|
|
|
| TickProcessor.VmStates = {
|
| @@ -285,9 +304,15 @@
|
|
|
|
|
| TickProcessor.prototype.processCodeCreation = function(
|
| - type, start, size, name) {
|
| + type, start, size, name, maybe_func) {
|
| name = this.deserializedEntriesNames_[start] || name;
|
| - var entry = this.profile_.addCode(type, name, start, size);
|
| + if (maybe_func.length) {
|
| + var funcAddr = parseInt(maybe_func[0]);
|
| + var state = parseState(maybe_func[1]);
|
| + this.profile_.addFuncCode(type, name, start, size, funcAddr, state);
|
| + } else {
|
| + this.profile_.addCode(type, name, start, size);
|
| + }
|
| };
|
|
|
|
|
| @@ -301,22 +326,11 @@
|
| };
|
|
|
|
|
| -TickProcessor.prototype.processFunctionCreation = function(
|
| - functionAddr, codeAddr) {
|
| - this.profile_.addCodeAlias(functionAddr, codeAddr);
|
| -};
|
| -
|
| -
|
| TickProcessor.prototype.processFunctionMove = function(from, to) {
|
| - this.profile_.safeMoveDynamicCode(from, to);
|
| + this.profile_.moveFunc(from, to);
|
| };
|
|
|
|
|
| -TickProcessor.prototype.processFunctionDelete = function(start) {
|
| - this.profile_.safeDeleteDynamicCode(start);
|
| -};
|
| -
|
| -
|
| TickProcessor.prototype.processSnapshotPosition = function(addr, pos) {
|
| if (this.snapshotLogProcessor_) {
|
| this.deserializedEntriesNames_[addr] =
|
| @@ -330,7 +344,7 @@
|
| };
|
|
|
|
|
| -TickProcessor.prototype.processTick = function(pc, sp, func, vmState, stack) {
|
| +TickProcessor.prototype.processTick = function(pc, sp, tos, vmState, stack) {
|
| this.ticks_.total++;
|
| if (vmState == TickProcessor.VmStates.GC) this.ticks_.gc++;
|
| if (!this.includeTick(vmState)) {
|
| @@ -338,25 +352,20 @@
|
| return;
|
| }
|
|
|
| - if (func) {
|
| - var funcEntry = this.profile_.findEntry(func);
|
| + if (tos) {
|
| + var funcEntry = this.profile_.findEntry(tos);
|
| if (!funcEntry || !funcEntry.isJSFunction || !funcEntry.isJSFunction()) {
|
| - func = 0;
|
| - } else {
|
| - var currEntry = this.profile_.findEntry(pc);
|
| - if (!currEntry || !currEntry.isJSFunction || currEntry.isJSFunction()) {
|
| - func = 0;
|
| - }
|
| + tos = 0;
|
| }
|
| }
|
|
|
| - this.profile_.recordTick(this.processStack(pc, func, stack));
|
| + this.profile_.recordTick(this.processStack(pc, tos, stack));
|
| };
|
|
|
|
|
| TickProcessor.prototype.processHeapSampleBegin = function(space, state, ticks) {
|
| if (space != 'Heap') return;
|
| - this.currentProducerProfile_ = new devtools.profiler.CallTree();
|
| + this.currentProducerProfile_ = new CallTree();
|
| };
|
|
|
|
|
|
|