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

    r29663 r31936  
    2222#include "CommonIdentifiers.h"
    2323
     24#if USE(MULTIPLE_THREADS)
     25#include <wtf/ThreadSpecific.h>
     26#endif
     27
    2428namespace KJS {
    2529
     
    3741CommonIdentifiers* CommonIdentifiers::shared()
    3842{
    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;
    4445    return sharedInstance;
     46#else
     47    static CommonIdentifiers sharedInstance;
     48    return &sharedInstance;
     49#endif
    4550}
    4651
Note: See TracChangeset for help on using the changeset viewer.