From 21939df44de1705786c545cd1bf519d47250322d Mon Sep 17 00:00:00 2001 From: Ben Murdoch Date: Tue, 11 May 2010 18:35:50 +0100 Subject: Merge Webkit at r58956: Initial merge by Git. Change-Id: I1d9fb60ea2c3f2ddc04c17a871acdb39353be228 --- JavaScriptCore/wtf/text/AtomicString.cpp | 15 +++++++++------ JavaScriptCore/wtf/text/AtomicStringImpl.h | 2 ++ JavaScriptCore/wtf/text/StringImpl.cpp | 4 ++-- JavaScriptCore/wtf/text/StringImpl.h | 15 ++++++++++++--- JavaScriptCore/wtf/text/StringImplBase.h | 2 +- 5 files changed, 26 insertions(+), 12 deletions(-) (limited to 'JavaScriptCore/wtf/text') diff --git a/JavaScriptCore/wtf/text/AtomicString.cpp b/JavaScriptCore/wtf/text/AtomicString.cpp index 79b9ab5..ab52488 100644 --- a/JavaScriptCore/wtf/text/AtomicString.cpp +++ b/JavaScriptCore/wtf/text/AtomicString.cpp @@ -28,8 +28,8 @@ #include "StaticConstructors.h" #include "StringHash.h" -#include #include +#include #include namespace WebCore { @@ -55,6 +55,9 @@ public: private: static void destroy(AtomicStringTable* table) { + HashSet::iterator end = table->m_table.end(); + for (HashSet::iterator iter = table->m_table.begin(); iter != end; ++iter) + (*iter)->setIsAtomic(false); delete table; } @@ -92,7 +95,7 @@ struct CStringTranslator { { location = StringImpl::create(c).releaseRef(); location->setHash(hash); - location->setInTable(); + location->setIsAtomic(true); } }; @@ -171,7 +174,7 @@ struct UCharBufferTranslator { { location = StringImpl::create(buf.s, buf.length).releaseRef(); location->setHash(hash); - location->setInTable(); + location->setIsAtomic(true); } }; @@ -197,7 +200,7 @@ struct HashAndCharactersTranslator { { location = StringImpl::create(buffer.characters, buffer.length).releaseRef(); location->setHash(hash); - location->setInTable(); + location->setIsAtomic(true); } }; @@ -254,7 +257,7 @@ PassRefPtr AtomicString::add(const UChar* s) PassRefPtr AtomicString::add(StringImpl* r) { - if (!r || r->inTable()) + if (!r || r->isAtomic()) return r; if (r->length() == 0) @@ -262,7 +265,7 @@ PassRefPtr AtomicString::add(StringImpl* r) StringImpl* result = *stringTable().add(r).first; if (result == r) - r->setInTable(); + r->setIsAtomic(true); return result; } diff --git a/JavaScriptCore/wtf/text/AtomicStringImpl.h b/JavaScriptCore/wtf/text/AtomicStringImpl.h index d21a00a..4b813f8 100644 --- a/JavaScriptCore/wtf/text/AtomicStringImpl.h +++ b/JavaScriptCore/wtf/text/AtomicStringImpl.h @@ -29,6 +29,8 @@ namespace WebCore { class AtomicStringImpl : public StringImpl { +public: + AtomicStringImpl() : StringImpl(0) {} }; } diff --git a/JavaScriptCore/wtf/text/StringImpl.cpp b/JavaScriptCore/wtf/text/StringImpl.cpp index 287e529..ff69737 100644 --- a/JavaScriptCore/wtf/text/StringImpl.cpp +++ b/JavaScriptCore/wtf/text/StringImpl.cpp @@ -42,7 +42,7 @@ StringImpl::~StringImpl() { ASSERT(!isStatic()); - if (inTable()) + if (isAtomic()) AtomicString::remove(this); #if USE(JSC) if (isIdentifier()) @@ -879,7 +879,7 @@ Vector StringImpl::ascii() for (unsigned i = 0; i != m_length; ++i) { UChar c = m_data[i]; if ((c >= 0x20 && c < 0x7F) || c == 0x00) - buffer[i] = c; + buffer[i] = static_cast(c); else buffer[i] = '?'; } diff --git a/JavaScriptCore/wtf/text/StringImpl.h b/JavaScriptCore/wtf/text/StringImpl.h index 6ac9e40..dbf51e3 100644 --- a/JavaScriptCore/wtf/text/StringImpl.h +++ b/JavaScriptCore/wtf/text/StringImpl.h @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -72,6 +73,7 @@ class StringImpl : public StringImplBase { friend struct CStringTranslator; friend struct HashAndCharactersTranslator; friend struct UCharBufferTranslator; + friend class AtomicStringImpl; private: // Used to construct static strings, which have an special refCount that can never hit zero. // This means that the static string will never be destroyed, which is important because @@ -178,6 +180,7 @@ public: return adoptRef(new(resultImpl) StringImpl(length)); } + static unsigned dataOffset() { return OBJECT_OFFSETOF(StringImpl, m_data); } static PassRefPtr createWithTerminatingNullCharacter(const StringImpl&); static PassRefPtr createStrippingNullCharacters(const UChar*, unsigned length); @@ -220,8 +223,15 @@ public: bool hasTerminatingNullCharacter() const { return m_refCountAndFlags & s_refCountFlagHasTerminatingNullCharacter; } - bool inTable() const { return m_refCountAndFlags & s_refCountFlagInTable; } - void setInTable() { m_refCountAndFlags |= s_refCountFlagInTable; } + bool isAtomic() const { return m_refCountAndFlags & s_refCountFlagIsAtomic; } + void setIsAtomic(bool isIdentifier) + { + ASSERT(!isStatic()); + if (isIdentifier) + m_refCountAndFlags |= s_refCountFlagIsAtomic; + else + m_refCountAndFlags &= ~s_refCountFlagIsAtomic; + } unsigned hash() const { if (!m_hash) m_hash = computeHash(m_data, m_length); return m_hash; } unsigned existingHash() const { ASSERT(m_hash); return m_hash; } @@ -317,7 +327,6 @@ private: BufferOwnership bufferOwnership() const { return static_cast(m_refCountAndFlags & s_refCountMaskBufferOwnership); } bool isStatic() const { return m_refCountAndFlags & s_refCountFlagStatic; } - const UChar* m_data; union { void* m_buffer; diff --git a/JavaScriptCore/wtf/text/StringImplBase.h b/JavaScriptCore/wtf/text/StringImplBase.h index a8e3385..6567672 100644 --- a/JavaScriptCore/wtf/text/StringImplBase.h +++ b/JavaScriptCore/wtf/text/StringImplBase.h @@ -83,7 +83,7 @@ protected: static const unsigned s_refCountIncrement = 0x80; static const unsigned s_refCountFlagStatic = 0x40; static const unsigned s_refCountFlagHasTerminatingNullCharacter = 0x20; - static const unsigned s_refCountFlagInTable = 0x10; + static const unsigned s_refCountFlagIsAtomic = 0x10; static const unsigned s_refCountFlagShouldReportedCost = 0x8; static const unsigned s_refCountFlagIsIdentifier = 0x4; static const unsigned s_refCountMaskBufferOwnership = 0x3; -- cgit v1.1