Bug 1108930 - Part 5: Call Map and Set with new in devtools. r=fitzgen
authorTooru Fujisawa <arai_a@mac.com>
Thu, 05 Feb 2015 00:59:15 +0900
changeset 227457 94276cdcc5fff760aec3eb59eaf866335ab9360c
parent 227456 65c74fc6e769c07901f04090a3d4fbffbddbc471
child 227458 798dc45a56108aea24215de76990d5b406182e6e
push id55126
push userarai_a@mac.com
push dateWed, 04 Feb 2015 16:00:49 +0000
treeherdermozilla-inbound@2c896a4f15ae [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfitzgen
bugs1108930
milestone38.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 1108930 - Part 5: Call Map and Set with new in devtools. r=fitzgen
browser/devtools/framework/ToolboxProcess.jsm
browser/devtools/shared/widgets/VariablesView.jsm
browser/devtools/shared/widgets/ViewHelpers.jsm
js/src/devtools/rootAnalysis/computeGCTypes.js
toolkit/devtools/server/tests/unit/test_breakpoint-actor-map.js
toolkit/devtools/server/tests/unit/test_forwardingprefix.js
--- a/browser/devtools/framework/ToolboxProcess.jsm
+++ b/browser/devtools/framework/ToolboxProcess.jsm
@@ -23,17 +23,17 @@ XPCOMUtils.defineLazyGetter(this, "Telem
 });
 XPCOMUtils.defineLazyGetter(this, "EventEmitter", function () {
   return devtools.require("devtools/toolkit/event-emitter");
 });
 const { Promise: promise } = Cu.import("resource://gre/modules/Promise.jsm", {});
 
 this.EXPORTED_SYMBOLS = ["BrowserToolboxProcess"];
 
