Revert "[test] Migrate cctest/test-weakmaps to unittests/"
This reverts commit d83346befb
.
Reason for revert: Seems to be breaking TSAN bot (https://ci.chromium.org/ui/p/v8/builders/ci/V8%20Linux64%20TSAN%20-%20stress-incremental-marking/8867/overview)
Original change's description:
> [test] Migrate cctest/test-weakmaps to unittests/
>
> Bug: v8:12781
> Change-Id: Ief6bd7ee0ff2876e19970b2fb6af4f3208ec7f4e
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3815486
> Commit-Queue: Leszek Swirski <leszeks@chromium.org>
> Reviewed-by: Leszek Swirski <leszeks@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#82699}
Bug: v8:12781
Change-Id: Ia20078e9f40d0e2257cf0b953ddd2e72594c4085
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3855938
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#82713}
This commit is contained in:
parent
776c95f3b7
commit
d9e0603c27
@ -215,6 +215,7 @@ v8_source_set("cctest_sources") {
|
||||
"test-usecounters.cc",
|
||||
"test-utils.cc",
|
||||
"test-verifiers.cc",
|
||||
"test-weakmaps.cc",
|
||||
"torque/test-torque.cc",
|
||||
"trace-extension.cc",
|
||||
"trace-extension.h",
|
||||
@ -269,8 +270,7 @@ v8_source_set("cctest_sources") {
|
||||
"test-macro-assembler-mips64.cc",
|
||||
]
|
||||
} else if (v8_current_cpu == "x64") {
|
||||
sources += [
|
||||
### gcmole(arch:x64) ###
|
||||
sources += [ ### gcmole(arch:x64) ###
|
||||
"test-log-stack-tracer.cc",
|
||||
]
|
||||
if (is_win) {
|
||||
|
@ -51,6 +51,9 @@
|
||||
# works as intended.
|
||||
'test-api/DisallowJavascriptExecutionScope': [FAIL],
|
||||
|
||||
# We do not yet shrink weak maps after they have been emptied by the GC
|
||||
'test-weakmaps/Shrinking': [FAIL],
|
||||
|
||||
# Boot up memory use is bloated in debug mode.
|
||||
'test-mark-compact/BootUpMemoryUse': [PASS, ['mode == debug', FAIL]],
|
||||
|
||||
@ -1098,6 +1101,8 @@
|
||||
'test-weak-references/WeakArrayListBasic': [SKIP],
|
||||
'test-weak-references/WeakArraysBasic': [SKIP],
|
||||
'test-weak-references/WeakReferencesBasic': [SKIP],
|
||||
'test-weakmaps/WeakMapsWithChainedEntries': [SKIP],
|
||||
'test-weakmaps/Weakness': [SKIP],
|
||||
# Timeout (too many GCs)
|
||||
'test-heap/Regress8014': [SKIP],
|
||||
'test-accessors/HandleScopePop': [SKIP],
|
||||
|
@ -34,15 +34,16 @@
|
||||
#include "src/objects/hash-table-inl.h"
|
||||
#include "src/objects/js-collection-inl.h"
|
||||
#include "src/objects/objects-inl.h"
|
||||
#include "test/unittests/heap/heap-utils.h"
|
||||
#include "test/unittests/test-utils.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "test/cctest/cctest.h"
|
||||
#include "test/cctest/heap/heap-utils.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
namespace test_weakmaps {
|
||||
|
||||
using WeakMapsTest = TestWithHeapInternalsAndContext;
|
||||
static Isolate* GetIsolateFrom(LocalContext* context) {
|
||||
return reinterpret_cast<Isolate*>((*context)->GetIsolate());
|
||||
}
|
||||
|
||||
static int NumberOfWeakCalls = 0;
|
||||
static void WeakPointerCallback(const v8::WeakCallbackInfo<void>& data) {
|
||||
@ -54,9 +55,11 @@ static void WeakPointerCallback(const v8::WeakCallbackInfo<void>& data) {
|
||||
p->first->Reset();
|
||||
}
|
||||
|
||||
TEST_F(WeakMapsTest, Weakness) {
|
||||
|
||||
TEST(Weakness) {
|
||||
FLAG_incremental_marking = false;
|
||||
Isolate* isolate = i_isolate();
|
||||
LocalContext context;
|
||||
Isolate* isolate = GetIsolateFrom(&context);
|
||||
Factory* factory = isolate->factory();
|
||||
HandleScope scope(isolate);
|
||||
Handle<JSWeakMap> weakmap = isolate->factory()->NewJSWeakMap();
|
||||
@ -86,7 +89,7 @@ TEST_F(WeakMapsTest, Weakness) {
|
||||
CHECK_EQ(2, EphemeronHashTable::cast(weakmap->table()).NumberOfElements());
|
||||
|
||||
// Force a full GC.
|
||||
PreciseCollectAllGarbage();
|
||||
CcTest::PreciseCollectAllGarbage();
|
||||
CHECK_EQ(0, NumberOfWeakCalls);
|
||||
CHECK_EQ(2, EphemeronHashTable::cast(weakmap->table()).NumberOfElements());
|
||||
CHECK_EQ(
|
||||
@ -99,15 +102,17 @@ TEST_F(WeakMapsTest, Weakness) {
|
||||
&WeakPointerCallback, v8::WeakCallbackType::kParameter);
|
||||
CHECK(global_handles->IsWeak(key.location()));
|
||||
|
||||
PreciseCollectAllGarbage();
|
||||
CcTest::PreciseCollectAllGarbage();
|
||||
CHECK_EQ(1, NumberOfWeakCalls);
|
||||
CHECK_EQ(0, EphemeronHashTable::cast(weakmap->table()).NumberOfElements());
|
||||
CHECK_EQ(
|
||||
2, EphemeronHashTable::cast(weakmap->table()).NumberOfDeletedElements());
|
||||
}
|
||||
|
||||
TEST_F(WeakMapsTest, Shrinking) {
|
||||
Isolate* isolate = i_isolate();
|
||||
|
||||
TEST(Shrinking) {
|
||||
LocalContext context;
|
||||
Isolate* isolate = GetIsolateFrom(&context);
|
||||
Factory* factory = isolate->factory();
|
||||
HandleScope scope(isolate);
|
||||
Handle<JSWeakMap> weakmap = isolate->factory()->NewJSWeakMap();
|
||||
@ -134,7 +139,7 @@ TEST_F(WeakMapsTest, Shrinking) {
|
||||
CHECK_EQ(32, EphemeronHashTable::cast(weakmap->table()).NumberOfElements());
|
||||
CHECK_EQ(
|
||||
0, EphemeronHashTable::cast(weakmap->table()).NumberOfDeletedElements());
|
||||
PreciseCollectAllGarbage();
|
||||
CcTest::PreciseCollectAllGarbage();
|
||||
CHECK_EQ(0, EphemeronHashTable::cast(weakmap->table()).NumberOfElements());
|
||||
CHECK_EQ(
|
||||
32, EphemeronHashTable::cast(weakmap->table()).NumberOfDeletedElements());
|
||||
@ -152,13 +157,14 @@ bool EphemeronHashTableContainsKey(EphemeronHashTable table, HeapObject key) {
|
||||
}
|
||||
} // namespace
|
||||
|
||||
TEST_F(WeakMapsTest, WeakMapPromotionMarkCompact) {
|
||||
Isolate* isolate = i_isolate();
|
||||
TEST(WeakMapPromotionMarkCompact) {
|
||||
LocalContext context;
|
||||
Isolate* isolate = GetIsolateFrom(&context);
|
||||
Factory* factory = isolate->factory();
|
||||
HandleScope scope(isolate);
|
||||
Handle<JSWeakMap> weakmap = isolate->factory()->NewJSWeakMap();
|
||||
|
||||
CollectAllGarbage();
|
||||
CcTest::CollectAllGarbage();
|
||||
|
||||
CHECK(!ObjectInYoungGeneration(weakmap->table()));
|
||||
|
||||
@ -170,28 +176,29 @@ TEST_F(WeakMapsTest, WeakMapPromotionMarkCompact) {
|
||||
|
||||
CHECK(EphemeronHashTableContainsKey(
|
||||
EphemeronHashTable::cast(weakmap->table()), *object));
|
||||
CollectAllGarbage();
|
||||
CcTest::CollectAllGarbage();
|
||||
|
||||
CHECK(!ObjectInYoungGeneration(*object));
|
||||
CHECK(!ObjectInYoungGeneration(weakmap->table()));
|
||||
CHECK(EphemeronHashTableContainsKey(
|
||||
EphemeronHashTable::cast(weakmap->table()), *object));
|
||||
|
||||
CollectAllGarbage();
|
||||
CcTest::CollectAllGarbage();
|
||||
CHECK(!ObjectInYoungGeneration(*object));
|
||||
CHECK(!ObjectInYoungGeneration(weakmap->table()));
|
||||
CHECK(EphemeronHashTableContainsKey(
|
||||
EphemeronHashTable::cast(weakmap->table()), *object));
|
||||
}
|
||||
|
||||
TEST_F(WeakMapsTest, WeakMapScavenge) {
|
||||
TEST(WeakMapScavenge) {
|
||||
if (i::FLAG_single_generation || i::FLAG_stress_incremental_marking) return;
|
||||
Isolate* isolate = i_isolate();
|
||||
LocalContext context;
|
||||
Isolate* isolate = GetIsolateFrom(&context);
|
||||
Factory* factory = isolate->factory();
|
||||
HandleScope scope(isolate);
|
||||
Handle<JSWeakMap> weakmap = isolate->factory()->NewJSWeakMap();
|
||||
|
||||
GcAndSweep(NEW_SPACE);
|
||||
heap::GcAndSweep(isolate->heap(), NEW_SPACE);
|
||||
CHECK(ObjectInYoungGeneration(weakmap->table()));
|
||||
|
||||
Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
|
||||
@ -204,14 +211,14 @@ TEST_F(WeakMapsTest, WeakMapScavenge) {
|
||||
EphemeronHashTable::cast(weakmap->table()), *object));
|
||||
|
||||
if (!FLAG_minor_mc) {
|
||||
GcAndSweep(NEW_SPACE);
|
||||
heap::GcAndSweep(isolate->heap(), NEW_SPACE);
|
||||
CHECK(ObjectInYoungGeneration(*object));
|
||||
CHECK(!ObjectInYoungGeneration(weakmap->table()));
|
||||
CHECK(EphemeronHashTableContainsKey(
|
||||
EphemeronHashTable::cast(weakmap->table()), *object));
|
||||
}
|
||||
|
||||
GcAndSweep(OLD_SPACE);
|
||||
heap::GcAndSweep(isolate->heap(), OLD_SPACE);
|
||||
CHECK(!ObjectInYoungGeneration(*object));
|
||||
CHECK(!ObjectInYoungGeneration(weakmap->table()));
|
||||
CHECK(EphemeronHashTableContainsKey(
|
||||
@ -220,12 +227,13 @@ TEST_F(WeakMapsTest, WeakMapScavenge) {
|
||||
|
||||
// Test that weak map values on an evacuation candidate which are not reachable
|
||||
// by other paths are correctly recorded in the slots buffer.
|
||||
TEST_F(WeakMapsTest, Regress2060a) {
|
||||
TEST(Regress2060a) {
|
||||
if (!i::FLAG_compact) return;
|
||||
if (i::FLAG_enable_third_party_heap) return;
|
||||
FLAG_compact_on_every_full_gc = true;
|
||||
FLAG_stress_concurrent_allocation = false; // For SimulateFullSpace.
|
||||
Isolate* isolate = i_isolate();
|
||||
LocalContext context;
|
||||
Isolate* isolate = GetIsolateFrom(&context);
|
||||
Factory* factory = isolate->factory();
|
||||
Heap* heap = isolate->heap();
|
||||
HandleScope scope(isolate);
|
||||
@ -236,7 +244,7 @@ TEST_F(WeakMapsTest, Regress2060a) {
|
||||
|
||||
// Start second old-space page so that values land on evacuation candidate.
|
||||
Page* first_page = heap->old_space()->first_page();
|
||||
SimulateFullSpace(heap->old_space());
|
||||
heap::SimulateFullSpace(heap->old_space());
|
||||
|
||||
// Fill up weak map with values on an evacuation candidate.
|
||||
{
|
||||
@ -254,12 +262,13 @@ TEST_F(WeakMapsTest, Regress2060a) {
|
||||
|
||||
// Force compacting garbage collection.
|
||||
CHECK(FLAG_compact_on_every_full_gc);
|
||||
CollectAllGarbage();
|
||||
CcTest::CollectAllGarbage();
|
||||
}
|
||||
|
||||
|
||||
// Test that weak map keys on an evacuation candidate which are reachable by
|
||||
// other strong paths are correctly recorded in the slots buffer.
|
||||
TEST_F(WeakMapsTest, Regress2060b) {
|
||||
TEST(Regress2060b) {
|
||||
if (!i::FLAG_compact) return;
|
||||
FLAG_compact_on_every_full_gc = true;
|
||||
#ifdef VERIFY_HEAP
|
||||
@ -267,7 +276,8 @@ TEST_F(WeakMapsTest, Regress2060b) {
|
||||
#endif
|
||||
FLAG_stress_concurrent_allocation = false; // For SimulateFullSpace.
|
||||
|
||||
Isolate* isolate = i_isolate();
|
||||
LocalContext context;
|
||||
Isolate* isolate = GetIsolateFrom(&context);
|
||||
Factory* factory = isolate->factory();
|
||||
Heap* heap = isolate->heap();
|
||||
HandleScope scope(isolate);
|
||||
@ -276,7 +286,7 @@ TEST_F(WeakMapsTest, Regress2060b) {
|
||||
|
||||
// Start second old-space page so that keys land on evacuation candidate.
|
||||
Page* first_page = heap->old_space()->first_page();
|
||||
SimulateFullSpace(heap->old_space());
|
||||
heap::SimulateFullSpace(heap->old_space());
|
||||
|
||||
// Fill up weak map with keys on an evacuation candidate.
|
||||
Handle<JSObject> keys[32];
|
||||
@ -296,34 +306,39 @@ TEST_F(WeakMapsTest, Regress2060b) {
|
||||
// Force compacting garbage collection. The subsequent collections are used
|
||||
// to verify that key references were actually updated.
|
||||
CHECK(FLAG_compact_on_every_full_gc);
|
||||
CollectAllGarbage();
|
||||
CollectAllGarbage();
|
||||
CollectAllGarbage();
|
||||
CcTest::CollectAllGarbage();
|
||||
CcTest::CollectAllGarbage();
|
||||
CcTest::CollectAllGarbage();
|
||||
}
|
||||
|
||||
TEST_F(WeakMapsTest, Regress399527) {
|
||||
|
||||
TEST(Regress399527) {
|
||||
if (!FLAG_incremental_marking) return;
|
||||
v8::HandleScope scope(v8_isolate());
|
||||
Isolate* isolate = i_isolate();
|
||||
CcTest::InitializeVM();
|
||||
v8::HandleScope scope(CcTest::isolate());
|
||||
Isolate* isolate = CcTest::i_isolate();
|
||||
Heap* heap = isolate->heap();
|
||||
{
|
||||
HandleScope inner_scope(isolate);
|
||||
isolate->factory()->NewJSWeakMap();
|
||||
SimulateIncrementalMarking(heap);
|
||||
heap::SimulateIncrementalMarking(heap);
|
||||
}
|
||||
// The weak map is marked black here but leaving the handle scope will make
|
||||
// the object unreachable. Aborting incremental marking will clear all the
|
||||
// marking bits which makes the weak map garbage.
|
||||
CollectAllGarbage();
|
||||
CcTest::CollectAllGarbage();
|
||||
}
|
||||
|
||||
TEST_F(WeakMapsTest, WeakMapsWithChainedEntries) {
|
||||
v8::Isolate* isolate = v8_isolate();
|
||||
TEST(WeakMapsWithChainedEntries) {
|
||||
ManualGCScope manual_gc_scope;
|
||||
CcTest::InitializeVM();
|
||||
v8::Isolate* isolate = CcTest::isolate();
|
||||
i::Isolate* i_isolate = CcTest::i_isolate();
|
||||
v8::HandleScope scope(isolate);
|
||||
|
||||
const int initial_gc_count = i_isolate()->heap()->gc_count();
|
||||
Handle<JSWeakMap> weakmap1 = i_isolate()->factory()->NewJSWeakMap();
|
||||
Handle<JSWeakMap> weakmap2 = i_isolate()->factory()->NewJSWeakMap();
|
||||
const int initial_gc_count = i_isolate->heap()->gc_count();
|
||||
Handle<JSWeakMap> weakmap1 = i_isolate->factory()->NewJSWeakMap();
|
||||
Handle<JSWeakMap> weakmap2 = i_isolate->factory()->NewJSWeakMap();
|
||||
v8::Global<v8::Object> g1;
|
||||
v8::Global<v8::Object> g2;
|
||||
{
|
||||
@ -336,15 +351,15 @@ TEST_F(WeakMapsTest, WeakMapsWithChainedEntries) {
|
||||
g2.SetWeak();
|
||||
Handle<Object> i_o1 = v8::Utils::OpenHandle(*o1);
|
||||
Handle<Object> i_o2 = v8::Utils::OpenHandle(*o2);
|
||||
int32_t hash1 = i_o1->GetOrCreateHash(i_isolate()).value();
|
||||
int32_t hash2 = i_o2->GetOrCreateHash(i_isolate()).value();
|
||||
int32_t hash1 = i_o1->GetOrCreateHash(i_isolate).value();
|
||||
int32_t hash2 = i_o2->GetOrCreateHash(i_isolate).value();
|
||||
JSWeakCollection::Set(weakmap1, i_o1, i_o2, hash1);
|
||||
JSWeakCollection::Set(weakmap2, i_o2, i_o1, hash2);
|
||||
}
|
||||
CollectGarbage(OLD_SPACE);
|
||||
CcTest::CollectGarbage(OLD_SPACE);
|
||||
CHECK(g1.IsEmpty());
|
||||
CHECK(g2.IsEmpty());
|
||||
CHECK_EQ(1, i_isolate()->heap()->gc_count() - initial_gc_count);
|
||||
CHECK_EQ(1, i_isolate->heap()->gc_count() - initial_gc_count);
|
||||
}
|
||||
|
||||
} // namespace test_weakmaps
|
@ -477,7 +477,6 @@ v8_source_set("unittests_sources") {
|
||||
"objects/symbols-unittest.cc",
|
||||
"objects/value-serializer-unittest.cc",
|
||||
"objects/weakarraylist-unittest.cc",
|
||||
"objects/weakmaps-unittest.cc",
|
||||
"objects/weaksets-unittest.cc",
|
||||
"parser/ast-value-unittest.cc",
|
||||
"parser/decls-unittest.cc",
|
||||
|
@ -97,15 +97,6 @@ class WithHeapInternals : public TMixin, HeapInternalsBase {
|
||||
page->MarkNeverAllocateForTesting();
|
||||
}
|
||||
}
|
||||
|
||||
void GcAndSweep(i::AllocationSpace space) {
|
||||
heap()->CollectGarbage(space, GarbageCollectionReason::kTesting);
|
||||
if (heap()->mark_compact_collector()->sweeping_in_progress()) {
|
||||
SafepointScope scope(heap());
|
||||
heap()->mark_compact_collector()->EnsureSweepingCompleted(
|
||||
MarkCompactCollector::SweepingForcedFinalizationMode::kV8Only);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
using TestWithHeapInternals = //
|
||||
|
@ -5,24 +5,20 @@
|
||||
[
|
||||
|
||||
[ALWAYS, {
|
||||
'IntlTest.StringLocaleCompareFastPath': [['mode != release', SKIP], SLOW, NO_VARIANTS],
|
||||
|
||||
# BUG(5193). The cpu profiler tests are notoriously flaky.
|
||||
'SamplerTest.LibSamplerCollectSample': [SKIP],
|
||||
|
||||
# This tests only the type system, no point in running several variants.
|
||||
'TypesTest.*': [PASS, NO_VARIANTS],
|
||||
|
||||
# https://crbug.com/v8/8919
|
||||
'PlatformTest.StackAlignment': [PASS, ['not is_clang', SKIP]],
|
||||
|
||||
# These tests are supposed to fail in a slow DCHECK, skip them otherwise.
|
||||
'LocalHandlesTest.DereferenceLocalHandleFailsWhenDisallowed': [SKIP, ['mode == debug', FAIL]],
|
||||
'PersistentHandlesTest.DereferencePersistentHandleFailsWhenDisallowed': [SKIP, ['mode == debug', FAIL]],
|
||||
|
||||
# https://crbug.com/v8/8919
|
||||
'PlatformTest.StackAlignment': [PASS, ['not is_clang', SKIP]],
|
||||
|
||||
# We do not yet shrink weak maps after they have been emptied by the GC
|
||||
'WeakMapsTest.Shrinking': [FAIL],
|
||||
|
||||
'IntlTest.StringLocaleCompareFastPath': [['mode != release', SKIP], SLOW, NO_VARIANTS],
|
||||
'WeakSetsTest.WeakSet_Shrinking': [FAIL],
|
||||
}], # ALWAYS
|
||||
|
||||
@ -211,8 +207,6 @@
|
||||
'UnifiedHeapDetachedTest.AllocationBeforeConfigureHeap': [SKIP],
|
||||
'UnifiedHeapTest.FindingV8ToBlinkReference': [SKIP],
|
||||
'ManagedTest.GCCausesDestruction': [SKIP],
|
||||
'WeakMapsTest.WeakMapsWithChainedEntries': [SKIP],
|
||||
'WeakMapsTest.Weakness': [SKIP],
|
||||
'WeakSetsTest.WeakSet_Weakness': [SKIP],
|
||||
'WebSnapshotTest.SFIDeduplicationAfterBytecodeFlushing': [SKIP],
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user