Chromium Code Reviews| Index: Source/WTF/wtf/text/StringStatics.cpp |
| diff --git a/Source/WTF/wtf/text/StringStatics.cpp b/Source/WTF/wtf/text/StringStatics.cpp |
| index 2e1b955acd14ed2312feb263f662dbd5c10e4910..b4c1c83de8f39e4abefc47ca769c4f8ffa3e2720 100644 |
| --- a/Source/WTF/wtf/text/StringStatics.cpp |
| +++ b/Source/WTF/wtf/text/StringStatics.cpp |
| @@ -24,6 +24,7 @@ |
| */ |
| #include "config.h" |
| +#include "StringStatics.h" |
| #ifdef SKIP_STATIC_CONSTRUCTORS_ON_GCC |
| #define ATOMICSTRING_HIDE_GLOBALS 1 |
| @@ -73,22 +74,32 @@ NEVER_INLINE unsigned StringImpl::hashSlowCase() const |
| void AtomicString::init() |
| { |
| static bool initialized; |
| - if (!initialized) { |
| - // Initialization is not thread safe, so this function must be called from the main thread first. |
| - ASSERT(isMainThread()); |
| + if (initialized) |
| + return; |
| + initialized = true; |
| - // 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); |
| + ASSERT(isMainThread()); |
| - initialized = true; |
| - } |
| + new (NotNull, (void*)&nullAtom) AtomicString; |
| + new (NotNull, (void*)&emptyAtom) AtomicString(""); |
|
eseidel
2013/04/10 20:53:50
I assume this is going to correctly end up with "e
abarth-chromium
2013/04/10 21:00:51
Yes. This part isn't changing. I'm just switchin
|
| +} |
| + |
| +void StringStatics::init() |
| +{ |
| + static bool initialized; |
| + if (initialized) |
| + return; |
| + initialized = true; |
| + |
| + ASSERT(isMainThread()); |
| + |
| + // FIXME: These should be allocated at compile time. |
| + 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); |
| } |
| } |