Title: [293879] trunk/Source
Revision
293879
Author
[email protected]
Date
2022-05-05 19:34:31 -0700 (Thu, 05 May 2022)

Log Message

Identifier::string() should return an AtomString
https://bugs.webkit.org/show_bug.cgi?id=240122

Reviewed by Yusuke Suzuki.

Identifier::string() should return an AtomString instead of a String, since
it holds an AtomString internally.

Also add some overloads to jsString() to resolve ambiguity for some callers.

* Source/_javascript_Core/API/JSContext.mm:
(-[JSContext dependencyIdentifiersForModuleJSScript:]):
* Source/_javascript_Core/bytecompiler/NodesCodegen.cpp:
(JSC::processClauseList):
* Source/_javascript_Core/dfg/DFGOperations.cpp:
(JSC::DFG::JSC_DEFINE_JIT_OPERATION):
* Source/_javascript_Core/inspector/JSInjectedScriptHost.cpp:
(Inspector::JSInjectedScriptHost::functionDetails):
* Source/_javascript_Core/jsc.cpp:
(JSC_DEFINE_HOST_FUNCTION):
* Source/_javascript_Core/runtime/Error.cpp:
(JSC::addErrorInfo):
* Source/_javascript_Core/runtime/ErrorInstance.cpp:
(JSC::ErrorInstance::finishCreation):
* Source/_javascript_Core/runtime/ErrorPrototype.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/_javascript_Core/runtime/FunctionExecutable.cpp:
(JSC::FunctionExecutable::toStringSlow):
* Source/_javascript_Core/runtime/Identifier.h:
(JSC::Identifier::string const):
(JSC::Identifier::atomString const): Deleted.
* Source/_javascript_Core/runtime/IdentifierInlines.h:
(JSC::identifierToJSValue):
(JSC::identifierToSafePublicJSValue):
* Source/_javascript_Core/runtime/IntlDateTimeFormat.cpp:
(JSC::IntlDateTimeFormat::format const):
(JSC::IntlDateTimeFormat::formatRange):
* Source/_javascript_Core/runtime/IntlDisplayNames.cpp:
(JSC::IntlDisplayNames::of const):
* Source/_javascript_Core/runtime/IntlListFormat.cpp:
(JSC::IntlListFormat::format const):
* Source/_javascript_Core/runtime/IntlRelativeTimeFormat.cpp:
(JSC::IntlRelativeTimeFormat::format const):
* Source/_javascript_Core/runtime/JSFunction.cpp:
(JSC::JSFunction::reifyName):
* Source/_javascript_Core/runtime/JSModuleLoader.cpp:
(JSC::JSModuleLoader::requestImportModule):
* Source/_javascript_Core/runtime/JSString.h:
(JSC::jsString):
* Source/_javascript_Core/runtime/JSStringInlines.h:
(JSC::repeatCharacter):
* Source/_javascript_Core/runtime/StringPrototype.cpp:
(JSC::jsSpliceSubstrings):
(JSC::jsSpliceSubstringsWithSeparators):
(JSC::toLocaleCase):
(JSC::normalize):
* Source/_javascript_Core/runtime/SymbolPrototype.cpp:
(JSC::JSC_DEFINE_CUSTOM_GETTER):
* Source/WTF/wtf/PrintStream.cpp:
(WTF::printInternal):
* Source/WTF/wtf/PrintStream.h:
* Source/WebCore/animation/KeyframeEffect.cpp:
(WebCore::processKeyframeLikeObject):
* Source/WebCore/inspector/WebInjectedScriptHost.cpp:
(WebCore::WebInjectedScriptHost::getInternalProperties):

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

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/API/JSContext.mm (293878 => 293879)


--- trunk/Source/_javascript_Core/API/JSContext.mm	2022-05-06 02:23:22 UTC (rev 293878)
+++ trunk/Source/_javascript_Core/API/JSContext.mm	2022-05-06 02:34:31 UTC (rev 293879)
@@ -159,7 +159,7 @@
     }
 
     auto scope = DECLARE_CATCH_SCOPE(vm);
