From e3369ae7d97af577577399b86208459e52e5e2d8 Mon Sep 17 00:00:00 2001 From: Greg Tatum Date: Wed, 3 May 2017 15:37:02 -0500 Subject: [PATCH] Filter out jitcode from C++ only call tree; Resolves #285 (#292) * Filter out jitcode from C++ only call tree * Address review comments --- src/content/profile-data.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/content/profile-data.js b/src/content/profile-data.js index f8035b94db..d075ced167 100644 --- a/src/content/profile-data.js +++ b/src/content/profile-data.js @@ -133,11 +133,24 @@ export function defaultThreadOrder(threads: Thread[]) { } export function filterThreadByImplementation(thread: Thread, implementation: string): Thread { - const { funcTable } = thread; + const { funcTable, stringTable } = thread; switch (implementation) { case 'cpp': - return _filterThreadByFunc(thread, funcIndex => !funcTable.isJS[funcIndex]); + return _filterThreadByFunc(thread, funcIndex => { + // Return quickly if this is a JS frame. + if (funcTable.isJS[funcIndex]) { + return false; + } + // Regular C++ functions are associated with a resource that describes the + // shared library that these C++ functions were loaded from. Jitcode is not + // loaded from shared libraries but instead generated at runtime, so Jitcode + // frames are not associated with a shared library and thus have no resource + const locationString = stringTable.getString(funcTable.name[funcIndex]); + const isProbablyJitCode = + funcTable.resource[funcIndex] === -1 && locationString.startsWith('0x'); + return !isProbablyJitCode; + }); case 'js': return _filterThreadByFunc(thread, funcIndex => funcTable.isJS[funcIndex]); }