Title: [291964] trunk/Source/WebCore
- Revision
- 291964
- Author
- cdu...@apple.com
- Date
- 2022-03-28 07:22:20 -0700 (Mon, 28 Mar 2022)
Log Message
Optimize toJS() for HTMLElements
https://bugs.webkit.org/show_bug.cgi?id=238426
Reviewed by Yusuke Suzuki.
Optimize toJS() for HTMLElements. Previously, the more generic Element's toJS() would be called,
which would have to do more checks.
This is a 0.6% progression on Speedometer 2.0 on MacBook Air 10,1 (AS).
* bindings/js/JSHTMLElementCustom.cpp:
(WebCore::toJS):
(WebCore::toJSNewlyCreated):
* html/HTMLElement.idl:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (291963 => 291964)
--- trunk/Source/WebCore/ChangeLog 2022-03-28 14:14:09 UTC (rev 291963)
+++ trunk/Source/WebCore/ChangeLog 2022-03-28 14:22:20 UTC (rev 291964)
@@ -1,5 +1,22 @@
2022-03-28 Chris Dumez <cdu...@apple.com>
+ Optimize toJS() for HTMLElements
+ https://bugs.webkit.org/show_bug.cgi?id=238426
+
+ Reviewed by Yusuke Suzuki.
+
+ Optimize toJS() for HTMLElements. Previously, the more generic Element's toJS() would be called,
+ which would have to do more checks.
+
+ This is a 0.6% progression on Speedometer 2.0 on MacBook Air 10,1 (AS).
+
+ * bindings/js/JSHTMLElementCustom.cpp:
+ (WebCore::toJS):
+ (WebCore::toJSNewlyCreated):
+ * html/HTMLElement.idl:
+
+2022-03-28 Chris Dumez <cdu...@apple.com>
+
Drop unnecessary isReachableFromDOM() function in JSNodeCustom.cpp
https://bugs.webkit.org/show_bug.cgi?id=238422
Modified: trunk/Source/WebCore/bindings/js/JSHTMLElementCustom.cpp (291963 => 291964)
--- trunk/Source/WebCore/bindings/js/JSHTMLElementCustom.cpp 2022-03-28 14:14:09 UTC (rev 291963)
+++ trunk/Source/WebCore/bindings/js/JSHTMLElementCustom.cpp 2022-03-28 14:22:20 UTC (rev 291964)
@@ -32,6 +32,7 @@
#include "HTMLFormElement.h"
#include "JSCustomElementInterface.h"
#include "JSDOMConstructorBase.h"
+#include "JSHTMLElementWrapperFactory.h"
#include "JSNodeCustom.h"
#include "ScriptExecutionContext.h"
#include <_javascript_Core/InternalFunction.h>
@@ -130,4 +131,23 @@
return JSWithScope::create(vm, lexicalGlobalObject, scope, asObject(toJS(lexicalGlobalObject, globalObject(), element)));
}
+JSValue toJS(JSGlobalObject*, JSDOMGlobalObject* globalObject, HTMLElement& element)
+{
+ if (auto* wrapper = getCachedWrapper(globalObject->world(), element))
+ return wrapper;
+ return createJSHTMLWrapper(globalObject, element);
+}
+
+JSValue toJSNewlyCreated(JSGlobalObject*, JSDOMGlobalObject* globalObject, Ref<HTMLElement>&& element)
+{
+ if (element->isDefinedCustomElement()) {
+ JSValue result = getCachedWrapper(globalObject->world(), element);
+ if (result)
+ return result;
+ ASSERT(!globalObject->vm().exceptionForInspection());
+ }
+ ASSERT(!getCachedWrapper(globalObject->world(), element));
+ return createJSHTMLWrapper(globalObject, WTFMove(element));
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/html/HTMLElement.idl (291963 => 291964)
--- trunk/Source/WebCore/html/HTMLElement.idl 2022-03-28 14:14:09 UTC (rev 291963)
+++ trunk/Source/WebCore/html/HTMLElement.idl 2022-03-28 14:22:20 UTC (rev 291964)
@@ -20,6 +20,7 @@
[
CustomPushEventHandlerScope,
+ CustomToJSObject,
ExportMacro=WEBCORE_EXPORT,
Exposed=Window,
GenerateForEachEventHandlerContentAttribute,
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes