PropertyName's internal string is always atomic.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Jul 2014 05:38:30 +0000 (05:38 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Jul 2014 05:38:30 +0000 (05:38 +0000)
<https://webkit.org/b/135451>

Source/JavaScriptCore:
Now that we've merged the JSC::Identifier and WTF::AtomicString tables,
we know that any string that's an Identifier is guaranteed to be atomic.

A PropertyName can be either an Identifier or a PrivateName, and the
private names are also guaranteed to be atomic internally.

Make PropertyName vend AtomicStringImpl* instead of StringImpl*.

Reviewed by Benjamin Poulain.

* runtime/PropertyName.h:
(JSC::PropertyName::PropertyName):
(JSC::PropertyName::uid):
(JSC::PropertyName::publicName):

Source/WebCore:
Use PropertyName::publicName() directly instead of taking the slow route
through AtomicString::findStringWithHash().

These strings are always atomic, and findStringWithHash() would trudge
through a full hash lookup just to discover that indeed, they are!

Reviewed by Benjamin Poulain.

* bindings/js/JSDOMBinding.cpp:
(WebCore::findAtomicString): Deleted.
* bindings/js/JSDOMBinding.h:
* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::namedItemGetter):
(WebCore::JSDOMWindow::getOwnPropertySlot):
(WebCore::JSDOMWindow::getOwnPropertySlotByIndex):
* bindings/js/JSHTMLDocumentCustom.cpp:
(WebCore::JSHTMLDocument::canGetItemsForName):
(WebCore::JSHTMLDocument::nameGetter):

Source/WTF:
Remove AtomicString::findStringWithHash() since nobody uses it anymore.

Reviewed by Benjamin Poulain.

* wtf/text/AtomicString.cpp:
(WTF::findString): Deleted.
(WTF::AtomicString::findStringWithHash): Deleted.
* wtf/text/AtomicString.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@171838 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/PropertyName.h
Source/WTF/ChangeLog
Source/WTF/wtf/text/AtomicString.cpp
Source/WTF/wtf/text/AtomicString.h
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSDOMBinding.cpp
Source/WebCore/bindings/js/JSDOMBinding.h
Source/WebCore/bindings/js/JSDOMWindowCustom.cpp
Source/WebCore/bindings/js/JSHTMLDocumentCustom.cpp

index 427e6bd..00608b5 100644 (file)
@@ -1,3 +1,23 @@
+2014-07-30  Andreas Kling  <akling@apple.com>
+
+        PropertyName's internal string is always atomic.
+        <https://webkit.org/b/135451>
+
+        Now that we've merged the JSC::Identifier and WTF::AtomicString tables,
+        we know that any string that's an Identifier is guaranteed to be atomic.
+
+        A PropertyName can be either an Identifier or a PrivateName, and the
+        private names are also guaranteed to be atomic internally.
+
+        Make PropertyName vend AtomicStringImpl* instead of StringImpl*.
+
+        Reviewed by Benjamin Poulain.
+
+        * runtime/PropertyName.h:
+        (JSC::PropertyName::PropertyName):
+        (JSC::PropertyName::uid):
+        (JSC::PropertyName::publicName):
+
 2014-07-30  Andy Estes  <aestes@apple.com>
 
         USE(CONTENT_FILTERING) should be ENABLE(CONTENT_FILTERING)
index 7d2464b..c9dd723 100644 (file)
@@ -79,25 +79,27 @@ ALWAYS_INLINE uint32_t toUInt32FromStringImpl(StringImpl* impl)
 class PropertyName {
 public:
     PropertyName(const Identifier& propertyName)
-        : m_impl(propertyName.impl())
+        : m_impl(static_cast<AtomicStringImpl*>(propertyName.impl()))
     {
         ASSERT(!m_impl || m_impl->isAtomic());
     }
 
     PropertyName(const PrivateName& propertyName)
-        : m_impl(propertyName.uid())
+        : m_impl(static_cast<AtomicStringImpl*>(propertyName.uid()))
     {
-        ASSERT(m_impl && m_impl->isEmptyUnique());
+        ASSERT(m_impl);
+        ASSERT(m_impl->isEmptyUnique());
+        ASSERT(m_impl->isAtomic());
     }
 
-    StringImpl* uid() const
+    AtomicStringImpl* uid() const
     {
         return m_impl;
     }
 
-    StringImpl* publicName() const
+    AtomicStringImpl* publicName() const
     {
-        return m_impl->isEmptyUnique() ? 0 : m_impl;
+        return m_impl->isEmptyUnique() ? nullptr : m_impl;
     }
 
     static const uint32_t NotAnIndex = UINT_MAX;
@@ -108,7 +110,7 @@ public:
     }
 
 private:
