Changeset 31936 in webkit for trunk/JavaScriptCore/kjs
- Timestamp:
- Apr 16, 2008, 2:30:01 AM (17 years ago)
- Location:
- trunk/JavaScriptCore/kjs
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/CommonIdentifiers.cpp
r29663 r31936 22 22 #include "CommonIdentifiers.h" 23 23 24 #if USE(MULTIPLE_THREADS) 25 #include <wtf/ThreadSpecific.h> 26 #endif 27 24 28 namespace KJS { 25 29 … … 37 41 CommonIdentifiers* CommonIdentifiers::shared() 38 42 { 39 static CommonIdentifiers* sharedInstance; 40 if (!sharedInstance) { 41 JSLock lock; 42 sharedInstance = new CommonIdentifiers; 43 } 43 #if USE(MULTIPLE_THREADS) 44 static ThreadSpecific<CommonIdentifiers> sharedInstance; 44 45 return sharedInstance; 46 #else 47 static CommonIdentifiers sharedInstance; 48 return &sharedInstance; 49 #endif 45 50 } 46 51 -
trunk/JavaScriptCore/kjs/CommonIdentifiers.h
r31208 r31936 24 24 #include "identifier.h" 25 25 #include <wtf/Noncopyable.h> 26 27 namespace WTF { 28 template<typename T> class ThreadSpecific; 29 } 26 30 27 31 // List of property names, passed to a macro so we can do set them up various … … 71 75 private: 72 76 CommonIdentifiers(); 77 template<typename T> friend class WTF::ThreadSpecific; 73 78 74 79 public: -
trunk/JavaScriptCore/kjs/InitializeThreading.cpp
r31813 r31936 32 32 #include "DateMath.h" 33 33 #include "dtoa.h" 34 #include "identifier.h" 35 #include "lexer.h" 36 #include "Parser.h" 34 37 #include "ustring.h" 35 38 #include <wtf/Threading.h> … … 44 47 s_dtoaP5Mutex = new Mutex; 45 48 UString::null(); 49 Identifier::initializeIdentifierThreading(); 50 CommonIdentifiers::shared(); 51 lexer(); 46 52 initDateMath(); 47 53 } -
trunk/JavaScriptCore/kjs/Parser.cpp
r31809 r31936 28 28 #include "lexer.h" 29 29 #include <wtf/HashSet.h> 30 #if USE(MULTIPLE_THREADS) 31 #include <wtf/ThreadSpecific.h> 32 #endif 30 33 #include <wtf/Vector.h> 31 34 … … 85 88 Parser& parser() 86 89 { 87 ASSERT(JSLock::currentThreadIsHoldingLock()); 88 89 static Parser& staticParser = *new Parser; 90 #if USE(MULTIPLE_THREADS) 91 static ThreadSpecific<Parser> staticParser; 92 return *staticParser; 93 #else 94 static Parser staticParser; 90 95 return staticParser; 96 #endif 91 97 } 92 98 -
trunk/JavaScriptCore/kjs/Parser.h
r31072 r31936 32 32 #include "nodes.h" 33 33 34 namespace WTF { 35 template<typename T> class ThreadSpecific; 36 } 37 34 38 namespace KJS { 35 39 … … 57 61 private: 58 62 friend Parser& parser(); 63 template<typename T> friend class WTF::ThreadSpecific; 59 64 60 65 Parser(); // Use parser() instead. -
trunk/JavaScriptCore/kjs/identifier.cpp
r31677 r31936 29 29 #include <wtf/FastMalloc.h> 30 30 #include <wtf/HashSet.h> 31 #if USE(MULTIPLE_THREADS) 32 #include <wtf/ThreadSpecific.h> 33 #endif 31 34 32 35 namespace WTF { … … 51 54 typedef HashSet<UString::Rep*> IdentifierTable; 52 55 typedef HashMap<const char*, UString::Rep*, PtrHash<const char*> > LiteralIdentifierTable; 53 static IdentifierTable* table;54 static LiteralIdentifierTable* literalTable;55 56 56 57 static inline IdentifierTable& identifierTable() 57 58 { 58 ASSERT(JSLock::lockCount() > 0); 59 60 if (!table) 61 table = new IdentifierTable; 59 #if USE(MULTIPLE_THREADS) 60 static ThreadSpecific<IdentifierTable> table; 62 61 return *table; 62 #else 63 static IdentifierTable table; 64 return table; 65 #endif 63 66 } 64 67 65 68 static inline LiteralIdentifierTable& literalIdentifierTable() 66 69 { 67 ASSERT(JSLock::lockCount() > 0); 68 69 if (!literalTable) 70 literalTable = new LiteralIdentifierTable; 71 return *literalTable; 72 } 73 70 #if USE(MULTIPLE_THREADS) 71 static ThreadSpecific<LiteralIdentifierTable> table; 72 return *table; 73 #else 74 static LiteralIdentifierTable table; 75 return table; 76 #endif 77 } 78 79 void Identifier::initializeIdentifierThreading() 80 { 81 identifierTable(); 82 literalIdentifierTable(); 83 } 74 84 75 85 bool Identifier::equal(const UString::Rep *r, const char *s) -
trunk/JavaScriptCore/kjs/identifier.h
r31319 r31936 70 70 static PassRefPtr<UString::Rep> add(const char*); 71 71 72 static void initializeIdentifierThreading(); 73 72 74 private: 73 75 UString _ustring; -
trunk/JavaScriptCore/kjs/lexer.cpp
r31811 r31936 33 33 #include <string.h> 34 34 #include <wtf/Assertions.h> 35 #if USE(MULTIPLE_THREADS) 36 #include <wtf/ThreadSpecific.h> 37 #endif 35 38 #include <wtf/unicode/Unicode.h> 36 39 … … 63 66 Lexer& lexer() 64 67 { 65 ASSERT(JSLock::currentThreadIsHoldingLock()); 66 67 // FIXME: We'd like to avoid calling new here, but we don't currently 68 // support tearing down the Lexer at app quit time, since that would involve 69 // tearing down its UString data members without holding the JSLock. 70 static Lexer* staticLexer = new Lexer; 68 #if USE(MULTIPLE_THREADS) 69 static ThreadSpecific<Lexer> staticLexer; 71 70 return *staticLexer; 71 #else 72 static Lexer staticLexer; 73 return staticLexer; 74 #endif 72 75 } 73 76 -
trunk/JavaScriptCore/kjs/lexer.h
r31811 r31936 27 27 #include "ustring.h" 28 28 #include <wtf/Vector.h> 29 30 namespace WTF { 31 template<typename T> class ThreadSpecific; 32 } 29 33 30 34 namespace KJS { … … 89 93 private: 90 94 friend Lexer& lexer(); 95 template<typename T> friend class WTF::ThreadSpecific; 91 96 Lexer(); 92 97
Note:
See TracChangeset
for help on using the changeset viewer.