[test] Only update FLAG_local_heaps if disabled
Avoid data race by only setting FLAG_local_heaps to true if not already enabled. Bug: v8:10315 Change-Id: Ib562b6d525448f5c088da39bf60928debd97db43 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2426610 Reviewed-by: Ulan Degenbaev <ulan@chromium.org> Commit-Queue: Dominik Inführ <dinfuehr@chromium.org> Cr-Commit-Position: refs/heads/master@{#70115}
This commit is contained in:
parent
5f265c3379
commit
d382dab9e5
@ -246,6 +246,12 @@ bool InCorrectGeneration(HeapObject object) {
|
||||
: i::Heap::InYoungGeneration(object);
|
||||
}
|
||||
|
||||
void EnsureFlagLocalHeapsEnabled() {
|
||||
// Avoid data race in concurrent thread by only setting the flag to true if
|
||||
// not already enabled.
|
||||
if (!FLAG_local_heaps) FLAG_local_heaps = true;
|
||||
}
|
||||
|
||||
} // namespace heap
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
@ -70,6 +70,8 @@ void InvokeScavenge(Isolate* isolate = nullptr);
|
||||
|
||||
void InvokeMarkSweep(Isolate* isolate = nullptr);
|
||||
|
||||
void EnsureFlagLocalHeapsEnabled();
|
||||
|
||||
template <typename GlobalOrPersistent>
|
||||
bool InYoungGeneration(v8::Isolate* isolate, const GlobalOrPersistent& global) {
|
||||
v8::HandleScope scope(isolate);
|
||||
|
@ -7206,7 +7206,7 @@ TEST(Regress978156) {
|
||||
}
|
||||
|
||||
TEST(GarbageCollectionWithLocalHeap) {
|
||||
FLAG_local_heaps = true;
|
||||
EnsureFlagLocalHeapsEnabled();
|
||||
ManualGCScope manual_gc_scope;
|
||||
CcTest::InitializeVM();
|
||||
|
||||
|
@ -70,7 +70,7 @@ class ConcurrentSearchThread final : public v8::base::Thread {
|
||||
|
||||
// Uses linear search on a flat object, with up to 8 elements.
|
||||
TEST(LinearSearchFlatObject) {
|
||||
FLAG_local_heaps = true;
|
||||
heap::EnsureFlagLocalHeapsEnabled();
|
||||
CcTest::InitializeVM();
|
||||
Isolate* isolate = CcTest::i_isolate();
|
||||
|
||||
@ -122,8 +122,8 @@ TEST(LinearSearchFlatObject) {
|
||||
|
||||
// Uses linear search on a flat object, which has more than 8 elements.
|
||||
TEST(LinearSearchFlatObject_ManyElements) {
|
||||
heap::EnsureFlagLocalHeapsEnabled();
|
||||
CcTest::InitializeVM();
|
||||
FLAG_local_heaps = true;
|
||||
Isolate* isolate = CcTest::i_isolate();
|
||||
|
||||
std::unique_ptr<PersistentHandles> ph = isolate->NewPersistentHandles();
|
||||
|
@ -68,8 +68,8 @@ class ConcurrentSearchThread final : public v8::base::Thread {
|
||||
|
||||
// Test to search on a background thread, while the main thread is idle.
|
||||
TEST(ProtoWalkBackground) {
|
||||
heap::EnsureFlagLocalHeapsEnabled();
|
||||
CcTest::InitializeVM();
|
||||
FLAG_local_heaps = true;
|
||||
Isolate* isolate = CcTest::i_isolate();
|
||||
|
||||
std::unique_ptr<PersistentHandles> ph = isolate->NewPersistentHandles();
|
||||
@ -108,8 +108,8 @@ TEST(ProtoWalkBackground) {
|
||||
// Test to search on a background thread, while the main thread modifies the
|
||||
// descriptor array.
|
||||
TEST(ProtoWalkBackground_DescriptorArrayWrite) {
|
||||
heap::EnsureFlagLocalHeapsEnabled();
|
||||
CcTest::InitializeVM();
|
||||
FLAG_local_heaps = true;
|
||||
Isolate* isolate = CcTest::i_isolate();
|
||||
|
||||
std::unique_ptr<PersistentHandles> ph = isolate->NewPersistentHandles();
|
||||
@ -155,8 +155,8 @@ TEST(ProtoWalkBackground_DescriptorArrayWrite) {
|
||||
}
|
||||
|
||||
TEST(ProtoWalkBackground_PrototypeChainWrite) {
|
||||
heap::EnsureFlagLocalHeapsEnabled();
|
||||
CcTest::InitializeVM();
|
||||
FLAG_local_heaps = true;
|
||||
Isolate* isolate = CcTest::i_isolate();
|
||||
|
||||
std::unique_ptr<PersistentHandles> ph = isolate->NewPersistentHandles();
|
||||
|
@ -69,8 +69,8 @@ class LocalHandlesThread final : public v8::base::Thread {
|
||||
};
|
||||
|
||||
TEST(CreateLocalHandles) {
|
||||
heap::EnsureFlagLocalHeapsEnabled();
|
||||
CcTest::InitializeVM();
|
||||
FLAG_local_heaps = true;
|
||||
Isolate* isolate = CcTest::i_isolate();
|
||||
|
||||
Address object = kNullAddress;
|
||||
@ -97,8 +97,8 @@ TEST(CreateLocalHandles) {
|
||||
}
|
||||
|
||||
TEST(CreateLocalHandlesWithoutLocalHandleScope) {
|
||||
heap::EnsureFlagLocalHeapsEnabled();
|
||||
CcTest::InitializeVM();
|
||||
FLAG_local_heaps = true;
|
||||
Isolate* isolate = CcTest::i_isolate();
|
||||
|
||||
{
|
||||
@ -108,8 +108,8 @@ TEST(CreateLocalHandlesWithoutLocalHandleScope) {
|
||||
}
|
||||
|
||||
TEST(DereferenceLocalHandle) {
|
||||
heap::EnsureFlagLocalHeapsEnabled();
|
||||
CcTest::InitializeVM();
|
||||
FLAG_local_heaps = true;
|
||||
Isolate* isolate = CcTest::i_isolate();
|
||||
|
||||
// Create a PersistentHandle to create the LocalHandle, and thus not have a
|
||||
|
@ -74,8 +74,8 @@ class PersistentHandlesThread final : public v8::base::Thread {
|
||||
};
|
||||
|
||||
TEST(CreatePersistentHandles) {
|
||||
heap::EnsureFlagLocalHeapsEnabled();
|
||||
CcTest::InitializeVM();
|
||||
FLAG_local_heaps = true;
|
||||
Isolate* isolate = CcTest::i_isolate();
|
||||
|
||||
std::unique_ptr<PersistentHandles> ph = isolate->NewPersistentHandles();
|
||||
@ -110,8 +110,8 @@ TEST(CreatePersistentHandles) {
|
||||
}
|
||||
|
||||
TEST(DereferencePersistentHandle) {
|
||||
heap::EnsureFlagLocalHeapsEnabled();
|
||||
CcTest::InitializeVM();
|
||||
FLAG_local_heaps = true;
|
||||
Isolate* isolate = CcTest::i_isolate();
|
||||
|
||||
std::unique_ptr<PersistentHandles> phs = isolate->NewPersistentHandles();
|
||||
|
@ -13,11 +13,17 @@
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
void EnsureFlagLocalHeapsEnabled() {
|
||||
// Avoid data race in concurrent thread by only setting the flag to true if
|
||||
// not already enabled.
|
||||
if (!FLAG_local_heaps) FLAG_local_heaps = true;
|
||||
}
|
||||
|
||||
using SafepointTest = TestWithIsolate;
|
||||
|
||||
TEST_F(SafepointTest, ReachSafepointWithoutLocalHeaps) {
|
||||
EnsureFlagLocalHeapsEnabled();
|
||||
Heap* heap = i_isolate()->heap();
|
||||
FLAG_local_heaps = true;
|
||||
bool run = false;
|
||||
{
|
||||
SafepointScope scope(heap);
|
||||
@ -47,8 +53,8 @@ class ParkedThread final : public v8::base::Thread {
|
||||
};
|
||||
|
||||
TEST_F(SafepointTest, StopParkedThreads) {
|
||||
EnsureFlagLocalHeapsEnabled();
|
||||
Heap* heap = i_isolate()->heap();
|
||||
FLAG_local_heaps = true;
|
||||
|
||||
int safepoints = 0;
|
||||
|
||||
@ -106,8 +112,8 @@ class RunningThread final : public v8::base::Thread {
|
||||
};
|
||||
|
||||
TEST_F(SafepointTest, StopRunningThreads) {
|
||||
EnsureFlagLocalHeapsEnabled();
|
||||
Heap* heap = i_isolate()->heap();
|
||||
FLAG_local_heaps = true;
|
||||
|
||||
const int kThreads = 10;
|
||||
const int kRuns = 5;
|
||||
@ -139,8 +145,8 @@ TEST_F(SafepointTest, StopRunningThreads) {
|
||||
}
|
||||
|
||||
TEST_F(SafepointTest, SkipLocalHeapOfThisThread) {
|
||||
EnsureFlagLocalHeapsEnabled();
|
||||
Heap* heap = i_isolate()->heap();
|
||||
FLAG_local_heaps = true;
|
||||
LocalHeap local_heap(heap);
|
||||
{
|
||||
SafepointScope scope(heap);
|
||||
|
Loading…
Reference in New Issue
Block a user