#include "include/v8-initialization.h"
#include "src/api/api-inl.h"
#include "src/api/api.h"
#include "src/base/strings.h"
#include "src/common/assert-scope.h"
#include "src/common/globals.h"
#include "src/flags/flags.h"
#include "src/heap/factory.h"
#include "src/heap/heap-inl.h"
#include "src/heap/heap.h"
#include "src/heap/memory-chunk-layout.h"
#include "src/heap/mutable-page-metadata.h"
#include "src/heap/parked-scope-inl.h"
#include "src/heap/remembered-set.h"
#include "src/heap/safepoint.h"
#include "src/objects/fixed-array.h"
#include "src/objects/heap-object.h"
#include "src/objects/js-weak-refs.h"
#include "src/objects/objects-inl.h"
#include "src/objects/string-forwarding-table-inl.h"
#include "test/cctest/cctest.h"
#include "test/cctest/heap/heap-utils.h"
namespace v8 {
namespace internal {
namespace test_shared_strings {
struct V8_NODISCARD IsolateWrapper { … };
struct V8_NODISCARD IsolateParkOnDisposeWrapper { … };
class MultiClientIsolateTest { … };
UNINITIALIZED_TEST(InPlaceInternalizableStringsAreShared) { … }
UNINITIALIZED_TEST(InPlaceInternalization) { … }
UNINITIALIZED_TEST(YoungInternalization) { … }
class ConcurrentStringThreadBase : public ParkingThread { … };
enum TestHitOrMiss { … };
class ConcurrentInternalizationThread final
: public ConcurrentStringThreadBase { … };
namespace {
std::pair<Handle<String>, MaybeHandle<String>> CreateSharedOneByteString(
Isolate* isolate, Factory* factory, int length, bool internalize) { … }
IndirectHandle<FixedArray> CreateSharedOneByteStrings(
Isolate* isolate, Factory* factory, int count, int lo_count,
int min_length = 2, bool internalize = false) { … }
void TestConcurrentInternalization(TestHitOrMiss hit_or_miss) { … }
}
UNINITIALIZED_TEST(ConcurrentInternalizationMiss) { … }
UNINITIALIZED_TEST(ConcurrentInternalizationHit) { … }
class ConcurrentStringTableLookupThread final
: public ConcurrentStringThreadBase { … };
UNINITIALIZED_TEST(ConcurrentStringTableLookup) { … }
namespace {
void CheckSharedStringIsEqualCopy(DirectHandle<String> shared,
DirectHandle<String> original) { … }
Handle<String> ShareAndVerify(Isolate* isolate, Handle<String> string) { … }
class OneByteResource : public v8::String::ExternalOneByteStringResource { … };
class TwoByteResource : public v8::String::ExternalStringResource { … };
class ExternalResourceFactory { … };
}
UNINITIALIZED_TEST(StringShare) { … }
UNINITIALIZED_TEST(PromotionMarkCompact) { … }
UNINITIALIZED_TEST(PromotionScavenge) { … }
UNINITIALIZED_TEST(PromotionScavengeOldToShared) { … }
UNINITIALIZED_TEST(PromotionMarkCompactNewToShared) { … }
UNINITIALIZED_TEST(PromotionMarkCompactOldToShared) { … }
UNINITIALIZED_TEST(PagePromotionRecordingOldToShared) { … }
namespace {
void TriggerGCWithTransitions(Heap* heap) { … }
}
UNINITIALIZED_TEST(InternalizedSharedStringsTransitionDuringGC) { … }
UNINITIALIZED_TEST(ShareExternalString) { … }
namespace {
void CheckExternalStringResource(
Handle<String> string, v8::String::ExternalStringResourceBase* resource) { … }
}
UNINITIALIZED_TEST(ExternalizeSharedString) { … }
UNINITIALIZED_TEST(ExternalizedSharedStringsTransitionDuringGC) { … }
UNINITIALIZED_TEST(ExternalizeInternalizedString) { … }
UNINITIALIZED_TEST(InternalizeSharedExternalString) { … }
UNINITIALIZED_TEST(ExternalizeAndInternalizeMissSharedString) { … }
UNINITIALIZED_TEST(InternalizeHitAndExternalizeSharedString) { … }
UNINITIALIZED_TEST(InternalizeMissAndExternalizeSharedString) { … }
class ConcurrentExternalizationThread final
: public ConcurrentStringThreadBase { … };
namespace {
void CreateExternalResources(Isolate* i_isolate,
DirectHandle<FixedArray> strings,
std::vector<OneByteResource*>& resources,
ExternalResourceFactory& resource_factory) { … }
void CheckStringAndResource(
Tagged<String> string, int index, bool should_be_alive,
Tagged<String> deleted_string, bool check_transition, bool shared_resources,
const std::vector<std::unique_ptr<ConcurrentExternalizationThread>>&
threads) { … }
}
void TestConcurrentExternalization(bool share_resources) { … }
UNINITIALIZED_TEST(ConcurrentExternalizationWithUniqueResources) { … }
UNINITIALIZED_TEST(ConcurrentExternalizationWithSharedResources) { … }
void TestConcurrentExternalizationWithDeadStrings(bool share_resources,
bool transition_with_stack) { … }
UNINITIALIZED_TEST(
ExternalizationWithDeadStringsAndUniqueResourcesTransitionWithStack) { … }
UNINITIALIZED_TEST(
ExternalizationWithDeadStringsAndSharedResourcesTransitionWithStack) { … }
UNINITIALIZED_TEST(ExternalizationWithDeadStringsAndUniqueResources) { … }
UNINITIALIZED_TEST(ExternalizationWithDeadStringsAndSharedResources) { … }
void TestConcurrentExternalizationAndInternalization(
TestHitOrMiss hit_or_miss) { … }
UNINITIALIZED_TEST(ConcurrentExternalizationAndInternalizationMiss) { … }
UNINITIALIZED_TEST(ConcurrentExternalizationAndInternalizationHit) { … }
UNINITIALIZED_TEST(SharedStringInGlobalHandle) { … }
class WakeupTask : public CancelableTask { … };
class WorkerIsolateThread : public v8::base::Thread { … };
UNINITIALIZED_TEST(SharedStringInClientGlobalHandle) { … }
class ClientIsolateThreadForPagePromotions : public v8::base::Thread { … };
UNINITIALIZED_TEST(RegisterOldToSharedForPromotedPageFromClient) { … }
UNINITIALIZED_TEST(
RegisterOldToSharedForPromotedPageFromClientDuringIncrementalMarking) { … }
class ClientIsolateThreadForRetainingByRememberedSet : public v8::base::Thread { … };
UNINITIALIZED_TEST(SharedObjectRetainedByClientRememberedSet) { … }
class Regress1424955ClientIsolateThread : public v8::base::Thread { … };
UNINITIALIZED_TEST(Regress1424955) { … }
class ProtectExternalStringTableAddStringClientIsolateThread
: public v8::base::Thread { … };
UNINITIALIZED_TEST(ProtectExternalStringTableAddString) { … }
}
}
}