Skip to content
Permalink
Browse files
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/JavaScriptCore/dfg/DFGOperations.cpp:
(JSC::DFG::JSC_DEFINE_JIT_OPERATION):
* Source/JavaScriptCore/jit/JITOperations.cpp:
(JSC::getByVal):
(JSC::JSC_DEFINE_JIT_OPERATION):
* Source/JavaScriptCore/llint/LLIntSlowPaths.cpp:
(JSC::LLInt::getByVal):
* Source/JavaScriptCore/runtime/CommonSlowPaths.cpp:
(JSC::JSC_DEFINE_COMMON_SLOW_PATH):
* Source/JavaScriptCore/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
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@293627 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
cdumez committed Apr 29, 2022
1 parent ded8047 commit 0b2981acf2f8e0a2af57a7dc093cdb0c88a335ef
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 26 deletions.
@@ -1584,10 +1584,10 @@ JSC_DEFINE_JIT_OPERATION(operationGetByValWithThis, EncodedJSValue, (JSGlobalObj
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);
}
}
@@ -2239,10 +2239,10 @@ ALWAYS_INLINE static JSValue getByVal(JSGlobalObject* globalObject, CallFrame* c
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 @@ JSC_DEFINE_JIT_OPERATION(operationGetByVal, EncodedJSValue, (JSGlobalObject* glo
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);
}
}
@@ -1056,10 +1056,10 @@ static ALWAYS_INLINE JSValue getByVal(VM& vm, JSGlobalObject* globalObject, Code
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;
}
}
@@ -1203,10 +1203,10 @@ JSC_DEFINE_COMMON_SLOW_PATH(slow_path_get_by_val_with_this)
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);
}
}
@@ -193,7 +193,7 @@ class JSString : public JSCell {

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 @@ ALWAYS_INLINE AtomString JSString::toAtomString(JSGlobalObject* globalObject) co
return atom;
}

ALWAYS_INLINE RefPtr<AtomStringImpl> JSString::toExistingAtomString(JSGlobalObject* globalObject) const
ALWAYS_INLINE AtomString JSString::toExistingAtomString(JSGlobalObject* globalObject) const
{
if constexpr (validateDFGDoesGC)
vm().verifyCanGC();
@@ -104,7 +104,7 @@ class StringView final {
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 @@ inline AtomString StringView::toAtomString() const
return AtomString(characters16(), m_length);
}

inline RefPtr<AtomStringImpl> StringView::toExistingAtomString() const
inline AtomString StringView::toExistingAtomString() const
{
if (is8Bit())
return AtomStringImpl::lookUp(characters8(), m_length);
@@ -230,7 +230,7 @@ template<typename T> struct Converter<IDLRequiresExistingAtomStringAdaptor<T>> :
{
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);
}
};

@@ -123,8 +123,8 @@ Element* TreeScope::getElementById(StringView elementId) const
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;
}
@@ -93,8 +93,8 @@ ResourceHandle::ResourceHandle(NetworkingContext* context, const ResourceRequest

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::failureTimerFired()

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;
}

0 comments on commit 0b2981a

Please sign in to comment.