-    JSC::JSArray* result = globalObject->moduleLoader()->dependencyKeysIfEvaluated(globalObject, JSC::jsString(vm, [[script sourceURL] absoluteString]));
+    JSC::JSArray* result = globalObject->moduleLoader()->dependencyKeysIfEvaluated(globalObject, JSC::jsString(vm, String([[script sourceURL] absoluteString])));
     if (scope.exception()) {
         JSValueRef exceptionValue = toRef(globalObject, scope.exception()->value());
         scope.clearException();

Modified: trunk/Source/_javascript_Core/ChangeLog (293878 => 293879)


--- trunk/Source/_javascript_Core/ChangeLog	2022-05-06 02:23:22 UTC (rev 293878)
+++ trunk/Source/_javascript_Core/ChangeLog	2022-05-06 02:34:31 UTC (rev 293879)
@@ -1,3 +1,64 @@
+2022-05-05  Chris Dumez  <[email protected]>
+
+        Identifier::string() should return an AtomString
+        https://bugs.webkit.org/show_bug.cgi?id=240122
+
+        Reviewed by Yusuke Suzuki.
+
+        Identifier::string() should return an AtomString instead of a String, since
+        it holds an AtomString internally.
+    
+        Also add some overloads to jsString() to resolve ambiguity for some callers.
+
+        * API/JSContext.mm:
+        (-[JSContext dependencyIdentifiersForModuleJSScript:]):
+        * bytecompiler/NodesCodegen.cpp:
+        (JSC::processClauseList):
+        * dfg/DFGOperations.cpp:
+        (JSC::DFG::JSC_DEFINE_JIT_OPERATION):
+        * inspector/JSInjectedScriptHost.cpp:
+        (Inspector::JSInjectedScriptHost::functionDetails):
+        * jsc.cpp:
+        (JSC_DEFINE_HOST_FUNCTION):
+        * runtime/Error.cpp:
+        (JSC::addErrorInfo):
+        * runtime/ErrorInstance.cpp:
+        (JSC::ErrorInstance::finishCreation):
+        * runtime/ErrorPrototype.cpp:
+        (JSC::JSC_DEFINE_HOST_FUNCTION):
+        * runtime/FunctionExecutable.cpp:
+        (JSC::FunctionExecutable::toStringSlow):
+        * runtime/Identifier.h:
+        (JSC::Identifier::string const):
+        (JSC::Identifier::atomString const): Deleted.
+        * runtime/IdentifierInlines.h:
+        (JSC::identifierToJSValue):
+        (JSC::identifierToSafePublicJSValue):
+        * runtime/IntlDateTimeFormat.cpp:
+        (JSC::IntlDateTimeFormat::format const):
+        (JSC::IntlDateTimeFormat::formatRange):
+        * runtime/IntlDisplayNames.cpp:
+        (JSC::IntlDisplayNames::of const):
+        * runtime/IntlListFormat.cpp:
+        (JSC::IntlListFormat::format const):
+        * runtime/IntlRelativeTimeFormat.cpp:
+        (JSC::IntlRelativeTimeFormat::format const):
+        * runtime/JSFunction.cpp:
+        (JSC::JSFunction::reifyName):
+        * runtime/JSModuleLoader.cpp:
+        (JSC::JSModuleLoader::requestImportModule):
+        * runtime/JSString.h:
+        (JSC::jsString):
+        * runtime/JSStringInlines.h:
+        (JSC::repeatCharacter):
+        * runtime/StringPrototype.cpp:
+        (JSC::jsSpliceSubstrings):
+        (JSC::jsSpliceSubstringsWithSeparators):
+        (JSC::toLocaleCase):
+        (JSC::normalize):
+        * runtime/SymbolPrototype.cpp:
+        (JSC::JSC_DEFINE_CUSTOM_GETTER):
+
 2022-05-05  Yusuke Suzuki  <[email protected]>
 
         Unreviewed, partial revert of r293813 because of proposal's issue.

Modified: trunk/Source/_javascript_Core/bytecompiler/NodesCodegen.cpp (293878 => 293879)


--- trunk/Source/_javascript_Core/bytecompiler/NodesCodegen.cpp	2022-05-06 02:23:22 UTC (rev 293878)
+++ trunk/Source/_javascript_Core/bytecompiler/NodesCodegen.cpp	2022-05-06 02:34:31 UTC (rev 293879)
@@ -4460,7 +4460,7 @@
                 typeForTable = SwitchNeither;
                 break;
             }
-            const String& value = static_cast<StringNode*>(clauseExpression)->value().string();
+            auto& value = static_cast<StringNode*>(clauseExpression)->value().string();
             if (singleCharacterSwitch &= value.length() == 1) {
                 int32_t intVal = value[0];
                 if (intVal < min_num)

Modified: trunk/Source/_javascript_Core/dfg/DFGOperations.cpp (293878 => 293879)


--- trunk/Source/_javascript_Core/dfg/DFGOperations.cpp	2022-05-06 02:23:22 UTC (rev 293878)
+++ trunk/Source/_javascript_Core/dfg/DFGOperations.cpp	2022-05-06 02:34:31 UTC (rev 293879)
@@ -2580,7 +2580,7 @@
     String lowercasedString = inputString.is8Bit() ? inputString.convertToLowercaseWithoutLocaleStartingAtFailingIndex8Bit(failingIndex) : inputString.convertToLowercaseWithoutLocale();
     if (lowercasedString.impl() == inputString.impl())
         return string;
-    RELEASE_AND_RETURN(scope, jsString(vm, lowercasedString));
+    RELEASE_AND_RETURN(scope, jsString(vm, WTFMove(lowercasedString)));
 }
 
 JSC_DEFINE_JIT_OPERATION(operationInt32ToString, char*, (JSGlobalObject* globalObject, int32_t value, int32_t radix))

