Shorten constructor names in JS tickprocessor.

As they are no more used in DevTools profiler, there is no
need to prefix them with "devtools.profiler" namespace.

Review URL: http://codereview.chromium.org/6456025

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6712 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 2f17f3e5
......@@ -30,7 +30,7 @@
function newCodeEntry(size, name) {
return new devtools.profiler.CodeMap.CodeEntry(size, name);
return new CodeMap.CodeEntry(size, name);
};
......@@ -47,7 +47,7 @@ function assertNoEntry(codeMap, addr) {
(function testLibrariesAndStaticCode() {
var codeMap = new devtools.profiler.CodeMap();
var codeMap = new CodeMap();
codeMap.addLibrary(0x1500, newCodeEntry(0x3000, 'lib1'));
codeMap.addLibrary(0x15500, newCodeEntry(0x5000, 'lib2'));
codeMap.addLibrary(0x155500, newCodeEntry(0x10000, 'lib3'));
......@@ -97,7 +97,7 @@ function assertNoEntry(codeMap, addr) {
(function testDynamicCode() {
var codeMap = new devtools.profiler.CodeMap();
var codeMap = new CodeMap();
codeMap.addCode(0x1500, newCodeEntry(0x200, 'code1'));
codeMap.addCode(0x1700, newCodeEntry(0x100, 'code2'));
codeMap.addCode(0x1900, newCodeEntry(0x50, 'code3'));
......@@ -123,7 +123,7 @@ function assertNoEntry(codeMap, addr) {
(function testCodeMovesAndDeletions() {
var codeMap = new devtools.profiler.CodeMap();
var codeMap = new CodeMap();
codeMap.addCode(0x1500, newCodeEntry(0x200, 'code1'));
codeMap.addCode(0x1700, newCodeEntry(0x100, 'code2'));
assertEntry(codeMap, 'code1', 0x1500);
......@@ -139,7 +139,7 @@ function assertNoEntry(codeMap, addr) {
(function testDynamicNamesDuplicates() {
var codeMap = new devtools.profiler.CodeMap();
var codeMap = new CodeMap();
// Code entries with same names but different addresses.
codeMap.addCode(0x1500, newCodeEntry(0x200, 'code'));
codeMap.addCode(0x1700, newCodeEntry(0x100, 'code'));
......@@ -152,7 +152,7 @@ function assertNoEntry(codeMap, addr) {
(function testStaticEntriesExport() {
var codeMap = new devtools.profiler.CodeMap();
var codeMap = new CodeMap();
codeMap.addStaticCode(0x1500, newCodeEntry(0x3000, 'lib1'));
codeMap.addStaticCode(0x15500, newCodeEntry(0x5000, 'lib2'));
codeMap.addStaticCode(0x155500, newCodeEntry(0x10000, 'lib3'));
......@@ -163,7 +163,7 @@ function assertNoEntry(codeMap, addr) {
(function testDynamicEntriesExport() {
var codeMap = new devtools.profiler.CodeMap();
var codeMap = new CodeMap();
codeMap.addCode(0x1500, newCodeEntry(0x200, 'code1'));
codeMap.addCode(0x1700, newCodeEntry(0x100, 'code2'));
codeMap.addCode(0x1900, newCodeEntry(0x50, 'code3'));
......
......@@ -28,7 +28,7 @@
// Load CSV parser implementation from <project root>/tools.
// Files: tools/csvparser.js
var parser = new devtools.profiler.CsvParser();
var parser = new CsvParser();
assertEquals(
[],
......
......@@ -58,7 +58,7 @@ function countNodes(profile, traverseFunc) {
function ProfileTestDriver() {
this.profile = new devtools.profiler.Profile();
this.profile = new Profile();
this.stack_ = [];
this.addFunctions_();
};
......
......@@ -30,7 +30,7 @@
function createNode(name, time, opt_parent) {
var node = new devtools.profiler.ProfileView.Node(name, time, time, null);
var node = new ProfileView.Node(name, time, time, null);
if (opt_parent) {
opt_parent.addChild(node);
}
......@@ -61,7 +61,7 @@ function createNode(name, time, opt_parent) {
createNode('d', 4, b3);
createNode('d', 2, b3);
var view = new devtools.profiler.ProfileView(root);
var view = new ProfileView(root);
var flatTree = [];
function fillFlatTree(node) {
......
......@@ -30,7 +30,7 @@
(function testIsEmpty() {
var tree = new goog.structs.SplayTree();
var tree = new SplayTree();
assertTrue(tree.isEmpty());
tree.insert(0, 'value');
assertFalse(tree.isEmpty());
......@@ -38,7 +38,7 @@
(function testExportValues() {
var tree = new goog.structs.SplayTree();
var tree = new SplayTree();
assertArrayEquals([], tree.exportValues());
tree.insert(0, 'value');
assertArrayEquals(['value'], tree.exportValues());
......@@ -79,7 +79,7 @@ function createSampleTree() {
(function testSplay() {
var tree = new goog.structs.SplayTree();
var tree = new SplayTree();
tree.root_ = createSampleTree();
assertArrayEquals(['50', '30', '60', '10', '40', '90', '20', '70', '100', '15', '80'],
tree.exportValues());
......@@ -93,7 +93,7 @@ function createSampleTree() {
(function testInsert() {
var tree = new goog.structs.SplayTree();
var tree = new SplayTree();
tree.insert(5, 'root');
tree.insert(3, 'left');
assertArrayEquals(['left', 'root'], tree.exportValues());
......@@ -103,7 +103,7 @@ function createSampleTree() {
(function testFind() {
var tree = new goog.structs.SplayTree();
var tree = new SplayTree();
tree.insert(5, 'root');
tree.insert(3, 'left');
tree.insert(7, 'right');
......@@ -117,7 +117,7 @@ function createSampleTree() {
(function testFindMin() {
var tree = new goog.structs.SplayTree();
var tree = new SplayTree();
assertEquals(null, tree.findMin());
tree.insert(5, 'root');
tree.insert(3, 'left');
......@@ -127,7 +127,7 @@ function createSampleTree() {
(function testFindMax() {
var tree = new goog.structs.SplayTree();
var tree = new SplayTree();
assertEquals(null, tree.findMax());
tree.insert(5, 'root');
tree.insert(3, 'left');
......@@ -137,7 +137,7 @@ function createSampleTree() {
(function testFindGreatestLessThan() {
var tree = new goog.structs.SplayTree();
var tree = new SplayTree();
assertEquals(null, tree.findGreatestLessThan(10));
tree.insert(5, 'root');
tree.insert(3, 'left');
......@@ -151,7 +151,7 @@ function createSampleTree() {
(function testRemove() {
var tree = new goog.structs.SplayTree();
var tree = new SplayTree();
assertThrows('tree.remove(5)');
tree.insert(5, 'root');
tree.insert(3, 'left');
......
......@@ -26,36 +26,31 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Initlialize namespaces
var devtools = devtools || {};
devtools.profiler = devtools.profiler || {};
/**
* Constructs a mapper that maps addresses into code entries.
*
* @constructor
*/
devtools.profiler.CodeMap = function() {
function CodeMap() {
/**
* Dynamic code entries. Used for JIT compiled code.
*/
this.dynamics_ = new goog.structs.SplayTree();
this.dynamics_ = new SplayTree();
/**
* Name generator for entries having duplicate names.
*/
this.dynamicsNameGen_ = new devtools.profiler.CodeMap.NameGenerator();
this.dynamicsNameGen_ = new CodeMap.NameGenerator();
/**
* Static code entries. Used for statically compiled code.
*/
this.statics_ = new goog.structs.SplayTree();
this.statics_ = new SplayTree();
/**
* Libraries entries. Used for the whole static code libraries.
*/
this.libraries_ = new goog.structs.SplayTree();
this.libraries_ = new SplayTree();
/**
* Map of memory pages occupied with static code.
......@@ -67,23 +62,23 @@ devtools.profiler.CodeMap = function() {
/**
* The number of alignment bits in a page address.
*/
devtools.profiler.CodeMap.PAGE_ALIGNMENT = 12;
CodeMap.PAGE_ALIGNMENT = 12;
/**
* Page size in bytes.
*/
devtools.profiler.CodeMap.PAGE_SIZE =
1 << devtools.profiler.CodeMap.PAGE_ALIGNMENT;
CodeMap.PAGE_SIZE =
1 << CodeMap.PAGE_ALIGNMENT;
/**
* Adds a dynamic (i.e. moveable and discardable) code entry.
*
* @param {number} start The starting address.
* @param {devtools.profiler.CodeMap.CodeEntry} codeEntry Code entry object.
* @param {CodeMap.CodeEntry} codeEntry Code entry object.
*/
devtools.profiler.CodeMap.prototype.addCode = function(start, codeEntry) {
CodeMap.prototype.addCode = function(start, codeEntry) {
this.dynamics_.insert(start, codeEntry);
};
......@@ -95,7 +90,7 @@ devtools.profiler.CodeMap.prototype.addCode = function(start, codeEntry) {
* @param {number} from The starting address of the entry being moved.
* @param {number} to The destination address.
*/
devtools.profiler.CodeMap.prototype.moveCode = function(from, to) {
CodeMap.prototype.moveCode = function(from, to) {
var removedNode = this.dynamics_.remove(from);
this.dynamics_.insert(to, removedNode.value);
};
......@@ -107,7 +102,7 @@ devtools.profiler.CodeMap.prototype.moveCode = function(from, to) {
*
* @param {number} start The starting address of the entry being deleted.
*/
devtools.profiler.CodeMap.prototype.deleteCode = function(start) {
CodeMap.prototype.deleteCode = function(start) {
var removedNode = this.dynamics_.remove(start);
};
......@@ -116,9 +111,9 @@ devtools.profiler.CodeMap.prototype.deleteCode = function(start) {
* Adds a library entry.
*
* @param {number} start The starting address.
* @param {devtools.profiler.CodeMap.CodeEntry} codeEntry Code entry object.
* @param {CodeMap.CodeEntry} codeEntry Code entry object.
*/
devtools.profiler.CodeMap.prototype.addLibrary = function(
CodeMap.prototype.addLibrary = function(
start, codeEntry) {
this.markPages_(start, start + codeEntry.size);
this.libraries_.insert(start, codeEntry);
......@@ -129,9 +124,9 @@ devtools.profiler.CodeMap.prototype.addLibrary = function(
* Adds a static code entry.
*
* @param {number} start The starting address.
* @param {devtools.profiler.CodeMap.CodeEntry} codeEntry Code entry object.
* @param {CodeMap.CodeEntry} codeEntry Code entry object.
*/
devtools.profiler.CodeMap.prototype.addStaticCode = function(
CodeMap.prototype.addStaticCode = function(
start, codeEntry) {
this.statics_.insert(start, codeEntry);
};
......@@ -140,10 +135,10 @@ devtools.profiler.CodeMap.prototype.addStaticCode = function(
/**
* @private
*/
devtools.profiler.CodeMap.prototype.markPages_ = function(start, end) {
CodeMap.prototype.markPages_ = function(start, end) {
for (var addr = start; addr <= end;
addr += devtools.profiler.CodeMap.PAGE_SIZE) {
this.pages_[addr >>> devtools.profiler.CodeMap.PAGE_ALIGNMENT] = 1;
addr += CodeMap.PAGE_SIZE) {
this.pages_[addr >>> CodeMap.PAGE_ALIGNMENT] = 1;
}
};
......@@ -151,7 +146,7 @@ devtools.profiler.CodeMap.prototype.markPages_ = function(start, end) {
/**
* @private
*/
devtools.profiler.CodeMap.prototype.isAddressBelongsTo_ = function(addr, node) {
CodeMap.prototype.isAddressBelongsTo_ = function(addr, node) {
return addr >= node.key && addr < (node.key + node.value.size);
};
......@@ -159,7 +154,7 @@ devtools.profiler.CodeMap.prototype.isAddressBelongsTo_ = function(addr, node) {
/**
* @private
*/
devtools.profiler.CodeMap.prototype.findInTree_ = function(tree, addr) {
CodeMap.prototype.findInTree_ = function(tree, addr) {
var node = tree.findGreatestLessThan(addr);
return node && this.isAddressBelongsTo_(addr, node) ? node.value : null;
};
......@@ -171,8 +166,8 @@ devtools.profiler.CodeMap.prototype.findInTree_ = function(tree, addr) {
*
* @param {number} addr Address.
*/
devtools.profiler.CodeMap.prototype.findEntry = function(addr) {
var pageAddr = addr >>> devtools.profiler.CodeMap.PAGE_ALIGNMENT;
CodeMap.prototype.findEntry = function(addr) {
var pageAddr = addr >>> CodeMap.PAGE_ALIGNMENT;
if (pageAddr in this.pages_) {
// Static code entries can contain "holes" of unnamed code.
// In this case, the whole library is assigned to this address.
......@@ -200,7 +195,7 @@ devtools.profiler.CodeMap.prototype.findEntry = function(addr) {
*
* @param {number} addr Address.
*/
devtools.profiler.CodeMap.prototype.findDynamicEntryByStartAddress =
CodeMap.prototype.findDynamicEntryByStartAddress =
function(addr) {
var node = this.dynamics_.find(addr);
return node ? node.value : null;
......@@ -210,7 +205,7 @@ devtools.profiler.CodeMap.prototype.findDynamicEntryByStartAddress =
/**
* Returns an array of all dynamic code entries.
*/
devtools.profiler.CodeMap.prototype.getAllDynamicEntries = function() {
CodeMap.prototype.getAllDynamicEntries = function() {
return this.dynamics_.exportValues();
};
......@@ -218,7 +213,7 @@ devtools.profiler.CodeMap.prototype.getAllDynamicEntries = function() {
/**
* Returns an array of all static code entries.
*/
devtools.profiler.CodeMap.prototype.getAllStaticEntries = function() {
CodeMap.prototype.getAllStaticEntries = function() {
return this.statics_.exportValues();
};
......@@ -226,7 +221,7 @@ devtools.profiler.CodeMap.prototype.getAllStaticEntries = function() {
/**
* Returns an array of all libraries entries.
*/
devtools.profiler.CodeMap.prototype.getAllLibrariesEntries = function() {
CodeMap.prototype.getAllLibrariesEntries = function() {
return this.libraries_.exportValues();
};
......@@ -238,29 +233,29 @@ devtools.profiler.CodeMap.prototype.getAllLibrariesEntries = function() {
* @param {string} opt_name Code entry name.
* @constructor
*/
devtools.profiler.CodeMap.CodeEntry = function(size, opt_name) {
CodeMap.CodeEntry = function(size, opt_name) {
this.size = size;
this.name = opt_name || '';
this.nameUpdated_ = false;
};
devtools.profiler.CodeMap.CodeEntry.prototype.getName = function() {
CodeMap.CodeEntry.prototype.getName = function() {
return this.name;
};
devtools.profiler.CodeMap.CodeEntry.prototype.toString = function() {
CodeMap.CodeEntry.prototype.toString = function() {
return this.name + ': ' + this.size.toString(16);
};
devtools.profiler.CodeMap.NameGenerator = function() {
CodeMap.NameGenerator = function() {
this.knownNames_ = {};
};
devtools.profiler.CodeMap.NameGenerator.prototype.getName = function(name) {
CodeMap.NameGenerator.prototype.getName = function(name) {
if (!(name in this.knownNames_)) {
this.knownNames_[name] = 0;
return name;
......
......@@ -26,15 +26,10 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Initlialize namespaces.
var devtools = devtools || {};
devtools.profiler = devtools.profiler || {};
/**
* Creates a CSV lines parser.
*/
devtools.profiler.CsvParser = function() {
function CsvParser() {
};
......@@ -42,14 +37,14 @@ devtools.profiler.CsvParser = function() {
* A regex for matching a CSV field.
* @private
*/
devtools.profiler.CsvParser.CSV_FIELD_RE_ = /^"((?:[^"]|"")*)"|([^,]*)/;
CsvParser.CSV_FIELD_RE_ = /^"((?:[^"]|"")*)"|([^,]*)/;
/**
* A regex for matching a double quote.
* @private
*/
devtools.profiler.CsvParser.DOUBLE_QUOTE_RE_ = /""/g;
CsvParser.DOUBLE_QUOTE_RE_ = /""/g;
/**
......@@ -57,9 +52,9 @@ devtools.profiler.CsvParser.DOUBLE_QUOTE_RE_ = /""/g;
*
* @param {string} line Input line.
*/
devtools.profiler.CsvParser.prototype.parseLine = function(line) {
var fieldRe = devtools.profiler.CsvParser.CSV_FIELD_RE_;
var doubleQuoteRe = devtools.profiler.CsvParser.DOUBLE_QUOTE_RE_;
CsvParser.prototype.parseLine = function(line) {
var fieldRe = CsvParser.CSV_FIELD_RE_;
var doubleQuoteRe = CsvParser.DOUBLE_QUOTE_RE_;
var pos = 0;
var endPos = line.length;
var fields = [];
......
......@@ -29,10 +29,6 @@
* @fileoverview Log Reader is used to process log file produced by V8.
*/
// Initlialize namespaces
var devtools = devtools || {};
devtools.profiler = devtools.profiler || {};
/**
* Base class for processing log files.
......@@ -41,7 +37,7 @@ devtools.profiler = devtools.profiler || {};
* log records.
* @constructor
*/
devtools.profiler.LogReader = function(dispatchTable) {
function LogReader(dispatchTable) {
/**
* @type {Array.<Object>}
*/
......@@ -55,9 +51,9 @@ devtools.profiler.LogReader = function(dispatchTable) {
/**
* CSV lines parser.
* @type {devtools.profiler.CsvParser}
* @type {CsvParser}
*/
this.csvParser_ = new devtools.profiler.CsvParser();
this.csvParser_ = new CsvParser();
};
......@@ -66,7 +62,7 @@ devtools.profiler.LogReader = function(dispatchTable) {
*
* @param {string} str Error message.
*/
devtools.profiler.LogReader.prototype.printError = function(str) {
LogReader.prototype.printError = function(str) {
// Do nothing.
};
......@@ -76,7 +72,7 @@ devtools.profiler.LogReader.prototype.printError = function(str) {
*
* @param {string} chunk A portion of log.
*/
devtools.profiler.LogReader.prototype.processLogChunk = function(chunk) {
LogReader.prototype.processLogChunk = function(chunk) {
this.processLog_(chunk.split('\n'));
};
......@@ -86,7 +82,7 @@ devtools.profiler.LogReader.prototype.processLogChunk = function(chunk) {
*
* @param {string} line A line of log.
*/
devtools.profiler.LogReader.prototype.processLogLine = function(line) {
LogReader.prototype.processLogLine = function(line) {
this.processLog_([line]);
};
......@@ -99,7 +95,7 @@ devtools.profiler.LogReader.prototype.processLogLine = function(line) {
* @param {Array.<string>} stack String representation of a stack.
* @return {Array.<number>} Processed stack.
*/
devtools.profiler.LogReader.prototype.processStack = function(pc, func, stack) {
LogReader.prototype.processStack = function(pc, func, stack) {
var fullStack = func ? [pc, func] : [pc];
var prevFrame = pc;
for (var i = 0, n = stack.length; i < n; ++i) {
......@@ -124,7 +120,7 @@ devtools.profiler.LogReader.prototype.processStack = function(pc, func, stack) {
* @param {!Object} dispatch Dispatch record.
* @return {boolean} True if dispatch must be skipped.
*/
devtools.profiler.LogReader.prototype.skipDispatch = function(dispatch) {
LogReader.prototype.skipDispatch = function(dispatch) {
return false;
};
......@@ -135,7 +131,7 @@ devtools.profiler.LogReader.prototype.skipDispatch = function(dispatch) {
* @param {Array.<string>} fields Log record.
* @private
*/
devtools.profiler.LogReader.prototype.dispatchLogRow_ = function(fields) {
LogReader.prototype.dispatchLogRow_ = function(fields) {
// Obtain the dispatch.
var command = fields[0];
if (!(command in this.dispatchTable_)) {
......@@ -173,7 +169,7 @@ devtools.profiler.LogReader.prototype.dispatchLogRow_ = function(fields) {
* @param {Array.<string>} lines Log lines.
* @private
*/
devtools.profiler.LogReader.prototype.processLog_ = function(lines) {
LogReader.prototype.processLog_ = function(lines) {
for (var i = 0, n = lines.length; i < n; ++i, ++this.lineNum_) {
var line = lines[i];
if (!line) {
......
This diff is collapsed.
......@@ -26,18 +26,13 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Initlialize namespaces
var devtools = devtools || {};
devtools.profiler = devtools.profiler || {};
/**
* Creates a Profile View builder object.
*
* @param {number} samplingRate Number of ms between profiler ticks.
* @constructor
*/
devtools.profiler.ViewBuilder = function(samplingRate) {
function ViewBuilder(samplingRate) {
this.samplingRate = samplingRate;
};
......@@ -45,11 +40,11 @@ devtools.profiler.ViewBuilder = function(samplingRate) {
/**
* Builds a profile view for the specified call tree.
*
* @param {devtools.profiler.CallTree} callTree A call tree.
* @param {CallTree} callTree A call tree.
* @param {boolean} opt_bottomUpViewWeights Whether remapping
* of self weights for a bottom up view is needed.
*/
devtools.profiler.ViewBuilder.prototype.buildView = function(
ViewBuilder.prototype.buildView = function(
callTree, opt_bottomUpViewWeights) {
var head;
var samplingRate = this.samplingRate;
......@@ -80,11 +75,11 @@ devtools.profiler.ViewBuilder.prototype.buildView = function(
/**
* Factory method for a profile view.
*
* @param {devtools.profiler.ProfileView.Node} head View head node.
* @return {devtools.profiler.ProfileView} Profile view.
* @param {ProfileView.Node} head View head node.
* @return {ProfileView} Profile view.
*/
devtools.profiler.ViewBuilder.prototype.createView = function(head) {
return new devtools.profiler.ProfileView(head);
ViewBuilder.prototype.createView = function(head) {
return new ProfileView(head);
};
......@@ -97,12 +92,12 @@ devtools.profiler.ViewBuilder.prototype.createView = function(head) {
* profile they can be either callees or callers.)
* @param {number} selfTime Amount of time that application spent in the
* corresponding function only.
* @param {devtools.profiler.ProfileView.Node} head Profile view head.
* @return {devtools.profiler.ProfileView.Node} Profile view node.
* @param {ProfileView.Node} head Profile view head.
* @return {ProfileView.Node} Profile view node.
*/
devtools.profiler.ViewBuilder.prototype.createViewNode = function(
ViewBuilder.prototype.createViewNode = function(
funcName, totalTime, selfTime, head) {
return new devtools.profiler.ProfileView.Node(
return new ProfileView.Node(
funcName, totalTime, selfTime, head);
};
......@@ -111,10 +106,10 @@ devtools.profiler.ViewBuilder.prototype.createViewNode = function(
* Creates a Profile View object. It allows to perform sorting
* and filtering actions on the profile.
*
* @param {devtools.profiler.ProfileView.Node} head Head (root) node.
* @param {ProfileView.Node} head Head (root) node.
* @constructor
*/
devtools.profiler.ProfileView = function(head) {
function ProfileView(head) {
this.head = head;
};
......@@ -122,11 +117,11 @@ devtools.profiler.ProfileView = function(head) {
/**
* Sorts the profile view using the specified sort function.
*
* @param {function(devtools.profiler.ProfileView.Node,
* devtools.profiler.ProfileView.Node):number} sortFunc A sorting
* @param {function(ProfileView.Node,
* ProfileView.Node):number} sortFunc A sorting
* functions. Must comply with Array.sort sorting function requirements.
*/
devtools.profiler.ProfileView.prototype.sort = function(sortFunc) {
ProfileView.prototype.sort = function(sortFunc) {
this.traverse(function (node) {
node.sortChildren(sortFunc);
});
......@@ -136,9 +131,9 @@ devtools.profiler.ProfileView.prototype.sort = function(sortFunc) {
/**
* Traverses profile view nodes in preorder.
*
* @param {function(devtools.profiler.ProfileView.Node)} f Visitor function.
* @param {function(ProfileView.Node)} f Visitor function.
*/
devtools.profiler.ProfileView.prototype.traverse = function(f) {
ProfileView.prototype.traverse = function(f) {
var nodesToTraverse = new ConsArray();
nodesToTraverse.concat([this.head]);
while (!nodesToTraverse.atEnd()) {
......@@ -159,10 +154,10 @@ devtools.profiler.ProfileView.prototype.traverse = function(f) {
* profile they can be either callees or callers.)
* @param {number} selfTime Amount of time that application spent in the
* corresponding function only.
* @param {devtools.profiler.ProfileView.Node} head Profile view head.
* @param {ProfileView.Node} head Profile view head.
* @constructor
*/
devtools.profiler.ProfileView.Node = function(
ProfileView.Node = function(
internalFuncName, totalTime, selfTime, head) {
this.internalFuncName = internalFuncName;
this.totalTime = totalTime;
......@@ -176,7 +171,7 @@ devtools.profiler.ProfileView.Node = function(
/**
* Returns a share of the function's total time in application's total time.
*/
devtools.profiler.ProfileView.Node.prototype.__defineGetter__(
ProfileView.Node.prototype.__defineGetter__(
'totalPercent',
function() { return this.totalTime /
(this.head ? this.head.totalTime : this.totalTime) * 100.0; });
......@@ -185,7 +180,7 @@ devtools.profiler.ProfileView.Node.prototype.__defineGetter__(
/**
* Returns a share of the function's self time in application's total time.
*/
devtools.profiler.ProfileView.Node.prototype.__defineGetter__(
ProfileView.Node.prototype.__defineGetter__(
'selfPercent',
function() { return this.selfTime /
(this.head ? this.head.totalTime : this.totalTime) * 100.0; });
......@@ -194,7 +189,7 @@ devtools.profiler.ProfileView.Node.prototype.__defineGetter__(
/**
* Returns a share of the function's total time in its parent's total time.
*/
devtools.profiler.ProfileView.Node.prototype.__defineGetter__(
ProfileView.Node.prototype.__defineGetter__(
'parentTotalPercent',
function() { return this.totalTime /
(this.parent ? this.parent.totalTime : this.totalTime) * 100.0; });
......@@ -203,9 +198,9 @@ devtools.profiler.ProfileView.Node.prototype.__defineGetter__(
/**
* Adds a child to the node.
*
* @param {devtools.profiler.ProfileView.Node} node Child node.
* @param {ProfileView.Node} node Child node.
*/
devtools.profiler.ProfileView.Node.prototype.addChild = function(node) {
ProfileView.Node.prototype.addChild = function(node) {
node.parent = this;
this.children.push(node);
};
......@@ -214,11 +209,11 @@ devtools.profiler.ProfileView.Node.prototype.addChild = function(node) {
/**
* Sorts all the node's children recursively.
*
* @param {function(devtools.profiler.ProfileView.Node,
* devtools.profiler.ProfileView.Node):number} sortFunc A sorting
* @param {function(ProfileView.Node,
* ProfileView.Node):number} sortFunc A sorting
* functions. Must comply with Array.sort sorting function requirements.
*/
devtools.profiler.ProfileView.Node.prototype.sortChildren = function(
ProfileView.Node.prototype.sortChildren = function(
sortFunc) {
this.children.sort(sortFunc);
};
......@@ -26,12 +26,6 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// A namespace stub. It will become more clear how to declare it properly
// during integration of this script into Dev Tools.
var goog = goog || {};
goog.structs = goog.structs || {};
/**
* Constructs a Splay tree. A splay tree is a self-balancing binary
* search tree with the additional property that recently accessed
......@@ -40,23 +34,23 @@ goog.structs = goog.structs || {};
*
* @constructor
*/
goog.structs.SplayTree = function() {
function SplayTree() {
};
/**
* Pointer to the root node of the tree.
*
* @type {goog.structs.SplayTree.Node}
* @type {SplayTree.Node}
* @private
*/
goog.structs.SplayTree.prototype.root_ = null;
SplayTree.prototype.root_ = null;
/**
* @return {boolean} Whether the tree is empty.
*/
goog.structs.SplayTree.prototype.isEmpty = function() {
SplayTree.prototype.isEmpty = function() {
return !this.root_;
};
......@@ -70,9 +64,9 @@ goog.structs.SplayTree.prototype.isEmpty = function() {
* @param {number} key Key to insert into the tree.
* @param {*} value Value to insert into the tree.
*/
goog.structs.SplayTree.prototype.insert = function(key, value) {
SplayTree.prototype.insert = function(key, value) {
if (this.isEmpty()) {
this.root_ = new goog.structs.SplayTree.Node(key, value);
this.root_ = new SplayTree.Node(key, value);
return;
}
// Splay on the key to move the last node on the search path for
......@@ -81,7 +75,7 @@ goog.structs.SplayTree.prototype.insert = function(key, value) {
if (this.root_.key == key) {
return;
}
var node = new goog.structs.SplayTree.Node(key, value);
var node = new SplayTree.Node(key, value);
if (key > this.root_.key) {
node.left = this.root_;
node.right = this.root_.right;
......@@ -101,9 +95,9 @@ goog.structs.SplayTree.prototype.insert = function(key, value) {
* key is not found, an exception is thrown.
*
* @param {number} key Key to find and remove from the tree.
* @return {goog.structs.SplayTree.Node} The removed node.
* @return {SplayTree.Node} The removed node.
*/
goog.structs.SplayTree.prototype.remove = function(key) {
SplayTree.prototype.remove = function(key) {
if (this.isEmpty()) {
throw Error('Key not found: ' + key);
}
......@@ -132,9 +126,9 @@ goog.structs.SplayTree.prototype.remove = function(key) {
* a node with the specified key.
*
* @param {number} key Key to find in the tree.
* @return {goog.structs.SplayTree.Node} Node having the specified key.
* @return {SplayTree.Node} Node having the specified key.
*/
goog.structs.SplayTree.prototype.find = function(key) {
SplayTree.prototype.find = function(key) {
if (this.isEmpty()) {
return null;
}
......@@ -144,9 +138,9 @@ goog.structs.SplayTree.prototype.find = function(key) {
/**
* @return {goog.structs.SplayTree.Node} Node having the minimum key value.
* @return {SplayTree.Node} Node having the minimum key value.
*/
goog.structs.SplayTree.prototype.findMin = function() {
SplayTree.prototype.findMin = function() {
if (this.isEmpty()) {
return null;
}
......@@ -159,9 +153,9 @@ goog.structs.SplayTree.prototype.findMin = function() {
/**
* @return {goog.structs.SplayTree.Node} Node having the maximum key value.
* @return {SplayTree.Node} Node having the maximum key value.
*/
goog.structs.SplayTree.prototype.findMax = function(opt_startNode) {
SplayTree.prototype.findMax = function(opt_startNode) {
if (this.isEmpty()) {
return null;
}
......@@ -174,10 +168,10 @@ goog.structs.SplayTree.prototype.findMax = function(opt_startNode) {
/**
* @return {goog.structs.SplayTree.Node} Node having the maximum key value that
* @return {SplayTree.Node} Node having the maximum key value that
* is less or equal to the specified key value.
*/
goog.structs.SplayTree.prototype.findGreatestLessThan = function(key) {
SplayTree.prototype.findGreatestLessThan = function(key) {
if (this.isEmpty()) {
return null;
}
......@@ -199,7 +193,7 @@ goog.structs.SplayTree.prototype.findGreatestLessThan = function(key) {
/**
* @return {Array<*>} An array containing all the values of tree's nodes.
*/
goog.structs.SplayTree.prototype.exportValues = function() {
SplayTree.prototype.exportValues = function() {
var result = [];
this.traverse_(function(node) { result.push(node.value); });
return result;
......@@ -216,7 +210,7 @@ goog.structs.SplayTree.prototype.exportValues = function() {
* @param {number} key Key to splay the tree on.
* @private
*/
goog.structs.SplayTree.prototype.splay_ = function(key) {
SplayTree.prototype.splay_ = function(key) {
if (this.isEmpty()) {
return;
}
......@@ -226,7 +220,7 @@ goog.structs.SplayTree.prototype.splay_ = function(key) {
// will hold the R tree of the algorithm. Using a dummy node, left
// and right will always be nodes and we avoid special cases.
var dummy, left, right;
dummy = left = right = new goog.structs.SplayTree.Node(null, null);
dummy = left = right = new SplayTree.Node(null, null);
var current = this.root_;
while (true) {
if (key < current.key) {
......@@ -281,10 +275,10 @@ goog.structs.SplayTree.prototype.splay_ = function(key) {
/**
* Performs a preorder traversal of the tree.
*
* @param {function(goog.structs.SplayTree.Node)} f Visitor function.
* @param {function(SplayTree.Node)} f Visitor function.
* @private
*/
goog.structs.SplayTree.prototype.traverse_ = function(f) {
SplayTree.prototype.traverse_ = function(f) {
var nodesToVisit = [this.root_];
while (nodesToVisit.length > 0) {
var node = nodesToVisit.shift();
......@@ -304,19 +298,19 @@ goog.structs.SplayTree.prototype.traverse_ = function(f) {
* @param {number} key Key.
* @param {*} value Value.
*/
goog.structs.SplayTree.Node = function(key, value) {
SplayTree.Node = function(key, value) {
this.key = key;
this.value = value;
};
/**
* @type {goog.structs.SplayTree.Node}
* @type {SplayTree.Node}
*/
goog.structs.SplayTree.Node.prototype.left = null;
SplayTree.Node.prototype.left = null;
/**
* @type {goog.structs.SplayTree.Node}
* @type {SplayTree.Node}
*/
goog.structs.SplayTree.Node.prototype.right = null;
SplayTree.Node.prototype.right = null;
......@@ -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,13 +57,8 @@ function readFile(fileName) {
}
function inherits(childCtor, parentCtor) {
childCtor.prototype.__proto__ = parentCtor.prototype;
};
function SnapshotLogProcessor() {
devtools.profiler.LogReader.call(this, {
LogReader.call(this, {
'code-creation': {
parsers: [null, parseInt, parseInt, null],
processor: this.processCodeCreation },
......@@ -72,8 +72,8 @@ function SnapshotLogProcessor() {
'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,10 +86,10 @@ function SnapshotLogProcessor() {
}
};
this.profile_ = new Profile();
this.profile_ = new V8Profile();
this.serializedEntries_ = [];
}
inherits(SnapshotLogProcessor, devtools.profiler.LogReader);
inherits(SnapshotLogProcessor, LogReader);
SnapshotLogProcessor.prototype.processCodeCreation = function(
......@@ -127,7 +127,7 @@ SnapshotLogProcessor.prototype.getSerializedEntryName = function(pos) {
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': {
......@@ -172,9 +172,9 @@ function TickProcessor(
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 +193,16 @@ function TickProcessor(
}
};
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 = {
......@@ -356,7 +356,7 @@ TickProcessor.prototype.processTick = function(pc, sp, func, vmState, stack) {
TickProcessor.prototype.processHeapSampleBegin = function(space, state, ticks) {
if (space != 'Heap') return;
this.currentProducerProfile_ = new devtools.profiler.CallTree();
this.currentProducerProfile_ = new CallTree();
};
......
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