Skip to content

Commit 9b2ca70

Browse files
committed
[JSC] Do not create JIT related data under non-JIT mode
https://bugs.webkit.org/show_bug.cgi?id=195982 Reviewed by Mark Lam. We avoid creations of JIT related data structures under non-JIT mode. This patch removes the following allocations. 1. JITThunks 2. FTLThunks 3. FixedVMPoolExecutableAllocator 4. noJITValueProfileSingleton since it is no longer used 5. ARM disassembler should be initialized when it is used 6. Wasm related data structures are accidentally allocated if VM::canUseJIT() == false && Options::useWebAssembly() == true. Add Wasm::isSupported() function to check the both conditions. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * heap/Heap.cpp: (JSC::Heap::runEndPhase): * jit/ExecutableAllocator.cpp: (JSC::FixedVMPoolExecutableAllocator::~FixedVMPoolExecutableAllocator): (JSC::ExecutableAllocator::initializeUnderlyingAllocator): (JSC::ExecutableAllocator::isValid const): (JSC::ExecutableAllocator::underMemoryPressure): (JSC::ExecutableAllocator::memoryPressureMultiplier): (JSC::ExecutableAllocator::allocate): (JSC::ExecutableAllocator::isValidExecutableMemory): (JSC::ExecutableAllocator::getLock const): (JSC::ExecutableAllocator::committedByteCount): (JSC::ExecutableAllocator::dumpProfile): (JSC::startOfFixedExecutableMemoryPoolImpl): (JSC::endOfFixedExecutableMemoryPoolImpl): (JSC::ExecutableAllocator::initialize): (JSC::ExecutableAllocator::initializeAllocator): Deleted. (JSC::ExecutableAllocator::ExecutableAllocator): Deleted. (JSC::ExecutableAllocator::~ExecutableAllocator): Deleted. * jit/ExecutableAllocator.h: (JSC::ExecutableAllocatorBase::isValid const): (JSC::ExecutableAllocatorBase::underMemoryPressure): (JSC::ExecutableAllocatorBase::memoryPressureMultiplier): (JSC::ExecutableAllocatorBase::dumpProfile): (JSC::ExecutableAllocatorBase::allocate): (JSC::ExecutableAllocatorBase::setJITEnabled): (JSC::ExecutableAllocatorBase::isValidExecutableMemory): (JSC::ExecutableAllocatorBase::committedByteCount): (JSC::ExecutableAllocatorBase::getLock const): (JSC::ExecutableAllocator::isValid const): Deleted. (JSC::ExecutableAllocator::underMemoryPressure): Deleted. (JSC::ExecutableAllocator::memoryPressureMultiplier): Deleted. (JSC::ExecutableAllocator::allocate): Deleted. (JSC::ExecutableAllocator::setJITEnabled): Deleted. (JSC::ExecutableAllocator::isValidExecutableMemory): Deleted. (JSC::ExecutableAllocator::committedByteCount): Deleted. (JSC::ExecutableAllocator::getLock const): Deleted. * jsc.cpp: (functionWebAssemblyMemoryMode): * runtime/InitializeThreading.cpp: (JSC::initializeThreading): * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSLock.cpp: (JSC::JSLock::didAcquireLock): * runtime/Options.cpp: (JSC::recomputeDependentOptions): * runtime/VM.cpp: (JSC::enableAssembler): (JSC::VM::canUseAssembler): (JSC::VM::VM): * runtime/VM.h: * wasm/WasmCapabilities.h: Added. (JSC::Wasm::isSupported): * wasm/WasmFaultSignalHandler.cpp: (JSC::Wasm::enableFastMemory): Canonical link: https://commits.webkit.org/210376@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243312 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 6a36d96 commit 9b2ca70

15 files changed

Lines changed: 228 additions & 97 deletions

File tree

