[WebIDL] Add a new extended attribute to model the forced return value optimization...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Jun 2017 20:38:52 +0000 (20:38 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Jun 2017 20:38:52 +0000 (20:38 +0000)
commit64562943c2ff89ff972e3ed4f3905a3e1140d23b
tree1d74686bca45d9c3db0da3b916e41ffa05968edf
parent4ae6e3f3bf9a0f11ddf270f7ab882ddb29975415
[WebIDL] Add a new extended attribute to model the forced return value optimization used on Node and Crypto
https://bugs.webkit.org/show_bug.cgi?id=173961

Patch by Sam Weinig <sam@webkit.org> on 2017-06-29
Reviewed by Darin Adler.

Source/WebCore:

Node and Crypto were both using custom bindings to implement an optimization
for operations that always returned one one of the arguments passed in. The
optimization directly returns the JSValue argument, avoiding wrapping and
unwrapping, and all the cache lookups that might entail. This allows that
optimization to work without custom bindings by adding a new extended attribute
[ReturnValue] that can annotate an argument. When used, the implementation
function is expected to return either void or ExceptionOr<void>.

* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSBindingsAllInOne.cpp:
* bindings/js/JSCryptoCustom.cpp: Removed.
Remove JSCryptoCustom.cpp.

* bindings/js/JSNodeCustom.cpp:
(WebCore::JSNode::insertBefore): Deleted.
(WebCore::JSNode::replaceChild): Deleted.
(WebCore::JSNode::removeChild): Deleted.
(WebCore::JSNode::appendChild): Deleted.
Remove custom functions.

* bindings/scripts/CodeGeneratorJS.pm:
(OperationHasForcedReturnValue):
Add helper to determine if an operation has [ReturnValue] on any argument.

(NeedsExplicitPropagateExceptionCall):
We must treat operations with a [ReturnValue] argument like we do operations
returning void, and explicitly check for exceptions.

(GenerateParametersCheck):
Pull out the argument in a variable called 'returnValue' if it is annotated
with [ReturnValue].

(GenerateImplementationFunctionCall):
Special case operations with a [ReturnValue] argument to return the previously
set aside 'returnValue' variable.

* bindings/scripts/IDLAttributes.json:
Add [ReturnValue].

* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore::jsTestObjPrototypeFunctionTestReturnValueOptimizationBody):
(WebCore::jsTestObjPrototypeFunctionTestReturnValueOptimization):
(WebCore::jsTestObjPrototypeFunctionTestReturnValueOptimizationWithExceptionBody):
(WebCore::jsTestObjPrototypeFunctionTestReturnValueOptimizationWithException):
* bindings/scripts/test/TestObj.idl:
Add tests for [ReturnValue].

* dom/Node.idl:
* page/Crypto.idl:
Add [ReturnValue] annotations and remove [Custom] annotations.

LayoutTests:

* js/dom/dot-node-base-exception-expected.txt: Removed.
* js/dom/dot-node-base-exception.html: Removed.
* js/dom/script-tests/dot-node-base-exception.js: Removed.
Remove now obsolete test.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@218960 268f45cc-cd09-0410-ab3c-d52691b4dbfc
16 files changed:
LayoutTests/ChangeLog
LayoutTests/js/dom/dot-node-base-exception-expected.txt [deleted file]
LayoutTests/js/dom/dot-node-base-exception.html [deleted file]
LayoutTests/js/dom/script-tests/dot-node-base-exception.js [deleted file]
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/JSBindingsAllInOne.cpp
Source/WebCore/bindings/js/JSCryptoCustom.cpp [deleted file]
Source/WebCore/bindings/js/JSNodeCustom.cpp
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/IDLAttributes.json
Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
Source/WebCore/bindings/scripts/test/TestObj.idl
Source/WebCore/dom/Node.idl
Source/WebCore/page/Crypto.idl