-    StringImpl* m_impl;
+    AtomicStringImpl* m_impl;
 };
 
 inline bool operator==(PropertyName a, const Identifier& b)
index 3668a9c..8f4f915 100644 (file)
@@ -1,3 +1,17 @@
+2014-07-30  Andreas Kling  <akling@apple.com>
+
+        PropertyName's internal string is always atomic.
+        <https://webkit.org/b/135451>
+
+        Remove AtomicString::findStringWithHash() since nobody uses it anymore.
+
+        Reviewed by Benjamin Poulain.
+
+        * wtf/text/AtomicString.cpp:
+        (WTF::findString): Deleted.
+        (WTF::AtomicString::findStringWithHash): Deleted.
+        * wtf/text/AtomicString.h:
+
 2014-07-30  Andy Estes  <aestes@apple.com>
 
         USE(CONTENT_FILTERING) should be ENABLE(CONTENT_FILTERING)
index f04801c..27521c6 100644 (file)
@@ -432,31 +432,6 @@ PassRefPtr<StringImpl> AtomicString::addSlowCase(AtomicStringTable& stringTable,
     return *addResult.iterator;
 }
 
-template<typename CharacterType>
-static inline HashSet<StringImpl*>::iterator findString(const StringImpl* stringImpl)
-{
-    HashAndCharacters<CharacterType> buffer = { stringImpl->existingHash(), stringImpl->characters<CharacterType>(), stringImpl->length() };
-    return stringTable().find<HashAndCharactersTranslator<CharacterType>>(buffer);
-}
-
-AtomicStringImpl* AtomicString::findStringWithHash(const StringImpl& stringImpl)
-{
-    ASSERT(stringImpl.existingHash());
-
-    if (!stringImpl.length())
-        return static_cast<AtomicStringImpl*>(StringImpl::empty());
-
-    AtomicStringTableLocker locker;
-    HashSet<StringImpl*>::iterator iterator;
-    if (stringImpl.is8Bit())
-        iterator = findString<LChar>(&stringImpl);
-    else
-        iterator = findString<UChar>(&stringImpl);
-    if (iterator == stringTable().end())
-        return 0;
-    return static_cast<AtomicStringImpl*>(*iterator);
-}
-
 void AtomicString::remove(StringImpl* string)
 {
     ASSERT(string->isAtomic());
index 345a48c..256fc25 100644 (file)
@@ -86,7 +86,6 @@ public:
     AtomicString(WTF::HashTableDeletedValueType) : m_string(WTF::HashTableDeletedValue) { }
     bool isHashTableDeletedValue() const { return m_string.isHashTableDeletedValue(); }
 
-    WTF_EXPORT_STRING_API static AtomicStringImpl* findStringWithHash(const StringImpl&);
     WTF_EXPORT_STRING_API static AtomicStringImpl* find(LChar*, unsigned length);
     WTF_EXPORT_STRING_API static AtomicStringImpl* find(UChar*, unsigned length);
     static AtomicStringImpl* find(StringImpl* string)
index 6341f53..343daf1 100644 (file)
@@ -1,3 +1,27 @@
+2014-07-30  Andreas Kling  <akling@apple.com>
+
+        PropertyName's internal string is always atomic.
+        <https://webkit.org/b/135451>
+
+        Use PropertyName::publicName() directly instead of taking the slow route
+        through AtomicString::findStringWithHash().
+
+        These strings are always atomic, and findStringWithHash() would trudge
+        through a full hash lookup just to discover that indeed, they are!
+
+        Reviewed by Benjamin Poulain.
+
+        * bindings/js/JSDOMBinding.cpp:
+        (WebCore::findAtomicString): Deleted.
+        * bindings/js/JSDOMBinding.h:
+        * bindings/js/JSDOMWindowCustom.cpp:
+        (WebCore::namedItemGetter):
+        (WebCore::JSDOMWindow::getOwnPropertySlot):
+        (WebCore::JSDOMWindow::getOwnPropertySlotByIndex):
+        * bindings/js/JSHTMLDocumentCustom.cpp:
+        (WebCore::JSHTMLDocument::canGetItemsForName):
+        (WebCore::JSHTMLDocument::nameGetter):
+
 2014-07-30  Benjamin Poulain  <benjamin@webkit.org>
 
         ElementRuleCollector: group the shadow tree code
index 6a0d7c9..36d1a00 100644 (file)
@@ -98,15 +98,6 @@ JSValue jsStringOrUndefined(ExecState* exec, const URL& url)
     return jsStringWithCache(exec, url.string());
 }
 
