Ignore:
Timestamp:
Apr 16, 2008, 2:30:01 AM (17 years ago)
Author:
[email protected]
Message:

Reviewed by Darin.

Implement an abstraction for thread-specific storage, use it to get rid of some static objects.

SunSpider results were not conclusive, possibly up to 0.2% slowdown.

  • wtf/ThreadSpecific.h: Added. (WTF::::ThreadSpecific): (WTF::::~ThreadSpecific): (WTF::::get): (WTF::::set): (WTF::::destroy): (WTF::T): (WTF::::operator): Only implemented for platforms that use pthreads.
  • kjs/CommonIdentifiers.cpp: (KJS::CommonIdentifiers::shared):
  • kjs/CommonIdentifiers.h:
  • kjs/InitializeThreading.cpp: (KJS::initializeThreading):
  • kjs/Parser.cpp: (KJS::parser):
  • kjs/Parser.h:
  • kjs/identifier.cpp: (KJS::identifierTable): (KJS::literalIdentifierTable): (KJS::Identifier::initializeIdentifierThreading):
  • kjs/identifier.h:
  • kjs/lexer.cpp: (KJS::lexer):
  • kjs/lexer.h: Make static instances per-thread.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/identifier.cpp

    r31677 r31936  
    2929#include <wtf/FastMalloc.h>
    3030#include <wtf/HashSet.h>
     31#if USE(MULTIPLE_THREADS)
     32#include <wtf/ThreadSpecific.h>
     33#endif
    3134
    3235namespace WTF {
     
    5154typedef HashSet<UString::Rep*> IdentifierTable;
    5255typedef HashMap<const char*, UString::Rep*, PtrHash<const char*> > LiteralIdentifierTable;
    53 static IdentifierTable* table;
    54 static LiteralIdentifierTable* literalTable;
    5556
    5657static inline IdentifierTable& identifierTable()
    5758{
    58     ASSERT(JSLock::lockCount() > 0);
    59 
    60     if (!table)
    61         table = new IdentifierTable;
     59#if USE(MULTIPLE_THREADS)
     60    static ThreadSpecific<IdentifierTable> table;
    6261    return *table;
     62#else
     63    static IdentifierTable table;
     64    return table;
     65#endif
    6366}
    6467
    6568static inline LiteralIdentifierTable& literalIdentifierTable()
    6669{
    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
     79void Identifier::initializeIdentifierThreading()
     80{
     81    identifierTable();
     82    literalIdentifierTable();
     83}
    7484
    7585bool Identifier::equal(const UString::Rep *r, const char *s)
Note: See TracChangeset for help on using the changeset viewer.