Commit 6fe9ea3a authored by Michael Lippautz's avatar Michael Lippautz Committed by V8 LUCI CQ

[cppgc-js] Delay reading flags until first GC

Unfortunately heap setup happens before setting up flags in practice.
This means that flags such as `--single-threaded-gc` were not respected
properly for Oilpan. Delay the setup until the GC is actually triggered.

Bug: chromium:1326723
Change-Id: Icabe7ecf27e879bd44bba5e09ca176beb012c58a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3657430Reviewed-by: 's avatarDominik Inführ <dinfuehr@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80667}
parent 0d57c9a8
...@@ -428,19 +428,6 @@ v8::metrics::Recorder::ContextId CppHeap::MetricRecorderAdapter::GetContextId() ...@@ -428,19 +428,6 @@ v8::metrics::Recorder::ContextId CppHeap::MetricRecorderAdapter::GetContextId()
GetIsolate()->native_context()); GetIsolate()->native_context());
} }
namespace {
CppHeap::MarkingType GetSupportedMarkingType() {
// Keep the selection simple for now as production configurations do not turn
// off parallel and/or concurrent marking independently.
if (!FLAG_parallel_marking || !FLAG_concurrent_marking)
return CppHeap::MarkingType::kIncremental;
return CppHeap::MarkingType::kIncrementalAndConcurrent;
}
} // namespace
CppHeap::CppHeap( CppHeap::CppHeap(
v8::Platform* platform, v8::Platform* platform,
const std::vector<std::unique_ptr<cppgc::CustomSpaceBase>>& custom_spaces, const std::vector<std::unique_ptr<cppgc::CustomSpaceBase>>& custom_spaces,
...@@ -449,9 +436,10 @@ CppHeap::CppHeap( ...@@ -449,9 +436,10 @@ CppHeap::CppHeap(
std::make_shared<CppgcPlatformAdapter>(platform), custom_spaces, std::make_shared<CppgcPlatformAdapter>(platform), custom_spaces,
cppgc::internal::HeapBase::StackSupport:: cppgc::internal::HeapBase::StackSupport::
kSupportsConservativeStackScan, kSupportsConservativeStackScan,
GetSupportedMarkingType(), // Default marking and sweeping types are only incremental. The types
FLAG_single_threaded_gc ? SweepingType::kIncremental // are updated respecting flags only on GC as the flags are not set
: SweepingType::kIncrementalAndConcurrent), // properly during heap setup.
MarkingType::kIncremental, SweepingType::kIncremental),
wrapper_descriptor_(wrapper_descriptor) { wrapper_descriptor_(wrapper_descriptor) {
CHECK_NE(WrapperDescriptor::kUnknownEmbedderId, CHECK_NE(WrapperDescriptor::kUnknownEmbedderId,
wrapper_descriptor_.embedder_id_for_garbage_collected); wrapper_descriptor_.embedder_id_for_garbage_collected);
...@@ -548,10 +536,26 @@ CppHeap::SweepingType CppHeap::SelectSweepingType() const { ...@@ -548,10 +536,26 @@ CppHeap::SweepingType CppHeap::SelectSweepingType() const {
return sweeping_support(); return sweeping_support();
} }
void CppHeap::UpdateSupportedGCTypesFromFlags() {
// Keep the selection simple for now as production configurations do not turn
// off parallel and/or concurrent marking independently.
if (!FLAG_parallel_marking || !FLAG_concurrent_marking) {
marking_support_ = MarkingType::kIncremental;
} else {
marking_support_ = MarkingType::kIncrementalAndConcurrent;
}
sweeping_support_ = FLAG_single_threaded_gc
? CppHeap::SweepingType::kIncremental
: CppHeap::SweepingType::kIncrementalAndConcurrent;
}
void CppHeap::InitializeTracing(CollectionType collection_type, void CppHeap::InitializeTracing(CollectionType collection_type,
GarbageCollectionFlags gc_flags) { GarbageCollectionFlags gc_flags) {
CHECK(!sweeper_.IsSweepingInProgress()); CHECK(!sweeper_.IsSweepingInProgress());
UpdateSupportedGCTypesFromFlags();
// Check that previous cycle metrics for the same collection type have been // Check that previous cycle metrics for the same collection type have been
// reported. // reported.
if (GetMetricRecorder()) { if (GetMetricRecorder()) {
......
...@@ -165,6 +165,8 @@ class V8_EXPORT_PRIVATE CppHeap final ...@@ -165,6 +165,8 @@ class V8_EXPORT_PRIVATE CppHeap final
std::unique_ptr<CppMarkingState> CreateCppMarkingStateForMutatorThread(); std::unique_ptr<CppMarkingState> CreateCppMarkingStateForMutatorThread();
private: private:
void UpdateSupportedGCTypesFromFlags();
void FinalizeIncrementalGarbageCollectionIfNeeded( void FinalizeIncrementalGarbageCollectionIfNeeded(
cppgc::Heap::StackState) final { cppgc::Heap::StackState) final {
// For unified heap, CppHeap shouldn't finalize independently (i.e. // For unified heap, CppHeap shouldn't finalize independently (i.e.
......
...@@ -311,8 +311,8 @@ class V8_EXPORT_PRIVATE HeapBase : public cppgc::HeapHandle { ...@@ -311,8 +311,8 @@ class V8_EXPORT_PRIVATE HeapBase : public cppgc::HeapHandle {
int creation_thread_id_ = v8::base::OS::GetCurrentThreadId(); int creation_thread_id_ = v8::base::OS::GetCurrentThreadId();
const MarkingType marking_support_; MarkingType marking_support_;
const SweepingType sweeping_support_; SweepingType sweeping_support_;
GenerationSupport generation_support_; GenerationSupport generation_support_;
HeapObjectNameForUnnamedObject name_for_unnamed_object_ = HeapObjectNameForUnnamedObject name_for_unnamed_object_ =
......
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