-AtomicStringImpl* findAtomicString(PropertyName propertyName)
-{
-    StringImpl* impl = propertyName.publicName();
-    if (!impl)
-        return 0;
-    ASSERT(impl->existingHash());
-    return AtomicString::findStringWithHash(*impl);
-}
-
 String valueToStringWithNullCheck(ExecState* exec, JSValue value)
 {
     if (value.isNull())
index 2ef138d..8157df0 100644 (file)
@@ -283,7 +283,6 @@ JSC::JSValue jsOwnedStringOrNull(JSC::ExecState*, const String&);
 String propertyNameToString(JSC::PropertyName);
 
 AtomicString propertyNameToAtomicString(JSC::PropertyName);
-AtomicStringImpl* findAtomicString(JSC::PropertyName);
 
 String valueToStringWithNullCheck(JSC::ExecState*, JSC::JSValue); // null if the value is null
 String valueToStringWithUndefinedOrNullCheck(JSC::ExecState*, JSC::JSValue); // null if the value is null or undefined
index 29256f3..8e0723c 100644 (file)
@@ -82,7 +82,7 @@ static EncodedJSValue namedItemGetter(ExecState* exec, JSObject* slotBase, Encod
     ASSERT(document);
     ASSERT(document->isHTMLDocument());
 
-    AtomicStringImpl* atomicPropertyName = findAtomicString(propertyName);
+    AtomicStringImpl* atomicPropertyName = propertyName.publicName();
     if (!atomicPropertyName || !toHTMLDocument(document)->hasWindowNamedItem(*atomicPropertyName))
         return JSValue::encode(jsUndefined());
 
@@ -245,7 +245,7 @@ bool JSDOMWindow::getOwnPropertySlot(JSObject* object, ExecState* exec, Property
     // Allow shortcuts like 'Image1' instead of document.images.Image1
     Document* document = thisObject->impl().frame()->document();
     if (document->isHTMLDocument()) {
-        AtomicStringImpl* atomicPropertyName = findAtomicString(propertyName);
+        AtomicStringImpl* atomicPropertyName = propertyName.publicName();
         if (atomicPropertyName && toHTMLDocument(document)->hasWindowNamedItem(*atomicPropertyName)) {
             slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, namedItemGetter);
             return true;
@@ -322,7 +322,7 @@ bool JSDOMWindow::getOwnPropertySlotByIndex(JSObject* object, ExecState* exec, u
     // Allow shortcuts like 'Image1' instead of document.images.Image1
     Document* document = thisObject->impl().frame()->document();
     if (document->isHTMLDocument()) {
-        AtomicStringImpl* atomicPropertyName = findAtomicString(propertyName);
+        AtomicStringImpl* atomicPropertyName = propertyName.publicName();
         if (atomicPropertyName && toHTMLDocument(document)->hasWindowNamedItem(*atomicPropertyName)) {
             slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, namedItemGetter);
             return true;
index b6ebc4c..1ad3c62 100644 (file)
@@ -53,7 +53,7 @@ using namespace HTMLNames;
 
 bool JSHTMLDocument::canGetItemsForName(ExecState*, HTMLDocument* document, PropertyName propertyName)
 {
-    AtomicStringImpl* atomicPropertyName = findAtomicString(propertyName);
+    AtomicStringImpl* atomicPropertyName = propertyName.publicName();
     return atomicPropertyName && document->hasDocumentNamedItem(*atomicPropertyName);
 }
 
@@ -62,7 +62,7 @@ EncodedJSValue JSHTMLDocument::nameGetter(ExecState* exec, JSObject* slotBase, E
     JSHTMLDocument* thisObj = jsCast<JSHTMLDocument*>(slotBase);
     HTMLDocument& document = thisObj->impl();
 
-    AtomicStringImpl* atomicPropertyName = findAtomicString(propertyName);
+    AtomicStringImpl* atomicPropertyName = propertyName.publicName();
     if (!atomicPropertyName || !document.hasDocumentNamedItem(*atomicPropertyName))
         return JSValue::encode(jsUndefined());