Ignore:
Timestamp:
Mar 28, 2008, 1:21:39 PM (17 years ago)
Author:
[email protected]
Message:

Reviewed by Sam Weinig.

Fix a dtoa thread safety issue.

WebCore can call kjs_strtod without holding JS lock, but we didn't have thread safety
compiled in for dtoa.

This is a 0.5% regression on SunSpider, which Sam Weinig has volunteered to cover with
his recent improvement.

  • kjs/dtoa.cpp: (Bigint::Balloc): (Bigint::Bfree): Changed to use fastMalloc/fastDelete - they are much faster than the dtoa custom version was in the presence of locking (but somewhat slower in single-threaded case). (Bigint::pow5mult): Got rid of the dreaded double-checked locking anti-pattern (had to restructure the code to avoid significant performance implications). (Bigint::lshift): Rewrote to avoid an allocation, if possible.

(Bigint::rv_alloc):
(Bigint::kjs_freedtoa):
(Bigint::kjs_dtoa):
Check for USE(MULTIPLE_THREADS), not dtoa legacy MULTIPLE_THREADS.

  • kjs/InitializeThreading.cpp: Added. (KJS::initializeThreading):
  • kjs/InitializeThreading.h: Added. Initialize threading at KJS level, if enabled.
  • kjs/dtoa.h: Expose dtoa mutex for KJS::initializeThreading.
  • kjs/testkjs.cpp: (kjsmain): Call initializeThreading.
  • wtf/Threading.h: Removed a using directive for WTF::initializeThreading - it is only to be called from KJS::initializeThreading, and having it in the global namespace is useless.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r31398 r31404  
    190190                D212022B0AD4310D00ED79B6 /* DateMath.h in Headers */ = {isa = PBXBuildFile; fileRef = D21202290AD4310C00ED79B6 /* DateMath.h */; };
    191191                E11D51760B2E798D0056C188 /* StringExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = E11D51750B2E798D0056C188 /* StringExtras.h */; settings = {ATTRIBUTES = (Private, ); }; };
     192                E17863400D9BEC0000D74E75 /* InitializeThreading.h in Headers */ = {isa = PBXBuildFile; fileRef = E178633F0D9BEC0000D74E75 /* InitializeThreading.h */; settings = {ATTRIBUTES = (Private, ); }; };
     193                E178636D0D9BEEC300D74E75 /* InitializeThreading.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E178636C0D9BEEC300D74E75 /* InitializeThreading.cpp */; };
    192194                E195679609E7CF1200B89D13 /* UnicodeIcu.h in Headers */ = {isa = PBXBuildFile; fileRef = E195678F09E7CF1200B89D13 /* UnicodeIcu.h */; settings = {ATTRIBUTES = (Private, ); }; };
    193195                E195679809E7CF1200B89D13 /* Unicode.h in Headers */ = {isa = PBXBuildFile; fileRef = E195679409E7CF1200B89D13 /* Unicode.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    490492                D21202290AD4310C00ED79B6 /* DateMath.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DateMath.h; sourceTree = "<group>"; };
    491493                E11D51750B2E798D0056C188 /* StringExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringExtras.h; sourceTree = "<group>"; };
     494                E178633F0D9BEC0000D74E75 /* InitializeThreading.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InitializeThreading.h; sourceTree = "<group>"; };
     495                E178636C0D9BEEC300D74E75 /* InitializeThreading.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InitializeThreading.cpp; sourceTree = "<group>"; };
    492496                E195678F09E7CF1200B89D13 /* UnicodeIcu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnicodeIcu.h; sourceTree = "<group>"; };
    493497                E195679409E7CF1200B89D13 /* Unicode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Unicode.h; sourceTree = "<group>"; };
     
    836840                                933A349D038AE80F008635CE /* identifier.cpp */,
    837841                                933A349A038AE7C6008635CE /* identifier.h */,
     842                                E178636C0D9BEEC300D74E75 /* InitializeThreading.cpp */,
     843                                E178633F0D9BEC0000D74E75 /* InitializeThreading.h */,
    838844                                F692A8610255597D01FF60F7 /* internal.cpp */,
    839845                                F692A8620255597D01FF60F7 /* internal.h */,
     
    10941100                                E1EE79280D6C964500FEA3BA /* Locker.h in Headers */,
    10951101                                E1A862AB0D7EBB7D001EC6AA /* Collator.h in Headers */,
     1102                                E17863400D9BEC0000D74E75 /* InitializeThreading.h in Headers */,
    10961103                        );
    10971104                        runOnlyForDeploymentPostprocessing = 0;
     
    13461353                                E1A862A90D7EBB76001EC6AA /* CollatorICU.cpp in Sources */,
    13471354                                E1A862D60D7F2B5C001EC6AA /* CollatorDefault.cpp in Sources */,
     1355                                E178636D0D9BEEC300D74E75 /* InitializeThreading.cpp in Sources */,
    13481356                        );
    13491357                        runOnlyForDeploymentPostprocessing = 0;
Note: See TracChangeset for help on using the changeset viewer.