Diff
Modified: trunk/Source/_javascript_Core/API/JSStringRef.cpp (152200 => 152201)
--- trunk/Source/_javascript_Core/API/JSStringRef.cpp 2013-06-29 01:39:20 UTC (rev 152200)
+++ trunk/Source/_javascript_Core/API/JSStringRef.cpp 2013-06-29 01:39:28 UTC (rev 152201)
@@ -63,7 +63,7 @@
JSStringRef JSStringCreateWithCharactersNoCopy(const JSChar* chars, size_t numChars)
{
initializeThreading();
- return OpaqueJSString::create(StringImpl::createWithoutCopying(chars, numChars, WTF::DoesNotHaveTerminatingNullCharacter)).leakRef();
+ return OpaqueJSString::create(StringImpl::createWithoutCopying(chars, numChars)).leakRef();
}
JSStringRef JSStringRetain(JSStringRef string)
Modified: trunk/Source/_javascript_Core/ChangeLog (152200 => 152201)
--- trunk/Source/_javascript_Core/ChangeLog 2013-06-29 01:39:20 UTC (rev 152200)
+++ trunk/Source/_javascript_Core/ChangeLog 2013-06-29 01:39:28 UTC (rev 152201)
@@ -1,3 +1,14 @@
+2013-06-28 Anders Carlsson <[email protected]>
+
+ Remove String::deprecatedCharactersWithNullTermination() and related code
+ https://bugs.webkit.org/show_bug.cgi?id=118211
+
+ Reviewed by Benjamin Poulain.
+
+ * API/JSStringRef.cpp:
+ (JSStringCreateWithCharactersNoCopy):
+ Update call to StringImpl::createWithoutCopying.
+
2013-06-27 Timothy Hatcher <[email protected]>
Notify the debugger about functions created from source code via new Function() or WebCore::JSLazyEventListener.
Modified: trunk/Source/WTF/ChangeLog (152200 => 152201)
--- trunk/Source/WTF/ChangeLog 2013-06-29 01:39:20 UTC (rev 152200)
+++ trunk/Source/WTF/ChangeLog 2013-06-29 01:39:28 UTC (rev 152201)
@@ -1,3 +1,26 @@
+2013-06-28 Anders Carlsson <[email protected]>
+
+ Remove String::deprecatedCharactersWithNullTermination() and related code
+ https://bugs.webkit.org/show_bug.cgi?id=118211
+
+ Reviewed by Benjamin Poulain.
+
+ Remove String::deprecatedCharactersWithNullTermination, StringImpl::createWithTerminatingNullCharacter
+ and the s_hashFlagHasTerminatingNullCharacter flag. We no longer care about whether strings have a
+ terminating null character.
+
+ * wtf/text/StringImpl.cpp:
+ (WTF::StringImpl::createFromLiteral):
+ (WTF::StringImpl::createWithoutCopying):
+ (WTF::StringImpl::getData16SlowCase):
+ (WTF::StringImpl::sizeInBytes):
+ * wtf/text/StringImpl.h:
+ (WTF::StringImpl::StringImpl):
+ (WTF::StringImpl::createFromLiteral):
+ (WTF::StringImpl::isolatedCopy):
+ * wtf/text/WTFString.cpp:
+ * wtf/text/WTFString.h:
+
2013-06-27 Anders Carlsson <[email protected]>
Add a new String::charactersWithNullTermination() function that returns a vector
Modified: trunk/Source/WTF/wtf/text/StringImpl.cpp (152200 => 152201)
--- trunk/Source/WTF/wtf/text/StringImpl.cpp 2013-06-29 01:39:20 UTC (rev 152200)
+++ trunk/Source/WTF/wtf/text/StringImpl.cpp 2013-06-29 01:39:28 UTC (rev 152201)
@@ -158,7 +158,7 @@
{
ASSERT_WITH_MESSAGE(length, "Use StringImpl::empty() to create an empty string");
ASSERT(charactersAreAllASCII<LChar>(reinterpret_cast<const LChar*>(characters), length));
- return adoptRef(new StringImpl(reinterpret_cast<const LChar*>(characters), length, DoesHaveTerminatingNullCharacter, ConstructWithoutCopying));
+ return adoptRef(new StringImpl(reinterpret_cast<const LChar*>(characters), length, ConstructWithoutCopying));
}
PassRefPtr<StringImpl> StringImpl::createFromLiteral(const char* characters)
@@ -166,20 +166,20 @@
return createFromLiteral(characters, strlen(characters));
}
-PassRefPtr<StringImpl> StringImpl::createWithoutCopying(const UChar* characters, unsigned length, HasTerminatingNullCharacter hasTerminatingNullCharacter)
+PassRefPtr<StringImpl> StringImpl::createWithoutCopying(const UChar* characters, unsigned length)
{
if (!length)
return empty();
- return adoptRef(new StringImpl(characters, length, hasTerminatingNullCharacter, ConstructWithoutCopying));
+ return adoptRef(new StringImpl(characters, length, ConstructWithoutCopying));
}
-PassRefPtr<StringImpl> StringImpl::createWithoutCopying(const LChar* characters, unsigned length, HasTerminatingNullCharacter hasTerminatingNullCharacter)
+PassRefPtr<StringImpl> StringImpl::createWithoutCopying(const LChar* characters, unsigned length)
{
if (!length)
return empty();
- return adoptRef(new StringImpl(characters, length, hasTerminatingNullCharacter, ConstructWithoutCopying));
+ return adoptRef(new StringImpl(characters, length, ConstructWithoutCopying));
}
PassRefPtr<StringImpl> StringImpl::createUninitialized(unsigned length, LChar*& data)
@@ -333,8 +333,6 @@
STRING_STATS_ADD_UPCONVERTED_STRING(m_length);
unsigned len = length();
- if (hasTerminatingNullCharacter())
- ++len;
m_copyData16 = static_cast<UChar*>(fastMalloc(len * sizeof(UChar)));
@@ -1955,30 +1953,6 @@
}
#endif
-PassRefPtr<StringImpl> StringImpl::createWithTerminatingNullCharacter(const StringImpl& string)
-{
- // Use createUninitialized instead of 'new StringImpl' so that the string and its buffer
- // get allocated in a single memory block.
- unsigned length = string.m_length;
- if (length >= numeric_limits<unsigned>::max())
- CRASH();
- RefPtr<StringImpl> terminatedString;
- if (string.is8Bit()) {
- LChar* data;
- terminatedString = createUninitialized(length + 1, data);
- memcpy(data, string.m_data8, length * sizeof(LChar));
- data[length] = 0;
- } else {
- UChar* data;
- terminatedString = createUninitialized(length + 1, data);
- memcpy(data, string.m_data16, length * sizeof(UChar));
- data[length] = 0;
- }
- --(terminatedString->m_length);
- terminatedString->m_hashAndFlags = (string.m_hashAndFlags & (~s_flagMask | s_hashFlag8BitBuffer)) | s_hashFlagHasTerminatingNullCharacter;
- return terminatedString.release();
-}
-
size_t StringImpl::sizeInBytes() const
{
// FIXME: support substrings
@@ -1986,8 +1960,6 @@
if (is8Bit()) {
if (has16BitShadow()) {
size += 2 * size;
- if (hasTerminatingNullCharacter())
- size += 2;
}
} else
size *= 2;
Modified: trunk/Source/WTF/wtf/text/StringImpl.h (152200 => 152201)
--- trunk/Source/WTF/wtf/text/StringImpl.h 2013-06-29 01:39:20 UTC (rev 152200)
+++ trunk/Source/WTF/wtf/text/StringImpl.h 2013-06-29 01:39:28 UTC (rev 152201)
@@ -73,12 +73,6 @@
TextCaseInsensitive
};
-enum HasTerminatingNullCharacter {
- DoesNotHaveTerminatingNullCharacter,
- DoesHaveTerminatingNullCharacter,
-};
-
-
typedef bool (*CharacterMatchFunctionPtr)(UChar);
typedef bool (*IsWhiteSpaceFunctionPtr)(UChar);
@@ -249,30 +243,28 @@
}
enum ConstructWithoutCopyingTag { ConstructWithoutCopying };
- StringImpl(const UChar* characters, unsigned length, HasTerminatingNullCharacter hasTerminatingNullCharacter, ConstructWithoutCopyingTag)
+ StringImpl(const UChar* characters, unsigned length, ConstructWithoutCopyingTag)
: m_refCount(s_refCountIncrement)
, m_length(length)
, m_data16(characters)
, m_buffer(0)
- , m_hashAndFlags(BufferInternal | (hasTerminatingNullCharacter ? s_hashFlagHasTerminatingNullCharacter : 0))
+ , m_hashAndFlags(BufferInternal)
{
ASSERT(m_data16);
ASSERT(m_length);
- ASSERT(!(m_hashAndFlags & s_hashFlagHasTerminatingNullCharacter) || !characters[length]);
STRING_STATS_ADD_16BIT_STRING(0);
}
- StringImpl(const LChar* characters, unsigned length, HasTerminatingNullCharacter hasTerminatingNullCharacter, ConstructWithoutCopyingTag)
+ StringImpl(const LChar* characters, unsigned length, ConstructWithoutCopyingTag)
: m_refCount(s_refCountIncrement)
, m_length(length)
, m_data8(characters)
, m_buffer(0)
- , m_hashAndFlags(s_hashFlag8BitBuffer | BufferInternal | (hasTerminatingNullCharacter ? s_hashFlagHasTerminatingNullCharacter : 0))
+ , m_hashAndFlags(s_hashFlag8BitBuffer | BufferInternal)
{
ASSERT(m_data8);
ASSERT(m_length);
- ASSERT(!(m_hashAndFlags & s_hashFlagHasTerminatingNullCharacter) || !characters[length]);
STRING_STATS_ADD_8BIT_STRING(0);
}
@@ -421,15 +413,15 @@
COMPILE_ASSERT(charactersCount > 1, StringImplFromLiteralNotEmpty);
COMPILE_ASSERT((charactersCount - 1 <= ((unsigned(~0) - sizeof(StringImpl)) / sizeof(LChar))), StringImplFromLiteralCannotOverflow);
- return createWithoutCopying(reinterpret_cast<const LChar*>(characters), charactersCount - 1, DoesHaveTerminatingNullCharacter);
+ return createWithoutCopying(reinterpret_cast<const LChar*>(characters), charactersCount - 1);
}
// FIXME: Transition off of these functions to createWithoutCopying instead.
WTF_EXPORT_STRING_API static PassRefPtr<StringImpl> createFromLiteral(const char* characters, unsigned length);
WTF_EXPORT_STRING_API static PassRefPtr<StringImpl> createFromLiteral(const char* characters);
- WTF_EXPORT_STRING_API static PassRefPtr<StringImpl> createWithoutCopying(const UChar* characters, unsigned length, HasTerminatingNullCharacter);
- WTF_EXPORT_STRING_API static PassRefPtr<StringImpl> createWithoutCopying(const LChar* characters, unsigned length, HasTerminatingNullCharacter);
+ WTF_EXPORT_STRING_API static PassRefPtr<StringImpl> createWithoutCopying(const UChar* characters, unsigned length);
+ WTF_EXPORT_STRING_API static PassRefPtr<StringImpl> createWithoutCopying(const LChar* characters, unsigned length);
WTF_EXPORT_STRING_API static PassRefPtr<StringImpl> createUninitialized(unsigned length, LChar*& data);
WTF_EXPORT_STRING_API static PassRefPtr<StringImpl> createUninitialized(unsigned length, UChar*& data);
@@ -471,7 +463,6 @@
static unsigned flagsOffset() { return OBJECT_OFFSETOF(StringImpl, m_hashAndFlags); }
static unsigned flagIs8Bit() { return s_hashFlag8BitBuffer; }
static unsigned dataOffset() { return OBJECT_OFFSETOF(StringImpl, m_data8); }
- static PassRefPtr<StringImpl> createWithTerminatingNullCharacter(const StringImpl&);
template<typename CharType, size_t inlineCapacity, typename OverflowHandler>
static PassRefPtr<StringImpl> adopt(Vector<CharType, inlineCapacity, OverflowHandler>& vector)
@@ -541,8 +532,6 @@
return !length() && !isStatic();
}
- bool hasTerminatingNullCharacter() const { return m_hashAndFlags & s_hashFlagHasTerminatingNullCharacter; }
-
bool isAtomic() const { return m_hashAndFlags & s_hashFlagIsAtomic; }
void setIsAtomic(bool isAtomic)
{
@@ -788,14 +777,13 @@
static const unsigned s_refCountFlagIsStaticString = 0x1;
static const unsigned s_refCountIncrement = 0x2; // This allows us to ref / deref without disturbing the static string flag.
- // The bottom 8 bits in the hash are flags.
- static const unsigned s_flagCount = 8;
+ // The bottom 7 bits in the hash are flags.
+ static const unsigned s_flagCount = 7;
static const unsigned s_flagMask = (1u << s_flagCount) - 1;
- COMPILE_ASSERT(s_flagCount == StringHasher::flagCount, StringHasher_reserves_enough_bits_for_StringImpl_flags);
+ COMPILE_ASSERT(s_flagCount <= StringHasher::flagCount, StringHasher_reserves_enough_bits_for_StringImpl_flags);
- static const unsigned s_hashFlagHas16BitShadow = 1u << 7;
- static const unsigned s_hashFlag8BitBuffer = 1u << 6;
- static const unsigned s_hashFlagHasTerminatingNullCharacter = 1u << 5;
+ static const unsigned s_hashFlagHas16BitShadow = 1u << 6;
+ static const unsigned s_hashFlag8BitBuffer = 1u << 5;
static const unsigned s_hashFlagIsAtomic = 1u << 4;
static const unsigned s_hashFlagDidReportCost = 1u << 3;
static const unsigned s_hashFlagIsIdentifier = 1u << 2;
@@ -816,7 +804,7 @@
// These values mimic ConstructFromLiteral.
static const unsigned s_initialRefCount = s_refCountIncrement;
- static const unsigned s_initialFlags = s_hashFlag8BitBuffer | BufferInternal | s_hashFlagHasTerminatingNullCharacter;
+ static const unsigned s_initialFlags = s_hashFlag8BitBuffer | BufferInternal;
static const unsigned s_hashShift = s_flagCount;
};
@@ -1362,8 +1350,8 @@
{
if (!requiresCopy()) {
if (is8Bit())
- return StringImpl::createWithoutCopying(m_data8, m_length, hasTerminatingNullCharacter() ? DoesHaveTerminatingNullCharacter : DoesNotHaveTerminatingNullCharacter);
- return StringImpl::createWithoutCopying(m_data16, m_length, hasTerminatingNullCharacter() ? DoesHaveTerminatingNullCharacter : DoesNotHaveTerminatingNullCharacter);
+ return StringImpl::createWithoutCopying(m_data8, m_length);
+ return StringImpl::createWithoutCopying(m_data16, m_length);
}
if (is8Bit())
Modified: trunk/Source/WTF/wtf/text/WTFString.cpp (152200 => 152201)
--- trunk/Source/WTF/wtf/text/WTFString.cpp 2013-06-29 01:39:20 UTC (rev 152200)
+++ trunk/Source/WTF/wtf/text/WTFString.cpp 2013-06-29 01:39:28 UTC (rev 152201)
@@ -416,16 +416,6 @@
return result;
}
-const UChar* String::deprecatedCharactersWithNullTermination()
-{
- if (!m_impl)
- return 0;
- if (m_impl->hasTerminatingNullCharacter())
- return m_impl->characters();
- m_impl = StringImpl::createWithTerminatingNullCharacter(*m_impl);
- return m_impl->characters();
-}
-
String String::format(const char *format, ...)
{
#if PLATFORM(QT)
Modified: trunk/Source/WTF/wtf/text/WTFString.h (152200 => 152201)
--- trunk/Source/WTF/wtf/text/WTFString.h 2013-06-29 01:39:20 UTC (rev 152200)
+++ trunk/Source/WTF/wtf/text/WTFString.h 2013-06-29 01:39:28 UTC (rev 152201)
@@ -282,7 +282,6 @@
{ return caseSensitive ? reverseFind(str, start) : reverseFindIgnoringCase(str, start); }
WTF_EXPORT_STRING_API Vector<UChar> charactersWithNullTermination() const;
- WTF_EXPORT_STRING_API const UChar* deprecatedCharactersWithNullTermination();
WTF_EXPORT_STRING_API UChar32 characterStartingAt(unsigned) const; // Ditto.
Modified: trunk/Tools/ChangeLog (152200 => 152201)
--- trunk/Tools/ChangeLog 2013-06-29 01:39:20 UTC (rev 152200)
+++ trunk/Tools/ChangeLog 2013-06-29 01:39:28 UTC (rev 152201)
@@ -1,3 +1,19 @@
+2013-06-28 Anders Carlsson <[email protected]>
+
+ Remove String::deprecatedCharactersWithNullTermination() and related code
+ https://bugs.webkit.org/show_bug.cgi?id=118211
+
+ Reviewed by Benjamin Poulain.
+
+ Remove all hasTerminatingNullCharacter() checks.
+
+ * TestWebKitAPI/Tests/WTF/AtomicString.cpp:
+ (TestWebKitAPI::TEST):
+ * TestWebKitAPI/Tests/WTF/StringImpl.cpp:
+ (TestWebKitAPI::TEST):
+ * TestWebKitAPI/Tests/WTF/WTFString.cpp:
+ (TestWebKitAPI::TEST):
+
2013-06-28 Alexey Proskuryakov <[email protected]>
[Mac] Crash when loading is stopped from -didReceiveResponse
Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/AtomicString.cpp (152200 => 152201)
--- trunk/Tools/TestWebKitAPI/Tests/WTF/AtomicString.cpp 2013-06-29 01:39:20 UTC (rev 152200)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/AtomicString.cpp 2013-06-29 01:39:28 UTC (rev 152201)
@@ -35,14 +35,12 @@
ASSERT_EQ(strlen("Template Literal"), stringWithTemplate.length());
ASSERT_TRUE(stringWithTemplate == "Template Literal");
ASSERT_TRUE(stringWithTemplate.string().is8Bit());
- ASSERT_TRUE(stringWithTemplate.impl()->hasTerminatingNullCharacter());
const char* programmaticStringData = "Explicit Size Literal";
AtomicString programmaticString(programmaticStringData, strlen(programmaticStringData), AtomicString::ConstructFromLiteral);
ASSERT_EQ(strlen(programmaticStringData), programmaticString.length());
ASSERT_TRUE(programmaticStringData == programmaticStringData);
ASSERT_TRUE(programmaticString.string().is8Bit());
- ASSERT_TRUE(programmaticString.impl()->hasTerminatingNullCharacter());
ASSERT_EQ(programmaticStringData, reinterpret_cast<const char*>(programmaticString.string().characters8()));
}
Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/StringImpl.cpp (152200 => 152201)
--- trunk/Tools/TestWebKitAPI/Tests/WTF/StringImpl.cpp 2013-06-29 01:39:20 UTC (rev 152200)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/StringImpl.cpp 2013-06-29 01:39:28 UTC (rev 152201)
@@ -37,7 +37,6 @@
ASSERT_EQ(strlen("Template Literal"), stringWithTemplate->length());
ASSERT_TRUE(equal(stringWithTemplate.get(), "Template Literal"));
ASSERT_TRUE(stringWithTemplate->is8Bit());
- ASSERT_TRUE(stringWithTemplate->hasTerminatingNullCharacter());
// Constructor taking the size explicitely.
const char* programmaticStringData = "Explicit Size Literal";
@@ -46,7 +45,6 @@
ASSERT_TRUE(equal(programmaticString.get(), programmaticStringData));
ASSERT_EQ(programmaticStringData, reinterpret_cast<const char*>(programmaticString->characters8()));
ASSERT_TRUE(programmaticString->is8Bit());
- ASSERT_TRUE(programmaticString->hasTerminatingNullCharacter());
// Constructor without explicit size.
const char* stringWithoutLengthLiteral = "No Size Literal";
@@ -55,7 +53,6 @@
ASSERT_TRUE(equal(programmaticStringNoLength.get(), stringWithoutLengthLiteral));
ASSERT_EQ(stringWithoutLengthLiteral, reinterpret_cast<const char*>(programmaticStringNoLength->characters8()));
ASSERT_TRUE(programmaticStringNoLength->is8Bit());
- ASSERT_TRUE(programmaticStringNoLength->hasTerminatingNullCharacter());
}
TEST(WTF, StringImplFromLiteralLoop16BitConversion)
Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp (152200 => 152201)
--- trunk/Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp 2013-06-29 01:39:20 UTC (rev 152200)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp 2013-06-29 01:39:28 UTC (rev 152201)
@@ -38,14 +38,12 @@
ASSERT_EQ(strlen("Explicit construction syntax"), stringFromLiteral.length());
ASSERT_TRUE(stringFromLiteral == "Explicit construction syntax");
ASSERT_TRUE(stringFromLiteral.is8Bit());
- ASSERT_TRUE(stringFromLiteral.impl()->hasTerminatingNullCharacter());
ASSERT_TRUE(String("Explicit construction syntax") == stringFromLiteral);
String stringWithTemplate("Template Literal", String::ConstructFromLiteral);
ASSERT_EQ(strlen("Template Literal"), stringWithTemplate.length());
ASSERT_TRUE(stringWithTemplate == "Template Literal");
ASSERT_TRUE(stringWithTemplate.is8Bit());
- ASSERT_TRUE(stringWithTemplate.impl()->hasTerminatingNullCharacter());
ASSERT_TRUE(String("Template Literal") == stringWithTemplate);
}