Add result caching for Math.cos
https://bugs.webkit.org/show_bug.cgi?id=123255
Patch by Iago Toral Quiroga <itoral@igalia.com> on 2013-10-30
Reviewed by Brent Fulgham.
* runtime/MathObject.cpp:
(JSC::mathProtoFuncCos):
* runtime/VM.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@158281 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog
index 864c9a2..ed36c0a 100644
--- a/Source/JavaScriptCore/ChangeLog
+++ b/Source/JavaScriptCore/ChangeLog
@@ -1,3 +1,14 @@
+2013-10-30 Iago Toral Quiroga <itoral@igalia.com>
+
+ Add result caching for Math.cos
+ https://bugs.webkit.org/show_bug.cgi?id=123255
+
+ Reviewed by Brent Fulgham.
+
+ * runtime/MathObject.cpp:
+ (JSC::mathProtoFuncCos):
+ * runtime/VM.h:
+
2013-10-30 Alex Christensen <achristensen@webkit.org>
Disabled JIT on Win64.
diff --git a/Source/JavaScriptCore/runtime/MathObject.cpp b/Source/JavaScriptCore/runtime/MathObject.cpp
index 1ff2f91..ebcdf29 100644
--- a/Source/JavaScriptCore/runtime/MathObject.cpp
+++ b/Source/JavaScriptCore/runtime/MathObject.cpp
@@ -136,7 +136,7 @@
EncodedJSValue JSC_HOST_CALL mathProtoFuncCos(ExecState* exec)
{
- return JSValue::encode(jsDoubleNumber(cos(exec->argument(0).toNumber(exec))));
+ return JSValue::encode(exec->vm().cachedCos(exec->argument(0).toNumber(exec)));
}
EncodedJSValue JSC_HOST_CALL mathProtoFuncExp(ExecState* exec)
diff --git a/Source/JavaScriptCore/runtime/VM.h b/Source/JavaScriptCore/runtime/VM.h
index 8ecc712..280c74f 100644
--- a/Source/JavaScriptCore/runtime/VM.h
+++ b/Source/JavaScriptCore/runtime/VM.h
@@ -420,6 +420,7 @@
ThreadIdentifier exclusiveThread;
CachedTranscendentalFunction<std::sin> cachedSin;
+ CachedTranscendentalFunction<std::cos> cachedCos;
JS_EXPORT_PRIVATE void resetDateCache();