Backed out changesets 19dd0130c6ae and d986a560fbdd (bug 865387) for Android test failures on a CLOSED TREE.
authorRyan VanderMeulen <ryanvm@gmail.com>
Mon, 26 Aug 2013 15:02:15 -0400
changeset 144344 1156c0bc98b1994ca3c587215ad1a7e9128abcc7
parent 144343 3fdb05a3cba27e03451b106db1fdd89ecf2413e7
child 144345 002ded1402a80107bb2d152ac7565b180b426406
push id25159
push userryanvm@gmail.com
push dateTue, 27 Aug 2013 00:17:44 +0000
treeherdermozilla-central@4353fc5afb5d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs865387
milestone26.0a1
backs out19dd0130c6ae1abfc714b68e19c32f22af210eb8
d986a560fbdd65c7effeb312512ce32d1edb1f2a
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
Backed out changesets 19dd0130c6ae and d986a560fbdd (bug 865387) for Android test failures on a CLOSED TREE.
dom/system/OSFileConstants.cpp
toolkit/components/osfile/modules/osfile_async_front.jsm
toolkit/components/osfile/modules/osfile_async_worker.js
toolkit/components/osfile/modules/osfile_shared_allthreads.jsm
toolkit/components/osfile/modules/osfile_shared_front.jsm
toolkit/components/osfile/modules/osfile_unix_back.jsm
toolkit/components/osfile/modules/osfile_unix_front.jsm
--- a/dom/system/OSFileConstants.cpp
+++ b/dom/system/OSFileConstants.cpp
@@ -10,20 +10,16 @@
 #include "prsystem.h"
 
 #if defined(XP_UNIX)
 #include "unistd.h"
 #include "dirent.h"
 #include "sys/stat.h"
 #endif // defined(XP_UNIX)
 
-#if defined(XP_LINUX)
-#include <linux/fadvise.h>
-#endif // defined(XP_LINUX)
-
 #if defined(XP_MACOSX)
 #include "copyfile.h"
 #endif // defined(XP_MACOSX)
 
 #if defined(XP_WIN)
 #include <windows.h>
 #endif // defined(XP_WIN)
 
@@ -319,20 +315,16 @@ static const dom::ConstantSpec gLibcProp
 #endif //defined(AT_EACCESS)
 #if defined(AT_FDCWD)
   INT_CONSTANT(AT_FDCWD),
 #endif //defined(AT_FDCWD)
 #if defined(AT_SYMLINK_NOFOLLOW)
   INT_CONSTANT(AT_SYMLINK_NOFOLLOW),
 #endif //defined(AT_SYMLINK_NOFOLLOW)
 
-#if defined(POSIX_FADV_SEQUENTIAL)
-  INT_CONSTANT(POSIX_FADV_SEQUENTIAL),
-#endif //defined(POSIX_FADV_SEQUENTIAL)
-
   // access
 #if defined(F_OK)
   INT_CONSTANT(F_OK),
   INT_CONSTANT(R_OK),
   INT_CONSTANT(W_OK),
   INT_CONSTANT(X_OK),
 #endif // defined(F_OK)
 
--- a/toolkit/components/osfile/modules/osfile_async_front.jsm
+++ b/toolkit/components/osfile/modules/osfile_async_front.jsm
@@ -89,19 +89,57 @@ if (!("localProfileDir" in OS.Constants.
         // Ignore errors: localProfileDir is still not available
       }
       return path;
     }
   });
 }
 
 /**
+ * A global constant used as a default refs parameter value when cloning.
+ */
+const noRefs = [];
+
+/**
  * Return a shallow clone of the enumerable properties of an object.
+ *
+ * Utility used whenever normalizing options requires making (shallow)
+ * changes to an option object. The copy ensures that we do not modify
+ * a client-provided object by accident.
+ *
+ * Note: to reference and not copy specific fields, provide an optional
+ * |refs| argument containing their names.
+ *
+ * @param {JSON} object Options to be cloned.
+ * @param {Array} refs An optional array of field names to be passed by
+ * reference instead of copying.
  */
-let clone = SharedAll.clone;
+let clone = function clone(object, refs = noRefs) {
+  let result = {};
+  // Make a reference between result[key] and object[key].
+  let refer = function refer(result, key, object) {
+    Object.defineProperty(result, key, {
+        enumerable: true,
+        get: function() {
+            return object[key];
+        },
+        set: function(value) {
+            object[key] = value;
+        }
+    });
+  };
+  for (let k in object) {
+    if (refs.indexOf(k) < 0) {
+      result[k] = object[k];
+    } else {
+      refer(result, k, object);
+    }
+  }
+  return result;
+};
 
 let worker = new PromiseWorker(
   "resource://gre/modules/osfile/osfile_async_worker.js", LOG);
 let Scheduler = {
   post: function post(...args) {
     // By convention, the last argument of any message may be an |options| object.
     let methodArgs = args[1];
     let options = methodArgs ? methodArgs[methodArgs.length - 1] : null;
@@ -324,18 +362,19 @@ File.prototype = {
    * @return {promise}
    * @resolves {number} The number of bytes effectively read.
    * @rejects {OS.File.Error}
    */
   readTo: function readTo(buffer, options = {}) {
     // If |buffer| is a typed array and there is no |bytes| options, we
     // need to extract the |byteLength| now, as it will be lost by
     // communication
-    if (isTypedArray(buffer) && !("bytes" in options)) {
-      // Preserve reference to option |outExecutionDuration|, if it is passed.
+    if (isTypedArray(buffer) && (!options || !("bytes" in options))) {
+      // Preserve the reference to |outExecutionDuration| option if it is
+      // passed.
       options = clone(options, ["outExecutionDuration"]);
       options.bytes = buffer.byteLength;
     }
     // Note: Type.void_t.out_ptr.toMsg ensures that
     // - the buffer is effectively shared (not neutered) between both
     //   threads;
     // - we take care of any |byteOffset|.
     return Scheduler.post("File_prototype_readTo",
@@ -361,18 +400,19 @@ File.prototype = {
    * if |buffer| is a C pointer.
    *
    * @return {number} The number of bytes actually written.
    */
   write: function write(buffer, options = {}) {
     // If |buffer| is a typed array and there is no |bytes| options,
     // we need to extract the |byteLength| now, as it will be lost
     // by communication
-    if (isTypedArray(buffer)) {
-      // Preserve reference to option |outExecutionDuration|, if it is passed.
+    if (isTypedArray(buffer) && (!options || !("bytes" in options))) {
+      // Preserve the reference to |outExecutionDuration| option if it is
+      // passed.
       options = clone(options, ["outExecutionDuration"]);
       options.bytes = buffer.byteLength;
     }
     // Note: Type.void_t.out_ptr.toMsg ensures that
     // - the buffer is effectively shared (not neutered) between both
     //   threads;
     // - we take care of any |byteOffset|.
     return Scheduler.post("File_prototype_write",
@@ -383,24 +423,23 @@ File.prototype = {
   },
 
   /**
    * Read bytes from this file to a new buffer.
    *
    * @param {number=} bytes If unspecified, read all the remaining bytes from
    * this file. If specified, read |bytes| bytes, or less if the file does not
    * contain that many bytes.
-   * @param {JSON} options
    * @return {promise}
    * @resolves {Uint8Array} An array containing the bytes read.
    */
-  read: function read(nbytes, options = {}) {
+  read: function read(nbytes) {
     let promise = Scheduler.post("File_prototype_read",
       [this._fdmsg,
-       nbytes, options]);
+       nbytes]);
     return promise.then(
       function onSuccess(data) {
         return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
       });
   },
 
   /**
    * Return the current position in the file, as bytes.
@@ -595,21 +634,16 @@ File.makeDir = function makeDir(path, op
 
 /**
  * Return the contents of a file
  *
  * @param {string} path The path to the file.
  * @param {number=} bytes Optionally, an upper bound to the number of bytes
  * to read.
  * @param {JSON} options Additional options.
- * - {boolean} sequential A flag that triggers a population of the page cache
- * with data from a file so that subsequent reads from that file would not
- * block on disk I/O. If |true| or unspecified, inform the system that the
- * contents of the file will be read in order. Otherwise, make no such
- * assumption. |true| by default.
  *
  * @resolves {Uint8Array} A buffer holding the bytes
  * read from the file.
  */
 File.read = function read(path, bytes, options) {
   let promise = Scheduler.post("read",
     [Type.path.toMsg(path), bytes, options], path);
   return promise.then(
--- a/toolkit/components/osfile/modules/osfile_async_worker.js
+++ b/toolkit/components/osfile/modules/osfile_async_worker.js
@@ -267,17 +267,17 @@ if (this.Components) {
          let file = File.open(filePath, mode, options);
          return OpenedFiles.add(file, {
            // Adding path information to keep track of opened files
            // to report leaks when debugging.
            path: filePath
          });
        },
        read: function read(path, bytes, options) {
-         let data = File.read(Type.path.fromMsg(path), bytes, options);
+         let data = File.read(Type.path.fromMsg(path), bytes);
          return new Transfer({buffer: data.buffer, byteOffset: data.byteOffset, byteLength: data.byteLength}, [data.buffer]);
        },
        exists: function exists(path) {
          return File.exists(Type.path.fromMsg(path));
        },
        writeAtomic: function writeAtomic(path, buffer, options) {
          if (options.tmpPath) {
            options.tmpPath = Type.path.fromMsg(options.tmpPath);
--- a/toolkit/components/osfile/modules/osfile_shared_allthreads.jsm
+++ b/toolkit/components/osfile/modules/osfile_shared_allthreads.jsm
@@ -29,17 +29,16 @@ if (typeof Components != "undefined") {
   const Ci = Components.interfaces;
   const Cc = Components.classes;
 
   Cu.import("resource://gre/modules/Services.jsm", this);
 }
 
 let EXPORTED_SYMBOLS = [
   "LOG",
-  "clone",
   "Config",
   "Constants",
   "Type",
   "HollowStructure",
   "OSError",
   "declareFFI",
   "projectValue",
   "isTypedArray",
@@ -158,56 +157,16 @@ let LOG = function (...args) {
       Services.console.logStringMessage(message + "\n");
     };
   }
   logFunc.apply(null, [stringifyArg(arg) for (arg of args)]);
 };
 
 exports.LOG = LOG;
 
-/**
- * Return a shallow clone of the enumerable properties of an object.
- *
- * Utility used whenever normalizing options requires making (shallow)
- * changes to an option object. The copy ensures that we do not modify
- * a client-provided object by accident.
- *
- * Note: to reference and not copy specific fields, provide an optional
- * |refs| argument containing their names.
- *
- * @param {JSON} object Options to be cloned.
- * @param {Array} refs An optional array of field names to be passed by
- * reference instead of copying.
- */
-let clone = function (object, refs = []) {
-  let result = {};
-  // Make a reference between result[key] and object[key].
-  let refer = function refer(result, key, object) {
-    Object.defineProperty(result, key, {
-      enumerable: true,
-      get: function() {
-        return object[key];
-      },
-      set: function(value) {
-        object[key] = value;
-      }
-    });
-  };
-  for (let k in object) {
-    if (refs.indexOf(k) < 0) {
-      result[k] = object[k];
-    } else {
-      refer(result, k, object);
-    }
-  }
-  return result;
-};
-
-exports.clone = clone;
-
 ///////////////////// Abstractions above js-ctypes
 
 /**
  * Abstraction above js-ctypes types.
  *
  * Use values of this type to register FFI functions. In addition to the
  * usual features of js-ctypes, values of this type perform the necessary
  * transformations to ensure that C errors are handled nicely, to connect
@@ -1010,17 +969,16 @@ exports.OSError = OSError;
 ///////////////////// Temporary boilerplate
 // Boilerplate, to simplify the transition to require()
 // Do not rely upon this symbol, it will disappear with
 // bug 883050.
 exports.OS = {
   Constants: exports.Constants,
   Shared: {
     LOG: LOG,
-    clone: clone,
     Type: Type,
     HollowStructure: HollowStructure,
     Error: OSError,
     declareFFI: declareFFI,
     projectValue: projectValue,
     isTypedArray: isTypedArray,
     defineLazyGetter: defineLazyGetter,
     offsetBy: offsetBy
@@ -1052,8 +1010,9 @@ Object.defineProperty(exports.OS.Shared,
 
 ///////////////////// Permanent boilerplate
 if (typeof Components != "undefined") {
   this.EXPORTED_SYMBOLS = EXPORTED_SYMBOLS;
   for (let symbol of EXPORTED_SYMBOLS) {
     this[symbol] = exports[symbol];
   }
 }
+
--- a/toolkit/components/osfile/modules/osfile_shared_front.jsm
+++ b/toolkit/components/osfile/modules/osfile_shared_front.jsm
@@ -12,17 +12,16 @@
 if (typeof Components != "undefined") {
   throw new Error("osfile_shared_front.jsm cannot be used from the main thread");
 }
 (function(exports) {
 
 exports.OS = require("resource://gre/modules/osfile/osfile_shared_allthreads.jsm").OS;
 
 let LOG = exports.OS.Shared.LOG.bind(OS.Shared, "Shared front-end");
-let clone = exports.OS.Shared.clone;
 
 /**
  * Code shared by implementations of File.
  *
  * @param {*} fd An OS-specific file handle.
  * @constructor
  */
 let AbstractFile = function AbstractFile(fd) {
@@ -40,27 +39,27 @@ AbstractFile.prototype = {
       return this._fd;
     }
     throw OS.File.Error.closed();
   },
   /**
    * Read bytes from this file to a new buffer.
    *
    * @param {number=} bytes If unspecified, read all the remaining bytes from
-   * this file. If specified, read |bytes| bytes, or less if the file does notclone
+   * this file. If specified, read |bytes| bytes, or less if the file does not
    * contain that many bytes.
-   * @param {JSON} options
    * @return {Uint8Array} An array containing the bytes read.
    */
-  read: function read(bytes, options = {}) {
-    options = clone(options);
-    options.bytes = bytes == null ? this.stat().size : bytes;
-    let buffer = new Uint8Array(options.bytes);
-    let size = this.readTo(buffer, options);
-    if (size == options.bytes) {
+  read: function read(bytes) {
+    if (bytes == null) {
+      bytes = this.stat().size;
+    }
+    let buffer = new Uint8Array(bytes);
+    let size = this.readTo(buffer, {bytes: bytes});
+    if (size == bytes) {
       return buffer;
     } else {
       return buffer.subarray(0, size);
     }
   },
 
   /**
    * Read bytes from this file to an existing buffer.
@@ -287,25 +286,24 @@ AbstractFile.normalizeOpenMode = functio
 };
 
 /**
  * Return the contents of a file.
  *
  * @param {string} path The path to the file.
  * @param {number=} bytes Optionally, an upper bound to the number of bytes
  * to read.
- * @param {JSON} options Optionally contains additional options.
  *
  * @return {Uint8Array} A buffer holding the bytes
  * and the number of bytes read from the file.
  */
-AbstractFile.read = function read(path, bytes, options = {}) {
+AbstractFile.read = function read(path, bytes) {
   let file = exports.OS.File.open(path);
   try {
-    return file.read(bytes, options);
+    return file.read(bytes);
   } finally {
     file.close();
   }
 };
 
 /**
  * Write a file, atomically.
  *
--- a/toolkit/components/osfile/modules/osfile_unix_back.jsm
+++ b/toolkit/components/osfile/modules/osfile_unix_back.jsm
@@ -442,24 +442,16 @@
 
        UnixFile.read =
          declareFFI("read", ctypes.default_abi,
                     /*return*/Types.negativeone_or_ssize_t,
                     /*fd*/    Types.fd,
                     /*buf*/   Types.void_t.out_ptr,
                     /*nbytes*/Types.size_t);
 
-       UnixFile.posix_fadvise =
-         declareFFI("posix_fadvise", ctypes.default_abi,
-                    /*return*/ Types.int,
-                    /*fd*/     Types.fd,
-                    /*offset*/ Types.off_t,
-                    /*len*/    Types.off_t,
-                    /*advise*/ Types.int);
-
        if (OS.Constants.libc._DARWIN_FEATURE_64_BIT_INODE) {
          // Special case for MacOS X 10.5+
          // Symbol name "readdir" still exists but is used for a
          // deprecated function that does not match the
          // constants of |OS.Constants.libc|.
          UnixFile.readdir =
            declareFFI("readdir$INODE64", ctypes.default_abi,
                      /*return*/Types.null_or_dirent_ptr,
--- a/toolkit/components/osfile/modules/osfile_unix_front.jsm
+++ b/toolkit/components/osfile/modules/osfile_unix_front.jsm
@@ -87,23 +87,16 @@
       * @param {*=} options Additional options for reading. Ignored in
       * this implementation.
       *
       * @return {number} The number of bytes effectively read. If zero,
       * the end of the file has been reached.
       * @throws {OS.File.Error} In case of I/O error.
       */
      File.prototype._read = function _read(buffer, nbytes, options) {
-      // Populate the page cache with data from a file so the subsequent reads
-      // from that file will not block on disk I/O.
-       if ((UnixFile.posix_fadvise &&
-            options.sequential || !("sequential" in options))) {
-         UnixFile.posix_fadvise(this.fd, 0, nbytes,
-          OS.Constants.libc.POSIX_FADV_SEQUENTIAL);
-       }
        return throw_on_negative("read",
          UnixFile.read(this.fd, buffer, nbytes)
        );
      };
 
      /**
       * Write some bytes to a file.
       *