Back out 5ebd6549bf93 and 73287cb2dc6a (bug 794091) on suspicion of breaking Win64 PGO builds
authorPhil Ringnalda <philringnalda@gmail.com>
Thu, 08 Nov 2012 20:43:18 -0800
changeset 112775 04fa7fd1c588db01e46325fe57848d86164e8963
parent 112774 16e931d21b6ff615475c1da5ed7224376b837628
child 112776 efb2dca4496552a88f22d3cc0e5dbcbd651b6674
push id17770
push userphilringnalda@gmail.com
push dateFri, 09 Nov 2012 04:44:41 +0000
treeherdermozilla-inbound@04fa7fd1c588 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs794091
milestone19.0a1
backs out5ebd6549bf932f6ea378e46e82f84e0870a48070
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Back out 5ebd6549bf93 and 73287cb2dc6a (bug 794091) on suspicion of breaking Win64 PGO builds
browser/components/sessionstore/src/SessionStore.jsm
toolkit/components/osfile/osfile.jsm
toolkit/components/osfile/osfile_unix_allthreads.jsm
toolkit/components/osfile/osfile_unix_back.jsm
toolkit/components/osfile/osfile_unix_front.jsm
toolkit/components/osfile/osfile_win_allthreads.jsm
toolkit/components/osfile/osfile_win_back.jsm
toolkit/components/osfile/osfile_win_front.jsm
--- a/browser/components/sessionstore/src/SessionStore.jsm
+++ b/browser/components/sessionstore/src/SessionStore.jsm
@@ -74,17 +74,16 @@ const TAB_EVENTS = [
 #endif
 
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 // debug.js adds NS_ASSERT. cf. bug 669196
 Cu.import("resource://gre/modules/debug.js");
 Cu.import("resource:///modules/TelemetryTimestamps.jsm");
 Cu.import("resource://gre/modules/TelemetryStopwatch.jsm");
-Cu.import("resource://gre/modules/osfile.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
   "resource://gre/modules/NetUtil.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "ScratchpadManager",
   "resource:///modules/devtools/scratchpad-manager.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "DocumentUtils",
   "resource:///modules/sessionstore/DocumentUtils.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "SessionStorage",
@@ -437,28 +436,19 @@ let SessionStoreInternal = {
     }
 
     // at this point, we've as good as resumed the session, so we can
     // clear the resume_session_once flag, if it's set
     if (this._loadState != STATE_QUITTING &&
         this._prefBranch.getBoolPref("sessionstore.resume_session_once"))
       this._prefBranch.setBoolPref("sessionstore.resume_session_once", false);
 
-    this._initEncoding();
-
     this._initialized = true;
   },
 
-  _initEncoding : function ssi_initEncoding() {
-    // The (UTF-8) encoder used to write to files.
-    XPCOMUtils.defineLazyGetter(this, "_writeFileEncoder", function () {
-      return new TextEncoder();
-    });
-  },
-
   _initPrefs : function() {
     XPCOMUtils.defineLazyGetter(this, "_prefBranch", function () {
       return Services.prefs.getBranch("browser.");
     });
 
     // minimal interval between two save operations (in milliseconds)
     XPCOMUtils.defineLazyGetter(this, "_interval", function () {
       // used often, so caching/observing instead of fetching on-demand
@@ -4440,31 +4430,37 @@ let SessionStoreInternal = {
    * @param aFile
    *        nsIFile
    * @param aData
    *        String data
    */
   _writeFile: function ssi_writeFile(aFile, aData) {
     let refObj = {};
     TelemetryStopwatch.start("FX_SESSION_RESTORE_WRITE_FILE_MS", refObj);
-    let path = aFile.path;
-    let encoded = this._writeFileEncoder.encode(aData);
-    let promise = OS.File.writeAtomic(path, encoded, {tmpPath: path + ".tmp"});
-
-    promise.then(
-      function onSuccess() {
+    // Initialize the file output stream.
+    var ostream = Cc["@mozilla.org/network/safe-file-output-stream;1"].
+                  createInstance(Ci.nsIFileOutputStream);
+    ostream.init(aFile, 0x02 | 0x08 | 0x20, 0600, ostream.DEFER_OPEN);
+
+    // Obtain a converter to convert our data to a UTF-8 encoded input stream.
+    var converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"].
+                    createInstance(Ci.nsIScriptableUnicodeConverter);
+    converter.charset = "UTF-8";
+
+    // Asynchronously copy the data to the file.
+    var istream = converter.convertToInputStream(aData);
+    var self = this;
+    NetUtil.asyncCopy(istream, ostream, function(rc) {
+      if (Components.isSuccessCode(rc)) {
         TelemetryStopwatch.finish("FX_SESSION_RESTORE_WRITE_FILE_MS", refObj);
         Services.obs.notifyObservers(null,
-                                      "sessionstore-state-write-complete",
-                                      "");
-      },
-      function onFailure(reason) {
-        TelemetryStopwatch.cancel("FX_SESSION_RESTORE_WRITE_FILE_MS", refObj);
-        Components.reportError("ssi_writeFile failure " + reason);
-      });
+                                     "sessionstore-state-write-complete",
+                                     "");
+      }
+    });
   }
 };
 
 // This is used to help meter the number of restoring tabs. This is the control
 // point for telling the next tab to restore. It gets attached to each gBrowser
 // via gBrowser.addTabsProgressListener
 let gRestoreTabsProgressListener = {
   onStateChange: function(aBrowser, aWebProgress, aRequest, aStateFlags, aStatus) {
--- a/toolkit/components/osfile/osfile.jsm
+++ b/toolkit/components/osfile/osfile.jsm
@@ -5,31 +5,14 @@
 /**
  * Common front for various implementations of OS.File
  */
 
 if (typeof Components != "undefined") {
   this.EXPORTED_SYMBOLS = ["OS"];
   Components.utils.import("resource://gre/modules/osfile/osfile_async_front.jsm", this);
 } else {
-  // At this stage, we need to import all sources at once to avoid
-  // a unique failure on tbpl + talos that seems caused by a
-  // what looks like a nested event loop bug (see bug 794091).
 #ifdef XP_WIN
-  importScripts(
-    "resource://gre/modules/osfile/osfile_shared_allthreads.jsm",
-    "resource://gre/modules/osfile/osfile_win_allthreads.jsm",
-    "resource://gre/modules/osfile/ospath_win_back.jsm",
-    "resource://gre/modules/osfile/osfile_win_back.jsm",
-    "resource://gre/modules/osfile/osfile_shared_front.jsm",
-    "resource://gre/modules/osfile/osfile_win_front.jsm"
-  );
+  importScripts("resource://gre/modules/osfile/osfile_win_front.jsm");
 #else
-  importScripts(
-    "resource://gre/modules/osfile/osfile_shared_allthreads.jsm",
-    "resource://gre/modules/osfile/osfile_unix_allthreads.jsm",
-    "resource://gre/modules/osfile/ospath_unix_back.jsm",
-    "resource://gre/modules/osfile/osfile_unix_back.jsm",
-    "resource://gre/modules/osfile/osfile_shared_front.jsm",
-    "resource://gre/modules/osfile/osfile_unix_front.jsm"
-  );
+  importScripts("resource://gre/modules/osfile/osfile_unix_front.jsm");
 #endif
-}
+}
\ No newline at end of file
--- a/toolkit/components/osfile/osfile_unix_allthreads.jsm
+++ b/toolkit/components/osfile/osfile_unix_allthreads.jsm
@@ -17,16 +17,19 @@
  * - opened from a chrome worker through importScripts.
  */
 
 if (typeof Components != "undefined") {
   // Module is opened as a jsm module
   this.EXPORTED_SYMBOLS = ["OS"];
   Components.utils.import("resource://gre/modules/ctypes.jsm");
   Components.utils.import("resource://gre/modules/osfile/osfile_shared_allthreads.jsm", this);
+} else {
+  // File is included from a chrome worker
+  importScripts("resource://gre/modules/osfile/osfile_shared_allthreads.jsm");
 }
 
 (function(exports) {
   "use strict";
   if (!exports.OS || !exports.OS.Shared) {
     throw new Error("osfile_unix_allthreads.jsm must be loaded after osfile_shared_allthreads.jsm");
   }
   if (exports.OS.Shared.Unix) {
--- a/toolkit/components/osfile/osfile_unix_back.jsm
+++ b/toolkit/components/osfile/osfile_unix_back.jsm
@@ -6,16 +6,18 @@
   if (typeof Components != "undefined") {
     // We do not wish osfile_unix_back.jsm to be used directly as a main thread
     // module yet. When time comes, it will be loaded by a combination of
     // a main thread front-end/worker thread implementation that makes sure
     // that we are not executing synchronous IO code in the main thread.
 
     throw new Error("osfile_unix_back.jsm cannot be used from the main thread yet");
   }
+  importScripts("resource://gre/modules/osfile/osfile_shared_allthreads.jsm");
+  importScripts("resource://gre/modules/osfile/osfile_unix_allthreads.jsm");
   (function(exports) {
      "use strict";
      if (!exports.OS) {
        exports.OS = {};
      }
      if (!exports.OS.Unix) {
        exports.OS.Unix = {};
      }
--- a/toolkit/components/osfile/osfile_unix_front.jsm
+++ b/toolkit/components/osfile/osfile_unix_front.jsm
@@ -11,16 +11,19 @@
 
 {
   if (typeof Components != "undefined") {
     // We do not wish osfile_unix_front.jsm to be used directly as a main thread
     // module yet.
 
     throw new Error("osfile_unix_front.jsm cannot be used from the main thread yet");
   }
+  importScripts("resource://gre/modules/osfile/osfile_unix_back.jsm");
+  importScripts("resource://gre/modules/osfile/ospath_unix_back.jsm");
+  importScripts("resource://gre/modules/osfile/osfile_shared_front.jsm");
   (function(exports) {
      "use strict";
 
      // exports.OS.Unix is created by osfile_unix_back.jsm
      if (exports.OS.File) {
        return; // Avoid double-initialization
      }
      exports.OS.Unix.File._init();
--- a/toolkit/components/osfile/osfile_win_allthreads.jsm
+++ b/toolkit/components/osfile/osfile_win_allthreads.jsm
@@ -17,16 +17,19 @@
  * - opened from a chrome worker through importScripts.
  */
 
 if (typeof Components != "undefined") {
   // Module is opened as a jsm module
   this.EXPORTED_SYMBOLS = ["OS"];
   Components.utils.import("resource://gre/modules/ctypes.jsm");
   Components.utils.import("resource://gre/modules/osfile/osfile_shared_allthreads.jsm", this);
+} else {
+  // File is included from a chrome worker
+  importScripts("resource://gre/modules/osfile/osfile_shared_allthreads.jsm");
 }
 
 (function(exports) {
   "use strict";
   if (!exports.OS || !exports.OS.Shared) {
     throw new Error("osfile_win_allthreads.jsm must be loaded after osfile_shared_allthreads.jsm");
   }
   if (exports.OS.Shared.Win) {
--- a/toolkit/components/osfile/osfile_win_back.jsm
+++ b/toolkit/components/osfile/osfile_win_back.jsm
@@ -23,16 +23,18 @@
   if (typeof Components != "undefined") {
     // We do not wish osfile_win.jsm to be used directly as a main thread
     // module yet. When time comes, it will be loaded by a combination of
     // a main thread front-end/worker thread implementation that makes sure
     // that we are not executing synchronous IO code in the main thread.
 
     throw new Error("osfile_win.jsm cannot be used from the main thread yet");
   }
+  importScripts("resource://gre/modules/osfile/osfile_shared_allthreads.jsm");
+  importScripts("resource://gre/modules/osfile/osfile_win_allthreads.jsm");
 
   (function(exports) {
      "use strict";
      if (!exports.OS) {
        exports.OS = {};
      }
      if (!exports.OS.Win) {
        exports.OS.Win = {};
--- a/toolkit/components/osfile/osfile_win_front.jsm
+++ b/toolkit/components/osfile/osfile_win_front.jsm
@@ -11,16 +11,20 @@
 
 {
   if (typeof Components != "undefined") {
     // We do not wish osfile_win_front.jsm to be used directly as a main thread
     // module yet.
     throw new Error("osfile_win_front.jsm cannot be used from the main thread yet");
   }
 
+  importScripts("resource://gre/modules/osfile/osfile_win_back.jsm");
+  importScripts("resource://gre/modules/osfile/ospath_win_back.jsm");
+  importScripts("resource://gre/modules/osfile/osfile_shared_front.jsm");
+
   (function(exports) {
      "use strict";
 
      // exports.OS.Win is created by osfile_win_back.jsm
      if (exports.OS.File) {
        return; // Avoid double-initialization
      }
      exports.OS.Win.File._init();