Repository navigation
Commit 12c9964
committed
Address Safer C++ static analysis warnings in WebCore bindings code
https://bugs.webkit.org/show_bug.cgi?id=326601
Reviewed by Geoffrey Garen.
Fix all Safer C++ warnings in the generated JS bindings and in bindings/js,
without adding ref counting churn to hot paths:
- Interface conversion results are now Ref<T> / RefPtr<T>. The converter already
refs the object, so this only moves the deref after the implementation call.
- Trivial accessors are marked NODELETE and pure pointer conversions are marked
CLANG_POINTER_CONVERSION.
- Values that are passed straight to toJS(), which refs them before anything can
run, are produced inside the toJS() functor, so a single suppression in
JSDOMConvertBase.h covers them.
- Code that runs on the GC thread, and other provably safe hot paths, use
suppressions with comments.
- Cold paths use protect().
* Source/JavaScriptCore/CMakeLists.txt:
* Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj:
Export HeapProfiler.h, which HeapSnapshotBuilder's constructor depends on.
* Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_separate_header.py:
Include FunctionExecutable.h, which the generated init() functions use.
* Source/JavaScriptCore/Scripts/tests/builtins/expected/WebCore-AnotherGuardedInternalBuiltin-Separate.js-result:
* Source/JavaScriptCore/Scripts/tests/builtins/expected/WebCore-ArbitraryConditionalGuard-Separate.js-result:
* Source/JavaScriptCore/Scripts/tests/builtins/expected/WebCore-GuardedBuiltin-Separate.js-result:
* Source/JavaScriptCore/Scripts/tests/builtins/expected/WebCore-GuardedInternalBuiltin-Separate.js-result:
* Source/JavaScriptCore/Scripts/tests/builtins/expected/WebCore-UnguardedBuiltin-Separate.js-result:
* Source/JavaScriptCore/Scripts/tests/builtins/expected/WebCore-xmlCasingTest-Separate.js-result:
Rebaseline.
* Source/WebCore/bindings/IDLTypes.h:
Use Ref<T> / RefPtr<T> as IDLInterface conversion results. Mark the
extractValueFromNullable() overloads that return references as pointer conversions.
* Source/WebCore/bindings/js/JSDOMConvertInterface.h:
Transfer the converter's reference into the conversion result.
* Source/WebCore/bindings/js/JSDOMConvertBase.h:
Mark getPtrOrRef() as pointer conversions and suppress the warnings for values
that toJS() passes straight to the converter.
* Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:
Pass interface arguments using .get(), produce interface and buffer source results
inside the toJS() functor, pass the union setter functor inline so it binds to
convert()'s NOESCAPE parameter, protect cold-path arguments, and suppress the
warnings for indexed / named property access, security checks and GC-thread code.
* Source/WebCore/bindings/scripts/test/JS/JSDOMWindow.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSExposedToWorkerAndWindow.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestAsyncIterable.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestCEReactions.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestCallTracer.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestConditionalIncludes.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestConditionallyReadWrite.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestDOMJIT.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestDefaultToJSON.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestDefaultToJSONInherit.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestDefaultToJSONInheritFinal.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestDomainSecurity.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestEnabledForContext.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestGenerateAddOpaqueRoot.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestGenerateIsReachable.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestIndexedSetterNoIdentifier.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestIndexedSetterThrowingException.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestIndexedSetterWithIdentifier.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestLegacyNoInterfaceObject.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestLegacyOverrideBuiltIns.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestNamedAndIndexedSetterNoIdentifier.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestNamedAndIndexedSetterThrowingException.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestNamedAndIndexedSetterWithIdentifier.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestNamedDeleterNoIdentifier.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestNamedDeleterThrowingException.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestNamedDeleterWithIdentifier.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestNamedDeleterWithIndexedGetter.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestNamedGetterCallWith.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestNamedGetterNoIdentifier.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestNamedGetterWithIdentifier.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterNoIdentifier.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterThrowingException.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithIdentifier.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithIndexedGetter.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithIndexedGetterAndSetter.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithLegacyOverrideBuiltIns.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithLegacyUnforgeableProperties.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithLegacyUnforgeablePropertiesAndLegacyOverrideBuiltIns.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestNamespaceObject.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestReportExtraMemoryCost.cpp:
* Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp:
Rebaseline.
* Source/WebCore/bindings/js/JSAudioBufferSourceNodeCustom.cpp:
* Source/WebCore/bindings/js/JSCSSRuleCustom.h:
* Source/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp:
* Source/WebCore/bindings/js/JSHTMLCanvasElementCustom.cpp:
* Source/WebCore/bindings/js/JSIDBTransactionCustom.cpp:
* Source/WebCore/bindings/js/JSIntersectionObserverCustom.cpp:
* Source/WebCore/bindings/js/JSMessageChannelCustom.cpp:
* Source/WebCore/bindings/js/JSOffscreenCanvasRenderingContext2DCustom.cpp:
* Source/WebCore/bindings/js/JSRangeCustom.cpp:
* Source/WebCore/bindings/js/JSSVGViewSpecCustom.cpp:
* Source/WebCore/bindings/js/JSStaticRangeCustom.cpp:
* Source/WebCore/bindings/js/JSStylePropertyMapReadOnlyCustom.cpp:
* Source/WebCore/bindings/js/JSTrustedTypePolicyFactoryCustom.cpp:
* Source/WebCore/bindings/js/JSWorkerGlobalScopeCustom.cpp:
* Source/WebCore/bindings/js/WebCoreTypedArrayController.cpp:
Suppress the warnings for code that runs on the GC thread.
* Source/WebCore/bindings/js/JSCustomElementInterface.cpp:
* Source/WebCore/bindings/js/JSDOMBindingSecurity.cpp:
* Source/WebCore/bindings/js/JSDOMGlobalObject.cpp:
* Source/WebCore/bindings/js/JSDOMPromiseDeferred.cpp:
* Source/WebCore/bindings/js/JSDOMPromiseDeferred.h:
* Source/WebCore/bindings/js/JSDOMWindowBase.cpp:
* Source/WebCore/bindings/js/JSExecState.cpp:
* Source/WebCore/bindings/js/JSLazyEventListener.cpp:
* Source/WebCore/bindings/js/JSWorkletGlobalScopeBase.cpp:
* Source/WebCore/bindings/js/ScheduledAction.cpp:
* Source/WebCore/bindings/js/ScriptBufferSourceProvider.h:
* Source/WebCore/bindings/js/ScriptController.cpp:
* Source/WebCore/bindings/js/ScriptControllerMac.mm:
* Source/WebCore/bindings/js/ScriptModuleLoader.cpp:
* Source/WebCore/bindings/js/SerializedScriptValue.cpp:
* Source/WebCore/bindings/js/WebAssemblyScriptBufferSourceProvider.h:
Use protect() / smart pointers.
* Source/WebCore/bindings/js/DOMPromiseProxy.h:
* Source/WebCore/bindings/js/JSDOMBindingSecurityInlines.h:
* Source/WebCore/bindings/js/JSDOMConvertEventListener.h:
* Source/WebCore/bindings/js/JSDOMIterator.h:
* Source/WebCore/bindings/js/JSEventTargetCustom.h:
Suppress the warnings where the object is provably kept alive.
* Source/WebCore/bindings/js/GarbageCollectionController.cpp:
* Source/WebCore/bindings/js/JSDOMWindowCustom.cpp:
* Source/WebCore/bindings/js/JSExecState.h:
* Source/WebCore/bindings/js/JSLocationCustom.cpp:
Include the headers for forward declared types.
* Source/WebCore/bindings/js/JSNodeCustom.cpp:
* Source/WebCore/bindings/js/JSPaintRenderingContext2DCustom.cpp:
Suppress the warnings for code that runs on the GC thread or where the object is
kept alive. Include CustomPaintCanvas.h.
* Source/WebCore/dom/Document.h:
* Source/WebCore/dom/EmptyScriptExecutionContext.h:
* Source/WebCore/dom/ScriptExecutionContext.h:
* Source/WebCore/workers/WorkerGlobalScope.h:
* Source/WebCore/worklets/WorkletGlobalScope.h:
Mark settingsValues(), quirks() and ensureQuirks() as NODELETE.
* Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp:
* Source/WebCore/html/canvas/CanvasRenderingContext2DBase.h:
Take Ref<> for the non-nullable gradient and pattern styles.
* Source/WebCore/SaferCPPExpectations/ForwardDeclCheckerExpectations:
* Source/WebCore/SaferCPPExpectations/NoUncheckedPtrMemberCheckerExpectations:
* Source/WebCore/SaferCPPExpectations/NoUncountedMemberCheckerExpectations:
* Source/WebCore/SaferCPPExpectations/UncheckedCallArgsCheckerExpectations:
* Source/WebCore/SaferCPPExpectations/UncountedCallArgsCheckerExpectations:
* Source/WebCore/SaferCPPExpectations/UnretainedLocalVarsCheckerExpectations:
Update expectations.
Canonical link: https://commits.webkit.org/323069@main1 parent 34f64e2 commit 12c9964
114 files changed
Lines changed: 648 additions & 499 deletions
File tree
- Source
- JavaScriptCore
- JavaScriptCore.xcodeproj
- Scripts
- tests/builtins/expected
- wkbuiltins
- WebCore
- SaferCPPExpectations
- bindings
- js
- scripts
- test/JS
- dom
- html/canvas
- workers
- worklets
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 | |
|---|---|---|---|
| |||
859 | 859 | | |
860 | 860 | | |
861 | 861 | | |
| 862 | + | |
862 | 863 | | |
863 | 864 | | |
864 | 865 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1631 | 1631 | | |
1632 | 1632 | | |
1633 | 1633 | | |
1634 | | - | |
| 1634 | + | |
1635 | 1635 | | |
1636 | 1636 | | |
1637 | 1637 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| 100 | + | |
| 101 | + | |
100 | 102 | | |
101 | 103 | | |
102 | 104 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | 1 | | |
10 | 2 | | |
11 | 3 | | |
| |||
0 commit comments