diff options
Diffstat (limited to 'Source/WTF/wtf/text/StringStatics.cpp')
-rw-r--r-- | Source/WTF/wtf/text/StringStatics.cpp | 36 |
1 files changed, 13 insertions, 23 deletions
diff --git a/Source/WTF/wtf/text/StringStatics.cpp b/Source/WTF/wtf/text/StringStatics.cpp index 8f0c74cc0..0c2119c1d 100644 --- a/Source/WTF/wtf/text/StringStatics.cpp +++ b/Source/WTF/wtf/text/StringStatics.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Apple Inc. All Rights Reserved. + * Copyright (C) 2010, 2016 Apple Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -30,8 +30,8 @@ #endif #include "AtomicString.h" -#include "DynamicAnnotations.h" #include "MainThread.h" +#include "NeverDestroyed.h" #include "StaticConstructors.h" #include "StringImpl.h" @@ -41,29 +41,11 @@ namespace WTF { -StringImpl* StringImpl::empty() -{ - // FIXME: This works around a bug in our port of PCRE, that a regular expression - // run on the empty string may still perform a read from the first element, and - // as such we need this to be a valid pointer. No code should ever be reading - // from a zero length string, so this should be able to be a non-null pointer - // into the zero-page. - // Replace this with 'reinterpret_cast<UChar*>(static_cast<intptr_t>(1))' once - // PCRE goes away. - static LChar emptyLCharData = 0; - DEFINE_STATIC_LOCAL(StringImpl, emptyString, (&emptyLCharData, 0, ConstructStaticString)); - WTF_ANNOTATE_BENIGN_RACE(&emptyString, "Benign race on StringImpl::emptyString reference counter"); - return &emptyString; -} - WTF_EXPORTDATA DEFINE_GLOBAL(AtomicString, nullAtom) WTF_EXPORTDATA DEFINE_GLOBAL(AtomicString, emptyAtom) -WTF_EXPORTDATA DEFINE_GLOBAL(AtomicString, textAtom) -WTF_EXPORTDATA DEFINE_GLOBAL(AtomicString, commentAtom) WTF_EXPORTDATA DEFINE_GLOBAL(AtomicString, starAtom) WTF_EXPORTDATA DEFINE_GLOBAL(AtomicString, xmlAtom) WTF_EXPORTDATA DEFINE_GLOBAL(AtomicString, xmlnsAtom) -WTF_EXPORTDATA DEFINE_GLOBAL(AtomicString, xlinkAtom) NEVER_INLINE unsigned StringImpl::hashSlowCase() const { @@ -74,6 +56,17 @@ NEVER_INLINE unsigned StringImpl::hashSlowCase() const return existingHash(); } +unsigned StringImpl::concurrentHash() const +{ + unsigned hash; + if (is8Bit()) + hash = StringHasher::computeHashAndMaskTop8Bits(m_data8, m_length); + else + hash = StringHasher::computeHashAndMaskTop8Bits(m_data16, m_length); + ASSERT(((hash << s_flagCount) >> s_flagCount) == hash); + return hash; +} + void AtomicString::init() { static bool initialized; @@ -84,12 +77,9 @@ void AtomicString::init() // Use placement new to initialize the globals. new (NotNull, (void*)&nullAtom) AtomicString; new (NotNull, (void*)&emptyAtom) AtomicString(""); - new (NotNull, (void*)&textAtom) AtomicString("#text", AtomicString::ConstructFromLiteral); - new (NotNull, (void*)&commentAtom) AtomicString("#comment", AtomicString::ConstructFromLiteral); new (NotNull, (void*)&starAtom) AtomicString("*", AtomicString::ConstructFromLiteral); new (NotNull, (void*)&xmlAtom) AtomicString("xml", AtomicString::ConstructFromLiteral); new (NotNull, (void*)&xmlnsAtom) AtomicString("xmlns", AtomicString::ConstructFromLiteral); - new (NotNull, (void*)&xlinkAtom) AtomicString("xlink", AtomicString::ConstructFromLiteral); initialized = true; } |