• ap@webkit.org's avatar
    Reviewed by Sam Weinig. · 8027278e
    ap@webkit.org authored
            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:
            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.
            Check for USE(MULTIPLE_THREADS), not dtoa legacy MULTIPLE_THREADS.
            * kjs/InitializeThreading.cpp: Added.
            * 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.
            * JavaScriptCore.exp: Export KJS::initializeThreading.
            * GNUmakefile.am:
            * JavaScriptCore.exp:
            * JavaScriptCore.pri:
            * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
            * JavaScriptCoreSources.bkl:
            * JavaScriptCore.xcodeproj/project.pbxproj:
            Added InitializeThreading.{h,cpp}.
            * 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.
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@31404 268f45cc-cd09-0410-ab3c-d52691b4dbfc
InitializeThreading.cpp 1.78 KB