-let processes = Set();
+let processes = new Set();
 
 /**
  * Constructor for creating a process that will hold a chrome toolbox.
  *
  * @param function aOnClose [optional]
  *        A function called when the process stops running.
  * @param function aOnRun [optional]
  *        A function called when the process starts running.
--- a/browser/devtools/shared/widgets/VariablesView.jsm
+++ b/browser/devtools/shared/widgets/VariablesView.jsm
@@ -2111,17 +2111,17 @@ Scope.prototype = {
   _title: null,
   _enum: null,
   _nonenum: null,
 };
 
 // Creating maps and arrays thousands of times for variables or properties
 // with a large number of children fills up a lot of memory. Make sure
 // these are instantiated only if needed.
-DevToolsUtils.defineLazyPrototypeGetter(Scope.prototype, "_store", Map);
+DevToolsUtils.defineLazyPrototypeGetter(Scope.prototype, "_store", () => new Map());
 DevToolsUtils.defineLazyPrototypeGetter(Scope.prototype, "_enumItems", Array);
 DevToolsUtils.defineLazyPrototypeGetter(Scope.prototype, "_nonEnumItems", Array);
 
 // An ellipsis symbol (usually "…") used for localization.
 XPCOMUtils.defineLazyGetter(Scope, "ellipsis", () =>
   Services.prefs.getComplexValue("intl.ellipsis", Ci.nsIPrefLocalizedString).data);
 
 /**
--- a/browser/devtools/shared/widgets/ViewHelpers.jsm
+++ b/browser/devtools/shared/widgets/ViewHelpers.jsm
@@ -612,17 +612,17 @@ Item.prototype = {
   _target: null,
   _prebuiltNode: null,
   finalize: null,
   attachment: null
 };
 
 // Creating maps thousands of times for widgets with a large number of children
 // fills up a lot of memory. Make sure these are instantiated only if needed.
-DevToolsUtils.defineLazyPrototypeGetter(Item.prototype, "_itemsByElement", Map);
+DevToolsUtils.defineLazyPrototypeGetter(Item.prototype, "_itemsByElement", () => new Map());
 
 /**
  * Some generic Widget methods handling Item instances.
  * Iterable via "for (let childItem of wrappedView) { }".
  *
  * Usage:
  *   function MyView() {
  *     this.widget = new MyWidget(document.querySelector(".my-node"));
--- a/js/src/devtools/rootAnalysis/computeGCTypes.js
+++ b/js/src/devtools/rootAnalysis/computeGCTypes.js
@@ -92,26 +92,26 @@ function markGCType(typeName, child, why
 
     if (depth == 0 && isRootedTypeName(typeName))
         return;
     if (depth == 1 && isRootedPointerTypeName(typeName))
         return;
 
     if (depth == 0) {
         if (!(typeName in gcTypes))
-            gcTypes[typeName] = Set();
+            gcTypes[typeName] = new Set();
         gcTypes[typeName].add(why);
     } else if (depth == 1) {
         if (!(typeName in gcPointers))
-            gcPointers[typeName] = Set();
+            gcPointers[typeName] = new Set();
         gcPointers[typeName].add(why);
     }
 
     if (!(typeName in gcFields))
-        gcFields[typeName] = Map();
+        gcFields[typeName] = new Map();
     gcFields[typeName].set(why, [ child, ptrdness ]);
 
     if (typeName in structureParents) {
         for (var field of structureParents[typeName]) {
             var [ holderType, fieldName ] = field;
             markGCType(holderType, typeName, fieldName, depth, 0);
         }
     }
@@ -143,17 +143,17 @@ addGCType('js::ion::IonCode');
 addGCPointer('JS::Value');
 addGCPointer('jsid');
 
 // AutoCheckCannotGC should also not be held live across a GC function.
 addGCPointer('JS::AutoCheckCannotGC');
 
 function explain(csu, indent, seen) {
     if (!seen)
-        seen = Set();
+        seen = new Set();
     seen.add(csu);
     if (!(csu in gcFields))
         return;
     if (gcFields[csu].has('<annotation>')) {
         print(indent + "which is a GCThing because I said so");
         return;
     }
     if (gcFields[csu].has('<pointer-annotation>')) {
--- a/toolkit/devtools/server/tests/unit/test_breakpoint-actor-map.js
+++ b/toolkit/devtools/server/tests/unit/test_breakpoint-actor-map.js
@@ -116,35 +116,35 @@ function test_find_actors() {
   let bpStore = new BreakpointActorMap();
 
   for (let bp of bps) {
     bpStore.setActor(bp, bp);
   }
 
   // All breakpoints
 
-  let bpSet = Set(bps);
+  let bpSet = new Set(bps);
   for (let bp of bpStore.findActors()) {
     bpSet.delete(bp);
   }
   do_check_eq(bpSet.size, 0,
               "Should be able to iterate over all breakpoints");
 
   // Breakpoints by URL
 
-  bpSet = Set(bps.filter(bp => { return bp.sourceActor.actorID === "actor1" }));
+  bpSet = new Set(bps.filter(bp => { return bp.sourceActor.actorID === "actor1" }));
   for (let bp of bpStore.findActors({ sourceActor: { actorID: "actor1" } })) {
     bpSet.delete(bp);
   }
   do_check_eq(bpSet.size, 0,
               "Should be able to filter the iteration by url");
 
   // Breakpoints by URL and line
 
-  bpSet = Set(bps.filter(bp => { return bp.sourceActor.actorID === "actor1" && bp.line === 10; }));
+  bpSet = new Set(bps.filter(bp => { return bp.sourceActor.actorID === "actor1" && bp.line === 10; }));
   let first = true;
   for (let bp of bpStore.findActors({ sourceActor: { actorID: "actor1" }, line: 10 })) {
     if (first) {
       do_check_eq(bp.column, undefined,
                   "Should always get the whole line breakpoint first");
       first = false;
     } else {
       do_check_neq(bp.column, undefined,
--- a/toolkit/devtools/server/tests/unit/test_forwardingprefix.js
+++ b/toolkit/devtools/server/tests/unit/test_forwardingprefix.js
@@ -99,17 +99,17 @@ function tryActors(aReachables, aComplet
 
 /*
  * With no forwarding established, sending messages to root should work,
  * but sending messages to prefixed actor names, or anyone else, should get
  * an error.
  */
 function TestNoForwardingYet()
 {
-  tryActors(Set(['root']), run_next_test);
+  tryActors(new Set(['root']), run_next_test);
 }
 
 /*
  * Create a new pipe connection which forwards its reply packets to
  * gMainConnection's client, and to which gMainConnection forwards packets
  * directed to actors whose names begin with |aPrefix + '/'|, and.
  *
  * Return an object { conn, transport }, as for newConnection.
@@ -133,31 +133,31 @@ function createSubconnection1()
   gSubconnection1 = conn;
   transport.ready();
   gClient.expectReply('prefix1/root', (aReply) => run_next_test());
 }
 
 // Establish forwarding, but don't put any actors in that server.
 function TestForwardPrefix1OnlyRoot()
 {
-  tryActors(Set(['root', 'prefix1/root']), run_next_test);
+  tryActors(new Set(['root', 'prefix1/root']), run_next_test);
 }
 
 /* Create a third root actor, to which we can forward things. */
 function createSubconnection2()
 {
   let { conn, transport } = newSubconnection('prefix2');
   gSubconnection2 = conn;
   transport.ready();
   gClient.expectReply('prefix2/root', (aReply) => run_next_test());
 }
 
 function TestForwardPrefix12OnlyRoot()
 {
-  tryActors(Set(['root', 'prefix1/root', 'prefix2/root']), run_next_test);
+  tryActors(new Set(['root', 'prefix1/root', 'prefix2/root']), run_next_test);
 }
 
 // A dumb actor that implements 'echo'.
 //
 // It's okay that both subconnections' actors behave identically, because
 // the reply-sending code attaches the replying actor's name to the packet,
 // so simply matching the 'from' field in the reply ensures that we heard
 // from the right actor.
@@ -178,19 +178,19 @@ EchoActor.prototype.requestTypes = {
 };
 
 function TestForwardPrefix12WithActor1()
 {
   let actor = new EchoActor(gSubconnection1)
   actor.actorID = 'prefix1/actor';
   gSubconnection1.addActor(actor);
 
-  tryActors(Set(['root', 'prefix1/root', 'prefix1/actor', 'prefix2/root']), run_next_test);
+  tryActors(new Set(['root', 'prefix1/root', 'prefix1/actor', 'prefix2/root']), run_next_test);
 }
 
 function TestForwardPrefix12WithActor12()
 {
   let actor = new EchoActor(gSubconnection2)
   actor.actorID = 'prefix2/actor';
   gSubconnection2.addActor(actor);
 
-  tryActors(Set(['root', 'prefix1/root', 'prefix1/actor', 'prefix2/root', 'prefix2/actor']), run_next_test);
+  tryActors(new Set(['root', 'prefix1/root', 'prefix1/actor', 'prefix2/root', 'prefix2/actor']), run_next_test);
 }