Merged
authorjonathandicarlo@jonathan-dicarlos-macbook-pro.local
Tue, 24 Jun 2008 21:15:23 -0700
changeset 44732 adaaa4e6751c71279186b704220481a36befdfc6
parent 44731 d3c67942281be44c167c751b9b1084331b8283a2 (current diff)
parent 44729 b01670b7e87e9d0960aaa585f1c147eff32bc7e1 (diff)
child 44733 3d03b79e0ba7609f2da3ed9824959c82ed5bd588
child 44740 28fbf7bce40aa896291642b6cdb859fd6afde4bd
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
Merged
--- a/services/sync/modules/async.js
+++ b/services/sync/modules/async.js
@@ -72,27 +72,27 @@ NamableTracker.prototype = {
 }
 
 let gCurrentId = 0;
 let gCurrentCbId = 0;
 let gOutstandingGenerators = new NamableTracker();
 
 function AsyncException(initFrame, message) {
   this.message = message;
-  this._trace = initFrame;
+  this._traceback = initFrame;
 }
 AsyncException.prototype = {
   get message() { return this._message; },
   set message(value) { this._message = value; },
 
-  get trace() { return this._trace; },
-  set trace(value) { this._trace = value; },
+  get traceback() { return this._traceback; },
+  set traceback(value) { this._traceback = value; },
 
   addFrame: function AsyncException_addFrame(frame) {
-    this.trace += (this.trace? "\n" : "") + formatFrame(frame);
+    this.traceback += (this.traceback? "\n" : "") + formatFrame(frame);
   },
 
   toString: function AsyncException_toString() {
     return this.message;
   }
 };
 
 function Generator(thisArg, method, onComplete, args) {
@@ -156,43 +156,43 @@ Generator.prototype = {
     };
   },
   set onComplete(value) {
     if (value && typeof value != "function")
       throw "Generator: expected type 'function', got type '" + typeof(value) + "'";
     this._onComplete = value;
   },
 
-  get trace() {
-    return "unknown (async) :: " + this.name + "\n" + trace(this._initFrame);
+  get traceback() {
+    return "unknown (async) :: " + this.name + "\n" + traceAsyncFrame(this._initFrame);
   },
 
   _handleException: function AsyncGen__handleException(e) {
     if (e instanceof StopIteration) {
       this._log.trace(this.name + ": End of coroutine reached.");
       // skip to calling done()
 
     } else if (this.onComplete.parentGenerator instanceof Generator) {
       this._log.trace("[" + this.name + "] Saving exception and stack trace");
       this._log.trace("Exception: " + Utils.exceptionStr(e));
 
         if (e instanceof AsyncException) {
           // FIXME: attempt to skip repeated frames, which can happen if the
           // child generator never yielded.  Would break for valid repeats (recursion)
-          if (e.trace.indexOf(formatFrame(this._initFrame)) == -1)
+          if (e.traceback.indexOf(formatFrame(this._initFrame)) == -1)
             e.addFrame(this._initFrame);
         } else {
-          e = new AsyncException(this.trace, e);
+          e = new AsyncException(this.traceback, e);
         }
 
       this._exception = e;
 
     } else {
       this._log.error("Exception: " + Utils.exceptionStr(e));
-      this._log.debug("Stack trace:\n" + (e.trace? e.trace : this.trace));
+      this._log.debug("Stack trace:\n" + (e.traceback? e.traceback : this.traceback));
     }
 
     // continue execution of caller.
     // in the case of StopIteration we could return an error right
     // away, but instead it's easiest/best to let the caller handle
     // the error after a yield / in a callback.
     if (!this._timer) {
       this._log.trace("[" + this.name + "] running done() from _handleException()");
@@ -259,17 +259,17 @@ Generator.prototype = {
                      "' may have outstanding callbacks.");
     this._timer = Utils.makeTimerForCall(cb);
   },
 
   _done: function AsyncGen__done(retval) {
     if (!this._generator) {
       this._log.error("Async method '" + this.name + "' is missing a 'yield' call " +
                       "(or called done() after being finalized)");
-      this._log.trace("Initial stack trace:\n" + this.trace);
+      this._log.trace("Initial stack trace:\n" + this.traceback);
     } else {
       this._generator.close();
     }
     this._generator = null;
     this._timer = null;
 
     if (this._exception) {
       this._log.trace("[" + this.name + "] Propagating exception to parent generator");
@@ -277,43 +277,45 @@ Generator.prototype = {
     } else {
       try {
         this._log.trace("[" + this.name + "] Running onComplete()");
         this.onComplete(retval);
       } catch (e) {
         this._log.error("Exception caught from onComplete handler of " +
                         this.name + " generator");
         this._log.error("Exception: " + Utils.exceptionStr(e));
-        this._log.trace("Current stack trace:\n" + trace(Components.stack));
-        this._log.trace("Initial stack trace:\n" + this.trace);
+        this._log.trace("Current stack trace:\n" + traceAsyncFrame(Components.stack));
+        this._log.trace("Initial stack trace:\n" + this.traceback);
       }
     }
     gOutstandingGenerators.remove(this);
   }
 };
 
 function formatFrame(frame) {
   // FIXME: sort of hackish, might be confusing if there are multiple
   // extensions with similar filenames
-  let tmp = frame.filename.replace(/^file:\/\/.*\/([^\/]+.js)$/, "module:$1");
+  let tmp = "<file:unknown>";
+  if (frame.filename)
+    tmp = frame.filename.replace(/^file:\/\/.*\/([^\/]+.js)$/, "module:$1");
   tmp += ":" + frame.lineNumber + " :: " + frame.name;
   return tmp;
 }
 
-function trace(frame, str) {
+function traceAsyncFrame(frame, str) {
   if (!str)
     str = "";
 
   // skip our frames
   // FIXME: we should have a pref for this, for debugging async.js itself
   while (frame.name && frame.name.match(/^Async(Gen|)_/))
     frame = frame.caller;
 
   if (frame.caller)
-    str = trace(frame.caller, str);
+    str = traceAsyncFrame(frame.caller, str);
   str = formatFrame(frame) + (str? "\n" : "") + str;
 
   return str;
 }
 
 
 Async = {
   get outstandingGenerators() { return gOutstandingGenerators; },