summaryrefslogtreecommitdiffstats
path: root/JavaScriptCore/wtf/text
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2010-05-11 18:35:50 +0100
committerBen Murdoch <benm@google.com>2010-05-14 10:23:05 +0100
commit21939df44de1705786c545cd1bf519d47250322d (patch)
treeef56c310f5c0cdc379c2abb2e212308a3281ce20 /JavaScriptCore/wtf/text
parent4ff1d8891d520763f17675827154340c7c740f90 (diff)
downloadexternal_webkit-21939df44de1705786c545cd1bf519d47250322d.zip
external_webkit-21939df44de1705786c545cd1bf519d47250322d.tar.gz
external_webkit-21939df44de1705786c545cd1bf519d47250322d.tar.bz2
Merge Webkit at r58956: Initial merge by Git.
Change-Id: I1d9fb60ea2c3f2ddc04c17a871acdb39353be228
Diffstat (limited to 'JavaScriptCore/wtf/text')
-rw-r--r--JavaScriptCore/wtf/text/AtomicString.cpp15
-rw-r--r--JavaScriptCore/wtf/text/AtomicStringImpl.h2
-rw-r--r--JavaScriptCore/wtf/text/StringImpl.cpp4
-rw-r--r--JavaScriptCore/wtf/text/StringImpl.h15
-rw-r--r--JavaScriptCore/wtf/text/StringImplBase.h2
5 files changed, 26 insertions, 12 deletions
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 <wtf/Threading.h>
#include <wtf/HashSet.h>
+#include <wtf/Threading.h>
#include <wtf/WTFThreadData.h>
namespace WebCore {
@@ -55,6 +55,9 @@ public:
private:
static void destroy(AtomicStringTable* table)
{
+ HashSet<StringImpl*>::iterator end = table->m_table.end();
+ for (HashSet<StringImpl*>::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<StringImpl> AtomicString::add(const UChar* s)
PassRefPtr<StringImpl> AtomicString::add(StringImpl* r)
{
- if (!r || r->inTable())
+ if (!r || r->isAtomic())
return r;
if (r->length() == 0)
@@ -262,7 +265,7 @@ PassRefPtr<StringImpl> 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<char> 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<char>(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 <wtf/ASCIICType.h>
#include <wtf/CrossThreadRefCounted.h>
#include <wtf/OwnFastMallocPtr.h>
+#include <wtf/StdLibExtras.h>
#include <wtf/StringHashFunctions.h>
#include <wtf/Vector.h>
#include <wtf/text/StringImplBase.h>
@@ -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<StringImpl> createWithTerminatingNullCharacter(const StringImpl&);
static PassRefPtr<StringImpl> 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<BufferOwnership>(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;