Modified: trunk/Source/_javascript_Core/inspector/JSInjectedScriptHost.cpp (293878 => 293879)


--- trunk/Source/_javascript_Core/inspector/JSInjectedScriptHost.cpp	2022-05-06 02:23:22 UTC (rev 293878)
+++ trunk/Source/_javascript_Core/inspector/JSInjectedScriptHost.cpp	2022-05-06 02:34:31 UTC (rev 293879)
@@ -266,7 +266,7 @@
 
     String scriptID = String::number(sourceCode->provider()->asID());
     JSObject* location = constructEmptyObject(globalObject);
-    location->putDirect(vm, Identifier::fromString(vm, "scriptId"_s), jsString(vm, scriptID));
+    location->putDirect(vm, Identifier::fromString(vm, "scriptId"_s), jsString(vm, WTFMove(scriptID)));
     location->putDirect(vm, Identifier::fromString(vm, "lineNumber"_s), jsNumber(lineNumber));
     location->putDirect(vm, Identifier::fromString(vm, "columnNumber"_s), jsNumber(columnNumber));
 
@@ -275,11 +275,11 @@
 
     String name = function->name(vm);
     if (!name.isEmpty())
-        result->putDirect(vm, Identifier::fromString(vm, "name"_s), jsString(vm, name));
+        result->putDirect(vm, Identifier::fromString(vm, "name"_s), jsString(vm, WTFMove(name)));
 
     String displayName = function->displayName(vm);
     if (!displayName.isEmpty())
-        result->putDirect(vm, Identifier::fromString(vm, "displayName"_s), jsString(vm, displayName));
+        result->putDirect(vm, Identifier::fromString(vm, "displayName"_s), jsString(vm, WTFMove(displayName)));
 
     return result;
 }

Modified: trunk/Source/_javascript_Core/jsc.cpp (293878 => 293879)


--- trunk/Source/_javascript_Core/jsc.cpp	2022-05-06 02:23:22 UTC (rev 293878)
+++ trunk/Source/_javascript_Core/jsc.cpp	2022-05-06 02:34:31 UTC (rev 293879)
@@ -2280,7 +2280,7 @@
     if (!string)
         return JSValue::encode(jsNull());
     
-    return JSValue::encode(jsString(vm, string));
+    return JSValue::encode(jsString(vm, WTFMove(string)));
 }
 
 JSC_DEFINE_HOST_FUNCTION(functionDollarAgentLeaving, (JSGlobalObject*, CallFrame*))
@@ -2305,7 +2305,7 @@
     if (!string)
         return JSValue::encode(jsNull());
     
-    return JSValue::encode(jsString(vm, string));
+    return JSValue::encode(jsString(vm, WTFMove(string)));
 }
 
 JSC_DEFINE_HOST_FUNCTION(functionHeapCapacity, (JSGlobalObject* globalObject, CallFrame*))
@@ -2755,7 +2755,7 @@
         jsonString = snapshotBuilder.json();
     }
     scope.releaseAssertNoException();
-    return JSValue::encode(jsString(vm, jsonString));
+    return JSValue::encode(jsString(vm, WTFMove(jsonString)));
 }
 
 JSC_DEFINE_HOST_FUNCTION(functionResetSuperSamplerState, (JSGlobalObject*, CallFrame*))

Modified: trunk/Source/_javascript_Core/runtime/Error.cpp (293878 => 293879)


--- trunk/Source/_javascript_Core/runtime/Error.cpp	2022-05-06 02:23:22 UTC (rev 293878)
+++ trunk/Source/_javascript_Core/runtime/Error.cpp	2022-05-06 02:34:31 UTC (rev 293879)
@@ -210,7 +210,7 @@
         obj->putDirect(vm, vm.propertyNames->line, jsNumber(line));
         obj->putDirect(vm, vm.propertyNames->column, jsNumber(column));
         if (!sourceURL.isEmpty())
-            obj->putDirect(vm, vm.propertyNames->sourceURL, jsString(vm, sourceURL));
+            obj->putDirect(vm, vm.propertyNames->sourceURL, jsString(vm, WTFMove(sourceURL)));
 
         obj->putDirect(vm, vm.propertyNames->stack, jsString(vm, Interpreter::stackTraceAsString(vm, *stackTrace)), static_cast<unsigned>(PropertyAttribute::DontEnum));
 

Modified: trunk/Source/_javascript_Core/runtime/ErrorInstance.cpp (293878 => 293879)


--- trunk/Source/_javascript_Core/runtime/ErrorInstance.cpp	2022-05-06 02:23:22 UTC (rev 293878)
+++ trunk/Source/_javascript_Core/runtime/ErrorInstance.cpp	2022-05-06 02:34:31 UTC (rev 293879)
@@ -141,7 +141,7 @@
     }
 
     if (!messageWithSource.isNull())
