Improve spew, prepare for lowering phase.
authorDavid Anderson <danderson@mozilla.com>
Wed, 18 May 2011 19:44:53 -0700
changeset 104802 83cfd0db698597af5fb26a6332066e28c8893087
parent 104801 a92f772f2c33acca704c3f618ab4fa90c636f66c
child 104803 21863a07248f8c27182e41a03a37af5290923d22
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
milestone6.0a1
Improve spew, prepare for lowering phase.
js/src/Makefile.in
js/src/ion/IonAnalysis.cpp
js/src/ion/IonAnalysis.h
js/src/ion/IonBuilder.cpp
js/src/ion/IonSpew.cpp
js/src/ion/MIR.cpp
js/src/ion/MIR.h
js/src/ion/MIRGraph.h
--- a/js/src/Makefile.in
+++ b/js/src/Makefile.in
@@ -365,16 +365,17 @@ CPPSRCS += 	MethodJIT.cpp \
 
 # Ion
 VPATH +=	$(srcdir)/ion
 
 CPPSRCS +=	MIR.cpp \
 		IonBuilder.cpp \
 		IonSpew.cpp \
 		MIRGraph.cpp \
+		IonAnalysis.cpp \
 		$(NULL)
 
 ifeq (86, $(findstring 86,$(TARGET_CPU)))
 ifeq (x86_64, $(TARGET_CPU))
 ifdef _MSC_VER
 ASFILES +=	TrampolineMasmX64.asm
 endif
 ifeq ($(OS_ARCH),WINNT)
new file mode 100644
--- /dev/null
+++ b/js/src/ion/IonAnalysis.cpp
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ * vim: set ts=4 sw=4 et tw=79:
+ *
+ * ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released
+ * March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 1998
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   David Anderson <danderson@mozilla.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include "IonBuilder.h"
+#include "MIRGraph.h"
+#include "Ion.h"
+#include "IonSpew.h"
+#include "IonAnalysis.h"
+
+using namespace js;
+using namespace js::ion;
+
+bool
+ion::InferRepresentations(MIRGenerator *gen, MIRGraph &graph)
+{
+    return true;
+}
+
new file mode 100644
--- /dev/null
+++ b/js/src/ion/IonAnalysis.h
@@ -0,0 +1,58 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ * vim: set ts=4 sw=4 et tw=79:
+ *
+ * ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released
+ * March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 1998
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   David Anderson <danderson@mozilla.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef jsion_ion_analysis_h__
+#define jsion_ion_analysis_h__
+
+namespace js {
+namespace ion {
+
+class MIRGenerator;
+class MIRGraph;
+
+bool
+InferRepresentations(MIRGenerator *gen, MIRGraph &graph);
+
+} // namespace js
+} // namespace ion
+
+#endif // jsion_ion_analysis_h__
+
--- a/js/src/ion/IonBuilder.cpp
+++ b/js/src/ion/IonBuilder.cpp
@@ -34,16 +34,17 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
+#include "IonAnalysis.h"
 #include "IonBuilder.h"
 #include "MIRGraph.h"
 #include "Ion.h"
 #include "IonSpew.h"
 #include "jsemit.h"
 #include "jsscriptinlines.h"
 
 using namespace js;
@@ -58,18 +59,21 @@ ion::Go(JSContext *cx, JSScript *script,
 
     MIRGraph graph(cx);
     C1Spewer spew(graph, script);
     IonBuilder analyzer(cx, script, fun, temp, graph);
     spew.enable("/tmp/ion.cfg");
 
     if (!analyzer.analyze())
         return false;
+    spew.spew("Build SSA");
 
-    spew.spew("Building SSA");
+    if (!InferRepresentations(&analyzer, graph))
+        return false;
+    spew.spew("Infer Representations");
 
     return false;
 }
 
 IonBuilder::IonBuilder(JSContext *cx, JSScript *script, JSFunction *fun, TempAllocator &temp,
                                    MIRGraph &graph)
   : MIRGenerator(cx, temp, script, fun, graph),
     cfgStack_(TempAllocPolicy(cx)),
