[INFER] Always print spew on debug mode type failures.
authorBrian Hackett <bhackett1024@gmail.com>
Wed, 17 Aug 2011 09:07:42 -0700
changeset 76129 2d95fc517e57fa1cecab8564b3832f3353742a81
parent 76128 aa547ed80bba625a45c620c2757489c263637d32
child 76130 044290f5a31d7ee3216a5f884f827b11fb9faae2
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
milestone8.0a1
[INFER] Always print spew on debug mode type failures.
js/src/jscntxt.cpp
js/src/jsinfer.cpp
js/src/jsinfer.h
--- a/js/src/jscntxt.cpp
+++ b/js/src/jscntxt.cpp
@@ -514,17 +514,17 @@ js_DestroyContext(JSContext *cx, JSDestr
              * Dump remaining type inference results first. This printing
              * depends on atoms still existing.
              */
             {
                 AutoLockGC lock(rt);
                 JSCompartment **compartment = rt->compartments.begin();
                 JSCompartment **end = rt->compartments.end();
                 while (compartment < end) {
-                    (*compartment)->types.print(cx);
+                    (*compartment)->types.print(cx, false);
                     compartment++;
                 }
             }
 
             /* Unpin all common atoms before final GC. */
             js_FinishCommonAtoms(cx);
 
             /* Clear debugging state to remove GC roots. */
--- a/js/src/jsinfer.cpp
+++ b/js/src/jsinfer.cpp
@@ -320,22 +320,18 @@ types::TypeFailure(JSContext *cx, const 
 
     va_list ap;
     va_start(ap, fmt);
     JS_vsnprintf(errbuf, sizeof(errbuf), fmt, ap);
     va_end(ap);
 
     JS_snprintf(msgbuf, sizeof(msgbuf), "[infer failure] %s", errbuf);
 
-    /*
-     * If the INFERFLAGS environment variable is set to 'result' or 'full', 
-     * this dumps the current type state of all scripts and type objects 
-     * to stdout.
-     */
-    cx->compartment->types.print(cx);
+    /* Dump type state, even if INFERFLAGS is unset. */
+    cx->compartment->types.print(cx, true);
 
     /* Always active, even in release builds */
     JS_Assert(msgbuf, __FILE__, __LINE__);
     
     *((int*)NULL) = 0;  /* Should never be reached */
 }
 
 /////////////////////////////////////////////////////////////////////
@@ -2267,21 +2263,24 @@ PrintObjectCallback(JSContext *cx, void 
                     size_t traceKind, size_t thingSize)
 {
     TypeObject *object = (TypeObject *) thing;
     object->print(cx);
 }
 #endif
 
 void
-TypeCompartment::print(JSContext *cx)
+TypeCompartment::print(JSContext *cx, bool force)
 {
     JSCompartment *compartment = this->compartment();
 
-    if (!InferSpewActive(ISpewResult) || JS_CLIST_IS_EMPTY(&compartment->scripts))
+    if (JS_CLIST_IS_EMPTY(&compartment->scripts))
+        return;
+
+    if (!force && !InferSpewActive(ISpewResult))
         return;
 
     for (JSScript *script = (JSScript *)compartment->scripts.next;
          &script->links != &compartment->scripts;
          script = (JSScript *)script->links.next) {
         if (script->hasAnalysis() && script->analysis()->ranInference())
             script->analysis()->printTypes(cx);
     }
--- a/js/src/jsinfer.h
+++ b/js/src/jsinfer.h
@@ -1045,18 +1045,18 @@ struct TypeCompartment
 
     /* Add a type to register with a list of constraints. */
     inline void addPending(JSContext *cx, TypeConstraint *constraint, TypeSet *source, Type type);
     void growPendingArray(JSContext *cx);
 
     /* Resolve pending type registrations, excluding delayed ones. */
     inline void resolvePending(JSContext *cx);
 
-    /* Prints results of this compartment if spew is enabled, checks for warnings. */
-    void print(JSContext *cx);
+    /* Prints results of this compartment if spew is enabled or force is set. */
+    void print(JSContext *cx, bool force);
 
     /*
      * Make a function or non-function object associated with an optional
      * script. The 'key' parameter here may be an array, typed array, function
      * or JSProto_Object to indicate a type whose class is unknown (not just
      * js_ObjectClass).
      */
     TypeObject *newTypeObject(JSContext *cx, JSScript *script,