-        putDirect(vm, vm.propertyNames->message, jsString(vm, messageWithSource), static_cast<unsigned>(PropertyAttribute::DontEnum));
+        putDirect(vm, vm.propertyNames->message, jsString(vm, WTFMove(messageWithSource)), static_cast<unsigned>(PropertyAttribute::DontEnum));
 
     if (!cause.isEmpty())
         putDirect(vm, vm.propertyNames->cause, cause, static_cast<unsigned>(PropertyAttribute::DontEnum));

Modified: trunk/Source/_javascript_Core/runtime/ErrorPrototype.cpp (293878 => 293879)


--- trunk/Source/_javascript_Core/runtime/ErrorPrototype.cpp	2022-05-06 02:23:22 UTC (rev 293878)
+++ trunk/Source/_javascript_Core/runtime/ErrorPrototype.cpp	2022-05-06 02:34:31 UTC (rev 293879)
@@ -117,11 +117,11 @@
 
     // 8. If name is the empty String, return msg.
     if (!nameString.length())
-        return JSValue::encode(message.isString() ? message : jsString(vm, messageString));
+        return JSValue::encode(message.isString() ? message : jsString(vm, WTFMove(messageString)));
 
     // 9. If msg is the empty String, return name.
     if (!messageString.length())
-        return JSValue::encode(name.isString() ? name : jsString(vm, nameString));
+        return JSValue::encode(name.isString() ? name : jsString(vm, WTFMove(nameString)));
 
     // 10. Return the result of concatenating name, ":", a single space character, and msg.
     RELEASE_AND_RETURN(scope, JSValue::encode(jsMakeNontrivialString(globalObject, nameString, ": ", messageString)));

Modified: trunk/Source/_javascript_Core/runtime/FunctionExecutable.cpp (293878 => 293879)


--- trunk/Source/_javascript_Core/runtime/FunctionExecutable.cpp	2022-05-06 02:23:22 UTC (rev 293878)
+++ trunk/Source/_javascript_Core/runtime/FunctionExecutable.cpp	2022-05-06 02:34:31 UTC (rev 293879)
@@ -227,10 +227,10 @@
         parametersStartOffset(),
         parametersStartOffset() + source().length());
 
-    String name = this->name().string();
+    auto name = this->name().string();
     if (name == vm.propertyNames->starDefaultPrivateName.string())
-        name = emptyString();
-    return cacheIfNoException(jsMakeNontrivialString(globalObject, functionHeader, name, src));
+        name = emptyAtom();
+    return cacheIfNoException(jsMakeNontrivialString(globalObject, functionHeader, WTFMove(name), src));
 }
 
 void FunctionExecutable::overrideInfo(const FunctionOverrideInfo& overrideInfo)

Modified: trunk/Source/_javascript_Core/runtime/Identifier.h (293878 => 293879)


--- trunk/Source/_javascript_Core/runtime/Identifier.h	2022-05-06 02:23:22 UTC (rev 293878)
+++ trunk/Source/_javascript_Core/runtime/Identifier.h	2022-05-06 02:34:31 UTC (rev 293879)
@@ -86,13 +86,11 @@
 class Identifier {
     friend class Structure;
 public:
-    Identifier() { }
+    Identifier() = default;
     enum EmptyIdentifierFlag { EmptyIdentifier };
     Identifier(EmptyIdentifierFlag) : m_string(StringImpl::empty()) { ASSERT(m_string.impl()->isAtom()); }
 
-    // FIXME: Consider renaming atomString() to string() and always return an AtomString.
-    const AtomString& atomString() const { return m_string; }
-    const String& string() const { return m_string.string(); }
+    const AtomString& string() const { return m_string; }
 
     UniquedStringImpl* impl() const { return static_cast<UniquedStringImpl*>(m_string.impl()); }
 

Modified: trunk/Source/_javascript_Core/runtime/IdentifierInlines.h (293878 => 293879)


--- trunk/Source/_javascript_Core/runtime/IdentifierInlines.h	2022-05-06 02:23:22 UTC (rev 293878)
+++ trunk/Source/_javascript_Core/runtime/IdentifierInlines.h	2022-05-06 02:34:31 UTC (rev 293879)
@@ -129,7 +129,7 @@
 {
     if (identifier.isSymbol())
         return Symbol::create(vm, static_cast<SymbolImpl&>(*identifier.impl()));
-    return jsString(vm, String { identifier.impl() });
+    return jsString(vm, identifier.string());
 }
 
 inline JSValue identifierToSafePublicJSValue(VM& vm, const Identifier& identifier) 
@@ -136,7 +136,7 @@
 {
     if (identifier.isSymbol() && !identifier.isPrivateName())
         return Symbol::create(vm, static_cast<SymbolImpl&>(*identifier.impl()));
-    return jsString(vm, String { identifier.impl() });
+    return jsString(vm, identifier.string());
 }
 
 } // namespace JSC

Modified: trunk/Source/_javascript_Core/runtime/IntlDateTimeFormat.cpp (293878 => 293879)


