[handles] Make DetachPersistent insert into ordered_blocks_

DetachPersistent() sets up PersistentHandles, but didn't properly set
up ordered_blocks_. So PersistentHandles::Contains failed for handles
that were detached from the main thread into PersistentHandles.

Bug: v8:10315
Change-Id: I5374ad64743cd519a9c5e92900c1fa401c4d93ab
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2336801
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69243}
This commit is contained in:
Dominik Inführ 2020-08-04 17:42:35 +02:00 committed by Commit Bot
parent a5f0f8e22f
commit c365959fc7
3 changed files with 12 additions and 2 deletions

View File

@ -11190,6 +11190,9 @@ std::unique_ptr<PersistentHandles> HandleScopeImplementer::DetachPersistent(
prev_limit == block_limit);
if (prev_limit == block_limit) break;
ph->blocks_.push_back(blocks_.back());
#if DEBUG
ph->ordered_blocks_.insert(blocks_.back());
#endif
blocks_.pop_back();
}

View File

@ -45,7 +45,7 @@ class PersistentHandles {
}
#ifdef DEBUG
bool Contains(Address* location);
V8_EXPORT_PRIVATE bool Contains(Address* location);
#endif
private:

View File

@ -89,15 +89,22 @@ TEST_F(PersistentHandlesTest, Iterate) {
CHECK_EQ(count_handles(isolate), handles_in_empty_scope + 1);
std::unique_ptr<PersistentHandles> ph;
Handle<String> verify_handle;
{
PersistentHandlesScope persistent_scope(isolate);
handle(ReadOnlyRoots(heap).empty_string(), isolate);
verify_handle = handle(ReadOnlyRoots(heap).empty_string(), isolate);
CHECK_NE(old_limit, data->limit);
CHECK_EQ(count_handles(isolate), handles_in_empty_scope + 2);
ph = persistent_scope.Detach();
}
#if DEBUG
CHECK(ph->Contains(verify_handle.location()));
#else
USE(verify_handle);
#endif
ph->NewHandle(ReadOnlyRoots(heap).empty_string());
CHECK_EQ(count_handles(ph.get()), 2);
CHECK_EQ(count_handles(isolate), handles_in_empty_scope + 1);