Title: [293627] trunk/Source
Revision
293627
Author
[email protected]
Date
2022-04-29 12:41:48 -0700 (Fri, 29 Apr 2022)

Log Message

Update toExistingAtomString() to return an AtomString
https://bugs.webkit.org/show_bug.cgi?id=239904

Reviewed by Darin Adler.

Update toExistingAtomString() to return an AtomString instead of a RefPtr<AtomStringImpl>
as it is a bit less awkward to use.

* Source/_javascript_Core/dfg/DFGOperations.cpp:
(JSC::DFG::JSC_DEFINE_JIT_OPERATION):
* Source/_javascript_Core/jit/JITOperations.cpp:
(JSC::getByVal):
(JSC::JSC_DEFINE_JIT_OPERATION):
* Source/_javascript_Core/llint/LLIntSlowPaths.cpp:
(JSC::LLInt::getByVal):
* Source/_javascript_Core/runtime/CommonSlowPaths.cpp:
(JSC::JSC_DEFINE_COMMON_SLOW_PATH):
* Source/_javascript_Core/runtime/JSString.h:
(JSC::JSString::toExistingAtomString const):
* Source/WTF/wtf/text/StringView.h:
(WTF::StringView::toExistingAtomString const):
* Source/WebCore/bindings/js/JSDOMConvertStrings.h:
(WebCore::Converter<IDLRequiresExistingAtomStringAdaptor<T>>::convert):
* Source/WebCore/dom/TreeScope.cpp:
(WebCore::TreeScope::getElementById const):
* Source/WebCore/platform/network/ResourceHandle.cpp:
(WebCore::ResourceHandle::create):
(WebCore::ResourceHandle::loadResourceSynchronously):

Canonical link: https://commits.webkit.org/250133@main

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/dfg/DFGOperations.cpp (293626 => 293627)


