- Revision
- 176622
- Author
- [email protected]
- Date
- 2014-12-01 18:21:16 -0800 (Mon, 01 Dec 2014)
Log Message
Optimize constructing JSC::Identifier from AtomicString.
<https://webkit.org/b/139157>
Reviewed by Michael Saboff.
Source/_javascript_Core:
Add constructors for Identifier taking AtomicString and AtomicStringImpl.
This avoids branching on the string's isAtomic flag, which is obviously
always true for AtomicString & AtomicStringImpl.
Had to add a Identifier(const char*) constructor to resolve implicit
ambiguity between String / AtomicString.
Also made PrivateName::uid() return AtomicStringImpl* to take advantage
of the new constructor in a few places.
* runtime/Identifier.h:
(JSC::Identifier::Identifier):
* runtime/IdentifierInlines.h:
(JSC::Identifier::Identifier):
* runtime/PrivateName.h:
(JSC::PrivateName::uid):
Source/WTF:
Make AtomicString::isInAtomicStringTable() public so it can be used
in some Identifier assertions.
* wtf/text/AtomicString.h:
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (176621 => 176622)
--- trunk/Source/_javascript_Core/ChangeLog 2014-12-02 02:16:55 UTC (rev 176621)
+++ trunk/Source/_javascript_Core/ChangeLog 2014-12-02 02:21:16 UTC (rev 176622)
@@ -1,3 +1,27 @@
+2014-12-01 Andreas Kling <[email protected]>
+
+ Optimize constructing JSC::Identifier from AtomicString.
+ <https://webkit.org/b/139157>
+
+ Reviewed by Michael Saboff.
+
+ Add constructors for Identifier taking AtomicString and AtomicStringImpl.
+ This avoids branching on the string's isAtomic flag, which is obviously
+ always true for AtomicString & AtomicStringImpl.
+
+ Had to add a Identifier(const char*) constructor to resolve implicit
+ ambiguity between String / AtomicString.
+
+ Also made PrivateName::uid() return AtomicStringImpl* to take advantage
+ of the new constructor in a few places.
+
+ * runtime/Identifier.h:
+ (JSC::Identifier::Identifier):
+ * runtime/IdentifierInlines.h:
+ (JSC::Identifier::Identifier):
+ * runtime/PrivateName.h:
+ (JSC::PrivateName::uid):
+
2014-12-01 Alexey Proskuryakov <[email protected]>
Several _javascript_Core date tests are flaky, because they expect time to be frozen during execution
Modified: trunk/Source/_javascript_Core/runtime/Identifier.h (176621 => 176622)
--- trunk/Source/_javascript_Core/runtime/Identifier.h 2014-12-02 02:16:55 UTC (rev 176621)
+++ trunk/Source/_javascript_Core/runtime/Identifier.h 2014-12-02 02:21:16 UTC (rev 176622)
@@ -44,8 +44,11 @@
template<unsigned charactersCount>
Identifier(VM* vm, const char (&characters)[charactersCount]) : m_string(add(vm, characters)) { ASSERT(m_string.impl()->isAtomic()); }
+ Identifier(ExecState*, AtomicStringImpl*);
+ Identifier(ExecState*, const AtomicString&);
Identifier(ExecState* exec, StringImpl* rep) : m_string(add(exec, rep)) { ASSERT(m_string.impl()->isAtomic()); }
Identifier(ExecState* exec, const String& s) : m_string(add(exec, s.impl())) { ASSERT(m_string.impl()->isAtomic()); }
+ Identifier(ExecState* exec, const char* s) : Identifier(exec, AtomicString(s)) { }
Identifier(VM* vm, const LChar* s, int length) : m_string(add(vm, s, length)) { ASSERT(m_string.impl()->isAtomic()); }
Identifier(VM* vm, const UChar* s, int length) : m_string(add(vm, s, length)) { ASSERT(m_string.impl()->isAtomic()); }
Modified: trunk/Source/_javascript_Core/runtime/IdentifierInlines.h (176621 => 176622)
--- trunk/Source/_javascript_Core/runtime/IdentifierInlines.h 2014-12-02 02:16:55 UTC (rev 176621)
+++ trunk/Source/_javascript_Core/runtime/IdentifierInlines.h 2014-12-02 02:21:16 UTC (rev 176622)
@@ -31,6 +31,30 @@
namespace JSC {
+inline Identifier::Identifier(ExecState* exec, AtomicStringImpl* string)
+ : m_string(string)
+{
+#ifndef NDEBUG
+ checkCurrentAtomicStringTable(exec);
+ if (string)
+ ASSERT_WITH_MESSAGE(!string->length() || AtomicString::isInAtomicStringTable(string), "The atomic string comes from an other thread!");
+#else
+ UNUSED_PARAM(exec);
+#endif
+}
+
+inline Identifier::Identifier(ExecState* exec, const AtomicString& string)
+ : m_string(string.string())
+{
+#ifndef NDEBUG
+ checkCurrentAtomicStringTable(exec);
+ if (!string.isNull())
+ ASSERT_WITH_MESSAGE(!string.length() || AtomicString::isInAtomicStringTable(string.impl()), "The atomic string comes from an other thread!");
+#else
+ UNUSED_PARAM(exec);
+#endif
+}
+
inline PassRef<StringImpl> Identifier::add(ExecState* exec, StringImpl* r)
{
#ifndef NDEBUG
Modified: trunk/Source/_javascript_Core/runtime/PrivateName.h (176621 => 176622)
--- trunk/Source/_javascript_Core/runtime/PrivateName.h 2014-12-02 02:16:55 UTC (rev 176621)
+++ trunk/Source/_javascript_Core/runtime/PrivateName.h 2014-12-02 02:21:16 UTC (rev 176622)
@@ -42,7 +42,7 @@
ASSERT(m_impl->isEmptyUnique());
}
- StringImpl* uid() const { return m_impl.get(); }
+ AtomicStringImpl* uid() const { return static_cast<AtomicStringImpl*>(m_impl.get()); }
private:
RefPtr<StringImpl> m_impl;
Modified: trunk/Source/WTF/ChangeLog (176621 => 176622)
--- trunk/Source/WTF/ChangeLog 2014-12-02 02:16:55 UTC (rev 176621)
+++ trunk/Source/WTF/ChangeLog 2014-12-02 02:21:16 UTC (rev 176622)
@@ -1,3 +1,15 @@
+2014-12-01 Andreas Kling <[email protected]>
+
+ Optimize constructing JSC::Identifier from AtomicString.
+ <https://webkit.org/b/139157>
+
+ Reviewed by Michael Saboff.
+
+ Make AtomicString::isInAtomicStringTable() public so it can be used
+ in some Identifier assertions.
+
+ * wtf/text/AtomicString.h:
+
2014-12-01 Oliver Hunt <[email protected]>
Fix non-mac builds.
Modified: trunk/Source/WTF/wtf/text/AtomicString.h (176621 => 176622)
--- trunk/Source/WTF/wtf/text/AtomicString.h 2014-12-02 02:16:55 UTC (rev 176621)
+++ trunk/Source/WTF/wtf/text/AtomicString.h 2014-12-02 02:21:16 UTC (rev 176622)
@@ -204,6 +204,10 @@
return addSlowCase(*stringTableProvider.atomicStringTable(), *string);
}
+#if !ASSERT_DISABLED
+ WTF_EXPORT_STRING_API static bool isInAtomicStringTable(StringImpl*);
+#endif
+
private:
// The explicit constructors with AtomicString::ConstructFromLiteral must be used for literals.
AtomicString(ASCIILiteral);
@@ -215,10 +219,6 @@
WTF_EXPORT_STRING_API static AtomicStringImpl* findSlowCase(StringImpl&);
WTF_EXPORT_STRING_API static AtomicString fromUTF8Internal(const char*, const char*);
-
-#if !ASSERT_DISABLED
- WTF_EXPORT_STRING_API static bool isInAtomicStringTable(StringImpl*);
-#endif
};
inline bool operator==(const AtomicString& a, const AtomicString& b) { return a.impl() == b.impl(); }