--- trunk/Source/_javascript_Core/runtime/IntlDateTimeFormat.cpp	2022-05-06 02:23:22 UTC (rev 293878)
+++ trunk/Source/_javascript_Core/runtime/IntlDateTimeFormat.cpp	2022-05-06 02:34:31 UTC (rev 293879)
@@ -1290,7 +1290,7 @@
     if (U_FAILURE(status))
         return throwTypeError(globalObject, scope, "failed to format date value"_s);
 
-    return jsString(vm, String(result));
+    return jsString(vm, String(WTFMove(result)));
 }
 
 static ASCIILiteral partTypeString(UDateFormatField field)
@@ -1613,7 +1613,7 @@
         return { };
     }
 
-    return jsString(vm, String(buffer));
+    return jsString(vm, String(WTFMove(buffer)));
 #endif
 }
 

Modified: trunk/Source/_javascript_Core/runtime/IntlDisplayNames.cpp (293878 => 293879)


--- trunk/Source/_javascript_Core/runtime/IntlDisplayNames.cpp	2022-05-06 02:23:22 UTC (rev 293878)
+++ trunk/Source/_javascript_Core/runtime/IntlDisplayNames.cpp	2022-05-06 02:34:31 UTC (rev 293879)
@@ -338,8 +338,8 @@
 
         buffer = vm.intlCache().getFieldDisplayName(m_localeCString.data(), field.value(), style, status);
         if (U_FAILURE(status))
-            return (m_fallback == Fallback::None) ? jsUndefined() : jsString(vm, code);
-        return jsString(vm, String(buffer));
+            return (m_fallback == Fallback::None) ? jsUndefined() : jsString(vm, WTFMove(code));
+        return jsString(vm, String(WTFMove(buffer)));
     }
     }
     if (U_FAILURE(status)) {
@@ -349,7 +349,7 @@
             return (m_fallback == Fallback::None) ? jsUndefined() : jsString(vm, String(canonicalCode.data(), canonicalCode.length()));
         return throwTypeError(globalObject, scope, "Failed to query a display name."_s);
     }
-    return jsString(vm, String(buffer));
+    return jsString(vm, String(WTFMove(buffer)));
 }
 
 // https://tc39.es/proposal-intl-displaynames/#sec-Intl.DisplayNames.prototype.resolvedOptions

Modified: trunk/Source/_javascript_Core/runtime/IntlListFormat.cpp (293878 => 293879)


--- trunk/Source/_javascript_Core/runtime/IntlListFormat.cpp	2022-05-06 02:23:22 UTC (rev 293878)
+++ trunk/Source/_javascript_Core/runtime/IntlListFormat.cpp	2022-05-06 02:34:31 UTC (rev 293879)
@@ -226,7 +226,7 @@
     if (U_FAILURE(status))
         return throwTypeError(globalObject, scope, "failed to format list of strings"_s);
 
-    return jsString(vm, String(result));
+    return jsString(vm, String(WTFMove(result)));
 #else
     UNUSED_PARAM(list);
     return throwTypeError(globalObject, scope, "failed to format list of strings"_s);

Modified: trunk/Source/_javascript_Core/runtime/IntlRelativeTimeFormat.cpp (293878 => 293879)


--- trunk/Source/_javascript_Core/runtime/IntlRelativeTimeFormat.cpp	2022-05-06 02:23:22 UTC (rev 293878)
+++ trunk/Source/_javascript_Core/runtime/IntlRelativeTimeFormat.cpp	2022-05-06 02:34:31 UTC (rev 293879)
@@ -270,7 +270,7 @@
     String result = formatInternal(globalObject, value, unit);
     RETURN_IF_EXCEPTION(scope, { });
 
-    return jsString(vm, result);
+    return jsString(vm, WTFMove(result));
 }
 
 // https://tc39.es/ecma402/#sec-FormatRelativeTimeToParts

Modified: trunk/Source/_javascript_Core/runtime/JSFunction.cpp (293878 => 293879)


--- trunk/Source/_javascript_Core/runtime/JSFunction.cpp	2022-05-06 02:23:22 UTC (rev 293878)
+++ trunk/Source/_javascript_Core/runtime/JSFunction.cpp	2022-05-06 02:34:31 UTC (rev 293879)
@@ -629,7 +629,7 @@
         name = makeString("set ", name);
 
     rareData->setHasReifiedName();
-    putDirect(vm, propID, jsString(vm, name), initialAttributes);
+    putDirect(vm, propID, jsString(vm, WTFMove(name)), initialAttributes);
 }
 
 JSFunction::PropertyStatus JSFunction::reifyLazyPropertyIfNeeded(VM& vm, JSGlobalObject* globalObject, PropertyName propertyName)

Modified: trunk/Source/_javascript_Core/runtime/JSModuleLoader.cpp (293878 => 293879)


