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/runtime/MathObject.cpp

    r57978 r58935  
    224224JSValue JSC_HOST_CALL mathProtoFuncSin(ExecState* exec, JSObject*, JSValue, const ArgList& args)
    225225{
    226     return jsDoubleNumber(exec, sin(args.at(0).toNumber(exec)));
     226    return exec->globalData().cachedSin(exec, args.at(0).toNumber(exec));
    227227}
    228228
Note: See TracChangeset for help on using the changeset viewer.