Commit c365959f authored by Dominik Inführ's avatar Dominik Inführ Committed by Commit Bot

[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/+/2336801Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69243}
parent a5f0f8e2
...@@ -11190,6 +11190,9 @@ std::unique_ptr<PersistentHandles> HandleScopeImplementer::DetachPersistent( ...@@ -11190,6 +11190,9 @@ std::unique_ptr<PersistentHandles> HandleScopeImplementer::DetachPersistent(
prev_limit == block_limit); prev_limit == block_limit);
if (prev_limit == block_limit) break; if (prev_limit == block_limit) break;
ph->blocks_.push_back(blocks_.back()); ph->blocks_.push_back(blocks_.back());
#if DEBUG
ph->ordered_blocks_.insert(blocks_.back());
#endif
blocks_.pop_back(); blocks_.pop_back();
} }
......
...@@ -45,7 +45,7 @@ class PersistentHandles { ...@@ -45,7 +45,7 @@ class PersistentHandles {
} }
#ifdef DEBUG #ifdef DEBUG
bool Contains(Address* location); V8_EXPORT_PRIVATE bool Contains(Address* location);
#endif #endif
private: private:
......
...@@ -89,15 +89,22 @@ TEST_F(PersistentHandlesTest, Iterate) { ...@@ -89,15 +89,22 @@ TEST_F(PersistentHandlesTest, Iterate) {
CHECK_EQ(count_handles(isolate), handles_in_empty_scope + 1); CHECK_EQ(count_handles(isolate), handles_in_empty_scope + 1);
std::unique_ptr<PersistentHandles> ph; std::unique_ptr<PersistentHandles> ph;
Handle<String> verify_handle;
{ {
PersistentHandlesScope persistent_scope(isolate); 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_NE(old_limit, data->limit);
CHECK_EQ(count_handles(isolate), handles_in_empty_scope + 2); CHECK_EQ(count_handles(isolate), handles_in_empty_scope + 2);
ph = persistent_scope.Detach(); ph = persistent_scope.Detach();
} }
#if DEBUG
CHECK(ph->Contains(verify_handle.location()));
#else
USE(verify_handle);
#endif
ph->NewHandle(ReadOnlyRoots(heap).empty_string()); ph->NewHandle(ReadOnlyRoots(heap).empty_string());
CHECK_EQ(count_handles(ph.get()), 2); CHECK_EQ(count_handles(ph.get()), 2);
CHECK_EQ(count_handles(isolate), handles_in_empty_scope + 1); CHECK_EQ(count_handles(isolate), handles_in_empty_scope + 1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment