Refactor SymbolImpl layout
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 4 Dec 2016 00:28:49 +0000 (00:28 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 4 Dec 2016 00:28:49 +0000 (00:28 +0000)
commitee21b9499e03f8a099890a2e353d0a1e41d9cce1
tree5aee4b60e0acf61b818fc35b085cc9265e094c68
parent2d44fd6bd14dc167751b0096583ebaf39c024d5f
Refactor SymbolImpl layout
https://bugs.webkit.org/show_bug.cgi?id=165247

Reviewed by Darin Adler.

Source/JavaScriptCore:

Use SymbolImpl::{create, createNullSymbol} instead.

* runtime/PrivateName.h:
(JSC::PrivateName::PrivateName):

Source/WTF:

This patch moves SymbolImpl initialization from StringImpl to SymbolImpl.
In SymbolImpl, we create the appropriate fields. At that time, these fields
should be aligned to the BufferSubstring StringImpl.

And we newly create the `m_flags` in SymbolImpl. Instead of using special
StringImpl::null(), we store s_flagIsNullSymbol flag here. In WTF, we have
the invariant that StringImpl::empty() is the only atomic empty string.
But StringImpl::null() breaks this invariant. Using a special flag is safer
way to represent the null Symbol `Symbol()`.

* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/StdLibExtras.h:
(WTF::roundUpToMultipleOfImpl0):
(WTF::roundUpToMultipleOfImpl):
(WTF::roundUpToMultipleOf):
* wtf/text/StringImpl.cpp:
(WTF::StringImpl::~StringImpl):
(WTF::StringImpl::createSymbol): Deleted.
(WTF::StringImpl::createNullSymbol): Deleted.
* wtf/text/StringImpl.h:
(WTF::StringImpl::isAtomic):
(WTF::StringImpl::StringImpl):
(WTF::StringImpl::requiresCopy):
(WTF::StringImpl::isNullSymbol): Deleted.
(WTF::StringImpl::symbolAwareHash): Deleted.
(WTF::StringImpl::existingSymbolAwareHash): Deleted.
(WTF::StringImpl::null): Deleted.
(WTF::StringImpl::extractFoldedStringInSymbol): Deleted.
(WTF::StringImpl::symbolRegistry): Deleted.
(WTF::StringImpl::hashForSymbol): Deleted.
* wtf/text/StringStatics.cpp:
(WTF::StringImpl::nextHashForSymbol): Deleted.
* wtf/text/SymbolImpl.cpp: Copied from Source/WTF/wtf/text/SymbolRegistry.cpp.
(WTF::SymbolImpl::nextHashForSymbol):
(WTF::SymbolImpl::create):
(WTF::SymbolImpl::createNullSymbol):
* wtf/text/SymbolImpl.h:
(WTF::SymbolImpl::hashForSymbol):
(WTF::SymbolImpl::symbolRegistry):
(WTF::SymbolImpl::isNullSymbol):
(WTF::SymbolImpl::extractFoldedString):
(WTF::SymbolImpl::SymbolImpl):
(WTF::StringImpl::symbolAwareHash):
(WTF::StringImpl::existingSymbolAwareHash):
* wtf/text/SymbolRegistry.cpp:
(WTF::SymbolRegistry::~SymbolRegistry):
(WTF::SymbolRegistry::symbolForKey):
(WTF::SymbolRegistry::keyForSymbol):
* wtf/text/UniquedStringImpl.h:
(WTF::UniquedStringImpl::UniquedStringImpl):

Tools:

* TestWebKitAPI/Tests/WTF/StringImpl.cpp:
(TestWebKitAPI::TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@209309 268f45cc-cd09-0410-ab3c-d52691b4dbfc
15 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/PrivateName.h
Source/WTF/ChangeLog
Source/WTF/WTF.xcodeproj/project.pbxproj
Source/WTF/wtf/CMakeLists.txt
Source/WTF/wtf/StdLibExtras.h
Source/WTF/wtf/text/StringImpl.cpp
Source/WTF/wtf/text/StringImpl.h
Source/WTF/wtf/text/StringStatics.cpp
Source/WTF/wtf/text/SymbolImpl.cpp [new file with mode: 0644]
Source/WTF/wtf/text/SymbolImpl.h
Source/WTF/wtf/text/SymbolRegistry.cpp
Source/WTF/wtf/text/UniquedStringImpl.h
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WTF/StringImpl.cpp