--- a/js/src/ion/IonSpew.cpp
+++ b/js/src/ion/IonSpew.cpp
@@ -95,22 +95,22 @@ C1Spewer::spew(FILE *fp, const char *pas
 
 static void
 DumpInstruction(FILE *fp, MInstruction *ins)
 {
     fprintf(fp, "      ");
     fprintf(fp, "0 %d ", ins->useCount());
     ins->printName(fp);
     fprintf(fp, " ");
-    ins->printName(fp);
+    ins->printOpcode(fp);
     fprintf(fp, " ");
     for (size_t j = 0; j < ins->numOperands(); j++) {
         ins->getOperand(j)->printName(fp);
         if (j != ins->numOperands() - 1)
-            fprintf(fp, ", ");
+            fprintf(fp, " ");
     }
     fprintf(fp, " <|@\n");
 }
 
 void
 C1Spewer::spew(FILE *fp, MBasicBlock *block)
 {
     fprintf(fp, "  begin_block\n");
--- a/js/src/ion/MIR.cpp
+++ b/js/src/ion/MIR.cpp
@@ -68,22 +68,28 @@ PrintOpcodeName(FILE *fp, MInstruction::
     size_t len = strlen(name);
     for (size_t i = 0; i < len; i++)
         fprintf(fp, "%c", tolower(name[i]));
 }
 
 void
 MInstruction::printName(FILE *fp)
 {
-    PrintOpcodeName(fp, op());
+    printOpcode(fp);
     fprintf(fp, "%u", id());
     fprintf(fp, ":v");
 }
 
 void
+MInstruction::printOpcode(FILE *fp)
+{
+    PrintOpcodeName(fp, op());
+}
+
+void
 MInstruction::unlinkUse(MOperand *prev, MOperand *use)
 {
     JS_ASSERT(use->ins() == this);
     if (!prev) {
         JS_ASSERT(uses_ = use);
         uses_ = use->next();
     } else {
         JS_ASSERT(prev->next() == use);
--- a/js/src/ion/MIR.h
+++ b/js/src/ion/MIR.h
@@ -270,16 +270,17 @@ class MInstruction : public TempObject
       : block_(NULL),
         representation_(Representation::None),
         type_(MIRType_Box),
         uses_(NULL)
     { }
 
     virtual Opcode op() const = 0;
     void printName(FILE *fp);
+    void printOpcode(FILE *fp);
 
     uint32 id() const {
         JS_ASSERT(block_);
         return id_;
     }
     void setId(uint32 id) {
         id_ = id;
     }
--- a/js/src/ion/MIRGraph.h
+++ b/js/src/ion/MIRGraph.h
@@ -117,16 +117,20 @@ class MBasicBlock : public TempObject
     bool setVariable(uint32 slot);
 
     // This function retrieves the internal instruction associated with a
     // slot, and should not be used for normal stack operations. It is an
     // internal helper that is also used to enhance spew.
     MInstruction *getSlot(uint32 index);
 
   public:
+    ///////////////////////////////////////////////////////
+    ////////// BEGIN GRAPH BUILDING INSTRUCTIONS //////////
+    ///////////////////////////////////////////////////////
+
     // Creates a new basic block for a MIR generator. If |pred| is not NULL,
     // its slots and stack depth are initialized from |pred|.
     static MBasicBlock *New(MIRGenerator *gen, MBasicBlock *pred, jsbytecode *entryPc);
     static MBasicBlock *NewLoopHeader(MIRGenerator *gen, MBasicBlock *pred, jsbytecode *entryPc);
 
     // Copies the stack state to the header. This should only be called if the
     // block was created with no predecessor, and should be called once the
     // stack state is initialized.
@@ -172,16 +176,20 @@ class MBasicBlock : public TempObject
     // automatically creates phi nodes and rewrites uses as needed.
     bool addPredecessor(MBasicBlock *pred);
 
     // Sets a back edge. This places phi nodes and rewrites instructions within
     // the current loop as necessary, and corrects the successor block's initial
     // state at the same time. There may be only one backedge per block.
     bool setBackedge(MBasicBlock *block, MBasicBlock *successor);
 
+    ///////////////////////////////////////////////////////
+    /////////// END GRAPH BUILDING INSTRUCTIONS ///////////
+    ///////////////////////////////////////////////////////
+
     jsbytecode *pc() const {
         return pc_;
     }
     uint32 id() const {
         return id_;
     }
     uint32 numPredecessors() const {
         return predecessors_.length();