Skip to content

Commit

Permalink
Postpone initialization of StructureAlignedMemoryAllocator.
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=263380

Reviewed by Keith Miller.

StructureAlignedMemoryAllocator reserves a large amount of pages at startup
even on UIProcess and NetworkProcess because the initialization is called from
JSC::initialize().

In this patch, we postpone the initialization of StructureAlignedMemoryAllocator
until the first time it is used. Because permanentlyFreeze() will be called
at the end of construction of VM, it is safe to postpone the initialization.

* Source/JavaScriptCore/heap/StructureAlignedMemoryAllocator.cpp:
(JSC::StructureAlignedMemoryAllocator::tryMallocBlock):
* Source/JavaScriptCore/runtime/InitializeThreading.cpp:
(JSC::initialize):

Canonical link: https://commits.webkit.org/269633@main
  • Loading branch information
basuke committed Oct 21, 2023
1 parent f02a465 commit 91adc5e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ void StructureAlignedMemoryAllocator::initializeStructureAddressSpace()

void* StructureAlignedMemoryAllocator::tryMallocBlock()
{
static std::once_flag s_onceFlag;
std::call_once(s_onceFlag, [] {
initializeStructureAddressSpace();
});
return s_structureMemoryManager->tryMallocStructureBlock();
}

Expand Down
2 changes: 0 additions & 2 deletions Source/JavaScriptCore/runtime/InitializeThreading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#include "LLIntData.h"
#include "NativeCalleeRegistry.h"
#include "Options.h"
#include "StructureAlignedMemoryAllocator.h"
#include "SuperSampler.h"
#include "VMTraps.h"
#include "WasmCapabilities.h"
Expand Down Expand Up @@ -92,7 +91,6 @@ void initialize()
isARM64E_FPAC(); // Call this to initialize g_jscConfig.canUseFPAC.
#endif
}
StructureAlignedMemoryAllocator::initializeStructureAddressSpace();
}
Options::finalize();

Expand Down

0 comments on commit 91adc5e

Please sign in to comment.