Should not use variable-length-array (VLA)
authorysuzuki@apple.com <ysuzuki@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 15 Mar 2020 10:16:52 +0000 (10:16 +0000)
committerysuzuki@apple.com <ysuzuki@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 15 Mar 2020 10:16:52 +0000 (10:16 +0000)
commit9ccee59cd5360a60b6bb2dd51f0442beadf31f96
treed2db67437818dc72a296ad584f341caa6e5de9b1
parentafb5822f59e57ec3ea05d0f5ef9ad02d4d23d219
Should not use variable-length-array (VLA)
https://bugs.webkit.org/show_bug.cgi?id=209043

Reviewed by Mark Lam.

PerformanceTests:

* MediaTime/Configurations/Base.xcconfig:

Source/bmalloc:

* Configurations/Base.xcconfig:

Source/JavaScriptCore:

This patch disables variable-length-array (VLA). If this feature uses user-input, user can
control the stack height consumed by C++ code. This patch avoids using VLA. To achieve that,

    1. We set `-Wvla` warning option to trigger warnings if it is used.
    2. Introduce MarkedJSValueRefArray for API. This replaces `JSValueRef arguments[variableLength]` use case.
       MarkedJSValueRefArray registers itself to JSC GC so that GC can mark it as a strong root.

* API/JSContext.mm:
(+[JSContext currentArguments]):
* API/JSValue.mm:
(-[JSValue callWithArguments:]):
(-[JSValue constructWithArguments:]):
(-[JSValue invokeMethod:withArguments:]):
* API/MarkedJSValueRefArray.cpp: Added.
(JSC::MarkedJSValueRefArray::MarkedJSValueRefArray):
(JSC::MarkedJSValueRefArray::~MarkedJSValueRefArray):
(JSC::MarkedJSValueRefArray::visitAggregate):
* API/MarkedJSValueRefArray.h: Added.
* API/tests/minidom.c:
(print):
* API/tests/testapi.cpp:
(TestAPI::markedJSValueArrayAndGC):
(testCAPIViaCpp):
* Configurations/Base.xcconfig:
* JavaScriptCore.xcodeproj/project.pbxproj:
* Sources.txt:
* heap/Heap.cpp:
(JSC::Heap::addCoreConstraints):
(JSC::Heap::addMarkedJSValueRefArray):
* heap/Heap.h:
* heap/MarkedSpace.h:
(JSC::MarkedSpace::activeWeakSetsBegin): Deleted.
(JSC::MarkedSpace::activeWeakSetsEnd): Deleted.
(JSC::MarkedSpace::newActiveWeakSetsBegin): Deleted.
(JSC::MarkedSpace::newActiveWeakSetsEnd): Deleted.
* runtime/ArgList.h:

Source/WebCore:

* Configurations/Base.xcconfig:
* crypto/mac/SerializedCryptoKeyWrapMac.mm:
(WebCore::wrapSerializedCryptoKey):
(WebCore::unwrapSerializedCryptoKey):
* html/canvas/WebGL2RenderingContext.cpp:
(WebCore::WebGL2RenderingContext::getInternalformatParameter):
* platform/mediastream/mac/CoreAudioCaptureDeviceManager.cpp:
(WebCore::CoreAudioCaptureDeviceManager::refreshAudioCaptureDevices):
* platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm:
(WebCore::updateDisplayID):
(WebCore::ScreenDisplayCaptureSourceMac::screenCaptureDevices):

Source/WebCore/PAL:

* Configurations/Base.xcconfig:

Source/WebInspectorUI:

* Configurations/Base.xcconfig:

Source/WebKit:

* Configurations/Base.xcconfig:
* UIProcess/_WKTouchEventGenerator.mm:
(-[_WKTouchEventGenerator touchDown:touchCount:]):
(-[_WKTouchEventGenerator liftUp:touchCount:]):
(-[_WKTouchEventGenerator moveToPoints:touchCount:duration:]):

Source/WebKitLegacy/mac:

* Configurations/Base.xcconfig:

Source/WTF:

* Configurations/Base.xcconfig:
* wtf/UUID.cpp:
(WTF::bootSessionUUIDString):

Tools:

* ContentExtensionTester/Configurations/Base.xcconfig:
* lldb/lldbWebKitTester/Configurations/Base.xcconfig:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@258478 268f45cc-cd09-0410-ab3c-d52691b4dbfc
39 files changed:
PerformanceTests/ChangeLog
PerformanceTests/MediaTime/Configurations/Base.xcconfig
Source/JavaScriptCore/API/JSContext.mm
Source/JavaScriptCore/API/JSValue.mm
Source/JavaScriptCore/API/MarkedJSValueRefArray.cpp [new file with mode: 0644]
Source/JavaScriptCore/API/MarkedJSValueRefArray.h [new file with mode: 0644]
Source/JavaScriptCore/API/tests/minidom.c
Source/JavaScriptCore/API/tests/testapi.cpp
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/Configurations/Base.xcconfig
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/Sources.txt
Source/JavaScriptCore/heap/Heap.cpp
Source/JavaScriptCore/heap/Heap.h
Source/JavaScriptCore/heap/MarkedSpace.h
Source/JavaScriptCore/runtime/ArgList.h
Source/WTF/ChangeLog
Source/WTF/Configurations/Base.xcconfig
Source/WTF/wtf/UUID.cpp
Source/WebCore/ChangeLog
Source/WebCore/Configurations/Base.xcconfig
Source/WebCore/PAL/ChangeLog
Source/WebCore/PAL/Configurations/Base.xcconfig
Source/WebCore/crypto/mac/SerializedCryptoKeyWrapMac.mm
Source/WebCore/html/canvas/WebGL2RenderingContext.cpp
Source/WebCore/platform/mediastream/mac/CoreAudioCaptureDeviceManager.cpp
Source/WebCore/platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/Configurations/Base.xcconfig
Source/WebKit/ChangeLog
Source/WebKit/Configurations/Base.xcconfig
Source/WebKit/UIProcess/_WKTouchEventGenerator.mm
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/Configurations/Base.xcconfig
Source/bmalloc/ChangeLog
Source/bmalloc/Configurations/Base.xcconfig
Tools/ChangeLog
Tools/ContentExtensionTester/Configurations/Base.xcconfig
Tools/lldb/lldbWebKitTester/Configurations/Base.xcconfig