Bug 1599221 - Fixed promoting and demoting of object actors with watchpoints r=jlast

Differential Revision: https://phabricator.services.mozilla.com/D54955

--HG--
extra : moz-landing-system : lando
This commit is contained in:
jaril 2019-11-27 22:32:05 +00:00
Родитель fe5b5a8b0b
Коммит 658cf442ca
4 изменённых файлов: 35 добавлений и 14 удалений

Просмотреть файл

@ -13,8 +13,9 @@ const { method } = require("devtools/shared/protocol");
* used to accumulate and quickly dispose of groups of actors that
* share a lifetime.
*/
function ActorPool(connection) {
function ActorPool(connection, label) {
this.conn = connection;
this._label = label;
this._actors = {};
}
@ -114,6 +115,12 @@ ActorPool.prototype = {
yield actor;
}
},
dumpPool() {
for (const actor in this._actors) {
console.log(`>> ${actor}`);
}
},
};
exports.ActorPool = ActorPool;

Просмотреть файл

@ -42,7 +42,7 @@ const FrameActor = ActorClassWithSpec(frameSpec, {
_frameLifetimePool: null,
get frameLifetimePool() {
if (!this._frameLifetimePool) {
this._frameLifetimePool = new ActorPool(this.conn);
this._frameLifetimePool = new ActorPool(this.conn, "frame");
this.conn.addActorPool(this._frameLifetimePool);
}
return this._frameLifetimePool;

Просмотреть файл

@ -191,6 +191,8 @@ const proto = {
const { dbgDesc } = this._originalDescriptors.get(property);
this._originalDescriptors.delete(property);
this.obj.defineProperty(property, dbgDesc);
this.thread.demoteObjectGrip(this);
},
removeWatchpoints() {

Просмотреть файл

@ -198,7 +198,7 @@ const ThreadActor = ActorClassWithSpec(threadSpec, {
get threadLifetimePool() {
if (!this._threadLifetimePool) {
this._threadLifetimePool = new ActorPool(this.conn);
this._threadLifetimePool = new ActorPool(this.conn, "thread");
this.conn.addActorPool(this._threadLifetimePool);
this._threadLifetimePool.objectActors = new WeakMap();
}
@ -1499,7 +1499,7 @@ const ThreadActor = ActorClassWithSpec(threadSpec, {
// Create the actor pool that will hold the pause actor and its
// children.
assert(!this._pausePool, "No pause pool should exist yet");
this._pausePool = new ActorPool(this.conn);
this._pausePool = new ActorPool(this.conn, "pause");
this.conn.addActorPool(this._pausePool);
// Give children of the pause pool a quick link back to the
@ -1591,12 +1591,12 @@ const ThreadActor = ActorClassWithSpec(threadSpec, {
const popped = [];
// Create the actor pool that will hold the still-living frames.
const framePool = new ActorPool(this.conn);
const framesPool = new ActorPool(this.conn, "frames");
const frameList = [];
for (const frameActor of this._frameActors) {
if (frameActor.frame.live) {
framePool.addActor(frameActor);
framesPool.addActor(frameActor);
frameList.push(frameActor);
} else {
popped.push(frameActor.actorID);
@ -1605,13 +1605,13 @@ const ThreadActor = ActorClassWithSpec(threadSpec, {
// Remove the old frame actor pool, this will expire
// any actors that weren't added to the new pool.
if (this._framePool) {
this.conn.removeActorPool(this._framePool);
if (this._framesPool) {
this.conn.removeActorPool(this._framesPool);
}
this._frameActors = frameList;
this._framePool = framePool;
this.conn.addActorPool(framePool);
this._framesPool = framesPool;
this.conn.addActorPool(framesPool);
return popped;
},
@ -1623,7 +1623,7 @@ const ThreadActor = ActorClassWithSpec(threadSpec, {
const actor = new FrameActor(frame, this, depth);
this._frameActors.push(actor);
this._framePool.addActor(actor);
this._framesPool.addActor(actor);
frame.actor = actor;
return actor;
@ -1724,13 +1724,25 @@ const ThreadActor = ActorClassWithSpec(threadSpec, {
* The object actor.
*/
threadObjectGrip: function(actor) {
// We want to reuse the existing actor ID, so we just remove it from the
// current pool's weak map and then let pool.addActor do the rest.
actor.registeredPool.objectActors.delete(actor.obj);
// Save the reference for when we need to demote the object
// back to its original registered pool
actor.originalRegisteredPool = actor.registeredPool;
this.threadLifetimePool.addActor(actor);
this.threadLifetimePool.objectActors.set(actor.obj, actor);
},
demoteObjectGrip: function(actor) {
// We want to reuse the existing actor ID, so we just remove it from the
// current pool's weak map and then let ActorPool.addActor do the rest.
actor.registeredPool.objectActors.delete(actor.obj);
actor.originalRegisteredPool.addActor(actor);
actor.originalRegisteredPool.objectActors.set(actor.obj, actor);
delete actor.originalRegisteredPool;
},
_onWindowReady: function({ isTopLevel, isBFCache, window }) {
if (isTopLevel && this.state != "detached") {
this.sources.reset();