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

[heap] Attach PersistentHandles with EnsurePersistentHandles

PersistentHandles were attached to the LocalHeap when passed in through
the constructor but not when created inside LocalHeap using
EnsurePersistentHandles.

Bug: v8:10315
Change-Id: Id24d36c935776cb0b643521c465763da7fbffd06
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2326630
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69167}
parent 8b57bdba
......@@ -56,6 +56,7 @@ void LocalHeap::EnsurePersistentHandles() {
if (!persistent_handles_) {
persistent_handles_.reset(
heap_->isolate()->NewPersistentHandles().release());
persistent_handles_->Attach(this);
}
}
......
......@@ -23,8 +23,9 @@ class LocalHandles;
class V8_EXPORT_PRIVATE LocalHeap {
public:
LocalHeap(Heap* heap,
std::unique_ptr<PersistentHandles> persistent_handles = nullptr);
explicit LocalHeap(
Heap* heap,
std::unique_ptr<PersistentHandles> persistent_handles = nullptr);
~LocalHeap();
// Invoked by main thread to signal this thread that it needs to halt in a
......
......@@ -122,6 +122,13 @@
'test-parsing/ObjectRestNegativeTestSlow': [PASS, ['mode == debug', SKIP]],
}], # ALWAYS
##############################################################################
['mode == debug', {
# These tests are supposed to fail in a DCHECK.
'test-persistent-handles/NewPersistentHandleFailsWhenParked': [FAIL],
'test-persistent-handles/NewPersistentHandleFailsWhenParkedExplicit': [FAIL],
}],
##############################################################################
['(arch != ia32 and arch != x64)', {
# BUG(v8:9860). We can only safely read the native context for a frame on
......
......@@ -129,6 +129,28 @@ TEST(DereferencePersistentHandle) {
}
}
TEST(NewPersistentHandleFailsWhenParked) {
CcTest::InitializeVM();
Isolate* isolate = CcTest::i_isolate();
LocalHeap local_heap(isolate->heap());
ParkedScope scope(&local_heap);
// Fail here in debug mode: Persistent handles can't be created if local heap
// is parked
local_heap.NewPersistentHandle(Smi::FromInt(1));
}
TEST(NewPersistentHandleFailsWhenParkedExplicit) {
CcTest::InitializeVM();
Isolate* isolate = CcTest::i_isolate();
LocalHeap local_heap(isolate->heap(), isolate->NewPersistentHandles());
ParkedScope scope(&local_heap);
// Fail here in debug mode: Persistent handles can't be created if local heap
// is parked
local_heap.NewPersistentHandle(Smi::FromInt(1));
}
} // anonymous namespace
} // namespace internal
......
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