Bug 1361332 - replace sdk/util/object by Object.assign in devtools;r=zer0
authorJulian Descottes <jdescottes@mozilla.com>
Mon, 31 Jul 2017 19:53:37 +0200
changeset 420890 0a02ac4abd5e7a921191bb0e1576cf9bf800c7ff
parent 420889 8086b15aa74b55cce1d4101eaa41293f88d48c42
child 420891 9408284f094afd5e07eb4acea49cbff29474c8ee
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerszer0
bugs1361332
milestone56.0a1
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
Bug 1361332 - replace sdk/util/object by Object.assign in devtools;r=zer0 MozReview-Commit-ID: 3IREzyuAjAF
devtools/client/performance/modules/logic/waterfall-utils.js
devtools/server/actors/performance-recording.js
devtools/server/actors/performance.js
devtools/server/actors/script.js
devtools/server/performance/recorder.js
devtools/shared/fronts/inspector.js
devtools/shared/fronts/performance-recording.js
devtools/shared/fronts/profiler.js
devtools/shared/performance/recording-utils.js
devtools/shared/protocol.js
--- a/devtools/client/performance/modules/logic/waterfall-utils.js
+++ b/devtools/client/performance/modules/logic/waterfall-utils.js
@@ -2,29 +2,28 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 "use strict";
 
 /**
  * Utility functions for collapsing markers into a waterfall.
  */
 
-const { extend } = require("sdk/util/object");
 const { MarkerBlueprintUtils } = require("devtools/client/performance/modules/marker-blueprint-utils");
 
 /**
  * Creates a parent marker, which functions like a regular marker,
  * but is able to hold additional child markers.
  *
  * The marker is seeded with values from `marker`.
  * @param object marker
  * @return object
  */
 function createParentNode(marker) {
-  return extend(marker, { submarkers: [] });
+  return Object.assign({}, marker, { submarkers: [] });
 }
 
 /**
  * Collapses markers into a tree-like structure.
  * @param object rootNode
  * @param array markersList
  * @param array filter
  */
