Skip to content

Commit

Permalink
chrome: do not merge gc/program frame + show idle frame jlfwong#176
Browse files Browse the repository at this point in the history
  • Loading branch information
vmarchaud committed Oct 10, 2018
1 parent 0fe0c45 commit 4b684dd
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions src/import/chrome.ts
Expand Up @@ -145,11 +145,7 @@ function shouldIgnoreFunction(callFrame: CPUProfileCallFrame) {
// See: https://github.com/v8/v8/blob/b8626ca4/tools/js2c.py#L419-L424
return true
}
return functionName === '(root)' || functionName === '(idle)'
}

function shouldPlaceOnTopOfPreviousStack(functionName: string) {
return functionName === '(garbage collector)' || functionName === '(program)'
return functionName === '(root)'
}

export function importFromChromeCPUProfile(chromeProfile: CPUProfile): Profile {
Expand Down Expand Up @@ -218,16 +214,6 @@ export function importFromChromeCPUProfile(chromeProfile: CPUProfile): Profile {
// Find lowest common ancestor of the current stack and the previous one
let lca: CPUProfileNode | null = null

// This is O(n^2), but n should be relatively small here (stack height),
// so hopefully this isn't much of a problem
for (
lca = stackTop;
lca && prevStack.indexOf(lca) === -1;
lca = shouldPlaceOnTopOfPreviousStack(lca.callFrame.functionName)
? lastOf(prevStack)
: lca.parent || null
) {}

// Close frames that are no longer open
while (prevStack.length > 0 && lastOf(prevStack) != lca) {
const closingNode = prevStack.pop()!
Expand All @@ -241,9 +227,7 @@ export function importFromChromeCPUProfile(chromeProfile: CPUProfile): Profile {
let node: CPUProfileNode | null = stackTop;
node && node != lca && !shouldIgnoreFunction(node.callFrame);
// Place Chrome internal functions on top of the previous call stack
node = shouldPlaceOnTopOfPreviousStack(node.callFrame.functionName)
? lastOf(prevStack)
: node.parent || null
node = node.parent || null
) {
toOpen.push(node)
}
Expand Down

0 comments on commit 4b684dd

Please sign in to comment.