Bug 862777: Hook Odinmonkey up to the spewlogger, r=luke
authorHannes Verschore <hv1989@gmail.com>
Thu, 18 Apr 2013 15:15:21 +0200
changeset 129196 e587fa3484d5d00dbdffc5f35e232ae228598e6b
parent 129195 62d955cfe160fb391750445372dff7bce6a9d06d
child 129197 76af6021d5d14a89ad9ddf21809c7d3353c1556e
push idunknown
push userunknown
push dateunknown
reviewersluke
bugs862777
milestone23.0a1
Bug 862777: Hook Odinmonkey up to the spewlogger, r=luke
js/src/ion/AsmJS.cpp
js/src/ion/C1Spewer.cpp
js/src/ion/IonSpewer.cpp
js/src/ion/JSONSpewer.cpp
--- a/js/src/ion/AsmJS.cpp
+++ b/js/src/ion/AsmJS.cpp
@@ -4441,25 +4441,29 @@ CheckFunctionBodiesSequential(ModuleComp
         // Use the scoped LifoAlloc for all temporaries,
         // including the MIRGenerator, MIRGraph, and LIRGraph.
         LifoAllocScope scope(&lifo);
 
         MIRGenerator *mirGen = CheckFunctionBody(m, func, lifo);
         if (!mirGen)
             return false;
 
+        IonSpewNewFunction(&mirGen->graph(), NullPtr());
+
         if (!OptimizeMIR(mirGen))
             return m.fail("Internal compiler failure (probably out of memory)", func.fn());
 
         LIRGraph *lir = GenerateLIR(mirGen);
         if (!lir)
             return m.fail("Internal compiler failure (probably out of memory)", func.fn());
 
         if (!GenerateAsmJSCode(m, func, *mirGen, *lir))
             return false;
+
+        IonSpewEndFunction();
     }
 
     return true;
 }
 
 #ifdef JS_PARALLEL_COMPILATION
 // State of compilation as tracked and updated by the main thread.
 struct ParallelGroupState
