Repository navigation
Commit 7a29252
committed
[JSC] Implement growable SharedArrayBuffer part 1
https://bugs.webkit.org/show_bug.cgi?id=247541
rdar://102006760
Reviewed by Mark Lam.
This patch adds first patch for growable SharedArrayBuffer. This patch does
not add TypedArray's length tracking (when backing ArrayBuffer is resized,
then TypedArray's length needs to be changed too).
1. We extract Wasm::MemoryHandle to runtime to use it for non wasm. This offers
growable memory infrastructure since it was used for growable shared Wasm::Memory.
This also requires moving MemoryMode, MemorySharingMode, and PageCount from wasm to runtime.
2. We add resizable TypedArrayTypes, and currently DFG does OSR exit when we encounter it.
We also change it from uint32_t to uint8_t to make room in TypedArray to have more information.
3. This patch adds growable SharedArrayBuffer's methods.
4. We add OSAllocator::protect to make (1) work on Windows too.
* JSTests/test262/config.yaml:
* JSTests/test262/expectations.yaml:
* JSTests/wasm/stress/shared-wasm-memory-buffer.js:
* Source/JavaScriptCore/CMakeLists.txt:
* Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj:
* Source/JavaScriptCore/Sources.txt:
* Source/JavaScriptCore/bytecode/AccessCase.cpp:
(JSC::AccessCase::generateWithGuard):
* Source/JavaScriptCore/bytecode/ExitKind.cpp:
(JSC::exitKindToString):
* Source/JavaScriptCore/bytecode/ExitKind.h:
* Source/JavaScriptCore/dfg/DFGOperations.cpp:
(JSC::DFG::newTypedArrayWithSize):
* Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::jumpForTypedArrayOutOfBounds):
(JSC::DFG::SpeculativeJIT::jumpForTypedArrayIsDetachedIfOutOfBounds):
* Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::compileGetTypedArrayLengthAsInt52):
(JSC::DFG::SpeculativeJIT::compileGetTypedArrayByteOffsetAsInt52):
(JSC::DFG::SpeculativeJIT::compile):
* Source/JavaScriptCore/ftl/FTLAbstractHeapRepository.h:
* Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::emitGetTypedArrayByteOffsetExceptSettingResult):
(JSC::FTL::DFG::LowerDFGToB3::compileGetArrayLength):
(JSC::FTL::DFG::LowerDFGToB3::compileGetTypedArrayLengthAsInt52):
(JSC::FTL::DFG::LowerDFGToB3::emitNewTypedArrayWithSize):
(JSC::FTL::DFG::LowerDFGToB3::compileCompareStrictEq):
* Source/JavaScriptCore/heap/StructureAlignedMemoryAllocator.cpp:
(JSC::StructureMemoryManager::commitBlock):
(JSC::StructureMemoryManager::decommitBlock):
* Source/JavaScriptCore/jit/AssemblyHelpers.cpp:
(JSC::AssemblyHelpers::branchIfFastTypedArray):
(JSC::AssemblyHelpers::branchIfNotFastTypedArray):
* Source/JavaScriptCore/jit/IntrinsicEmitter.cpp:
(JSC::IntrinsicGetterAccessCase::emitIntrinsicGetter):
* Source/JavaScriptCore/jsc.cpp:
(JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/llint/LowLevelInterpreter.asm:
* Source/JavaScriptCore/llint/WebAssembly.asm:
* Source/JavaScriptCore/runtime/ArrayBuffer.cpp:
(JSC::ArrayBufferContents::tryAllocate):
(JSC::ArrayBufferContents::makeShared):
(JSC::ArrayBufferContents::copyTo):
(JSC::ArrayBufferContents::shareWith):
(JSC::ArrayBuffer::createFromBytes):
(JSC::ArrayBuffer::createShared):
(JSC::ArrayBuffer::tryCreate):
(JSC::ArrayBuffer::grow):
(JSC::tryAllocate):
(JSC::ArrayBuffer::tryCreateShared):
(JSC::SharedArrayBufferContents::grow):
* Source/JavaScriptCore/runtime/ArrayBuffer.h:
(JSC::ArrayBuffer::byteLength const):
(JSC::ArrayBuffer::maxByteLength const):
(JSC::IdempotentArrayBufferByteLengthGetter::IdempotentArrayBufferByteLengthGetter):
(JSC::IdempotentArrayBufferByteLengthGetter::operator()):
* Source/JavaScriptCore/runtime/BufferMemoryHandle.cpp: Added.
(JSC::BufferMemoryHandle::fastMappedRedzoneBytes):
(JSC::BufferMemoryHandle::fastMappedBytes):
(JSC::BufferMemoryResult::toString):
(JSC::BufferMemoryResult::dump const):
(JSC::BufferMemoryManager::tryAllocateFastMemory):
(JSC::BufferMemoryManager::freeFastMemory):
(JSC::BufferMemoryManager::tryAllocateGrowableBoundsCheckingMemory):
(JSC::BufferMemoryManager::freeGrowableBoundsCheckingMemory):
(JSC::BufferMemoryManager::isInGrowableOrFastMemory):
(JSC::BufferMemoryManager::tryAllocatePhysicalBytes):
(JSC::BufferMemoryManager::freePhysicalBytes):
(JSC::BufferMemoryManager::dump const):
(JSC::BufferMemoryManager::singleton):
(JSC::BufferMemoryHandle::BufferMemoryHandle):
(JSC::BufferMemoryHandle::~BufferMemoryHandle):
(JSC::BufferMemoryHandle::memory const):
* Source/JavaScriptCore/runtime/BufferMemoryHandle.h: Added.
(JSC::BufferMemoryResult::BufferMemoryResult):
(JSC::BufferMemoryManager::memoryLimit const):
* Source/JavaScriptCore/runtime/CommonIdentifiers.h:
* Source/JavaScriptCore/runtime/JSArrayBufferConstructor.cpp:
(JSC::JSGenericArrayBufferConstructor<sharingMode>::constructImpl):
* Source/JavaScriptCore/runtime/JSArrayBufferPrototype.cpp:
(JSC::arrayBufferSlice):
(JSC::JSC_DEFINE_HOST_FUNCTION):
(JSC::JSArrayBufferPrototype::finishCreation):
* Source/JavaScriptCore/runtime/JSArrayBufferView.cpp:
(JSC::JSArrayBufferView::ConstructionContext::ConstructionContext):
(JSC::JSArrayBufferView::JSArrayBufferView):
(JSC::JSArrayBufferView::finishCreation):
(JSC::JSArrayBufferView::detach):
(JSC::JSArrayBufferView::slowDownAndWasteMemory):
(JSC::isIntegerIndexedObjectOutOfBounds):
(JSC::integerIndexedObjectLength):
(JSC::integerIndexedObjectByteLength):
(WTF::printInternal):
* Source/JavaScriptCore/runtime/JSArrayBufferView.h:
(JSC::hasArrayBuffer):
(JSC::isResizable):
(JSC::JSArrayBufferView::ConstructionContext::vector const):
(JSC::JSArrayBufferView::ConstructionContext::maxByteLength const):
(JSC::JSArrayBufferView::ConstructionContext::maxByteLengthUnsafe const):
(JSC::JSArrayBufferView::vector const):
(JSC::JSArrayBufferView::maxByteLength const):
(JSC::JSArrayBufferView::offsetOfMaxByteLength):
* Source/JavaScriptCore/runtime/JSArrayBufferViewInlines.h:
(JSC::JSArrayBufferView::isShared):
(JSC::JSArrayBufferView::possiblySharedBufferImpl):
(JSC::JSArrayBufferView::existingBufferInButterfly):
* Source/JavaScriptCore/runtime/JSCJSValue.h:
* Source/JavaScriptCore/runtime/JSCJSValueInlines.h:
(JSC::JSValue::toTypedArrayIndex const):
* Source/JavaScriptCore/runtime/JSGenericTypedArrayView.h:
* Source/JavaScriptCore/runtime/JSGenericTypedArrayViewConstructorInlines.h:
(JSC::constructGenericTypedArrayViewWithArguments):
(JSC::constructGenericTypedArrayViewImpl):
* Source/JavaScriptCore/runtime/JSGenericTypedArrayViewInlines.h:
(JSC::JSGenericTypedArrayView<Adaptor>::deletePropertyByIndex):
(JSC::JSGenericTypedArrayView<Adaptor>::visitChildrenImpl):
* Source/JavaScriptCore/runtime/MemoryMode.cpp: Renamed from Source/JavaScriptCore/wasm/WasmMemoryMode.cpp.
(WTF::printInternal):
* Source/JavaScriptCore/runtime/MemoryMode.h: Renamed from Source/JavaScriptCore/wasm/WasmMemoryMode.h.
* Source/JavaScriptCore/runtime/OptionsList.h:
* Source/JavaScriptCore/runtime/PageCount.cpp: Renamed from Source/JavaScriptCore/wasm/WasmPageCount.cpp.
(JSC::PageCount::dump const):
* Source/JavaScriptCore/runtime/PageCount.h: Renamed from Source/JavaScriptCore/wasm/WasmPageCount.h.
(JSC::PageCount::PageCount):
(JSC::PageCount::bytes const):
(JSC::PageCount::pageCount const):
(JSC::PageCount::isValid):
(JSC::PageCount::isValid const):
(JSC::PageCount::fromBytes):
(JSC::PageCount::fromBytesWithRoundUp):
(JSC::PageCount::max):
(JSC::PageCount::operator bool const):
(JSC::PageCount::operator< const):
(JSC::PageCount::operator> const):
(JSC::PageCount::operator>= const):
(JSC::PageCount::operator== const):
(JSC::PageCount::operator!= const):
(JSC::PageCount::operator+ const):
* Source/JavaScriptCore/runtime/StructureInlines.h:
(JSC::Structure::hasIndexingHeader const):
* Source/JavaScriptCore/wasm/WasmAirIRGenerator.cpp:
(JSC::Wasm::AirIRGenerator::addCurrentMemory):
* Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp:
(JSC::Wasm::B3IRGenerator::addCurrentMemory):
* Source/JavaScriptCore/wasm/WasmCallee.h:
* Source/JavaScriptCore/wasm/WasmCalleeGroup.cpp:
(JSC::Wasm::CalleeGroup::isSafeToRun):
* Source/JavaScriptCore/wasm/WasmCalleeGroup.h:
* Source/JavaScriptCore/wasm/WasmFormat.h:
* Source/JavaScriptCore/wasm/WasmMemory.cpp:
(JSC::Wasm::Memory::Memory):
(JSC::Wasm::Memory::create):
(JSC::Wasm::Memory::createZeroSized):
(JSC::Wasm::Memory::tryCreate):
(JSC::Wasm::Memory::addressIsInGrowableOrFastMemory):
(JSC::Wasm::Memory::growShared):
(JSC::Wasm::Memory::grow):
(JSC::Wasm::Memory::dump const):
(JSC::Wasm::MemoryHandle::MemoryHandle): Deleted.
(JSC::Wasm::MemoryHandle::~MemoryHandle): Deleted.
(JSC::Wasm::MemoryHandle::memory const): Deleted.
(JSC::Wasm::Memory::fastMappedRedzoneBytes): Deleted.
(JSC::Wasm::Memory::fastMappedBytes): Deleted.
* Source/JavaScriptCore/wasm/WasmMemory.h:
(JSC::Wasm::Memory::maxFastMemoryCount): Deleted.
* Source/JavaScriptCore/wasm/WasmMemoryInformation.h:
* Source/JavaScriptCore/wasm/WasmModule.cpp:
(JSC::Wasm::Module::copyInitialCalleeGroupToAllMemoryModes):
* Source/JavaScriptCore/wasm/WasmModule.h:
* Source/JavaScriptCore/wasm/WasmOperations.cpp:
(JSC::Wasm::JSC_DEFINE_JIT_OPERATION):
* Source/JavaScriptCore/wasm/js/JSToWasm.cpp:
(JSC::Wasm::createJSToWasmWrapper):
* Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.cpp:
(JSC::JSWebAssemblyInstance::tryCreate):
* Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.h:
* Source/JavaScriptCore/wasm/js/JSWebAssemblyMemory.cpp:
(JSC::JSWebAssemblyMemory::buffer):
(JSC::JSWebAssemblyMemory::grow):
(JSC::JSWebAssemblyMemory::type):
(JSC::JSWebAssemblyMemory::growSuccessCallback):
* Source/JavaScriptCore/wasm/js/JSWebAssemblyMemory.h:
* Source/JavaScriptCore/wasm/js/JSWebAssemblyModule.h:
* Source/JavaScriptCore/wasm/js/WebAssemblyFunction.cpp:
(JSC::WebAssemblyFunction::calleeSaves const):
(JSC::WebAssemblyFunction::jsCallEntrypointSlow):
* Source/JavaScriptCore/wasm/js/WebAssemblyMemoryConstructor.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/wasm/js/WebAssemblyMemoryPrototype.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.cpp:
(JSC::WebAssemblyModuleRecord::initializeImports):
* Source/WTF/wtf/OSAllocator.h:
* Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp:
(WTF::OSAllocator::protect):
* Source/WTF/wtf/win/OSAllocatorWin.cpp:
(WTF::OSAllocator::protect):
* Source/WebCore/bindings/js/SerializedScriptValue.cpp:
(WebCore::CloneSerializer::dumpIfTerminal):
(WebCore::CloneDeserializer::readTerminal):
* Source/WebCore/bindings/js/SerializedScriptValue.h:
Canonical link: https://commits.webkit.org/256524@main1 parent 7c870a9 commit 7a29252
67 files changed
Lines changed: 1997 additions & 741 deletions
File tree
- JSTests/test262
- Source
- JavaScriptCore
- JavaScriptCore.xcodeproj
- bytecode
- dfg
- ftl
- heap
- jit
- llint
- runtime
- wasm
- js
- WTF/wtf
- posix
- win
- WebCore/bindings/js
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | | - | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| |||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
956 | 956 | | |
957 | 957 | | |
958 | 958 | | |
| 959 | + | |
959 | 960 | | |
960 | 961 | | |
961 | 962 | | |
| |||
1136 | 1137 | | |
1137 | 1138 | | |
1138 | 1139 | | |
| 1140 | + | |
1139 | 1141 | | |
1140 | 1142 | | |
1141 | 1143 | | |
| |||
1152 | 1154 | | |
1153 | 1155 | | |
1154 | 1156 | | |
| 1157 | + | |
1155 | 1158 | | |
1156 | 1159 | | |
1157 | 1160 | | |
| |||
1268 | 1271 | | |
1269 | 1272 | | |
1270 | 1273 | | |
1271 | | - | |
1272 | 1274 | | |
1273 | 1275 | | |
1274 | 1276 | | |
1275 | 1277 | | |
1276 | 1278 | | |
1277 | | - | |
1278 | 1279 | | |
1279 | 1280 | | |
1280 | 1281 | | |
| |||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
762 | 762 | | |
763 | 763 | | |
764 | 764 | | |
| 765 | + | |
765 | 766 | | |
766 | 767 | | |
767 | 768 | | |
| |||
964 | 965 | | |
965 | 966 | | |
966 | 967 | | |
| 968 | + | |
967 | 969 | | |
968 | 970 | | |
969 | 971 | | |
| |||
981 | 983 | | |
982 | 984 | | |
983 | 985 | | |
| 986 | + | |
984 | 987 | | |
985 | 988 | | |
986 | 989 | | |
| |||
1124 | 1127 | | |
1125 | 1128 | | |
1126 | 1129 | | |
1127 | | - | |
1128 | 1130 | | |
1129 | 1131 | | |
1130 | 1132 | | |
1131 | 1133 | | |
1132 | 1134 | | |
1133 | 1135 | | |
1134 | 1136 | | |
1135 | | - | |
1136 | 1137 | | |
1137 | 1138 | | |
1138 | 1139 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1237 | 1237 | | |
1238 | 1238 | | |
1239 | 1239 | | |
1240 | | - | |
| 1240 | + | |
1241 | 1241 | | |
1242 | | - | |
| 1242 | + | |
1243 | 1243 | | |
1244 | 1244 | | |
1245 | 1245 | | |
| |||
1661 | 1661 | | |
1662 | 1662 | | |
1663 | 1663 | | |
1664 | | - | |
| 1664 | + | |
1665 | 1665 | | |
1666 | | - | |
| 1666 | + | |
1667 | 1667 | | |
1668 | 1668 | | |
1669 | 1669 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| 96 | + | |
| 97 | + | |
96 | 98 | | |
97 | 99 | | |
98 | 100 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
198 | | - | |
| 198 | + | |
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3608 | 3608 | | |
3609 | 3609 | | |
3610 | 3610 | | |
| 3611 | + | |
| 3612 | + | |
3611 | 3613 | | |
3612 | 3614 | | |
3613 | 3615 | | |
| |||
3638 | 3640 | | |
3639 | 3641 | | |
3640 | 3642 | | |
3641 | | - | |
3642 | | - | |
| 3643 | + | |
| 3644 | + | |
3643 | 3645 | | |
3644 | 3646 | | |
| 3647 | + | |
| 3648 | + | |
3645 | 3649 | | |
3646 | 3650 | | |
3647 | 3651 | | |
| |||
8403 | 8407 | | |
8404 | 8408 | | |
8405 | 8409 | | |
8406 | | - | |
| 8410 | + | |
8407 | 8411 | | |
8408 | 8412 | | |
8409 | 8413 | | |
| |||
8483 | 8487 | | |
8484 | 8488 | | |
8485 | 8489 | | |
8486 | | - | |
8487 | | - | |
| 8490 | + | |
| 8491 | + | |
8488 | 8492 | | |
8489 | 8493 | | |
| 8494 | + | |
| 8495 | + | |
8490 | 8496 | | |
8491 | 8497 | | |
8492 | 8498 | | |
| |||
8791 | 8797 | | |
8792 | 8798 | | |
8793 | 8799 | | |
| 8800 | + | |
| 8801 | + | |
8794 | 8802 | | |
8795 | 8803 | | |
8796 | 8804 | | |
| |||
11658 | 11666 | | |
11659 | 11667 | | |
11660 | 11668 | | |
| 11669 | + | |
11661 | 11670 | | |
11662 | 11671 | | |
11663 | 11672 | | |
| |||
11684 | 11693 | | |
11685 | 11694 | | |
11686 | 11695 | | |
| 11696 | + | |
| 11697 | + | |
| 11698 | + | |
11687 | 11699 | | |
11688 | 11700 | | |
11689 | 11701 | | |
11690 | 11702 | | |
| 11703 | + | |
| 11704 | + | |
| 11705 | + | |
11691 | 11706 | | |
11692 | | - | |
| 11707 | + | |
11693 | 11708 | | |
11694 | 11709 | | |
11695 | 11710 | | |
| |||
0 commit comments