@@ -51,17 +50,17 @@ function collapseMarkersIntoNode({ rootN
 
     let finalized = false;
 
     // Extend the marker with extra properties needed in the marker tree
     let extendedProps = { index: i };
     if (collapsible) {
       extendedProps.submarkers = [];
     }
-    curr = extend(curr, extendedProps);
+    Object.assign(curr, extendedProps);
 
     // If not nestible, just push it inside the root node. Additionally,
     // markers originating outside the main thread are considered to be
     // "never collapsible", to avoid confusion.
     // A beter solution would be to collapse every marker with its siblings
     // from the same thread, but that would require a thread id attached
     // to all markers, which is potentially expensive and rather useless at
     // the moment, since we don't really have that many OTMT markers.
--- a/devtools/server/actors/performance-recording.js
+++ b/devtools/server/actors/performance-recording.js
@@ -2,29 +2,29 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 const { Actor, ActorClassWithSpec } = require("devtools/shared/protocol");
 const { performanceRecordingSpec } = require("devtools/shared/specs/performance-recording");
 
-loader.lazyRequireGetter(this, "merge", "sdk/util/object", true);
 loader.lazyRequireGetter(this, "RecordingUtils",
   "devtools/shared/performance/recording-utils");
 loader.lazyRequireGetter(this, "PerformanceRecordingCommon",
   "devtools/shared/performance/recording-common", true);
 
 /**
  * This actor wraps the Performance module at devtools/shared/shared/performance.js
  * and provides RDP definitions.
  *
  * @see devtools/shared/shared/performance.js for documentation.
  */
-const PerformanceRecordingActor = ActorClassWithSpec(performanceRecordingSpec, merge({
+const PerformanceRecordingActor = ActorClassWithSpec(performanceRecordingSpec,
+Object.assign({
   form: function (detail) {
     if (detail === "actorid") {
       return this.actorID;
     }
 
     let form = {
       // actorID is set when this is added to a pool
       actor: this.actorID,
@@ -137,12 +137,11 @@ const PerformanceRecordingActor = ActorC
         // in a waterfall view.
         this._markers = this._markers.sort((a, b) => (a.start > b.start));
 
         this._completed = true;
         break;
       }
     }
   },
-
 }, PerformanceRecordingCommon));
 
 exports.PerformanceRecordingActor = PerformanceRecordingActor;
--- a/devtools/server/actors/performance.js
+++ b/devtools/server/actors/performance.js
@@ -5,17 +5,16 @@
 "use strict";
 
 const { Task } = require("devtools/shared/task");
 const { Actor, ActorClassWithSpec } = require("devtools/shared/protocol");
 const { actorBridgeWithSpec } = require("devtools/server/actors/common");
 const { performanceSpec } = require("devtools/shared/specs/performance");
 
 loader.lazyRequireGetter(this, "events", "sdk/event/core");
-loader.lazyRequireGetter(this, "extend", "sdk/util/object", true);
 
 loader.lazyRequireGetter(this, "PerformanceRecorder",
   "devtools/server/performance/recorder", true);
 loader.lazyRequireGetter(this, "normalizePerformanceFeatures",
   "devtools/shared/performance/recording-utils", true);
 
 const PIPE_TO_FRONT_EVENTS = new Set([
   "recording-started", "recording-stopping", "recording-stopped",
--- a/devtools/server/actors/script.js
+++ b/devtools/server/actors/script.js
@@ -12,17 +12,16 @@ const { ActorPool, OriginalLocation, Gen
 const { ObjectActor, createValueGrip, longStringGrip } = require("devtools/server/actors/object");
 const { ActorClassWithSpec } = require("devtools/shared/protocol");
 const DevToolsUtils = require("devtools/shared/DevToolsUtils");
 const flags = require("devtools/shared/flags");
 const { assert, dumpn } = DevToolsUtils;
 const promise = require("promise");
 const xpcInspector = require("xpcInspector");
 const { DevToolsWorker } = require("devtools/shared/worker/worker");
-const object = require("sdk/util/object");
 const { threadSpec } = require("devtools/shared/specs/script");
 
 const { resolve, reject, all } = promise;
 
 loader.lazyGetter(this, "Debugger", () => {
   let Debugger = require("Debugger");
   hackDebugger(Debugger);
   return Debugger;
@@ -2035,17 +2034,17 @@ const ThreadActor = ActorClassWithSpec(t
       }
       result[actorID] = handler.call(actor, {});
     }
     return { from: this.actorID,
              actors: result };
   }
 });
 
-ThreadActor.prototype.requestTypes = object.merge(ThreadActor.prototype.requestTypes, {
+Object.assign(ThreadActor.prototype.requestTypes, {
   "attach": ThreadActor.prototype.onAttach,
   "detach": ThreadActor.prototype.onDetach,
   "reconfigure": ThreadActor.prototype.onReconfigure,
   "resume": ThreadActor.prototype.onResume,
   "clientEvaluate": ThreadActor.prototype.onClientEvaluate,
   "frames": ThreadActor.prototype.onFrames,
   "interrupt": ThreadActor.prototype.onInterrupt,
   "eventListeners": ThreadActor.prototype.onEventListeners,
--- a/devtools/server/performance/recorder.js
+++ b/devtools/server/performance/recorder.js
@@ -3,18 +3,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 "use strict";
 
 const { Cu } = require("chrome");
 const { Task } = require("devtools/shared/task");
 
 loader.lazyRequireGetter(this, "Services");
 loader.lazyRequireGetter(this, "promise");
-loader.lazyRequireGetter(this, "extend",
-  "sdk/util/object", true);
 loader.lazyRequireGetter(this, "Class",
   "sdk/core/heritage", true);
 loader.lazyRequireGetter(this, "EventTarget",
   "sdk/event/target", true);
 loader.lazyRequireGetter(this, "events",
   "sdk/event/core");
 
 loader.lazyRequireGetter(this, "Memory",
@@ -178,17 +176,17 @@ exports.PerformanceRecorder = Class({
     if (recordings.find(e => e.getLabel() === profileLabel)) {
       return;
     }
 
     // Immediately emit this so the client can start setting things up,
     // expecting a recording very soon.
     events.emit(this, "console-profile-start");
 
-    yield this.startRecording(extend({}, getPerformanceRecordingPrefs(), {
+    yield this.startRecording(Object.assign({}, getPerformanceRecordingPrefs(), {
       console: true,
       label: profileLabel
     }));
   }),
 
   /**
    * Invoked whenever `console.profileEnd` is called.
    *
@@ -344,17 +342,17 @@ exports.PerformanceRecorder = Class({
     if (options.withMarkers || options.withTicks || options.withMemory) {
       timelineStart = this._timeline.start(mapRecordingOptions("timeline", options));
     }
 
     if (options.withAllocations) {
       if (this._memory.getState() === "detached") {
         this._memory.attach();
       }
-      let recordingOptions = extend(mapRecordingOptions("memory", options), {
+      let recordingOptions = Object.assign(mapRecordingOptions("memory", options), {
         drainAllocationsTimeout: DRAIN_ALLOCATIONS_TIMEOUT
       });
       memoryStart = this._memory.startRecordingAllocations(recordingOptions);
     }
 
     let [profilerStartData, timelineStartData, memoryStartData] = yield promise.all([
       profilerStart, timelineStart, memoryStart
     ]);
@@ -475,17 +473,17 @@ exports.PerformanceRecorder = Class({
    */
   getConfiguration: function () {
     let allocationSettings = Object.create(null);
 
     if (this._memory.getState() === "attached") {
       allocationSettings = this._memory.getAllocationsSettings();
     }
 
-    return extend({}, allocationSettings, this._profiler.getStartOptions());
+    return Object.assign({}, allocationSettings, this._profiler.getStartOptions());
   },
 
   toString: () => "[object PerformanceRecorder]"
 });
 
 /**
  * Creates an object of configurations based off of
  * preferences for a PerformanceRecording.
--- a/devtools/shared/fronts/inspector.js
+++ b/devtools/shared/fronts/inspector.js
@@ -19,17 +19,16 @@ const {
   nodeSpec,
   nodeListSpec,
   walkerSpec
 } = require("devtools/shared/specs/inspector");
 const promise = require("promise");
 const defer = require("devtools/shared/defer");
 const { Task } = require("devtools/shared/task");
 const events = require("sdk/event/core");
-const object = require("sdk/util/object");
 const nodeConstants = require("devtools/shared/dom-node-constants.js");
 loader.lazyRequireGetter(this, "CommandUtils",
   "devtools/client/shared/developer-toolbar", true);
 
 const HIDDEN_CLASS = "__fx-devtools-hide-shortcut__";
 
 /**
  * Convenience API for building a list of attribute modifications
@@ -119,17 +118,17 @@ const NodeFront = FrontClassWithSpec(nod
     if (form.shortValue) {
       // If the value is not complete, set nodeValue to null, it will be fetched
       // when calling getNodeValue()
       form.nodeValue = form.incompleteValue ? null : form.shortValue;
     }
 
     // Shallow copy of the form.  We could just store a reference, but
     // eventually we'll want to update some of the data.
-    this._form = object.merge(form);
+    this._form = Object.assign({}, form);
     this._form.attrs = this._form.attrs ? this._form.attrs.slice() : [];
 
     if (form.parent) {
       // Get the owner actor for this actor (the walker), and find the
       // parent node of this actor from it, creating a standin node if
       // necessary.
       let parentNodeFront = ctx.marshallPool().ensureParentFront(form.parent);
       this.reparent(parentNodeFront);
@@ -767,17 +766,17 @@ const WalkerFront = FrontClassWithSpec(w
 
         if (!targetFront) {
           console.warn("Got a mutation for an unexpected actor: " + targetID +
             ", please file a bug on bugzilla.mozilla.org!");
           console.trace();
           continue;
         }
 
-        let emittedMutation = object.merge(change, { target: targetFront });
+        let emittedMutation = Object.assign(change, { target: targetFront });
 
         if (change.type === "childList" ||
             change.type === "nativeAnonymousChildList") {
           // Update the ownership tree according to the mutation record.
           let addedFronts = [];
           let removedFronts = [];
           for (let removed of change.removed) {
             let removedFront = this.get(removed);
--- a/devtools/shared/fronts/performance-recording.js
+++ b/devtools/shared/fronts/performance-recording.js
@@ -7,23 +7,23 @@ const { Front, FrontClassWithSpec } = re
 const { performanceRecordingSpec } = require("devtools/shared/specs/performance-recording");
 
 loader.lazyRequireGetter(this, "PerformanceIO",
   "devtools/client/performance/modules/io");
 loader.lazyRequireGetter(this, "PerformanceRecordingCommon",
   "devtools/shared/performance/recording-common", true);
 loader.lazyRequireGetter(this, "RecordingUtils",
   "devtools/shared/performance/recording-utils");
-loader.lazyRequireGetter(this, "merge", "sdk/util/object", true);
 
 /**
  * This can be used on older Profiler implementations, but the methods cannot
  * be changed -- you must introduce a new method, and detect the server.
  */
-const PerformanceRecordingFront = FrontClassWithSpec(performanceRecordingSpec, merge({
+const PerformanceRecordingFront = FrontClassWithSpec(performanceRecordingSpec,
+Object.assign({
   form: function (form, detail) {
     if (detail === "actorid") {
       this.actorID = form;
       return;
     }
     this.actorID = form.actor;
     this._form = form;
     this._configuration = form.configuration;
--- a/devtools/shared/fronts/profiler.js
+++ b/devtools/shared/fronts/profiler.js
@@ -7,17 +7,16 @@ const { Cu } = require("chrome");
 const {
   Front,
   FrontClassWithSpec,
   custom
 } = require("devtools/shared/protocol");
 const { profilerSpec } = require("devtools/shared/specs/profiler");
 
 loader.lazyRequireGetter(this, "events", "sdk/event/core");
-loader.lazyRequireGetter(this, "extend", "sdk/util/object", true);
 
 /**
  * This can be used on older Profiler implementations, but the methods cannot
  * be changed -- you must introduce a new method, and detect the server.
  */
 exports.ProfilerFront = FrontClassWithSpec(profilerSpec, {
   initialize: function (client, form) {
     Front.prototype.initialize.call(this, client, form);
@@ -35,17 +34,17 @@ exports.ProfilerFront = FrontClassWithSp
 
   /**
    * If using the protocol.js Fronts, then make stringify default,
    * since the read/write mechanisms will expose it as an object anyway, but
    * this lets other consumers who connect directly (xpcshell tests, Gecko Profiler) to
    * have unchanged behaviour.
    */
   getProfile: custom(function (options) {
-    return this._getProfile(extend({ stringify: true }, options));
+    return this._getProfile(Object.assign({ stringify: true }, options));
   }, {
     impl: "_getProfile"
   }),
 
   /**
    * Also emit an old `eventNotification` for older consumers of the profiler.
    */
   _onProfilerEvent: function (eventName, data) {
--- a/devtools/shared/performance/recording-utils.js
+++ b/devtools/shared/performance/recording-utils.js
@@ -1,16 +1,13 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 "use strict";
 
-loader.lazyRequireGetter(this, "extend",
-  "sdk/util/object", true);
-
 /**
  * Utility functions for managing recording models and their internal data,
  * such as filtering profile samples or offsetting timestamps.
  */
 
 function mapRecordingOptions(type, options) {
   if (type === "profiler") {
     return {
--- a/devtools/shared/protocol.js
+++ b/devtools/shared/protocol.js
@@ -4,17 +4,16 @@
 
 "use strict";
 
 var promise = require("promise");
 var defer = require("devtools/shared/defer");
 var {Class} = require("sdk/core/heritage");
 var {EventTarget} = require("sdk/event/target");
 var events = require("sdk/event/core");
-var object = require("sdk/util/object");
 var {getStack, callFunctionWithAsyncStack} = require("devtools/shared/platform/stack");
 var {settleAll} = require("devtools/shared/DevToolsUtils");
 
 exports.emit = events.emit;
 
 /**
  * Types: named marshallers/demarshallers.
  *
@@ -142,17 +141,17 @@ function identityWrite(v) {
  *
  * @returns a type object that can be used in protocol definitions.
  */
 types.addType = function (name, typeObject = {}, options = {}) {
   if (registeredTypes.has(name)) {
     throw Error("Type '" + name + "' already exists.");
   }
 
-  let type = object.merge({
+  let type = Object.assign({
     toString() {
       return "[protocol type:" + name + "]";
     },
     name: name,
     primitive: !(typeObject.read || typeObject.write),
     read: identityWrite,
     write: identityWrite
   }, typeObject);
@@ -1004,50 +1003,50 @@ var generateActorSpec = function (actorD
         actorSpec[name] = types.addDictType(actorDesc.typeName + "__" + name, desc.value);
       }
     }
 
     if (desc.value._methodSpec) {
       let methodSpec = desc.value._methodSpec;
       let spec = {};
       spec.name = methodSpec.name || name;
-      spec.request = Request(object.merge({type: spec.name},
+      spec.request = Request(Object.assign({type: spec.name},
                                           methodSpec.request || undefined));
       spec.response = Response(methodSpec.response || undefined);
       spec.release = methodSpec.release;
       spec.oneway = methodSpec.oneway;
 
       actorSpec.methods.push(spec);
     }
   }
 
   // Find additional method specifications
   if (actorDesc.methods) {
     for (let name in actorDesc.methods) {
       let methodSpec = actorDesc.methods[name];
       let spec = {};
 
       spec.name = methodSpec.name || name;
-      spec.request = Request(object.merge({type: spec.name},
+      spec.request = Request(Object.assign({type: spec.name},
                                           methodSpec.request || undefined));
       spec.response = Response(methodSpec.response || undefined);
       spec.release = methodSpec.release;
       spec.oneway = methodSpec.oneway;
 
       actorSpec.methods.push(spec);
     }
   }
 
   // Find event specifications
   if (actorDesc.events) {
     actorSpec.events = new Map();
     for (let name in actorDesc.events) {
       let eventRequest = actorDesc.events[name];
       Object.freeze(eventRequest);
-      actorSpec.events.set(name, Request(object.merge({type: name}, eventRequest)));
+      actorSpec.events.set(name, Request(Object.assign({type: name}, eventRequest)));
     }
   }
 
   if (!registeredTypes.has(actorSpec.typeName)) {
     types.addActorType(actorSpec.typeName);
   }
   registeredTypes.get(actorSpec.typeName).actorSpec = actorSpec;