Reland "[global-handles] Do not clear finalization callback on moving"

This is a reland of d8a457cbb7

Original change's description:
> [global-handles] Do not clear finalization callback on moving
>
> Bug: chromium:923361
> Change-Id: Id4a0f6515f6b17cec2732df561c1e82080dc29c8
> Reviewed-on: https://chromium-review.googlesource.com/c/1462963
> Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#59498}

Bug: chromium:923361
Tbr: mlippautz@chromium.org
Change-Id: I05bbaa05daf07232f5356cb0a71d6d1c959ddadd
Reviewed-on: https://chromium-review.googlesource.com/c/1466648
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Mythri Alle <mythria@chromium.org>
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59533}
This commit is contained in:
Michael Lippautz 2019-02-11 14:24:44 +01:00 committed by Commit Bot
parent a439a7a210
commit 0a78f454cc

View File

@ -654,6 +654,7 @@ class GlobalHandles::TracedNode final
set_parameter(parameter);
callback_ = callback;
}
bool HasFinalizationCallback() const { return callback_ != nullptr; }
void CollectPhantomCallbackData(
std::vector<std::pair<TracedNode*, PendingPhantomCallback>>*
@ -769,7 +770,12 @@ void GlobalHandles::MoveTracedGlobal(Address** from, Address** to) {
DCHECK_NOT_NULL(*to);
DCHECK_EQ(*from, *to);
TracedNode* node = TracedNode::FromLocation(*from);
node->set_parameter(to);
// Only set the backpointer for clearing a phantom handle when there is no
// finalization callback attached. As soon as a callback is attached to a node
// the embedder is on its own when resetting a handle.
if (!node->HasFinalizationCallback()) {
node->set_parameter(to);
}
}
void GlobalHandles::Destroy(Address* location) {