Bug 1270816 - Tracelogger: Add more hooks to log items, r=bbouvier

This commit is contained in:
Hannes Verschore 2016-05-14 11:50:38 +02:00
parent fd683c7b4d
commit 9c6551efdd
7 changed files with 58 additions and 11 deletions

View File

@ -791,6 +791,13 @@ ModuleGenerator::startFuncDef(uint32_t lineOrBytecode, FunctionGenerator* fg)
bool
ModuleGenerator::finishFuncDef(uint32_t funcIndex, unsigned generateTime, FunctionGenerator* fg)
{
TraceLoggerThread* logger = nullptr;
if (cx_->isJSContext())
logger = TraceLoggerForMainThread(cx_->asJSContext()->runtime());
else
logger = TraceLoggerForCurrentThread();
AutoTraceLog logCompile(logger, TraceLogger_WasmCompilation);
MOZ_ASSERT(activeFunc_ == fg);
auto func = js::MakeUnique<FuncBytes>(Move(fg->bytes_),

View File

@ -3731,6 +3731,11 @@ jit::AnalyzeNewScriptDefiniteProperties(JSContext* cx, JSFunction* fun,
if (script->length() > MAX_SCRIPT_SIZE)
return true;
TraceLoggerThread* logger = TraceLoggerForMainThread(cx->runtime());
TraceLoggerEvent event(logger, TraceLogger_AnnotateScripts, script);
AutoTraceLog logScript(logger, event);
AutoTraceLog logCompile(logger, TraceLogger_IonAnalysis);
Vector<PropertyName*> accessedProperties(cx);
LifoAlloc alloc(TempAllocator::PreferredLifoChunkSize);
@ -3971,6 +3976,11 @@ jit::AnalyzeArgumentsUsage(JSContext* cx, JSScript* scriptArg)
if (!script->ensureHasTypes(cx))
return false;
TraceLoggerThread* logger = TraceLoggerForMainThread(cx->runtime());
TraceLoggerEvent event(logger, TraceLogger_AnnotateScripts, script);
AutoTraceLog logScript(logger, event);
AutoTraceLog logCompile(logger, TraceLogger_IonAnalysis);
LifoAlloc alloc(TempAllocator::PreferredLifoChunkSize);
TempAllocator temp(&alloc);
JitContext jctx(cx, &temp);

View File

@ -2487,6 +2487,8 @@ IonBuilder::finishLoop(CFGState& state, MBasicBlock* successor)
IonBuilder::ControlStatus
IonBuilder::restartLoop(const CFGState& state)
{
AutoTraceLog logCompile(traceLogger(), TraceLogger_IonBuilderRestartLoop);
spew("New types at loop header, restarting loop body");
if (JitOptions.limitScriptSize) {

View File

@ -1134,6 +1134,11 @@ class IonBuilder
return actionableAbortScript_ != nullptr;
}
TraceLoggerThread *traceLogger() {
// Currently ionbuilder only runs on the main thread.
return TraceLoggerForMainThread(compartment->runtime()->mainThread()->runtimeFromMainThread());
}
void actionableAbortLocationAndMessage(JSScript** abortScript, jsbytecode** abortPc,
const char** abortMessage)
{

View File

@ -1110,6 +1110,9 @@ HelperThread::handleGCParallelWorkload()
MOZ_ASSERT(HelperThreadState().canStartGCParallelTask());
MOZ_ASSERT(idle());
TraceLoggerThread* logger = TraceLoggerForCurrentThread();
AutoTraceLog logCompile(logger, TraceLogger_GC);
currentTask.emplace(HelperThreadState().gcParallelWorklist().popCopy());
gcParallelTask()->runFromHelperThread();
currentTask.reset();
@ -1361,6 +1364,10 @@ HelperThread::handleWasmWorkload()
wasm::IonCompileTask* task = wasmTask();
{
AutoUnlockHelperThreadState unlock;
TraceLoggerThread* logger = TraceLoggerForCurrentThread();
AutoTraceLog logCompile(logger, TraceLogger_WasmCompilation);
PerThreadData::AutoEnterRuntime enter(threadData.ptr(), task->runtime());
success = wasm::IonCompileFunction(task);
}
@ -1403,15 +1410,16 @@ HelperThread::handleIonWorkload()
currentTask.emplace(builder);
builder->setPauseFlag(&pause);
TraceLoggerThread* logger = TraceLoggerForCurrentThread();
TraceLoggerEvent event(logger, TraceLogger_AnnotateScripts, builder->script());
AutoTraceLog logScript(logger, event);
AutoTraceLog logCompile(logger, TraceLogger_IonCompilation);
JSRuntime* rt = builder->script()->compartment()->runtimeFromAnyThread();
{
AutoUnlockHelperThreadState unlock;
TraceLoggerThread* logger = TraceLoggerForCurrentThread();
TraceLoggerEvent event(logger, TraceLogger_AnnotateScripts, builder->script());
AutoTraceLog logScript(logger, event);
AutoTraceLog logCompile(logger, TraceLogger_IonCompilation);
PerThreadData::AutoEnterRuntime enter(threadData.ptr(),
builder->script()->runtimeFromAnyThread());
jit::JitContext jctx(jit::CompileRuntime::get(rt),
@ -1566,6 +1574,10 @@ HelperThread::handleCompressionWorkload()
{
AutoUnlockHelperThreadState unlock;
TraceLoggerThread* logger = TraceLoggerForCurrentThread();
AutoTraceLog logCompile(logger, TraceLogger_CompressSource);
task->result = task->work();
}

View File

@ -356,6 +356,8 @@ TraceLoggerThread::getOrCreateEventPayload(const char* text)
return p->value();
}
AutoTraceLog internal(this, TraceLogger_Internal);
size_t len = strlen(text);
char* str = js_pod_malloc<char>(len + 1);
if (!str)
@ -411,6 +413,8 @@ TraceLoggerThread::getOrCreateEventPayload(TraceLoggerTextId type, const char* f
return p->value();
}
AutoTraceLog internal(this, TraceLogger_Internal);
// Compute the length of the string to create.
size_t lenFilename = strlen(filename);
size_t lenLineno = 1;
@ -644,10 +648,10 @@ TraceLoggerThreadState::init()
"Collections:\n"
" Default Output all default. It includes:\n"
" AnnotateScripts, Bailout, Baseline, BaselineCompilation, GC,\n"
" GCAllocation, GCSweeping, Interpreter, IonCompilation, IonLinking,\n"
" IonMonkey, MinorGC, ParserCompileFunction, ParserCompileScript,\n"
" ParserCompileLazy, ParserCompileModule, IrregexpCompile,\n"
" IrregexpExecute, Scripts, Engine\n"
" GCAllocation, GCSweeping, Interpreter, IonAnalysis, IonCompilation,\n"
" IonLinking, IonMonkey, MinorGC, ParserCompileFunction,\n"
" ParserCompileScript, ParserCompileLazy, ParserCompileModule,\n"
" IrregexpCompile, IrregexpExecute, Scripts, Engine, WasmCompilation\n"
"\n"
" IonCompiler Output all information about compilation. It includes:\n"
" IonCompilation, IonLinking, PruneUnusedBranches, FoldTests,\n"
@ -657,7 +661,7 @@ TraceLoggerThreadState::init()
" LoopUnrolling, EffectiveAddressAnalysis, AlignmentMaskAnalysis, \n"
" EliminateDeadCode, ReorderInstructions, EdgeCaseAnalysis, \n"
" EliminateRedundantChecks, AddKeepAliveInstructions, GenerateLIR, \n"
" RegisterAllocation, GenerateCode, Scripts\n"
" RegisterAllocation, GenerateCode, Scripts, IonBuilderRestartLoop\n"
"\n"
"Specific log items:\n"
);
@ -689,6 +693,7 @@ TraceLoggerThreadState::init()
enabledTextIds[TraceLogger_GCAllocation] = true;
enabledTextIds[TraceLogger_GCSweeping] = true;
enabledTextIds[TraceLogger_Interpreter] = true;
enabledTextIds[TraceLogger_IonAnalysis] = true;
enabledTextIds[TraceLogger_IonCompilation] = true;
enabledTextIds[TraceLogger_IonLinking] = true;
enabledTextIds[TraceLogger_IonMonkey] = true;
@ -701,6 +706,7 @@ TraceLoggerThreadState::init()
enabledTextIds[TraceLogger_IrregexpExecute] = true;
enabledTextIds[TraceLogger_Scripts] = true;
enabledTextIds[TraceLogger_Engine] = true;
enabledTextIds[TraceLogger_WasmCompilation] = true;
}
if (ContainsFlag(env, "IonCompiler")) {
@ -733,6 +739,7 @@ TraceLoggerThreadState::init()
enabledTextIds[TraceLogger_RegisterAllocation] = true;
enabledTextIds[TraceLogger_GenerateCode] = true;
enabledTextIds[TraceLogger_Scripts] = true;
enabledTextIds[TraceLogger_IonBuilderRestartLoop] = true;
}
enabledTextIds[TraceLogger_Interpreter] = enabledTextIds[TraceLogger_Engine];

View File

@ -21,6 +21,7 @@
_(Internal) \
_(Interpreter) \
_(InlinedScripts) \
_(IonAnalysis) \
_(IonCompilation) \
_(IonCompilationPaused) \
_(IonLinking) \
@ -34,6 +35,8 @@
_(ParserCompileModule) \
_(Scripts) \
_(VM) \
_(CompressSource) \
_(WasmCompilation) \
\
/* Specific passes during ion compilation */ \
_(PruneUnusedBranches) \
@ -63,7 +66,8 @@
_(AddKeepAliveInstructions) \
_(GenerateLIR) \
_(RegisterAllocation) \
_(GenerateCode)
_(GenerateCode) \
_(IonBuilderRestartLoop)
#define TRACELOGGER_LOG_ITEMS(_) \
_(Bailout) \