Changeset 31936 in webkit for trunk/JavaScriptCore/kjs/lexer.cpp


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/lexer.cpp

    r31811 r31936  
    3333#include <string.h>
    3434#include <wtf/Assertions.h>
     35#if USE(MULTIPLE_THREADS)
     36#include <wtf/ThreadSpecific.h>
     37#endif
    3538#include <wtf/unicode/Unicode.h>
    3639
     
    6366Lexer& lexer()
    6467{
    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;
    7170    return *staticLexer;
     71#else
     72    static Lexer staticLexer;
     73    return staticLexer;
     74#endif
    7275}
    7376
Note: See TracChangeset for help on using the changeset viewer.