--- trunk/Source/_javascript_Core/runtime/JSModuleLoader.cpp	2022-05-06 02:23:22 UTC (rev 293878)
+++ trunk/Source/_javascript_Core/runtime/JSModuleLoader.cpp	2022-05-06 02:34:31 UTC (rev 293879)
@@ -232,7 +232,7 @@
     ASSERT(callData.type != CallData::Type::None);
 
     MarkedArgumentBuffer arguments;
-    arguments.append(jsString(vm, String { moduleKey.impl() }));
+    arguments.append(jsString(vm, moduleKey.string()));
     arguments.append(parameters);
     arguments.append(scriptFetcher);
     ASSERT(!arguments.hasOverflowed());

Modified: trunk/Source/_javascript_Core/runtime/JSString.h (293878 => 293879)


--- trunk/Source/_javascript_Core/runtime/JSString.h	2022-05-06 02:23:22 UTC (rev 293878)
+++ trunk/Source/_javascript_Core/runtime/JSString.h	2022-05-06 02:34:31 UTC (rev 293879)
@@ -50,8 +50,14 @@
 JSString* jsEmptyString(VM&);
 JSString* jsString(VM&, const String&); // returns empty string if passed null string
 JSString* jsString(VM&, String&&); // returns empty string if passed null string
+JSString* jsString(VM&, const AtomString&); // returns empty string if passed null string
+JSString* jsString(VM&, AtomString&&); // returns empty string if passed null string
 JSString* jsString(VM&, StringView); // returns empty string if passed null string
 
+JSString* jsString(VM&, RefPtr<AtomStringImpl>&&);
+JSString* jsString(VM&, Ref<AtomStringImpl>&&);
+JSString* jsString(VM&, Ref<StringImpl>&&);
+
 JSString* jsSingleCharacterString(VM&, UChar);
 JSString* jsSubstring(VM&, const String&, unsigned offset, unsigned length);
 
@@ -894,6 +900,16 @@
     return JSString::create(vm, s.releaseImpl().releaseNonNull());
 }
 
+ALWAYS_INLINE JSString* jsString(VM& vm, const AtomString& s)
+{
+    return jsString(vm, s.string());
+}
+
+ALWAYS_INLINE JSString* jsString(VM& vm, AtomString&& s)
+{
+    return jsString(vm, s.releaseString());
+}
+
 inline JSString* jsString(VM& vm, StringView s)
 {
     int size = s.length();
@@ -908,6 +924,21 @@
     return JSString::create(vm, WTFMove(impl));
 }
 
+ALWAYS_INLINE JSString* jsString(VM& vm, RefPtr<AtomStringImpl>&& s)
+{
+    return jsString(vm, String { WTFMove(s) });
+}
+
+ALWAYS_INLINE JSString* jsString(VM& vm, Ref<AtomStringImpl>&& s)
+{
+    return jsString(vm, String { WTFMove(s) });
+}
+
+ALWAYS_INLINE JSString* jsString(VM& vm, Ref<StringImpl>&& s)
+{
+    return jsString(vm, String { WTFMove(s) });
+}
+
 inline JSString* jsSubstring(VM& vm, JSGlobalObject* globalObject, JSString* base, unsigned offset, unsigned length)
 {
     auto scope = DECLARE_THROW_SCOPE(vm);

Modified: trunk/Source/_javascript_Core/runtime/JSStringInlines.h (293878 => 293879)


--- trunk/Source/_javascript_Core/runtime/JSStringInlines.h	2022-05-06 02:23:22 UTC (rev 293878)
+++ trunk/Source/_javascript_Core/runtime/JSStringInlines.h	2022-05-06 02:34:31 UTC (rev 293879)
@@ -77,7 +77,7 @@
 
     std::fill_n(buffer, repeatCount, character);
 
-    RELEASE_AND_RETURN(scope, jsString(vm, WTFMove(impl)));
+    RELEASE_AND_RETURN(scope, jsString(vm, impl.releaseNonNull()));
 }
 
 } // namespace JSC

Modified: trunk/Source/_javascript_Core/runtime/StringPrototype.cpp (293878 => 293879)


--- trunk/Source/_javascript_Core/runtime/StringPrototype.cpp	2022-05-06 02:23:22 UTC (rev 293878)
+++ trunk/Source/_javascript_Core/runtime/StringPrototype.cpp	2022-05-06 02:34:31 UTC (rev 293879)
@@ -332,7 +332,7 @@
             }
         }
 
-        RELEASE_AND_RETURN(scope, jsString(vm, WTFMove(impl)));
+        RELEASE_AND_RETURN(scope, jsString(vm, impl.releaseNonNull()));
     }
 
     UChar* buffer;
@@ -352,7 +352,7 @@
         }
     }
 
-    RELEASE_AND_RETURN(scope, jsString(vm, WTFMove(impl)));
+    RELEASE_AND_RETURN(scope, jsString(vm, impl.releaseNonNull()));
 }
 
 static ALWAYS_INLINE JSString* jsSpliceSubstringsWithSeparators(JSGlobalObject* globalObject, JSString* sourceVal, const String& source, const StringRange* substringRanges, int rangeCount, const String* separators, int separatorCount)
