Skip to content

Commit 4e1544b

Browse files
sygCommit Bot
authored andcommitted
[weakrefs] Fix [[KeptObjects]] assertion for only when a microtask checkpoint is performed
Bug: chromium:1073263 Change-Id: I5c054e34242a91dafd6788814a39e97075d1035d Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2160019 Reviewed-by: Ross McIlroy <rmcilroy@chromium.org> Commit-Queue: Shu-yu Guo <syg@chromium.org> Cr-Commit-Position: refs/heads/master@{#67319}
1 parent 3a8feab commit 4e1544b

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

src/api/api.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ class CallDepthScope {
328328
bool CheckKeptObjectsClearedAfterMicrotaskCheckpoint(
329329
i::MicrotaskQueue* microtask_queue) {
330330
bool did_perform_microtask_checkpoint =
331+
isolate_->thread_local_top()->CallDepthIsZero() &&
331332
do_callback && microtask_queue &&
332333
microtask_queue->microtasks_policy() == MicrotasksPolicy::kAuto;
333334
return !did_perform_microtask_checkpoint ||
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2020 the V8 project authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
// Flags: --harmony-weak-refs
6+
7+
// A newly created WeakRef is kept alive until the end of the next microtask
8+
// checkpoint. V8 asserts that the kept objects list is cleared at the end of
9+
// microtask checkpoints when the microtask policy is auto. Test that d8, which
10+
// uses the auto policy, upholds the assert when manually quitting.
11+
let obj = {};
12+
let wr = new WeakRef(obj);
13+
testRunner.quit();

0 commit comments

Comments
 (0)