--- trunk/Source/_javascript_Core/dfg/DFGOperations.cpp	2022-04-29 19:25:30 UTC (rev 293626)
+++ trunk/Source/_javascript_Core/dfg/DFGOperations.cpp	2022-04-29 19:41:48 UTC (rev 293627)
@@ -1584,10 +1584,10 @@
     if (LIKELY(baseValue.isCell() && subscript.isString())) {
         Structure& structure = *baseValue.asCell()->structure();
         if (JSCell::canUseFastGetOwnProperty(structure)) {
-            RefPtr<AtomStringImpl> existingAtomString = asString(subscript)->toExistingAtomString(globalObject);
+            auto existingAtomString = asString(subscript)->toExistingAtomString(globalObject);
             RETURN_IF_EXCEPTION(scope, encodedJSValue());
-            if (existingAtomString) {
-                if (JSValue result = baseValue.asCell()->fastGetOwnProperty(vm, structure, existingAtomString.get()))
+            if (!existingAtomString.isNull()) {
+                if (JSValue result = baseValue.asCell()->fastGetOwnProperty(vm, structure, existingAtomString.impl()))
                     return JSValue::encode(result);
             }
         }

Modified: trunk/Source/_javascript_Core/jit/JITOperations.cpp (293626 => 293627)


--- trunk/Source/_javascript_Core/jit/JITOperations.cpp	2022-04-29 19:25:30 UTC (rev 293626)
+++ trunk/Source/_javascript_Core/jit/JITOperations.cpp	2022-04-29 19:41:48 UTC (rev 293627)
@@ -2239,10 +2239,10 @@
     if (LIKELY(baseValue.isCell() && subscript.isString())) {
         Structure& structure = *baseValue.asCell()->structure();
         if (JSCell::canUseFastGetOwnProperty(structure)) {
-            RefPtr<AtomStringImpl> existingAtomString = asString(subscript)->toExistingAtomString(globalObject);
+            auto existingAtomString = asString(subscript)->toExistingAtomString(globalObject);
             RETURN_IF_EXCEPTION(scope, JSValue());
-            if (existingAtomString) {
-                if (JSValue result = baseValue.asCell()->fastGetOwnProperty(vm, structure, existingAtomString.get())) {
+            if (!existingAtomString.isNull()) {
+                if (JSValue result = baseValue.asCell()->fastGetOwnProperty(vm, structure, existingAtomString.impl())) {
                     ASSERT(callFrame->bytecodeIndex() != BytecodeIndex(0));
                     return result;
                 }
@@ -2368,10 +2368,10 @@
         if (property.isString()) {
             Structure& structure = *base->structure();
             if (JSCell::canUseFastGetOwnProperty(structure)) {
-                RefPtr<AtomStringImpl> existingAtomString = asString(property)->toExistingAtomString(globalObject);
+                auto existingAtomString = asString(property)->toExistingAtomString(globalObject);
                 RETURN_IF_EXCEPTION(scope, encodedJSValue());
-                if (existingAtomString) {
-                    if (JSValue result = base->fastGetOwnProperty(vm, structure, existingAtomString.get()))
+                if (!existingAtomString.isNull()) {
+                    if (JSValue result = base->fastGetOwnProperty(vm, structure, existingAtomString.impl()))
                         return JSValue::encode(result);
                 }
             }

Modified: trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp (293626 => 293627)


--- trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp	2022-04-29 19:25:30 UTC (rev 293626)
+++ trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp	2022-04-29 19:41:48 UTC (rev 293627)
@@ -1056,10 +1056,10 @@
     if (LIKELY(baseValue.isCell() && subscript.isString())) {
         Structure& structure = *baseValue.asCell()->structure();
         if (JSCell::canUseFastGetOwnProperty(structure)) {
-            RefPtr<AtomStringImpl> existingAtomString = asString(subscript)->toExistingAtomString(globalObject);
+            auto existingAtomString = asString(subscript)->toExistingAtomString(globalObject);
             RETURN_IF_EXCEPTION(scope, JSValue());
-            if (existingAtomString) {
-                if (JSValue result = baseValue.asCell()->fastGetOwnProperty(vm, structure, existingAtomString.get()))
+            if (!existingAtomString.isNull()) {
+                if (JSValue result = baseValue.asCell()->fastGetOwnProperty(vm, structure, existingAtomString.impl()))
                     return result;
             }
         }

Modified: trunk/Source/_javascript_Core/runtime/CommonSlowPaths.cpp (293626 => 293627)


--- trunk/Source/_javascript_Core/runtime/CommonSlowPaths.cpp	2022-04-29 19:25:30 UTC (rev 293626)
+++ trunk/Source/_javascript_Core/runtime/CommonSlowPaths.cpp	2022-04-29 19:41:48 UTC (rev 293627)
@@ -1203,10 +1203,10 @@
     if (LIKELY(baseValue.isCell() && subscript.isString())) {
         Structure& structure = *baseValue.asCell()->structure();
         if (JSCell::canUseFastGetOwnProperty(structure)) {
-            RefPtr<AtomStringImpl> existingAtomString = asString(subscript)->toExistingAtomString(globalObject);
+            auto existingAtomString = asString(subscript)->toExistingAtomString(globalObject);
             CHECK_EXCEPTION();
-            if (existingAtomString) {
-                if (JSValue result = baseValue.asCell()->fastGetOwnProperty(vm, structure, existingAtomString.get()))
+            if (!existingAtomString.isNull()) {
+                if (JSValue result = baseValue.asCell()->fastGetOwnProperty(vm, structure, existingAtomString.impl()))
                     RETURN_PROFILED(result);
             }
         }

Modified: trunk/Source/_javascript_Core/runtime/JSString.h (293626 => 293627)


--- trunk/Source/_javascript_Core/runtime/JSString.h	2022-04-29 19:25:30 UTC (rev 293626)
+++ trunk/Source/_javascript_Core/runtime/JSString.h	2022-04-29 19:41:48 UTC (rev 293627)
@@ -193,7 +193,7 @@
 
     Identifier toIdentifier(JSGlobalObject*) const;
     AtomString toAtomString(JSGlobalObject*) const;
-    RefPtr<AtomStringImpl> toExistingAtomString(JSGlobalObject*) const;
+    AtomString toExistingAtomString(JSGlobalObject*) const;
 
     StringViewWithUnderlyingString viewWithUnderlyingString(JSGlobalObject*) const;
 
@@ -824,7 +824,7 @@
     return atom;
 }
 
-ALWAYS_INLINE RefPtr<AtomStringImpl> JSString::toExistingAtomString(JSGlobalObject* globalObject) const
+ALWAYS_INLINE AtomString JSString::toExistingAtomString(JSGlobalObject* globalObject) const
 {
     if constexpr (validateDFGDoesGC)
         vm().verifyCanGC();

Modified: trunk/Source/WTF/wtf/text/StringView.h (293626 => 293627)


--- trunk/Source/WTF/wtf/text/StringView.h	2022-04-29 19:25:30 UTC (rev 293626)
+++ trunk/Source/WTF/wtf/text/StringView.h	2022-04-29 19:41:48 UTC (rev 293627)
@@ -104,7 +104,7 @@
     String toString() const;
     String toStringWithoutCopying() const;
     AtomString toAtomString() const;
-    RefPtr<AtomStringImpl> toExistingAtomString() const;
+    AtomString toExistingAtomString() const;
 
 #if USE(CF)
     // These functions convert null strings to empty strings.
@@ -600,7 +600,7 @@
     return AtomString(characters16(), m_length);
 }
 
-inline RefPtr<AtomStringImpl> StringView::toExistingAtomString() const
+inline AtomString StringView::toExistingAtomString() const
 {
     if (is8Bit())
         return AtomStringImpl::lookUp(characters8(), m_length);

Modified: trunk/Source/WebCore/bindings/js/JSDOMConvertStrings.h (293626 => 293627)


--- trunk/Source/WebCore/bindings/js/JSDOMConvertStrings.h	2022-04-29 19:25:30 UTC (rev 293626)
+++ trunk/Source/WebCore/bindings/js/JSDOMConvertStrings.h	2022-04-29 19:41:48 UTC (rev 293627)
@@ -230,7 +230,7 @@
     {
         static_assert(std::is_same<T, IDLDOMString>::value, "This adaptor is only supported for IDLDOMString at the moment.");
     
-        return AtomString(value.toString(&lexicalGlobalObject)->toExistingAtomString(&lexicalGlobalObject));
+        return value.toString(&lexicalGlobalObject)->toExistingAtomString(&lexicalGlobalObject);
     }
 };
 

Modified: trunk/Source/WebCore/dom/TreeScope.cpp (293626 => 293627)


--- trunk/Source/WebCore/dom/TreeScope.cpp	2022-04-29 19:25:30 UTC (rev 293626)
+++ trunk/Source/WebCore/dom/TreeScope.cpp	2022-04-29 19:41:48 UTC (rev 293627)
@@ -123,8 +123,8 @@
     if (!m_elementsById)
         return nullptr;
 
-    if (auto atomElementId = elementId.toExistingAtomString())
-        return m_elementsById->getElementById(*atomElementId, *this);
+    if (auto atomElementId = elementId.toExistingAtomString(); !atomElementId.isNull())
+        return m_elementsById->getElementById(*atomElementId.impl(), *this);
 
     return nullptr;
 }

Modified: trunk/Source/WebCore/platform/network/ResourceHandle.cpp (293626 => 293627)


--- trunk/Source/WebCore/platform/network/ResourceHandle.cpp	2022-04-29 19:25:30 UTC (rev 293626)
+++ trunk/Source/WebCore/platform/network/ResourceHandle.cpp	2022-04-29 19:41:48 UTC (rev 293627)
@@ -93,8 +93,8 @@
 
 RefPtr<ResourceHandle> ResourceHandle::create(NetworkingContext* context, const ResourceRequest& request, ResourceHandleClient* client, bool defersLoading, bool shouldContentSniff, bool shouldContentEncodingSniff, RefPtr<SecurityOrigin>&& sourceOrigin, bool isMainFrameNavigation)
 {
-    if (auto protocol = request.url().protocol().toExistingAtomString(); protocol) {
-        if (auto constructor = builtinResourceHandleConstructorMap().get(AtomString(protocol.releaseNonNull())))
+    if (auto protocol = request.url().protocol().toExistingAtomString(); !protocol.isNull()) {
+        if (auto constructor = builtinResourceHandleConstructorMap().get(protocol))
             return constructor(request, client);
     }
 
@@ -139,8 +139,8 @@
 
 void ResourceHandle::loadResourceSynchronously(NetworkingContext* context, const ResourceRequest& request, StoredCredentialsPolicy storedCredentialsPolicy, SecurityOrigin* sourceOrigin, ResourceError& error, ResourceResponse& response, Vector<uint8_t>& data)
 {
-    if (auto protocol = request.url().protocol().toExistingAtomString(); protocol) {
-        if (auto constructor = builtinResourceHandleSynchronousLoaderMap().get(AtomString(protocol.releaseNonNull()))) {
+    if (auto protocol = request.url().protocol().toExistingAtomString(); !protocol.isNull()) {
+        if (auto constructor = builtinResourceHandleSynchronousLoaderMap().get(protocol)) {
             constructor(context, request, storedCredentialsPolicy, error, response, data);
             return;
         }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to