@@ -420,7 +420,7 @@
             }
         }        
 
-        RELEASE_AND_RETURN(scope, jsString(vm, WTFMove(impl)));
+        RELEASE_AND_RETURN(scope, jsString(vm, impl.releaseNonNull()));
     }
 
     UChar* buffer;
@@ -453,7 +453,7 @@
         }
     }
 
-    RELEASE_AND_RETURN(scope, jsString(vm, WTFMove(impl)));
+    RELEASE_AND_RETURN(scope, jsString(vm, impl.releaseNonNull()));
 }
 
 #define OUT_OF_MEMORY(exec__, scope__) \
@@ -1624,7 +1624,7 @@
         return throwVMTypeError(globalObject, scope, String::fromLatin1(u_errorName(status)));
 
     // 18. Return L.
-    RELEASE_AND_RETURN(scope, JSValue::encode(jsString(vm, String { buffer })));
+    RELEASE_AND_RETURN(scope, JSValue::encode(jsString(vm, String { WTFMove(buffer) })));
 }
 
 JSC_DEFINE_HOST_FUNCTION(stringProtoFuncToLocaleLowerCase, (JSGlobalObject* globalObject, CallFrame* callFrame))
@@ -1923,7 +1923,7 @@
     unorm2_normalize(normalizer, characters, view.length(), buffer, normalizedStringLength, &status);
     ASSERT(U_SUCCESS(status));
 
-    RELEASE_AND_RETURN(scope, jsString(vm, WTFMove(result)));
+    RELEASE_AND_RETURN(scope, jsString(vm, result.releaseNonNull()));
 }
 
 JSC_DEFINE_HOST_FUNCTION(stringProtoFuncNormalize, (JSGlobalObject* globalObject, CallFrame* callFrame))

Modified: trunk/Source/_javascript_Core/runtime/SymbolPrototype.cpp (293878 => 293879)


--- trunk/Source/_javascript_Core/runtime/SymbolPrototype.cpp	2022-05-06 02:23:22 UTC (rev 293878)
+++ trunk/Source/_javascript_Core/runtime/SymbolPrototype.cpp	2022-05-06 02:34:31 UTC (rev 293879)
@@ -97,8 +97,8 @@
         return throwVMTypeError(globalObject, scope, SymbolDescriptionTypeError);
     scope.release();
     Integrity::auditStructureID(symbol->structureID());
-    const auto description = symbol->description();
-    return JSValue::encode(description.isNull() ? jsUndefined() : jsString(vm, description));
+    auto description = symbol->description();
+    return JSValue::encode(description.isNull() ? jsUndefined() : jsString(vm, WTFMove(description)));
 }
 
 JSC_DEFINE_HOST_FUNCTION(symbolProtoFuncToString, (JSGlobalObject* globalObject, CallFrame* callFrame))

Modified: trunk/Source/WTF/ChangeLog (293878 => 293879)


--- trunk/Source/WTF/ChangeLog	2022-05-06 02:23:22 UTC (rev 293878)
+++ trunk/Source/WTF/ChangeLog	2022-05-06 02:34:31 UTC (rev 293879)
@@ -1,3 +1,14 @@
+2022-05-05  Chris Dumez  <[email protected]>
+
+        Identifier::string() should return an AtomString
+        https://bugs.webkit.org/show_bug.cgi?id=240122
+
+        Reviewed by Yusuke Suzuki.
+
+        * wtf/PrintStream.cpp:
+        (WTF::printInternal):
+        * wtf/PrintStream.h:
+
 2022-05-05  Brent Fulgham  <[email protected]>
 
         Remove abandoned WKPreference for AlwaysUseAcceleratedOverflowScroll

Modified: trunk/Source/WTF/wtf/PrintStream.cpp (293878 => 293879)


--- trunk/Source/WTF/wtf/PrintStream.cpp	2022-05-06 02:23:22 UTC (rev 293878)
+++ trunk/Source/WTF/wtf/PrintStream.cpp	2022-05-06 02:34:31 UTC (rev 293879)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include <wtf/PrintStream.h>
 
+#include <wtf/text/AtomString.h>
 #include <wtf/text/CString.h>
 #include <wtf/text/WTFString.h>
 
@@ -104,6 +105,11 @@
     printExpectedCStringHelper(out, "String", string.tryGetUtf8());
 }
 