--- a/js/src/ion/C1Spewer.cpp
+++ b/js/src/ion/C1Spewer.cpp
@@ -30,18 +30,23 @@ C1Spewer::beginFunction(MIRGraph *graph,
 {
     if (!spewout_)
         return;
 
     this->graph  = graph;
     this->script = script;
 
     fprintf(spewout_, "begin_compilation\n");
-    fprintf(spewout_, "  name \"%s:%d\"\n", script->filename(), script->lineno);
-    fprintf(spewout_, "  method \"%s:%d\"\n", script->filename(), script->lineno);
+    if (script) {
+        fprintf(spewout_, "  name \"%s:%d\"\n", script->filename(), script->lineno);
+        fprintf(spewout_, "  method \"%s:%d\"\n", script->filename(), script->lineno);
+    } else {
+        fprintf(spewout_, "  name \"asm.js compilation\"\n");
+        fprintf(spewout_, "  method \"asm.js compilation\"\n");
+    }
     fprintf(spewout_, "  date %d\n", (int)time(NULL));
     fprintf(spewout_, "end_compilation\n");
 }
 
 void
 C1Spewer::spewPass(const char *pass)
 {
     if (!spewout_)
@@ -171,31 +176,32 @@ C1Spewer::spewPass(FILE *fp, MBasicBlock
 
     if (block->lir() && block->lir()->begin() != block->lir()->end()) {
         fprintf(fp, "    first_lir_id %d\n", block->lir()->firstId());
         fprintf(fp, "    last_lir_id %d\n", block->lir()->lastId());
     }
 
     fprintf(fp, "    begin_states\n");
 
-    fprintf(fp, "      begin_locals\n");
-    fprintf(fp, "        size %d\n", (int)block->numEntrySlots());
-    fprintf(fp, "        method \"None\"\n");
-    for (uint32_t i = 0; i < block->numEntrySlots(); i++) {
-        MDefinition *ins = block->getEntrySlot(i);
-        fprintf(fp, "        ");
-        fprintf(fp, "%d ", i);
-        if (ins->isUnused())
-            fprintf(fp, "unused");
-        else
-            ins->printName(fp);
-        fprintf(fp, "\n");
+    if (block->entryResumePoint()) {
+        fprintf(fp, "      begin_locals\n");
+        fprintf(fp, "        size %d\n", (int)block->numEntrySlots());
+        fprintf(fp, "        method \"None\"\n");
+        for (uint32_t i = 0; i < block->numEntrySlots(); i++) {
+            MDefinition *ins = block->getEntrySlot(i);
+            fprintf(fp, "        ");
+            fprintf(fp, "%d ", i);
+            if (ins->isUnused())
+                fprintf(fp, "unused");
+            else
+                ins->printName(fp);
+            fprintf(fp, "\n");
+        }
+        fprintf(fp, "      end_locals\n");
     }
-    fprintf(fp, "      end_locals\n");
-
     fprintf(fp, "    end_states\n");
 
     fprintf(fp, "    begin_HIR\n");
     for (MPhiIterator phi(block->phisBegin()); phi != block->phisEnd(); phi++)
         DumpDefinition(fp, *phi);
     for (MInstructionIterator i(block->begin()); i != block->end(); i++)
         DumpDefinition(fp, *i);
     fprintf(fp, "    end_HIR\n");
--- a/js/src/ion/IonSpewer.cpp
+++ b/js/src/ion/IonSpewer.cpp
@@ -32,24 +32,30 @@ static uint32_t filteredOutCompilations 
 static const char *ChannelNames[] =
 {
 #define IONSPEW_CHANNEL(name) #name,
     IONSPEW_CHANNEL_LIST(IONSPEW_CHANNEL)
 #undef IONSPEW_CHANNEL
 };
 
 static bool
-FilterContainsLocation(const char *filename, const size_t line = size_t(-1))
+FilterContainsLocation(HandleScript function)
 {
     static const char *filter = getenv("IONFILTER");
 
     // If there is no filter we accept all outputs.
     if (!filter || !filter[0])
         return true;
 
+    // Disable asm.js output when filter is set.
+    if (!function)
+        return false;
+
+    const char *filename = function->filename();
+    const size_t line = function->lineno;
     static size_t filelen = strlen(filename);
     const char *index = strstr(filter, filename);
     while (index) {
         if (index == filter || index[-1] == ',') {
             if (index[filelen] == 0 || index[filelen] == ',')
                 return true;
             if (index[filelen] == ':' && line != size_t(-1)) {
                 size_t read_line = strtoul(&index[filelen + 1], NULL, 10);
@@ -128,17 +134,17 @@ IonSpewer::isSpewingFunction() const
 }
 
 void
 IonSpewer::beginFunction(MIRGraph *graph, HandleScript function)
 {
     if (!inited_)
         return;
 
-    if (!FilterContainsLocation(function->filename(), function->lineno)) {
+    if (!FilterContainsLocation(function)) {
         JS_ASSERT(!this->graph);
         // filter out logs during the compilation.
         filteredOutCompilations++;
         return;
     }
 
     this->graph = graph;
     this->function = function;
--- a/js/src/ion/JSONSpewer.cpp
+++ b/js/src/ion/JSONSpewer.cpp
@@ -178,32 +178,38 @@ JSONSpewer::init(const char *path)
 
 void
 JSONSpewer::beginFunction(RawScript script)
 {
     if (inFunction_)
         endFunction();
 
     beginObject();
-    stringProperty("name", "%s:%d", script->filename(), script->lineno);
+    if (script)
+        stringProperty("name", "%s:%d", script->filename(), script->lineno);
+    else
+        stringProperty("name", "asm.js compilation");
     beginListProperty("passes");
 
     inFunction_ = true;
 }
 
 void
 JSONSpewer::beginPass(const char *pass)
 {
     beginObject();
     stringProperty("name", pass);
 }
 
 void
 JSONSpewer::spewMResumePoint(MResumePoint *rp)
 {
+    if (!rp)
+        return;
+
     beginObjectProperty("resumePoint");
 
     if (rp->caller())
         integerProperty("caller", rp->caller()->block()->id());
 
     property("mode");
     switch (rp->mode()) {
       case MResumePoint::ResumeAt: