Ignore:
Timestamp:
May 6, 2010, 9:58:02 PM (15 years ago)
Author:
[email protected]
Message:

Bug 38714 - Add result caching for Math.sin

Reviewed by Geoff Garen.

Math.sin is frequently called with the same operand, caching the result should
improve performance. CachedTranscendentalFunction adds a generic mechanism to
cache results for pure functions with the signature "double func(double)", and
where NaN maps to NaN.

CachedTranscendentalFunction uses a very simple hash function designed to be
fast to execute since we cannot cache the result, and trivial to JIT generate,
should we wish to do so.

  • JavaScriptCore.xcodeproj/project.pbxproj:
  • runtime/CachedTranscendentalFunction.h: Added.

(JSC::CachedTranscendentalFunction::CachedTranscendentalFunction):
(JSC::CachedTranscendentalFunction::~CachedTranscendentalFunction):
(JSC::CachedTranscendentalFunction::operator()):
(JSC::CachedTranscendentalFunction::initialize):
(JSC::CachedTranscendentalFunction::hash):

  • runtime/JSGlobalData.h:
  • runtime/MathObject.cpp:

(JSC::mathProtoFuncSin):

  • wtf/Platform.h:
File:
1 edited

Legend:

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

    r58712 r58935  
    212212                8698B86910D44D9400D8D01B /* StringBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 8698B86810D44D9400D8D01B /* StringBuilder.h */; settings = {ATTRIBUTES = (Private, ); }; };
    213213                8698BB3910D86BAF00D8D01B /* UStringImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 8698BB3710D86BAF00D8D01B /* UStringImpl.h */; settings = {ATTRIBUTES = (Private, ); }; };
     214                869D04AF1193B54D00803475 /* CachedTranscendentalFunction.h in Headers */ = {isa = PBXBuildFile; fileRef = 869D04AE1193B54D00803475 /* CachedTranscendentalFunction.h */; settings = {ATTRIBUTES = (Private, ); }; };
    214215                869EBCB70E8C6D4A008722CC /* ResultType.h in Headers */ = {isa = PBXBuildFile; fileRef = 869EBCB60E8C6D4A008722CC /* ResultType.h */; settings = {ATTRIBUTES = (Private, ); }; };
    215216                86A90ED00EE7D51F00AB350D /* JITArithmetic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86A90ECF0EE7D51F00AB350D /* JITArithmetic.cpp */; };
     
    764765                8698B86810D44D9400D8D01B /* StringBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringBuilder.h; sourceTree = "<group>"; };
    765766                8698BB3710D86BAF00D8D01B /* UStringImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UStringImpl.h; sourceTree = "<group>"; };
     767                869D04AE1193B54D00803475 /* CachedTranscendentalFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedTranscendentalFunction.h; sourceTree = "<group>"; };
    766768                869EBCB60E8C6D4A008722CC /* ResultType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResultType.h; sourceTree = "<group>"; };
    767769                86A90ECF0EE7D51F00AB350D /* JITArithmetic.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JITArithmetic.cpp; sourceTree = "<group>"; };
     
    15241526                                BC7952340E15EB5600A898AB /* BooleanPrototype.cpp */,
    15251527                                BC7952350E15EB5600A898AB /* BooleanPrototype.h */,
     1528                                869D04AE1193B54D00803475 /* CachedTranscendentalFunction.h */,
    15261529                                BCA62DFE0E2826230004F30D /* CallData.cpp */,
    15271530                                145C507F0D9DF63B0088F6B9 /* CallData.h */,
     
    21272130                                A7386554118697B400540279 /* SpecializedThunkJIT.h in Headers */,
    21282131                                A7386556118697B400540279 /* ThunkGenerators.h in Headers */,
     2132                                869D04AF1193B54D00803475 /* CachedTranscendentalFunction.h in Headers */,
    21292133                        );
    21302134                        runOnlyForDeploymentPostprocessing = 0;
Note: See TracChangeset for help on using the changeset viewer.