Source/JavaScriptCore/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,7 @@ set(JavaScriptCore_PRIVATE_FRAMEWORK_HEADERS
977977
runtime/WriteBarrier.h
978978
runtime/WriteBarrierInlines.h
979979

980+
wasm/WasmCapabilities.h
980981
wasm/WasmCodeBlock.h
981982
wasm/WasmContext.h
982983
wasm/WasmEmbedder.h

Source/JavaScriptCore/ChangeLog

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,80 @@
1+
2019-03-21 Yusuke Suzuki <ysuzuki@apple.com>
2+
3+
[JSC] Do not create JIT related data under non-JIT mode
4+
https://bugs.webkit.org/show_bug.cgi?id=195982
5+
6+
Reviewed by Mark Lam.
7+
8+
We avoid creations of JIT related data structures under non-JIT mode.
9+
This patch removes the following allocations.
10+
11+
1. JITThunks
12+
2. FTLThunks
13+
3. FixedVMPoolExecutableAllocator
14+
4. noJITValueProfileSingleton since it is no longer used
15+
5. ARM disassembler should be initialized when it is used
16+
6. Wasm related data structures are accidentally allocated if VM::canUseJIT() == false &&
17+
Options::useWebAssembly() == true. Add Wasm::isSupported() function to check the both conditions.
18+
19+
* CMakeLists.txt:
20+
* JavaScriptCore.xcodeproj/project.pbxproj:
21+
* heap/Heap.cpp:
22+
(JSC::Heap::runEndPhase):
23+
* jit/ExecutableAllocator.cpp:
24+
(JSC::FixedVMPoolExecutableAllocator::~FixedVMPoolExecutableAllocator):
25+
(JSC::ExecutableAllocator::initializeUnderlyingAllocator):
26+
(JSC::ExecutableAllocator::isValid const):
27+
(JSC::ExecutableAllocator::underMemoryPressure):
28+
(JSC::ExecutableAllocator::memoryPressureMultiplier):
29+
(JSC::ExecutableAllocator::allocate):
30+
(JSC::ExecutableAllocator::isValidExecutableMemory):
31+
(JSC::ExecutableAllocator::getLock const):
32+
(JSC::ExecutableAllocator::committedByteCount):
33+
(JSC::ExecutableAllocator::dumpProfile):
34+
(JSC::startOfFixedExecutableMemoryPoolImpl):
35+
(JSC::endOfFixedExecutableMemoryPoolImpl):
36+
(JSC::ExecutableAllocator::initialize):
37+
(JSC::ExecutableAllocator::initializeAllocator): Deleted.
38+
(JSC::ExecutableAllocator::ExecutableAllocator): Deleted.
39+
(JSC::ExecutableAllocator::~ExecutableAllocator): Deleted.
40+
* jit/ExecutableAllocator.h:
41+
(JSC::ExecutableAllocatorBase::isValid const):
42+
(JSC::ExecutableAllocatorBase::underMemoryPressure):
43+
(JSC::ExecutableAllocatorBase::memoryPressureMultiplier):
44+
(JSC::ExecutableAllocatorBase::dumpProfile):
45+
(JSC::ExecutableAllocatorBase::allocate):
46+
(JSC::ExecutableAllocatorBase::setJITEnabled):
47+
(JSC::ExecutableAllocatorBase::isValidExecutableMemory):
48+
(JSC::ExecutableAllocatorBase::committedByteCount):
49+
(JSC::ExecutableAllocatorBase::getLock const):
50+
(JSC::ExecutableAllocator::isValid const): Deleted.
51+
(JSC::ExecutableAllocator::underMemoryPressure): Deleted.
52+
(JSC::ExecutableAllocator::memoryPressureMultiplier): Deleted.
53+
(JSC::ExecutableAllocator::allocate): Deleted.
54+
(JSC::ExecutableAllocator::setJITEnabled): Deleted.
55+
(JSC::ExecutableAllocator::isValidExecutableMemory): Deleted.
56+
(JSC::ExecutableAllocator::committedByteCount): Deleted.
57+
(JSC::ExecutableAllocator::getLock const): Deleted.
58+
* jsc.cpp:
59+
(functionWebAssemblyMemoryMode):
60+
* runtime/InitializeThreading.cpp:
61+
(JSC::initializeThreading):
62+
* runtime/JSGlobalObject.cpp:
63+
(JSC::JSGlobalObject::init):
64+
* runtime/JSLock.cpp:
65+
(JSC::JSLock::didAcquireLock):
66+
* runtime/Options.cpp:
67+
(JSC::recomputeDependentOptions):
68+
* runtime/VM.cpp:
69+
(JSC::enableAssembler):
70+
(JSC::VM::canUseAssembler):
71+
(JSC::VM::VM):
72+
* runtime/VM.h:
73+
* wasm/WasmCapabilities.h: Added.
74+
(JSC::Wasm::isSupported):
75+
* wasm/WasmFaultSignalHandler.cpp:
76+
(JSC::Wasm::enableFastMemory):
77+
178
2019-03-21 Yusuke Suzuki <ysuzuki@apple.com>
279

380
[JSC] Fix JSC build with newer ICU

Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1752,6 +1752,7 @@
17521752
E32AB2441DCD75F400D7533A /* MacroAssemblerHelpers.h in Headers */ = {isa = PBXBuildFile; fileRef = E380A76B1DCD7195000F89E6 /* MacroAssemblerHelpers.h */; settings = {ATTRIBUTES = (Private, ); }; };
17531753
E334CBB521FD96A9000EB178 /* RegExpGlobalData.h in Headers */ = {isa = PBXBuildFile; fileRef = E334CBB321FD96A9000EB178 /* RegExpGlobalData.h */; settings = {ATTRIBUTES = (Private, ); }; };
17541754
E33637A61B63220200EE0840 /* ReflectObject.h in Headers */ = {isa = PBXBuildFile; fileRef = E33637A41B63220200EE0840 /* ReflectObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
1755+
E337B967224324EA0093A820 /* WasmCapabilities.h in Headers */ = {isa = PBXBuildFile; fileRef = E337B966224324E50093A820 /* WasmCapabilities.h */; settings = {ATTRIBUTES = (Private, ); }; };
17551756
E33B3E261B7ABD750048DB2E /* InspectorInstrumentationObject.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = E33B3E251B7ABD750048DB2E /* InspectorInstrumentationObject.lut.h */; };
17561757
E33E8D1D1B9013C300346B52 /* JSNativeStdFunction.h in Headers */ = {isa = PBXBuildFile; fileRef = E33E8D1B1B9013C300346B52 /* JSNativeStdFunction.h */; settings = {ATTRIBUTES = (Private, ); }; };
17571758
E33E8D211B9013DE00346B52 /* NativeStdFunctionCell.h in Headers */ = {isa = PBXBuildFile; fileRef = E33E8D1F1B9013DE00346B52 /* NativeStdFunctionCell.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -4693,6 +4694,7 @@
46934694
E334CBB321FD96A9000EB178 /* RegExpGlobalData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegExpGlobalData.h; sourceTree = "<group>"; };
46944695
E33637A31B63220200EE0840 /* ReflectObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ReflectObject.cpp; sourceTree = "<group>"; };
46954696
E33637A41B63220200EE0840 /* ReflectObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReflectObject.h; sourceTree = "<group>"; };
4697+
E337B966224324E50093A820 /* WasmCapabilities.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WasmCapabilities.h; sourceTree = "<group>"; };
46964698
E33B3E251B7ABD750048DB2E /* InspectorInstrumentationObject.lut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorInstrumentationObject.lut.h; sourceTree = "<group>"; };
46974699
E33E8D1A1B9013C300346B52 /* JSNativeStdFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSNativeStdFunction.cpp; sourceTree = "<group>"; };
46984700
E33E8D1B1B9013C300346B52 /* JSNativeStdFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSNativeStdFunction.h; sourceTree = "<group>"; };
@@ -5083,11 +5085,11 @@
50835085
0F6183431C45F62A0072450B /* testair */,
50845086
14BD59BF0A3E8F9000BAF59C /* testapi */,
50855087
0FEC85AD1BDB5CF10080FF74 /* testb3 */,
5088+
52CD0F642242F569004A18A5 /* testdfg */,
50865089
FE533CAC1F217DB40016A1FE /* testmasm */,
50875090
79281BDC20B62B3E002E2A60 /* testmem */,
50885091
6511230514046A4C002B101D /* testRegExp */,
50895092
932F5BD90822A1C700736975 /* JavaScriptCore.framework */,
5090-
52CD0F642242F569004A18A5 /* testdfg */,
50915093
);
50925094
name = Products;
50935095
sourceTree = "<group>";
@@ -6493,6 +6495,7 @@
64936495
525C0DD81E935847002184CD /* WasmCallee.h */,
64946496
53FD04D11D7AB187003287D3 /* WasmCallingConvention.cpp */,
64956497
53FD04D21D7AB187003287D3 /* WasmCallingConvention.h */,
6498+
E337B966224324E50093A820 /* WasmCapabilities.h */,
64966499
526AC4B41E977C5D003500E1 /* WasmCodeBlock.cpp */,
64976500
526AC4B51E977C5D003500E1 /* WasmCodeBlock.h */,
64986501
AD412B321E7B2E8A008AF157 /* WasmContext.h */,
@@ -9824,6 +9827,7 @@
98249827
AD4B1DFA1DF244E20071AE32 /* WasmBinding.h in Headers */,
98259828
525C0DDA1E935847002184CD /* WasmCallee.h in Headers */,
98269829
53FD04D41D7AB291003287D3 /* WasmCallingConvention.h in Headers */,
9830+
E337B967224324EA0093A820 /* WasmCapabilities.h in Headers */,
98279831
526AC4B71E977C5D003500E1 /* WasmCodeBlock.h in Headers */,
98289832
AD412B341E7B2E9E008AF157 /* WasmContext.h in Headers */,
98299833
7593C898BE714A64BE93A6E7 /* WasmContextInlines.h in Headers */,

Source/JavaScriptCore/heap/Heap.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,9 +1496,6 @@ NEVER_INLINE bool Heap::runEndPhase(GCConductor conn)
14961496
if (vm()->typeProfiler())
14971497
vm()->typeProfiler()->invalidateTypeSetCache();
14981498

1499-
if (ValueProfile* profile = vm()->noJITValueProfileSingleton.get())
1500-
*profile = ValueProfile(0);
1501-
15021499
reapWeakHandles();
15031500
pruneStaleEntriesFromWeakGCMaps();
15041501
sweepArrayBuffers();

Source/JavaScriptCore/jit/ExecutableAllocator.cpp

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ static uintptr_t startOfFixedWritableMemoryPool;
115115

116116
class FixedVMPoolExecutableAllocator;
117117
static FixedVMPoolExecutableAllocator* allocator = nullptr;
118-
static ExecutableAllocator* executableAllocator = nullptr;
119118

120119
static bool s_isJITEnabled = true;
121120
static bool isJITEnabled()
@@ -404,49 +403,37 @@ class FixedVMPoolExecutableAllocator : public MetaAllocator {
404403
MacroAssemblerCodePtr<ExecutableMemoryPtrTag> m_memoryEnd;
405404
};
406405

407-
void ExecutableAllocator::initializeAllocator()
408-
{
409-
ASSERT(!allocator);
410-
allocator = new FixedVMPoolExecutableAllocator();
411-
CodeProfiling::notifyAllocator(allocator);
412-
413-
executableAllocator = new ExecutableAllocator;
414-
}
415-
416-
ExecutableAllocator& ExecutableAllocator::singleton()
417-
{
418-
ASSERT(allocator);
419-
ASSERT(executableAllocator);
420-
return *executableAllocator;
421-
}
422-
423-
ExecutableAllocator::ExecutableAllocator()
424-
{
425-
ASSERT(allocator);
426-
}
427-
428-
ExecutableAllocator::~ExecutableAllocator()
406+
FixedVMPoolExecutableAllocator::~FixedVMPoolExecutableAllocator()
429407
{
408+
m_reservation.deallocate();
430409
}
431410

432-
FixedVMPoolExecutableAllocator::~FixedVMPoolExecutableAllocator()
411+
void ExecutableAllocator::initializeUnderlyingAllocator()
433412
{
434-
m_reservation.deallocate();
413+
ASSERT(!allocator);
414+
allocator = new FixedVMPoolExecutableAllocator();
415+
CodeProfiling::notifyAllocator(allocator);
435416
}
436417

437418
bool ExecutableAllocator::isValid() const
438419
{
420+
if (!allocator)
421+
return Base::isValid();
439422
return !!allocator->bytesReserved();
440423
}
441424

442425
bool ExecutableAllocator::underMemoryPressure()
443426
{
427+
if (!allocator)
428+
return Base::underMemoryPressure();
444429
MetaAllocator::Statistics statistics = allocator->currentStatistics();
445430
return statistics.bytesAllocated > statistics.bytesReserved / 2;
446431
}
447432

448433
double ExecutableAllocator::memoryPressureMultiplier(size_t addedMemoryUsage)
449434
{
435+
if (!allocator)
436+
return Base::memoryPressureMultiplier(addedMemoryUsage);
450437
MetaAllocator::Statistics statistics = allocator->currentStatistics();
451438
ASSERT(statistics.bytesAllocated <= statistics.bytesReserved);
452439
size_t bytesAllocated = statistics.bytesAllocated + addedMemoryUsage;
@@ -465,6 +452,8 @@ double ExecutableAllocator::memoryPressureMultiplier(size_t addedMemoryUsage)
465452

466453
RefPtr<ExecutableMemoryHandle> ExecutableAllocator::allocate(size_t sizeInBytes, void* ownerUID, JITCompilationEffort effort)
467454
{
455+
if (!allocator)
456+
return Base::allocate(sizeInBytes, ownerUID, effort);
468457
if (Options::logExecutableAllocation()) {
469458
MetaAllocator::Statistics stats = allocator->currentStatistics();
470459
dataLog("Allocating ", sizeInBytes, " bytes of executable memory with ", stats.bytesAllocated, " bytes allocated, ", stats.bytesReserved, " bytes reserved, and ", stats.bytesCommitted, " committed.\n");
@@ -514,33 +503,45 @@ RefPtr<ExecutableMemoryHandle> ExecutableAllocator::allocate(size_t sizeInBytes,
514503

515504
bool ExecutableAllocator::isValidExecutableMemory(const AbstractLocker& locker, void* address)
516505
{
506+
if (!allocator)
507+
return Base::isValidExecutableMemory(locker, address);
517508
return allocator->isInAllocatedMemory(locker, address);
518509
}
519510

520511
Lock& ExecutableAllocator::getLock() const
521512
{
513+
if (!allocator)
514+
return Base::getLock();
522515
return allocator->getLock();
523516
}
524517

525518
size_t ExecutableAllocator::committedByteCount()
526519
{
520+
if (!allocator)
521+
return Base::committedByteCount();
527522
return allocator->bytesCommitted();
528523
}
529524

530525
#if ENABLE(META_ALLOCATOR_PROFILE)
531526
void ExecutableAllocator::dumpProfile()
532527
{
528+
if (!allocator)
529+
return;
533530
allocator->dumpProfile();
534531
}
535532
#endif
536533

537534
void* startOfFixedExecutableMemoryPoolImpl()
538535
{
536+
if (!allocator)
537+
return nullptr;
539538
return allocator->memoryStart();
540539
}
541540

542541
void* endOfFixedExecutableMemoryPoolImpl()
543542
{
543+
if (!allocator)
544+
return nullptr;
544545
return allocator->memoryEnd();
545546
}
546547

@@ -551,13 +552,13 @@ bool isJITPC(void* pc)
551552

552553
} // namespace JSC
553554

554-
#else // !ENABLE(JIT)
555+
#endif // ENABLE(JIT)
555556

556557
namespace JSC {
557558

558559
static ExecutableAllocator* executableAllocator;
559560

560-
void ExecutableAllocator::initializeAllocator()
561+
void ExecutableAllocator::initialize()
561562
{
562563
executableAllocator = new ExecutableAllocator;
563564
}
@@ -569,5 +570,3 @@ ExecutableAllocator& ExecutableAllocator::singleton()
569570
}
570571

571572
} // namespace JSC
572-
573-
#endif // ENABLE(JIT)

0 commit comments

Comments
 (0)