+void printInternal(PrintStream& out, const AtomString& string)
+{
+    printExpectedCStringHelper(out, "String", string.string().tryGetUtf8());
+}
+
 void printInternal(PrintStream& out, const StringImpl* string)
 {
     if (!string) {

Modified: trunk/Source/WTF/wtf/PrintStream.h (293878 => 293879)


--- trunk/Source/WTF/wtf/PrintStream.h	2022-05-06 02:23:22 UTC (rev 293878)
+++ trunk/Source/WTF/wtf/PrintStream.h	2022-05-06 02:34:31 UTC (rev 293879)
@@ -98,6 +98,7 @@
 WTF_EXPORT_PRIVATE void printInternal(PrintStream&, StringView);
 WTF_EXPORT_PRIVATE void printInternal(PrintStream&, const CString&);
 WTF_EXPORT_PRIVATE void printInternal(PrintStream&, const String&);
+WTF_EXPORT_PRIVATE void printInternal(PrintStream&, const AtomString&);
 WTF_EXPORT_PRIVATE void printInternal(PrintStream&, const StringImpl*);
 inline void printInternal(PrintStream& out, const AtomStringImpl* value) { printInternal(out, bitwise_cast<const StringImpl*>(value)); }
 inline void printInternal(PrintStream& out, const UniquedStringImpl* value) { printInternal(out, bitwise_cast<const StringImpl*>(value)); }

Modified: trunk/Source/WebCore/ChangeLog (293878 => 293879)


--- trunk/Source/WebCore/ChangeLog	2022-05-06 02:23:22 UTC (rev 293878)
+++ trunk/Source/WebCore/ChangeLog	2022-05-06 02:34:31 UTC (rev 293879)
@@ -1,3 +1,15 @@
+2022-05-05  Chris Dumez  <[email protected]>
+
+        Identifier::string() should return an AtomString
+        https://bugs.webkit.org/show_bug.cgi?id=240122
+
+        Reviewed by Yusuke Suzuki.
+
+        * animation/KeyframeEffect.cpp:
+        (WebCore::processKeyframeLikeObject):
+        * inspector/WebInjectedScriptHost.cpp:
+        (WebCore::WebInjectedScriptHost::getInternalProperties):
+
 2022-05-05  Nikolaos Mouchtaris  <[email protected]>
 
         Add check if referenced element is SVG for clip-path

Modified: trunk/Source/WebCore/animation/KeyframeEffect.cpp (293878 => 293879)


--- trunk/Source/WebCore/animation/KeyframeEffect.cpp	2022-05-06 02:23:22 UTC (rev 293878)
+++ trunk/Source/WebCore/animation/KeyframeEffect.cpp	2022-05-06 02:34:31 UTC (rev 293879)
@@ -230,7 +230,7 @@
     //    properties, or which are in input properties and conform to the <custom-property-name> production.
     Vector<JSC::Identifier> animationProperties;
     for (auto& inputProperty : inputProperties) {
-        auto cssProperty = IDLAttributeNameToAnimationPropertyName(inputProperty.atomString());
+        auto cssProperty = IDLAttributeNameToAnimationPropertyName(inputProperty.string());
         auto resolvedCSSProperty = CSSProperty::resolveDirectionAwareProperty(cssProperty, RenderStyle::initialDirection(), RenderStyle::initialWritingMode());
         if (CSSPropertyAnimation::isPropertyAnimatable(resolvedCSSProperty))
             animationProperties.append(inputProperty);
@@ -238,7 +238,7 @@
 
     // 5. Sort animation properties in ascending order by the Unicode codepoints that define each property name.
     std::sort(animationProperties.begin(), animationProperties.end(), [](auto& lhs, auto& rhs) {
-        return lhs.string().utf8() < rhs.string().utf8();
+        return lhs.string().string().utf8() < rhs.string().string().utf8();
     });
 
     // 6. For each property name in animation properties,
@@ -271,7 +271,7 @@
         RETURN_IF_EXCEPTION(scope, Exception { TypeError });
 
         // 4. Calculate the normalized property name as the result of applying the IDL attribute name to animation property name algorithm to property name.
-        auto cssPropertyID = IDLAttributeNameToAnimationPropertyName(animationProperties[i].atomString());
+        auto cssPropertyID = IDLAttributeNameToAnimationPropertyName(animationProperties[i].string());
 
         // 5. Add a property to to keyframe output with normalized property name as the property name, and property values as the property value.
         keyframeOuput.propertiesAndValues.append({ cssPropertyID, propertyValues });

Modified: trunk/Source/WebCore/inspector/WebInjectedScriptHost.cpp (293878 => 293879)


--- trunk/Source/WebCore/inspector/WebInjectedScriptHost.cpp	2022-05-06 02:23:22 UTC (rev 293878)
+++ trunk/Source/WebCore/inspector/WebInjectedScriptHost.cpp	2022-05-06 02:34:31 UTC (rev 293879)
@@ -219,7 +219,7 @@
 
         String name = worker->name();
         if (!name.isEmpty())
-            array->putDirectIndex(exec, index++, constructInternalProperty(vm, exec, "name"_s, jsString(vm, name)));
+            array->putDirectIndex(exec, index++, constructInternalProperty(vm, exec, "name"_s, jsString(vm, WTFMove(name))));
 
         array->putDirectIndex(exec, index++, constructInternalProperty(vm, exec, "terminated"_s, jsBoolean(worker->wasTerminated())));
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to