Permalink
Browse files

Revert accidental r9229 and r9230

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@9231 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
  • Loading branch information...
1 parent 42d4ae4 commit bcd2725f0722882371ce35538330547d43a73c7b mikhail.naganov@gmail.com committed Sep 12, 2011
Showing with 45 additions and 54 deletions.
  1. +0 −14 test/mjsunit/tools/codemap.js
  2. +0 −31 tools/codemap.js
  3. +24 −7 tools/profile.js
  4. +21 −2 tools/tickprocessor.js
@@ -138,20 +138,6 @@ function assertNoEntry(codeMap, addr) {
})();
-(function testDeadCodeCleanups() {
- var codeMap = new CodeMap();
- codeMap.addCode(0x1500, newCodeEntry(0x200, 'code1'));
- codeMap.addCode(0x1700, newCodeEntry(0x100, 'code2'));
- assertEntry(codeMap, 'code1', 0x1500);
- assertEntry(codeMap, 'code2', 0x1700);
- codeMap.moveCode(0x1500, 0x1700); // Deprecate code2.
- assertEntry(codeMap, 'code1', 0x1700);
- codeMap.addCode(0x1750, newCodeEntry(0x100, 'code3'));
- assertNoEntry(codeMap, 0x1700);
- assertEntry(codeMap, 'code3', 0x1750);
-})();
-
-
(function testDynamicNamesDuplicates() {
var codeMap = new CodeMap();
// Code entries with same names but different addresses.
View
@@ -79,7 +79,6 @@ CodeMap.PAGE_SIZE =
* @param {CodeMap.CodeEntry} codeEntry Code entry object.
*/
CodeMap.prototype.addCode = function(start, codeEntry) {
- this.removeAllCoveredNodes_(this.dynamics_, start, start + codeEntry.size);
this.dynamics_.insert(start, codeEntry);
};
@@ -92,9 +91,7 @@ CodeMap.prototype.addCode = function(start, codeEntry) {
* @param {number} to The destination address.
*/
CodeMap.prototype.moveCode = function(from, to) {
- if (from === to) return;
var removedNode = this.dynamics_.remove(from);
- this.removeAllCoveredNodes_(this.dynamics_, to, to + removedNode.value.size);
this.dynamics_.insert(to, removedNode.value);
};
@@ -154,26 +151,6 @@ CodeMap.prototype.isAddressBelongsTo_ = function(addr, node) {
};
-/**
- * @private
- */
-CodeMap.prototype.findAllCoveredNodes_ = function(tree, start, end) {
- var result = [];
- var addr = end - 1;
- while (addr >= start) {
- var node = tree.findGreatestLessThan(addr);
- if (!node) break;
- var start2 = node.key, end2 = node.key + node.value.size;
- if (start2 < end && start < end2) {
- // Node overlaps with the interval given
- result.push(node);
- }
- addr = node.key - 1;
- }
- return result;
-};
-
-
/**
* @private
*/
@@ -257,14 +234,6 @@ CodeMap.prototype.getAllLibrariesEntries = function() {
};
-CodeMap.prototype.removeAllCoveredNodes_ = function(tree, start, end) {
- var covered = this.findAllCoveredNodes_(tree, start, end);
- for (var i = 0, l = covered.length; i < l; ++i) {
- tree.remove(covered[i].key);
- }
-};
-
-
/**
* Creates a code entry object.
*
View
@@ -58,7 +58,8 @@ Profile.prototype.skipThisFunction = function(name) {
*/
Profile.Operation = {
MOVE: 0,
- TICK: 1
+ DELETE: 1,
+ TICK: 2
};
@@ -162,13 +163,15 @@ Profile.prototype.addFuncCode = function(
func.name = name;
}
var entry = this.codeMap_.findDynamicEntryByStartAddress(start);
- if (entry && entry.size === size && entry.func === func) {
- // Entry state has changed.
- entry.state = state;
- return entry;
+ if (entry) {
+ if (entry.size === size && entry.func === func) {
+ // Entry state has changed.
+ entry.state = state;
+ }
+ } else {
+ entry = new Profile.DynamicFuncCodeEntry(size, type, func, state);
+ this.codeMap_.addCode(start, entry);
}
- entry = new Profile.DynamicFuncCodeEntry(size, type, func, state);
- this.codeMap_.addCode(start, entry);
return entry;
};
@@ -188,6 +191,20 @@ Profile.prototype.moveCode = function(from, to) {
};
+/**
+ * Reports about deletion of a dynamic code entry.
+ *
+ * @param {number} start Starting address.
+ */
+Profile.prototype.deleteCode = function(start) {
+ try {
+ this.codeMap_.deleteCode(start);
+ } catch (e) {
+ this.handleUnknownCode(Profile.Operation.DELETE, start);
+ }
+};
+
+
/**
* Reports about moving of a dynamic code entry.
*
View
@@ -77,7 +77,8 @@ function SnapshotLogProcessor() {
processor: this.processCodeCreation },
'code-move': { parsers: [parseInt, parseInt],
processor: this.processCodeMove },
- 'code-delete': null,
+ 'code-delete': { parsers: [parseInt],
+ processor: this.processCodeDelete },
'function-creation': null,
'function-move': null,
'function-delete': null,
@@ -92,6 +93,10 @@ function SnapshotLogProcessor() {
print('Snapshot: Code move event for unknown code: 0x' +
addr.toString(16));
break;
+ case op.DELETE:
+ print('Snapshot: Code delete event for unknown code: 0x' +
+ addr.toString(16));
+ break;
}
};
@@ -118,6 +123,11 @@ SnapshotLogProcessor.prototype.processCodeMove = function(from, to) {
};
+SnapshotLogProcessor.prototype.processCodeDelete = function(start) {
+ this.profile_.deleteCode(start);
+};
+
+
SnapshotLogProcessor.prototype.processSnapshotPosition = function(addr, pos) {
this.serializedEntries_[pos] = this.profile_.findEntry(addr);
};
@@ -145,7 +155,8 @@ function TickProcessor(
processor: this.processCodeCreation },
'code-move': { parsers: [parseInt, parseInt],
processor: this.processCodeMove },
- 'code-delete': null,
+ 'code-delete': { parsers: [parseInt],
+ processor: this.processCodeDelete },
'sfi-move': { parsers: [parseInt, parseInt],
processor: this.processFunctionMove },
'snapshot-pos': { parsers: [parseInt, parseInt],
@@ -184,6 +195,9 @@ function TickProcessor(
case op.MOVE:
print('Code move event for unknown code: 0x' + addr.toString(16));
break;
+ case op.DELETE:
+ print('Code delete event for unknown code: 0x' + addr.toString(16));
+ break;
case op.TICK:
// Only unknown PCs (the first frame) are reported as unaccounted,
// otherwise tick balance will be corrupted (this behavior is compatible
@@ -304,6 +318,11 @@ TickProcessor.prototype.processCodeMove = function(from, to) {
};
+TickProcessor.prototype.processCodeDelete = function(start) {
+ this.profile_.deleteCode(start);
+};
+
+
TickProcessor.prototype.processFunctionMove = function(from, to) {
this.profile_.moveFunc(from, to);
};

0 comments on commit bcd2725

Please sign in to comment.