2009-04-17 17:40:52 +00:00
|
|
|
// Copyright 2009 the V8 project authors. All rights reserved.
|
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are
|
|
|
|
// met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright
|
|
|
|
// notice, this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above
|
|
|
|
// copyright notice, this list of conditions and the following
|
|
|
|
// disclaimer in the documentation and/or other materials provided
|
|
|
|
// with the distribution.
|
|
|
|
// * Neither the name of Google Inc. nor the names of its
|
|
|
|
// contributors may be used to endorse or promote products derived
|
|
|
|
// from this software without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
2020-09-23 10:30:17 +00:00
|
|
|
// TODO: move to separate modules
|
|
|
|
class SourcePosition {
|
|
|
|
constructor(script, line, column) {
|
|
|
|
this.script = script;
|
|
|
|
this.line = line;
|
|
|
|
this.column = column;
|
|
|
|
this.entries = [];
|
|
|
|
}
|
|
|
|
addEntry(entry) {
|
|
|
|
this.entries.push(entry);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Script {
|
|
|
|
|
|
|
|
constructor(id, name, source) {
|
|
|
|
this.id = id;
|
|
|
|
this.name = name;
|
|
|
|
this.source = source;
|
|
|
|
this.sourcePositions = [];
|
|
|
|
// Map<line, Map<column, SourcePosition>>
|
|
|
|
this.lineToColumn = new Map();
|
|
|
|
}
|
|
|
|
|
|
|
|
addSourcePosition(line, column, entry) {
|
|
|
|
let sourcePosition = this.lineToColumn.get(line)?.get(column);
|
|
|
|
if (sourcePosition === undefined) {
|
|
|
|
sourcePosition = new SourcePosition(this, line, column, )
|
|
|
|
this.#addSourcePosition(line, column, sourcePosition);
|
|
|
|
}
|
|
|
|
sourcePosition.addEntry(entry);
|
|
|
|
return sourcePosition;
|
|
|
|
}
|
|
|
|
|
|
|
|
#addSourcePosition(line, column, sourcePosition) {
|
|
|
|
let columnToSourcePosition;
|
|
|
|
if (this.lineToColumn.has(line)) {
|
|
|
|
columnToSourcePosition = this.lineToColumn.get(line);
|
|
|
|
} else {
|
|
|
|
columnToSourcePosition = new Map();
|
|
|
|
this.lineToColumn.set(line, columnToSourcePosition);
|
|
|
|
}
|
|
|
|
this.sourcePositions.push(sourcePosition);
|
|
|
|
columnToSourcePosition.set(column, sourcePosition);
|
|
|
|
}
|
|
|
|
}
|
2009-04-17 17:40:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a profile object for processing profiling-related events
|
|
|
|
* and calculating function execution times.
|
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
*/
|
2011-02-10 07:47:28 +00:00
|
|
|
function Profile() {
|
|
|
|
this.codeMap_ = new CodeMap();
|
|
|
|
this.topDownTree_ = new CallTree();
|
|
|
|
this.bottomUpTree_ = new CallTree();
|
2014-10-17 15:44:02 +00:00
|
|
|
this.c_entries_ = {};
|
2017-03-04 13:04:58 +00:00
|
|
|
this.ticks_ = [];
|
2020-08-28 14:41:56 +00:00
|
|
|
this.scripts_ = [];
|
|
|
|
this.urlToScript_ = new Map();
|
2009-04-17 17:40:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether a function with the specified name must be skipped.
|
|
|
|
* Should be overriden by subclasses.
|
|
|
|
*
|
|
|
|
* @param {string} name Function name.
|
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
Profile.prototype.skipThisFunction = function (name) {
|
2009-04-17 17:40:52 +00:00
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-04-24 11:37:38 +00:00
|
|
|
/**
|
|
|
|
* Enum for profiler operations that involve looking up existing
|
|
|
|
* code entries.
|
|
|
|
*
|
|
|
|
* @enum {number}
|
|
|
|
*/
|
2011-02-10 07:47:28 +00:00
|
|
|
Profile.Operation = {
|
2009-04-24 11:37:38 +00:00
|
|
|
MOVE: 0,
|
2011-09-12 10:50:40 +00:00
|
|
|
DELETE: 1,
|
|
|
|
TICK: 2
|
2009-04-24 11:37:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-02-22 16:31:24 +00:00
|
|
|
/**
|
|
|
|
* Enum for code state regarding its dynamic optimization.
|
|
|
|
*
|
|
|
|
* @enum {number}
|
|
|
|
*/
|
|
|
|
Profile.CodeState = {
|
|
|
|
COMPILED: 0,
|
|
|
|
OPTIMIZABLE: 1,
|
|
|
|
OPTIMIZED: 2
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-04-17 17:40:52 +00:00
|
|
|
/**
|
|
|
|
* Called whenever the specified operation has failed finding a function
|
|
|
|
* containing the specified address. Should be overriden by subclasses.
|
2011-02-10 07:47:28 +00:00
|
|
|
* See the Profile.Operation enum for the list of
|
2009-04-24 11:37:38 +00:00
|
|
|
* possible operations.
|
2009-04-17 17:40:52 +00:00
|
|
|
*
|
2009-04-24 11:37:38 +00:00
|
|
|
* @param {number} operation Operation.
|
2009-04-17 17:40:52 +00:00
|
|
|
* @param {number} addr Address of the unknown code.
|
2009-04-24 11:37:38 +00:00
|
|
|
* @param {number} opt_stackPos If an unknown address is encountered
|
|
|
|
* during stack strace processing, specifies a position of the frame
|
|
|
|
* containing the address.
|
2009-04-17 17:40:52 +00:00
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
Profile.prototype.handleUnknownCode = function (
|
|
|
|
operation, addr, opt_stackPos) {
|
2009-04-17 17:40:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2009-07-14 09:47:44 +00:00
|
|
|
* Registers a library.
|
|
|
|
*
|
|
|
|
* @param {string} name Code entry name.
|
|
|
|
* @param {number} startAddr Starting address.
|
|
|
|
* @param {number} endAddr Ending address.
|
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
Profile.prototype.addLibrary = function (
|
|
|
|
name, startAddr, endAddr) {
|
2011-02-10 07:47:28 +00:00
|
|
|
var entry = new CodeMap.CodeEntry(
|
2020-08-25 06:31:43 +00:00
|
|
|
endAddr - startAddr, name, 'SHARED_LIB');
|
2009-07-14 09:47:44 +00:00
|
|
|
this.codeMap_.addLibrary(startAddr, entry);
|
|
|
|
return entry;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Registers statically compiled code entry.
|
2009-04-17 17:40:52 +00:00
|
|
|
*
|
|
|
|
* @param {string} name Code entry name.
|
|
|
|
* @param {number} startAddr Starting address.
|
|
|
|
* @param {number} endAddr Ending address.
|
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
Profile.prototype.addStaticCode = function (
|
|
|
|
name, startAddr, endAddr) {
|
2011-02-10 07:47:28 +00:00
|
|
|
var entry = new CodeMap.CodeEntry(
|
2020-08-25 06:31:43 +00:00
|
|
|
endAddr - startAddr, name, 'CPP');
|
2009-04-24 11:37:38 +00:00
|
|
|
this.codeMap_.addStaticCode(startAddr, entry);
|
|
|
|
return entry;
|
2009-04-17 17:40:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Registers dynamic (JIT-compiled) code entry.
|
|
|
|
*
|
|
|
|
* @param {string} type Code entry type.
|
|
|
|
* @param {string} name Code entry name.
|
|
|
|
* @param {number} start Starting address.
|
|
|
|
* @param {number} size Code entry size.
|
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
Profile.prototype.addCode = function (
|
|
|
|
type, name, timestamp, start, size) {
|
2011-02-10 07:47:28 +00:00
|
|
|
var entry = new Profile.DynamicCodeEntry(size, type, name);
|
2009-04-24 11:37:38 +00:00
|
|
|
this.codeMap_.addCode(start, entry);
|
|
|
|
return entry;
|
2009-04-17 17:40:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
Fix issue 553: function frame is skipped in profile when compare stub is called.
The problem appeared due to a fact that stubs doesn't create a stack
frame, reusing the stack frame of the caller function. When building
stack traces, the current function is retrieved from PC, and its
callees are retrieved by traversing the stack backwards. Thus, for
stubs, the stub itself was discovered via PC, and then stub's caller's
caller was retrieved from stack.
To fix this problem, a pointer to JSFunction object is now captured
from the topmost stack frame, and is saved into stack trace log
record. Then a simple heuristics is applied whether a referred
function should be added to decoded stack, or not, to avoid reporting
the same function twice (from PC and from the pointer.)
BUG=553
TEST=added to mjsunit/tools/tickprocessor
Review URL: http://codereview.chromium.org/546089
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3673 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-01-21 16:42:41 +00:00
|
|
|
/**
|
2011-02-22 16:31:24 +00:00
|
|
|
* Registers dynamic (JIT-compiled) code entry.
|
Fix issue 553: function frame is skipped in profile when compare stub is called.
The problem appeared due to a fact that stubs doesn't create a stack
frame, reusing the stack frame of the caller function. When building
stack traces, the current function is retrieved from PC, and its
callees are retrieved by traversing the stack backwards. Thus, for
stubs, the stub itself was discovered via PC, and then stub's caller's
caller was retrieved from stack.
To fix this problem, a pointer to JSFunction object is now captured
from the topmost stack frame, and is saved into stack trace log
record. Then a simple heuristics is applied whether a referred
function should be added to decoded stack, or not, to avoid reporting
the same function twice (from PC and from the pointer.)
BUG=553
TEST=added to mjsunit/tools/tickprocessor
Review URL: http://codereview.chromium.org/546089
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3673 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-01-21 16:42:41 +00:00
|
|
|
*
|
2011-02-22 16:31:24 +00:00
|
|
|
* @param {string} type Code entry type.
|
|
|
|
* @param {string} name Code entry name.
|
|
|
|
* @param {number} start Starting address.
|
|
|
|
* @param {number} size Code entry size.
|
|
|
|
* @param {number} funcAddr Shared function object address.
|
|
|
|
* @param {Profile.CodeState} state Optimization state.
|
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
Profile.prototype.addFuncCode = function (
|
|
|
|
type, name, timestamp, start, size, funcAddr, state) {
|
2011-02-22 16:31:24 +00:00
|
|
|
// As code and functions are in the same address space,
|
|
|
|
// it is safe to put them in a single code map.
|
|
|
|
var func = this.codeMap_.findDynamicEntryByStartAddress(funcAddr);
|
|
|
|
if (!func) {
|
|
|
|
func = new Profile.FunctionEntry(name);
|
|
|
|
this.codeMap_.addCode(funcAddr, func);
|
|
|
|
} else if (func.name !== name) {
|
|
|
|
// Function object has been overwritten with a new one.
|
|
|
|
func.name = name;
|
Fix issue 553: function frame is skipped in profile when compare stub is called.
The problem appeared due to a fact that stubs doesn't create a stack
frame, reusing the stack frame of the caller function. When building
stack traces, the current function is retrieved from PC, and its
callees are retrieved by traversing the stack backwards. Thus, for
stubs, the stub itself was discovered via PC, and then stub's caller's
caller was retrieved from stack.
To fix this problem, a pointer to JSFunction object is now captured
from the topmost stack frame, and is saved into stack trace log
record. Then a simple heuristics is applied whether a referred
function should be added to decoded stack, or not, to avoid reporting
the same function twice (from PC and from the pointer.)
BUG=553
TEST=added to mjsunit/tools/tickprocessor
Review URL: http://codereview.chromium.org/546089
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3673 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-01-21 16:42:41 +00:00
|
|
|
}
|
2011-07-13 11:31:22 +00:00
|
|
|
var entry = this.codeMap_.findDynamicEntryByStartAddress(start);
|
2011-09-12 10:50:40 +00:00
|
|
|
if (entry) {
|
|
|
|
if (entry.size === size && entry.func === func) {
|
|
|
|
// Entry state has changed.
|
|
|
|
entry.state = state;
|
2020-01-23 10:31:41 +00:00
|
|
|
} else {
|
|
|
|
this.codeMap_.deleteCode(start);
|
|
|
|
entry = null;
|
2011-09-12 10:50:40 +00:00
|
|
|
}
|
2020-01-23 10:31:41 +00:00
|
|
|
}
|
|
|
|
if (!entry) {
|
2011-09-12 10:50:40 +00:00
|
|
|
entry = new Profile.DynamicFuncCodeEntry(size, type, func, state);
|
|
|
|
this.codeMap_.addCode(start, entry);
|
2011-07-13 11:31:22 +00:00
|
|
|
}
|
2011-02-22 16:31:24 +00:00
|
|
|
return entry;
|
Fix issue 553: function frame is skipped in profile when compare stub is called.
The problem appeared due to a fact that stubs doesn't create a stack
frame, reusing the stack frame of the caller function. When building
stack traces, the current function is retrieved from PC, and its
callees are retrieved by traversing the stack backwards. Thus, for
stubs, the stub itself was discovered via PC, and then stub's caller's
caller was retrieved from stack.
To fix this problem, a pointer to JSFunction object is now captured
from the topmost stack frame, and is saved into stack trace log
record. Then a simple heuristics is applied whether a referred
function should be added to decoded stack, or not, to avoid reporting
the same function twice (from PC and from the pointer.)
BUG=553
TEST=added to mjsunit/tools/tickprocessor
Review URL: http://codereview.chromium.org/546089
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3673 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-01-21 16:42:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-04-17 17:40:52 +00:00
|
|
|
/**
|
|
|
|
* Reports about moving of a dynamic code entry.
|
|
|
|
*
|
|
|
|
* @param {number} from Current code entry address.
|
|
|
|
* @param {number} to New code entry address.
|
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
Profile.prototype.moveCode = function (from, to) {
|
2009-04-17 17:40:52 +00:00
|
|
|
try {
|
|
|
|
this.codeMap_.moveCode(from, to);
|
|
|
|
} catch (e) {
|
2011-02-10 07:47:28 +00:00
|
|
|
this.handleUnknownCode(Profile.Operation.MOVE, from);
|
2009-04-17 17:40:52 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-08-25 06:31:43 +00:00
|
|
|
Profile.prototype.deoptCode = function (
|
|
|
|
timestamp, code, inliningId, scriptOffset, bailoutType,
|
|
|
|
sourcePositionText, deoptReasonText) {
|
2017-03-22 16:02:25 +00:00
|
|
|
};
|
2009-04-17 17:40:52 +00:00
|
|
|
|
2011-09-12 10:50:40 +00:00
|
|
|
/**
|
|
|
|
* Reports about deletion of a dynamic code entry.
|
|
|
|
*
|
|
|
|
* @param {number} start Starting address.
|
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
Profile.prototype.deleteCode = function (start) {
|
2011-09-12 10:50:40 +00:00
|
|
|
try {
|
|
|
|
this.codeMap_.deleteCode(start);
|
|
|
|
} catch (e) {
|
|
|
|
this.handleUnknownCode(Profile.Operation.DELETE, start);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-07-27 19:46:32 +00:00
|
|
|
/**
|
|
|
|
* Adds source positions for given code.
|
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
Profile.prototype.addSourcePositions = function (
|
|
|
|
start, script, startPos, endPos, sourcePositions, inliningPositions,
|
|
|
|
inlinedFunctions) {
|
2017-07-27 19:46:32 +00:00
|
|
|
// CLI does not need source code => ignore.
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds script source code.
|
|
|
|
*/
|
2020-09-23 10:30:17 +00:00
|
|
|
Profile.prototype.addScriptSource = function (id, url, source) {
|
|
|
|
const script = new Script(id, url, source);
|
|
|
|
this.scripts_[id] = script;
|
|
|
|
this.urlToScript_.set(url, script);
|
2020-08-28 14:41:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds script source code.
|
|
|
|
*/
|
|
|
|
Profile.prototype.getScript = function (url) {
|
|
|
|
return this.urlToScript_.get(url);
|
2017-07-27 19:46:32 +00:00
|
|
|
};
|
2011-09-12 10:50:40 +00:00
|
|
|
|
Fix issue 553: function frame is skipped in profile when compare stub is called.
The problem appeared due to a fact that stubs doesn't create a stack
frame, reusing the stack frame of the caller function. When building
stack traces, the current function is retrieved from PC, and its
callees are retrieved by traversing the stack backwards. Thus, for
stubs, the stub itself was discovered via PC, and then stub's caller's
caller was retrieved from stack.
To fix this problem, a pointer to JSFunction object is now captured
from the topmost stack frame, and is saved into stack trace log
record. Then a simple heuristics is applied whether a referred
function should be added to decoded stack, or not, to avoid reporting
the same function twice (from PC and from the pointer.)
BUG=553
TEST=added to mjsunit/tools/tickprocessor
Review URL: http://codereview.chromium.org/546089
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3673 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-01-21 16:42:41 +00:00
|
|
|
/**
|
|
|
|
* Reports about moving of a dynamic code entry.
|
|
|
|
*
|
|
|
|
* @param {number} from Current code entry address.
|
|
|
|
* @param {number} to New code entry address.
|
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
Profile.prototype.moveFunc = function (from, to) {
|
Fix issue 553: function frame is skipped in profile when compare stub is called.
The problem appeared due to a fact that stubs doesn't create a stack
frame, reusing the stack frame of the caller function. When building
stack traces, the current function is retrieved from PC, and its
callees are retrieved by traversing the stack backwards. Thus, for
stubs, the stub itself was discovered via PC, and then stub's caller's
caller was retrieved from stack.
To fix this problem, a pointer to JSFunction object is now captured
from the topmost stack frame, and is saved into stack trace log
record. Then a simple heuristics is applied whether a referred
function should be added to decoded stack, or not, to avoid reporting
the same function twice (from PC and from the pointer.)
BUG=553
TEST=added to mjsunit/tools/tickprocessor
Review URL: http://codereview.chromium.org/546089
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3673 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-01-21 16:42:41 +00:00
|
|
|
if (this.codeMap_.findDynamicEntryByStartAddress(from)) {
|
|
|
|
this.codeMap_.moveCode(from, to);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-01-18 16:04:25 +00:00
|
|
|
/**
|
|
|
|
* Retrieves a code entry by an address.
|
|
|
|
*
|
|
|
|
* @param {number} addr Entry address.
|
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
Profile.prototype.findEntry = function (addr) {
|
2010-01-18 16:04:25 +00:00
|
|
|
return this.codeMap_.findEntry(addr);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-04-17 17:40:52 +00:00
|
|
|
/**
|
|
|
|
* Records a tick event. Stack must contain a sequence of
|
|
|
|
* addresses starting with the program counter value.
|
|
|
|
*
|
|
|
|
* @param {Array<number>} stack Stack sample.
|
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
Profile.prototype.recordTick = function (time_ns, vmState, stack) {
|
2009-04-17 17:40:52 +00:00
|
|
|
var processedStack = this.resolveAndFilterFuncs_(stack);
|
|
|
|
this.bottomUpTree_.addPath(processedStack);
|
|
|
|
processedStack.reverse();
|
|
|
|
this.topDownTree_.addPath(processedStack);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Translates addresses into function names and filters unneeded
|
|
|
|
* functions.
|
|
|
|
*
|
|
|
|
* @param {Array<number>} stack Stack sample.
|
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
Profile.prototype.resolveAndFilterFuncs_ = function (stack) {
|
2009-04-17 17:40:52 +00:00
|
|
|
var result = [];
|
2014-10-17 15:44:02 +00:00
|
|
|
var last_seen_c_function = '';
|
|
|
|
var look_for_first_c_function = false;
|
2009-04-17 17:40:52 +00:00
|
|
|
for (var i = 0; i < stack.length; ++i) {
|
|
|
|
var entry = this.codeMap_.findEntry(stack[i]);
|
|
|
|
if (entry) {
|
|
|
|
var name = entry.getName();
|
2015-01-20 16:06:03 +00:00
|
|
|
if (i === 0 && (entry.type === 'CPP' || entry.type === 'SHARED_LIB')) {
|
2014-10-17 15:44:02 +00:00
|
|
|
look_for_first_c_function = true;
|
|
|
|
}
|
2015-01-20 16:06:03 +00:00
|
|
|
if (look_for_first_c_function && entry.type === 'CPP') {
|
|
|
|
last_seen_c_function = name;
|
2014-10-17 15:44:02 +00:00
|
|
|
}
|
2009-04-17 17:40:52 +00:00
|
|
|
if (!this.skipThisFunction(name)) {
|
|
|
|
result.push(name);
|
|
|
|
}
|
|
|
|
} else {
|
2015-01-20 16:06:03 +00:00
|
|
|
this.handleUnknownCode(Profile.Operation.TICK, stack[i], i);
|
|
|
|
if (i === 0) result.push("UNKNOWN");
|
|
|
|
}
|
|
|
|
if (look_for_first_c_function &&
|
2020-08-25 06:31:43 +00:00
|
|
|
i > 0 &&
|
|
|
|
(!entry || entry.type !== 'CPP') &&
|
|
|
|
last_seen_c_function !== '') {
|
2015-01-20 16:06:03 +00:00
|
|
|
if (this.c_entries_[last_seen_c_function] === undefined) {
|
|
|
|
this.c_entries_[last_seen_c_function] = 0;
|
|
|
|
}
|
|
|
|
this.c_entries_[last_seen_c_function]++;
|
|
|
|
look_for_first_c_function = false; // Found it, we're done.
|
2009-04-17 17:40:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2009-04-30 08:10:27 +00:00
|
|
|
* Performs a BF traversal of the top down call graph.
|
2009-04-17 17:40:52 +00:00
|
|
|
*
|
2011-02-10 07:47:28 +00:00
|
|
|
* @param {function(CallTree.Node)} f Visitor function.
|
2009-04-17 17:40:52 +00:00
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
Profile.prototype.traverseTopDownTree = function (f) {
|
2009-04-17 17:40:52 +00:00
|
|
|
this.topDownTree_.traverse(f);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2009-04-30 08:10:27 +00:00
|
|
|
* Performs a BF traversal of the bottom up call graph.
|
2009-04-17 17:40:52 +00:00
|
|
|
*
|
2011-02-10 07:47:28 +00:00
|
|
|
* @param {function(CallTree.Node)} f Visitor function.
|
2009-04-17 17:40:52 +00:00
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
Profile.prototype.traverseBottomUpTree = function (f) {
|
2009-04-17 17:40:52 +00:00
|
|
|
this.bottomUpTree_.traverse(f);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-04-24 11:37:38 +00:00
|
|
|
/**
|
2009-04-30 08:10:27 +00:00
|
|
|
* Calculates a top down profile for a node with the specified label.
|
|
|
|
* If no name specified, returns the whole top down calls tree.
|
2009-04-24 11:37:38 +00:00
|
|
|
*
|
2009-04-30 08:10:27 +00:00
|
|
|
* @param {string} opt_label Node label.
|
2009-04-24 11:37:38 +00:00
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
Profile.prototype.getTopDownProfile = function (opt_label) {
|
2009-04-30 08:10:27 +00:00
|
|
|
return this.getTreeProfile_(this.topDownTree_, opt_label);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculates a bottom up profile for a node with the specified label.
|
|
|
|
* If no name specified, returns the whole bottom up calls tree.
|
|
|
|
*
|
|
|
|
* @param {string} opt_label Node label.
|
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
Profile.prototype.getBottomUpProfile = function (opt_label) {
|
2009-04-30 08:10:27 +00:00
|
|
|
return this.getTreeProfile_(this.bottomUpTree_, opt_label);
|
2009-04-24 11:37:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2009-04-30 08:10:27 +00:00
|
|
|
* Helper function for calculating a tree profile.
|
2009-04-24 11:37:38 +00:00
|
|
|
*
|
2011-02-10 07:47:28 +00:00
|
|
|
* @param {Profile.CallTree} tree Call tree.
|
2009-04-30 08:10:27 +00:00
|
|
|
* @param {string} opt_label Node label.
|
2009-04-24 11:37:38 +00:00
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
Profile.prototype.getTreeProfile_ = function (tree, opt_label) {
|
2009-04-30 08:10:27 +00:00
|
|
|
if (!opt_label) {
|
|
|
|
tree.computeTotalWeights();
|
|
|
|
return tree;
|
2009-04-24 11:37:38 +00:00
|
|
|
} else {
|
2009-04-30 08:10:27 +00:00
|
|
|
var subTree = tree.cloneSubtree(opt_label);
|
|
|
|
subTree.computeTotalWeights();
|
|
|
|
return subTree;
|
2009-04-24 11:37:38 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-04-17 17:40:52 +00:00
|
|
|
/**
|
2009-04-30 08:10:27 +00:00
|
|
|
* Calculates a flat profile of callees starting from a node with
|
|
|
|
* the specified label. If no name specified, starts from the root.
|
2009-04-17 17:40:52 +00:00
|
|
|
*
|
2009-04-30 08:10:27 +00:00
|
|
|
* @param {string} opt_label Starting node label.
|
2009-04-17 17:40:52 +00:00
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
Profile.prototype.getFlatProfile = function (opt_label) {
|
2011-02-10 07:47:28 +00:00
|
|
|
var counters = new CallTree();
|
|
|
|
var rootLabel = opt_label || CallTree.ROOT_NODE_LABEL;
|
2009-04-17 17:40:52 +00:00
|
|
|
var precs = {};
|
2009-04-30 08:10:27 +00:00
|
|
|
precs[rootLabel] = 0;
|
|
|
|
var root = counters.findOrAddChild(rootLabel);
|
|
|
|
|
2009-04-17 17:40:52 +00:00
|
|
|
this.topDownTree_.computeTotalWeights();
|
|
|
|
this.topDownTree_.traverseInDepth(
|
|
|
|
function onEnter(node) {
|
|
|
|
if (!(node.label in precs)) {
|
|
|
|
precs[node.label] = 0;
|
|
|
|
}
|
2009-04-30 08:10:27 +00:00
|
|
|
var nodeLabelIsRootLabel = node.label == rootLabel;
|
|
|
|
if (nodeLabelIsRootLabel || precs[rootLabel] > 0) {
|
|
|
|
if (precs[rootLabel] == 0) {
|
|
|
|
root.selfWeight += node.selfWeight;
|
|
|
|
root.totalWeight += node.totalWeight;
|
|
|
|
} else {
|
|
|
|
var rec = root.findOrAddChild(node.label);
|
|
|
|
rec.selfWeight += node.selfWeight;
|
|
|
|
if (nodeLabelIsRootLabel || precs[node.label] == 0) {
|
|
|
|
rec.totalWeight += node.totalWeight;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
precs[node.label]++;
|
2009-04-17 17:40:52 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
function onExit(node) {
|
2009-04-30 08:10:27 +00:00
|
|
|
if (node.label == rootLabel || precs[rootLabel] > 0) {
|
|
|
|
precs[node.label]--;
|
|
|
|
}
|
2009-04-17 17:40:52 +00:00
|
|
|
},
|
2009-04-30 08:10:27 +00:00
|
|
|
null);
|
|
|
|
|
|
|
|
if (!opt_label) {
|
|
|
|
// If we have created a flat profile for the whole program, we don't
|
|
|
|
// need an explicit root in it. Thus, replace the counters tree
|
|
|
|
// root with the node corresponding to the whole program.
|
|
|
|
counters.root_ = root;
|
|
|
|
} else {
|
|
|
|
// Propagate weights so percents can be calculated correctly.
|
|
|
|
counters.getRoot().selfWeight = root.selfWeight;
|
|
|
|
counters.getRoot().totalWeight = root.totalWeight;
|
|
|
|
}
|
2009-04-24 11:37:38 +00:00
|
|
|
return counters;
|
2009-04-17 17:40:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-08-25 06:31:43 +00:00
|
|
|
Profile.CEntryNode = function (name, ticks) {
|
2014-10-17 15:44:02 +00:00
|
|
|
this.name = name;
|
|
|
|
this.ticks = ticks;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-25 06:31:43 +00:00
|
|
|
Profile.prototype.getCEntryProfile = function () {
|
2014-10-17 15:44:02 +00:00
|
|
|
var result = [new Profile.CEntryNode("TOTAL", 0)];
|
|
|
|
var total_ticks = 0;
|
|
|
|
for (var f in this.c_entries_) {
|
|
|
|
var ticks = this.c_entries_[f];
|
|
|
|
total_ticks += ticks;
|
|
|
|
result.push(new Profile.CEntryNode(f, ticks));
|
|
|
|
}
|
|
|
|
result[0].ticks = total_ticks; // Sorting will keep this at index 0.
|
2020-08-25 06:31:43 +00:00
|
|
|
result.sort(function (n1, n2) {
|
2014-10-17 15:44:02 +00:00
|
|
|
return n2.ticks - n1.ticks || (n2.name < n1.name ? -1 : 1)
|
|
|
|
});
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-07-13 11:31:22 +00:00
|
|
|
/**
|
|
|
|
* Cleans up function entries that are not referenced by code entries.
|
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
Profile.prototype.cleanUpFuncEntries = function () {
|
2011-07-13 11:31:22 +00:00
|
|
|
var referencedFuncEntries = [];
|
|
|
|
var entries = this.codeMap_.getAllDynamicEntriesWithAddresses();
|
|
|
|
for (var i = 0, l = entries.length; i < l; ++i) {
|
|
|
|
if (entries[i][1].constructor === Profile.FunctionEntry) {
|
|
|
|
entries[i][1].used = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (var i = 0, l = entries.length; i < l; ++i) {
|
|
|
|
if ("func" in entries[i][1]) {
|
|
|
|
entries[i][1].func.used = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (var i = 0, l = entries.length; i < l; ++i) {
|
|
|
|
if (entries[i][1].constructor === Profile.FunctionEntry &&
|
2020-08-25 06:31:43 +00:00
|
|
|
!entries[i][1].used) {
|
2011-07-13 11:31:22 +00:00
|
|
|
this.codeMap_.deleteCode(entries[i][0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-04-17 17:40:52 +00:00
|
|
|
/**
|
|
|
|
* Creates a dynamic code entry.
|
|
|
|
*
|
|
|
|
* @param {number} size Code size.
|
|
|
|
* @param {string} type Code type.
|
|
|
|
* @param {string} name Function name.
|
|
|
|
* @constructor
|
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
Profile.DynamicCodeEntry = function (size, type, name) {
|
2014-10-17 15:44:02 +00:00
|
|
|
CodeMap.CodeEntry.call(this, size, name, type);
|
2009-04-17 17:40:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns node name.
|
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
Profile.DynamicCodeEntry.prototype.getName = function () {
|
2011-02-22 16:31:24 +00:00
|
|
|
return this.type + ': ' + this.name;
|
2009-04-17 17:40:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-01-18 16:04:25 +00:00
|
|
|
/**
|
|
|
|
* Returns raw node name (without type decoration).
|
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
Profile.DynamicCodeEntry.prototype.getRawName = function () {
|
2010-01-18 16:04:25 +00:00
|
|
|
return this.name;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-08-25 06:31:43 +00:00
|
|
|
Profile.DynamicCodeEntry.prototype.isJSFunction = function () {
|
2011-02-22 16:31:24 +00:00
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-08-25 06:31:43 +00:00
|
|
|
Profile.DynamicCodeEntry.prototype.toString = function () {
|
2011-07-13 11:31:22 +00:00
|
|
|
return this.getName() + ': ' + this.size.toString(16);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-02-22 16:31:24 +00:00
|
|
|
/**
|
|
|
|
* Creates a dynamic code entry.
|
|
|
|
*
|
|
|
|
* @param {number} size Code size.
|
|
|
|
* @param {string} type Code type.
|
|
|
|
* @param {Profile.FunctionEntry} func Shared function entry.
|
|
|
|
* @param {Profile.CodeState} state Code optimization state.
|
|
|
|
* @constructor
|
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
Profile.DynamicFuncCodeEntry = function (size, type, func, state) {
|
2014-10-17 15:44:02 +00:00
|
|
|
CodeMap.CodeEntry.call(this, size, '', type);
|
2011-02-22 16:31:24 +00:00
|
|
|
this.func = func;
|
|
|
|
this.state = state;
|
|
|
|
};
|
|
|
|
|
|
|
|
Profile.DynamicFuncCodeEntry.STATE_PREFIX = ["", "~", "*"];
|
|
|
|
|
2017-04-25 12:01:18 +00:00
|
|
|
/**
|
|
|
|
* Returns state.
|
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
Profile.DynamicFuncCodeEntry.prototype.getState = function () {
|
2017-04-25 12:01:18 +00:00
|
|
|
return Profile.DynamicFuncCodeEntry.STATE_PREFIX[this.state];
|
|
|
|
};
|
|
|
|
|
2011-02-22 16:31:24 +00:00
|
|
|
/**
|
|
|
|
* Returns node name.
|
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
Profile.DynamicFuncCodeEntry.prototype.getName = function () {
|
2011-02-22 16:31:24 +00:00
|
|
|
var name = this.func.getName();
|
2017-04-25 12:01:18 +00:00
|
|
|
return this.type + ': ' + this.getState() + name;
|
2011-02-22 16:31:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns raw node name (without type decoration).
|
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
Profile.DynamicFuncCodeEntry.prototype.getRawName = function () {
|
2011-02-22 16:31:24 +00:00
|
|
|
return this.func.getName();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-08-25 06:31:43 +00:00
|
|
|
Profile.DynamicFuncCodeEntry.prototype.isJSFunction = function () {
|
2011-02-22 16:31:24 +00:00
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-08-25 06:31:43 +00:00
|
|
|
Profile.DynamicFuncCodeEntry.prototype.toString = function () {
|
2011-07-13 11:31:22 +00:00
|
|
|
return this.getName() + ': ' + this.size.toString(16);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-02-22 16:31:24 +00:00
|
|
|
/**
|
|
|
|
* Creates a shared function object entry.
|
|
|
|
*
|
|
|
|
* @param {string} name Function name.
|
|
|
|
* @constructor
|
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
Profile.FunctionEntry = function (name) {
|
2011-02-22 16:31:24 +00:00
|
|
|
CodeMap.CodeEntry.call(this, 0, name);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns node name.
|
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
Profile.FunctionEntry.prototype.getName = function () {
|
2011-02-22 16:31:24 +00:00
|
|
|
var name = this.name;
|
|
|
|
if (name.length == 0) {
|
|
|
|
name = '<anonymous>';
|
|
|
|
} else if (name.charAt(0) == ' ') {
|
|
|
|
// An anonymous function with location: " aaa.js:10".
|
|
|
|
name = '<anonymous>' + name;
|
|
|
|
}
|
|
|
|
return name;
|
Fix issue 553: function frame is skipped in profile when compare stub is called.
The problem appeared due to a fact that stubs doesn't create a stack
frame, reusing the stack frame of the caller function. When building
stack traces, the current function is retrieved from PC, and its
callees are retrieved by traversing the stack backwards. Thus, for
stubs, the stub itself was discovered via PC, and then stub's caller's
caller was retrieved from stack.
To fix this problem, a pointer to JSFunction object is now captured
from the topmost stack frame, and is saved into stack trace log
record. Then a simple heuristics is applied whether a referred
function should be added to decoded stack, or not, to avoid reporting
the same function twice (from PC and from the pointer.)
BUG=553
TEST=added to mjsunit/tools/tickprocessor
Review URL: http://codereview.chromium.org/546089
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3673 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-01-21 16:42:41 +00:00
|
|
|
};
|
|
|
|
|
2011-07-13 11:31:22 +00:00
|
|
|
Profile.FunctionEntry.prototype.toString = CodeMap.CodeEntry.prototype.toString;
|
Fix issue 553: function frame is skipped in profile when compare stub is called.
The problem appeared due to a fact that stubs doesn't create a stack
frame, reusing the stack frame of the caller function. When building
stack traces, the current function is retrieved from PC, and its
callees are retrieved by traversing the stack backwards. Thus, for
stubs, the stub itself was discovered via PC, and then stub's caller's
caller was retrieved from stack.
To fix this problem, a pointer to JSFunction object is now captured
from the topmost stack frame, and is saved into stack trace log
record. Then a simple heuristics is applied whether a referred
function should be added to decoded stack, or not, to avoid reporting
the same function twice (from PC and from the pointer.)
BUG=553
TEST=added to mjsunit/tools/tickprocessor
Review URL: http://codereview.chromium.org/546089
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3673 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-01-21 16:42:41 +00:00
|
|
|
|
2009-04-17 17:40:52 +00:00
|
|
|
/**
|
|
|
|
* Constructs a call graph.
|
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
*/
|
2011-02-10 07:47:28 +00:00
|
|
|
function CallTree() {
|
|
|
|
this.root_ = new CallTree.Node(
|
2020-08-25 06:31:43 +00:00
|
|
|
CallTree.ROOT_NODE_LABEL);
|
2009-04-17 17:40:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-04-30 08:10:27 +00:00
|
|
|
/**
|
|
|
|
* The label of the root node.
|
|
|
|
*/
|
2011-02-10 07:47:28 +00:00
|
|
|
CallTree.ROOT_NODE_LABEL = '';
|
2009-04-30 08:10:27 +00:00
|
|
|
|
|
|
|
|
2009-04-17 17:40:52 +00:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
*/
|
2011-02-10 07:47:28 +00:00
|
|
|
CallTree.prototype.totalsComputed_ = false;
|
2009-04-17 17:40:52 +00:00
|
|
|
|
|
|
|
|
2009-04-24 11:37:38 +00:00
|
|
|
/**
|
|
|
|
* Returns the tree root.
|
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
CallTree.prototype.getRoot = function () {
|
2009-04-24 11:37:38 +00:00
|
|
|
return this.root_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-04-17 17:40:52 +00:00
|
|
|
/**
|
|
|
|
* Adds the specified call path, constructing nodes as necessary.
|
|
|
|
*
|
|
|
|
* @param {Array<string>} path Call path.
|
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
CallTree.prototype.addPath = function (path) {
|
2009-04-17 17:40:52 +00:00
|
|
|
if (path.length == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var curr = this.root_;
|
|
|
|
for (var i = 0; i < path.length; ++i) {
|
|
|
|
curr = curr.findOrAddChild(path[i]);
|
|
|
|
}
|
|
|
|
curr.selfWeight++;
|
|
|
|
this.totalsComputed_ = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-04-24 11:37:38 +00:00
|
|
|
/**
|
|
|
|
* Finds an immediate child of the specified parent with the specified
|
|
|
|
* label, creates a child node if necessary. If a parent node isn't
|
|
|
|
* specified, uses tree root.
|
|
|
|
*
|
|
|
|
* @param {string} label Child node label.
|
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
CallTree.prototype.findOrAddChild = function (label) {
|
2009-04-30 08:10:27 +00:00
|
|
|
return this.root_.findOrAddChild(label);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a subtree by cloning and merging all subtrees rooted at nodes
|
|
|
|
* with a given label. E.g. cloning the following call tree on label 'A'
|
|
|
|
* will give the following result:
|
|
|
|
*
|
|
|
|
* <A>--<B> <B>
|
|
|
|
* / /
|
|
|
|
* <root> == clone on 'A' ==> <root>--<A>
|
|
|
|
* \ \
|
|
|
|
* <C>--<A>--<D> <D>
|
|
|
|
*
|
|
|
|
* And <A>'s selfWeight will be the sum of selfWeights of <A>'s from the
|
|
|
|
* source call tree.
|
|
|
|
*
|
|
|
|
* @param {string} label The label of the new root node.
|
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
CallTree.prototype.cloneSubtree = function (label) {
|
2011-02-10 07:47:28 +00:00
|
|
|
var subTree = new CallTree();
|
2020-08-25 06:31:43 +00:00
|
|
|
this.traverse(function (node, parent) {
|
2009-04-30 08:10:27 +00:00
|
|
|
if (!parent && node.label != label) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
var child = (parent ? parent : subTree).findOrAddChild(node.label);
|
|
|
|
child.selfWeight += node.selfWeight;
|
|
|
|
return child;
|
|
|
|
});
|
|
|
|
return subTree;
|
2009-04-24 11:37:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-04-17 17:40:52 +00:00
|
|
|
/**
|
|
|
|
* Computes total weights in the call graph.
|
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
CallTree.prototype.computeTotalWeights = function () {
|
2009-04-17 17:40:52 +00:00
|
|
|
if (this.totalsComputed_) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.root_.computeTotalWeight();
|
|
|
|
this.totalsComputed_ = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2009-04-24 11:37:38 +00:00
|
|
|
* Traverses the call graph in preorder. This function can be used for
|
|
|
|
* building optionally modified tree clones. This is the boilerplate code
|
|
|
|
* for this scenario:
|
2009-04-17 17:40:52 +00:00
|
|
|
*
|
2009-04-24 11:37:38 +00:00
|
|
|
* callTree.traverse(function(node, parentClone) {
|
|
|
|
* var nodeClone = cloneNode(node);
|
|
|
|
* if (parentClone)
|
|
|
|
* parentClone.addChild(nodeClone);
|
|
|
|
* return nodeClone;
|
|
|
|
* });
|
|
|
|
*
|
2011-02-10 07:47:28 +00:00
|
|
|
* @param {function(CallTree.Node, *)} f Visitor function.
|
2009-04-24 11:37:38 +00:00
|
|
|
* The second parameter is the result of calling 'f' on the parent node.
|
2009-04-17 17:40:52 +00:00
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
CallTree.prototype.traverse = function (f) {
|
2009-04-27 13:50:42 +00:00
|
|
|
var pairsToProcess = new ConsArray();
|
2020-08-25 06:31:43 +00:00
|
|
|
pairsToProcess.concat([{ node: this.root_, param: null }]);
|
2009-04-27 13:50:42 +00:00
|
|
|
while (!pairsToProcess.atEnd()) {
|
|
|
|
var pair = pairsToProcess.next();
|
2009-04-24 11:37:38 +00:00
|
|
|
var node = pair.node;
|
|
|
|
var newParam = f(node, pair.param);
|
2009-04-27 13:50:42 +00:00
|
|
|
var morePairsToProcess = [];
|
|
|
|
node.forEachChild(function (child) {
|
2020-08-25 06:31:43 +00:00
|
|
|
morePairsToProcess.push({ node: child, param: newParam });
|
|
|
|
});
|
2009-04-27 13:50:42 +00:00
|
|
|
pairsToProcess.concat(morePairsToProcess);
|
2009-04-17 17:40:52 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Performs an indepth call graph traversal.
|
|
|
|
*
|
2011-02-10 07:47:28 +00:00
|
|
|
* @param {function(CallTree.Node)} enter A function called
|
2009-04-17 17:40:52 +00:00
|
|
|
* prior to visiting node's children.
|
2011-02-10 07:47:28 +00:00
|
|
|
* @param {function(CallTree.Node)} exit A function called
|
2009-04-17 17:40:52 +00:00
|
|
|
* after visiting node's children.
|
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
CallTree.prototype.traverseInDepth = function (enter, exit) {
|
2009-04-17 17:40:52 +00:00
|
|
|
function traverse(node) {
|
|
|
|
enter(node);
|
|
|
|
node.forEachChild(traverse);
|
|
|
|
exit(node);
|
|
|
|
}
|
2009-04-30 08:10:27 +00:00
|
|
|
traverse(this.root_);
|
2009-04-17 17:40:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructs a call graph node.
|
|
|
|
*
|
|
|
|
* @param {string} label Node label.
|
2011-02-10 07:47:28 +00:00
|
|
|
* @param {CallTree.Node} opt_parent Node parent.
|
2009-04-17 17:40:52 +00:00
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
CallTree.Node = function (label, opt_parent) {
|
2009-04-17 17:40:52 +00:00
|
|
|
this.label = label;
|
|
|
|
this.parent = opt_parent;
|
|
|
|
this.children = {};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Node self weight (how many times this node was the last node in
|
|
|
|
* a call path).
|
|
|
|
* @type {number}
|
|
|
|
*/
|
2011-02-10 07:47:28 +00:00
|
|
|
CallTree.Node.prototype.selfWeight = 0;
|
2009-04-17 17:40:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Node total weight (includes weights of all children).
|
|
|
|
* @type {number}
|
|
|
|
*/
|
2011-02-10 07:47:28 +00:00
|
|
|
CallTree.Node.prototype.totalWeight = 0;
|
2009-04-17 17:40:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a child node.
|
|
|
|
*
|
|
|
|
* @param {string} label Child node label.
|
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
CallTree.Node.prototype.addChild = function (label) {
|
2011-02-10 07:47:28 +00:00
|
|
|
var child = new CallTree.Node(label, this);
|
2009-04-17 17:40:52 +00:00
|
|
|
this.children[label] = child;
|
|
|
|
return child;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Computes node's total weight.
|
|
|
|
*/
|
2011-02-10 07:47:28 +00:00
|
|
|
CallTree.Node.prototype.computeTotalWeight =
|
2020-08-25 06:31:43 +00:00
|
|
|
function () {
|
|
|
|
var totalWeight = this.selfWeight;
|
|
|
|
this.forEachChild(function (child) {
|
|
|
|
totalWeight += child.computeTotalWeight();
|
|
|
|
});
|
|
|
|
return this.totalWeight = totalWeight;
|
|
|
|
};
|
2009-04-17 17:40:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns all node's children as an array.
|
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
CallTree.Node.prototype.exportChildren = function () {
|
2009-04-17 17:40:52 +00:00
|
|
|
var result = [];
|
|
|
|
this.forEachChild(function (node) { result.push(node); });
|
|
|
|
return result;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Finds an immediate child with the specified label.
|
|
|
|
*
|
|
|
|
* @param {string} label Child node label.
|
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
CallTree.Node.prototype.findChild = function (label) {
|
2009-04-17 17:40:52 +00:00
|
|
|
return this.children[label] || null;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Finds an immediate child with the specified label, creates a child
|
|
|
|
* node if necessary.
|
|
|
|
*
|
|
|
|
* @param {string} label Child node label.
|
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
CallTree.Node.prototype.findOrAddChild = function (label) {
|
2009-04-17 17:40:52 +00:00
|
|
|
return this.findChild(label) || this.addChild(label);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Calls the specified function for every child.
|
|
|
|
*
|
2011-02-10 07:47:28 +00:00
|
|
|
* @param {function(CallTree.Node)} f Visitor function.
|
2009-04-17 17:40:52 +00:00
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
CallTree.Node.prototype.forEachChild = function (f) {
|
2009-04-17 17:40:52 +00:00
|
|
|
for (var c in this.children) {
|
|
|
|
f(this.children[c]);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Walks up from the current node up to the call tree root.
|
|
|
|
*
|
2011-02-10 07:47:28 +00:00
|
|
|
* @param {function(CallTree.Node)} f Visitor function.
|
2009-04-17 17:40:52 +00:00
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
CallTree.Node.prototype.walkUpToRoot = function (f) {
|
2009-04-17 17:40:52 +00:00
|
|
|
for (var curr = this; curr != null; curr = curr.parent) {
|
|
|
|
f(curr);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tries to find a node with the specified path.
|
|
|
|
*
|
|
|
|
* @param {Array<string>} labels The path.
|
2011-02-10 07:47:28 +00:00
|
|
|
* @param {function(CallTree.Node)} opt_f Visitor function.
|
2009-04-17 17:40:52 +00:00
|
|
|
*/
|
2020-08-25 06:31:43 +00:00
|
|
|
CallTree.Node.prototype.descendToChild = function (
|
|
|
|
labels, opt_f) {
|
2009-04-17 17:40:52 +00:00
|
|
|
for (var pos = 0, curr = this; pos < labels.length && curr != null; pos++) {
|
|
|
|
var child = curr.findChild(labels[pos]);
|
|
|
|
if (opt_f) {
|
|
|
|
opt_f(child, pos);
|
|
|
|
}
|
|
|
|
curr = child;
|
|
|
|
}
|
|
|
|
return curr;
|
|
|
|
};
|
2017-03-04 13:04:58 +00:00
|
|
|
|
|
|
|
function JsonProfile() {
|
|
|
|
this.codeMap_ = new CodeMap();
|
|
|
|
this.codeEntries_ = [];
|
|
|
|
this.functionEntries_ = [];
|
|
|
|
this.ticks_ = [];
|
2017-07-27 19:46:32 +00:00
|
|
|
this.scripts_ = [];
|
2017-03-04 13:04:58 +00:00
|
|
|
}
|
|
|
|
|
2020-08-25 06:31:43 +00:00
|
|
|
JsonProfile.prototype.addLibrary = function (
|
|
|
|
name, startAddr, endAddr) {
|
2017-03-04 13:04:58 +00:00
|
|
|
var entry = new CodeMap.CodeEntry(
|
2020-08-25 06:31:43 +00:00
|
|
|
endAddr - startAddr, name, 'SHARED_LIB');
|
2017-03-04 13:04:58 +00:00
|
|
|
this.codeMap_.addLibrary(startAddr, entry);
|
|
|
|
|
|
|
|
entry.codeId = this.codeEntries_.length;
|
2020-08-25 06:31:43 +00:00
|
|
|
this.codeEntries_.push({ name: entry.name, type: entry.type });
|
2017-03-04 13:04:58 +00:00
|
|
|
return entry;
|
|
|
|
};
|
|
|
|
|
2020-08-25 06:31:43 +00:00
|
|
|
JsonProfile.prototype.addStaticCode = function (
|
|
|
|
name, startAddr, endAddr) {
|
2017-03-04 13:04:58 +00:00
|
|
|
var entry = new CodeMap.CodeEntry(
|
2020-08-25 06:31:43 +00:00
|
|
|
endAddr - startAddr, name, 'CPP');
|
2017-03-04 13:04:58 +00:00
|
|
|
this.codeMap_.addStaticCode(startAddr, entry);
|
|
|
|
|
|
|
|
entry.codeId = this.codeEntries_.length;
|
2020-08-25 06:31:43 +00:00
|
|
|
this.codeEntries_.push({ name: entry.name, type: entry.type });
|
2017-03-04 13:04:58 +00:00
|
|
|
return entry;
|
|
|
|
};
|
|
|
|
|
2020-08-25 06:31:43 +00:00
|
|
|
JsonProfile.prototype.addCode = function (
|
|
|
|
kind, name, timestamp, start, size) {
|
2018-09-27 10:55:49 +00:00
|
|
|
let codeId = this.codeEntries_.length;
|
|
|
|
// Find out if we have a static code entry for the code. If yes, we will
|
|
|
|
// make sure it is written to the JSON file just once.
|
|
|
|
let staticEntry = this.codeMap_.findAddress(start);
|
|
|
|
if (staticEntry && staticEntry.entry.type === 'CPP') {
|
|
|
|
codeId = staticEntry.entry.codeId;
|
|
|
|
}
|
|
|
|
|
2017-03-04 13:04:58 +00:00
|
|
|
var entry = new CodeMap.CodeEntry(size, name, 'CODE');
|
|
|
|
this.codeMap_.addCode(start, entry);
|
|
|
|
|
2018-09-27 10:55:49 +00:00
|
|
|
entry.codeId = codeId;
|
|
|
|
this.codeEntries_[codeId] = {
|
2020-08-25 06:31:43 +00:00
|
|
|
name: entry.name,
|
2017-03-22 16:02:25 +00:00
|
|
|
timestamp: timestamp,
|
2020-08-25 06:31:43 +00:00
|
|
|
type: entry.type,
|
|
|
|
kind: kind
|
2018-09-27 10:55:49 +00:00
|
|
|
};
|
2017-03-04 13:04:58 +00:00
|
|
|
|
|
|
|
return entry;
|
|
|
|
};
|
|
|
|
|
2020-08-25 06:31:43 +00:00
|
|
|
JsonProfile.prototype.addFuncCode = function (
|
|
|
|
kind, name, timestamp, start, size, funcAddr, state) {
|
2017-03-04 13:04:58 +00:00
|
|
|
// As code and functions are in the same address space,
|
|
|
|
// it is safe to put them in a single code map.
|
|
|
|
var func = this.codeMap_.findDynamicEntryByStartAddress(funcAddr);
|
|
|
|
if (!func) {
|
|
|
|
var func = new CodeMap.CodeEntry(0, name, 'SFI');
|
|
|
|
this.codeMap_.addCode(funcAddr, func);
|
|
|
|
|
|
|
|
func.funcId = this.functionEntries_.length;
|
2020-08-25 06:31:43 +00:00
|
|
|
this.functionEntries_.push({ name: name, codes: [] });
|
2017-03-04 13:04:58 +00:00
|
|
|
} else if (func.name !== name) {
|
|
|
|
// Function object has been overwritten with a new one.
|
|
|
|
func.name = name;
|
|
|
|
|
|
|
|
func.funcId = this.functionEntries_.length;
|
2020-08-25 06:31:43 +00:00
|
|
|
this.functionEntries_.push({ name: name, codes: [] });
|
2017-03-04 13:04:58 +00:00
|
|
|
}
|
|
|
|
// TODO(jarin): Insert the code object into the SFI's code list.
|
|
|
|
var entry = this.codeMap_.findDynamicEntryByStartAddress(start);
|
|
|
|
if (entry) {
|
|
|
|
if (entry.size === size && entry.func === func) {
|
|
|
|
// Entry state has changed.
|
|
|
|
entry.state = state;
|
2020-01-23 10:31:41 +00:00
|
|
|
} else {
|
|
|
|
this.codeMap_.deleteCode(start);
|
|
|
|
entry = null;
|
2017-03-04 13:04:58 +00:00
|
|
|
}
|
2020-01-23 10:31:41 +00:00
|
|
|
}
|
|
|
|
if (!entry) {
|
|
|
|
entry = new CodeMap.CodeEntry(size, name, 'JS');
|
2017-03-04 13:04:58 +00:00
|
|
|
this.codeMap_.addCode(start, entry);
|
|
|
|
|
|
|
|
entry.codeId = this.codeEntries_.length;
|
|
|
|
|
|
|
|
this.functionEntries_[func.funcId].codes.push(entry.codeId);
|
|
|
|
|
|
|
|
if (state === 0) {
|
|
|
|
kind = "Builtin";
|
|
|
|
} else if (state === 1) {
|
|
|
|
kind = "Unopt";
|
|
|
|
} else if (state === 2) {
|
|
|
|
kind = "Opt";
|
|
|
|
}
|
|
|
|
|
|
|
|
this.codeEntries_.push({
|
2020-08-25 06:31:43 +00:00
|
|
|
name: entry.name,
|
|
|
|
type: entry.type,
|
|
|
|
kind: kind,
|
|
|
|
func: func.funcId,
|
|
|
|
tm: timestamp
|
2017-03-04 13:04:58 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
return entry;
|
|
|
|
};
|
|
|
|
|
2020-08-25 06:31:43 +00:00
|
|
|
JsonProfile.prototype.moveCode = function (from, to) {
|
2017-03-04 13:04:58 +00:00
|
|
|
try {
|
|
|
|
this.codeMap_.moveCode(from, to);
|
|
|
|
} catch (e) {
|
|
|
|
printErr("Move: unknown source " + from);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-08-25 06:31:43 +00:00
|
|
|
JsonProfile.prototype.addSourcePositions = function (
|
|
|
|
start, script, startPos, endPos, sourcePositions, inliningPositions,
|
|
|
|
inlinedFunctions) {
|
2017-07-27 19:46:32 +00:00
|
|
|
var entry = this.codeMap_.findDynamicEntryByStartAddress(start);
|
|
|
|
if (!entry) return;
|
|
|
|
var codeId = entry.codeId;
|
|
|
|
|
2018-08-31 09:50:07 +00:00
|
|
|
// Resolve the inlined functions list.
|
2017-07-27 19:46:32 +00:00
|
|
|
if (inlinedFunctions.length > 0) {
|
|
|
|
inlinedFunctions = inlinedFunctions.substring(1).split("S");
|
|
|
|
for (var i = 0; i < inlinedFunctions.length; i++) {
|
|
|
|
var funcAddr = parseInt(inlinedFunctions[i]);
|
|
|
|
var func = this.codeMap_.findDynamicEntryByStartAddress(funcAddr);
|
|
|
|
if (!func || func.funcId === undefined) {
|
|
|
|
printErr("Could not find function " + inlinedFunctions[i]);
|
|
|
|
inlinedFunctions[i] = null;
|
|
|
|
} else {
|
|
|
|
inlinedFunctions[i] = func.funcId;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
inlinedFunctions = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
this.codeEntries_[entry.codeId].source = {
|
2020-08-25 06:31:43 +00:00
|
|
|
script: script,
|
|
|
|
start: startPos,
|
|
|
|
end: endPos,
|
|
|
|
positions: sourcePositions,
|
|
|
|
inlined: inliningPositions,
|
|
|
|
fns: inlinedFunctions
|
2017-07-27 19:46:32 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-09-23 10:30:17 +00:00
|
|
|
JsonProfile.prototype.addScriptSource = function (id, url, source) {
|
|
|
|
this.scripts_[id] = new Script(id, url, source);
|
2017-07-27 19:46:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-08-25 06:31:43 +00:00
|
|
|
JsonProfile.prototype.deoptCode = function (
|
|
|
|
timestamp, code, inliningId, scriptOffset, bailoutType,
|
|
|
|
sourcePositionText, deoptReasonText) {
|
2017-03-22 16:02:25 +00:00
|
|
|
let entry = this.codeMap_.findDynamicEntryByStartAddress(code);
|
|
|
|
if (entry) {
|
|
|
|
let codeId = entry.codeId;
|
|
|
|
if (!this.codeEntries_[codeId].deopt) {
|
|
|
|
// Only add the deopt if there was no deopt before.
|
|
|
|
// The subsequent deoptimizations should be lazy deopts for
|
|
|
|
// other on-stack activations.
|
|
|
|
this.codeEntries_[codeId].deopt = {
|
2020-08-25 06:31:43 +00:00
|
|
|
tm: timestamp,
|
|
|
|
inliningId: inliningId,
|
|
|
|
scriptOffset: scriptOffset,
|
|
|
|
posText: sourcePositionText,
|
|
|
|
reason: deoptReasonText,
|
|
|
|
bailoutType: bailoutType
|
2017-03-22 16:02:25 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-08-25 06:31:43 +00:00
|
|
|
JsonProfile.prototype.deleteCode = function (start) {
|
2017-03-04 13:04:58 +00:00
|
|
|
try {
|
|
|
|
this.codeMap_.deleteCode(start);
|
|
|
|
} catch (e) {
|
|
|
|
printErr("Delete: unknown address " + start);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-08-25 06:31:43 +00:00
|
|
|
JsonProfile.prototype.moveFunc = function (from, to) {
|
2017-03-04 13:04:58 +00:00
|
|
|
if (this.codeMap_.findDynamicEntryByStartAddress(from)) {
|
|
|
|
this.codeMap_.moveCode(from, to);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-08-25 06:31:43 +00:00
|
|
|
JsonProfile.prototype.findEntry = function (addr) {
|
2017-03-04 13:04:58 +00:00
|
|
|
return this.codeMap_.findEntry(addr);
|
|
|
|
};
|
|
|
|
|
2020-08-25 06:31:43 +00:00
|
|
|
JsonProfile.prototype.recordTick = function (time_ns, vmState, stack) {
|
2017-03-04 13:04:58 +00:00
|
|
|
// TODO(jarin) Resolve the frame-less case (when top of stack is
|
|
|
|
// known code).
|
|
|
|
var processedStack = [];
|
|
|
|
for (var i = 0; i < stack.length; i++) {
|
|
|
|
var resolved = this.codeMap_.findAddress(stack[i]);
|
|
|
|
if (resolved) {
|
|
|
|
processedStack.push(resolved.entry.codeId, resolved.offset);
|
|
|
|
} else {
|
|
|
|
processedStack.push(-1, stack[i]);
|
|
|
|
}
|
|
|
|
}
|
2020-08-25 06:31:43 +00:00
|
|
|
this.ticks_.push({ tm: time_ns, vm: vmState, s: processedStack });
|
2017-03-04 13:04:58 +00:00
|
|
|
};
|
|
|
|
|
2017-07-27 19:46:32 +00:00
|
|
|
function writeJson(s) {
|
|
|
|
write(JSON.stringify(s, null, 2));
|
|
|
|
}
|
|
|
|
|
2020-08-25 06:31:43 +00:00
|
|
|
JsonProfile.prototype.writeJson = function () {
|
2017-03-21 10:58:24 +00:00
|
|
|
// Write out the JSON in a partially manual way to avoid creating too-large
|
|
|
|
// strings in one JSON.stringify call when there are a lot of ticks.
|
|
|
|
write('{\n')
|
2017-07-27 19:46:32 +00:00
|
|
|
|
|
|
|
write(' "code": ');
|
|
|
|
writeJson(this.codeEntries_);
|
|
|
|
write(',\n');
|
|
|
|
|
|
|
|
write(' "functions": ');
|
|
|
|
writeJson(this.functionEntries_);
|
|
|
|
write(',\n');
|
|
|
|
|
2017-03-21 10:58:24 +00:00
|
|
|
write(' "ticks": [\n');
|
|
|
|
for (var i = 0; i < this.ticks_.length; i++) {
|
2017-07-27 19:46:32 +00:00
|
|
|
write(' ');
|
|
|
|
writeJson(this.ticks_[i]);
|
2017-03-21 10:58:24 +00:00
|
|
|
if (i < this.ticks_.length - 1) {
|
|
|
|
write(',\n');
|
|
|
|
} else {
|
|
|
|
write('\n');
|
|
|
|
}
|
|
|
|
}
|
2017-07-27 19:46:32 +00:00
|
|
|
write(' ],\n');
|
|
|
|
|
|
|
|
write(' "scripts": ');
|
|
|
|
writeJson(this.scripts_);
|
|
|
|
|
2017-03-21 10:58:24 +00:00
|
|
|
write('}\n');
|
2017-03-04 13:04:58 +00:00
|
|
|
};
|