Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(757)

Unified Diff: src/math.js

Issue 78813003: Add trigonometric table to the snapshot. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/math.js
diff --git a/src/math.js b/src/math.js
index 2df0ec2a5f4a442e998afafcddc2c5e542b0da5b..8e21bee230db9991ad53036fed723f83485dc7f7 100644
--- a/src/math.js
+++ b/src/math.js
@@ -78,9 +78,7 @@ function MathCeil(x) {
}
// ECMA 262 - 15.8.2.7
-function MathCos(x) {
- return MathCosImpl(x);
-}
+var MathCos;
// ECMA 262 - 15.8.2.8
function MathExp(x) {
@@ -178,9 +176,7 @@ function MathRound(x) {
}
// ECMA 262 - 15.8.2.16
-function MathSin(x) {
- return MathSinImpl(x);
-}
+var MathSin;
// ECMA 262 - 15.8.2.17
function MathSqrt(x) {
@@ -189,7 +185,7 @@ function MathSqrt(x) {
// ECMA 262 - 15.8.2.18
function MathTan(x) {
- return MathSinImpl(x) / MathCosImpl(x);
+ return MathSin(x) / MathCos(x);
}
// Non-standard extension.
@@ -198,18 +194,6 @@ function MathImul(x, y) {
}
-var MathSinImpl = function(x) {
- InitTrigonometricFunctions();
- return MathSinImpl(x);
-}
-
-
-var MathCosImpl = function(x) {
- InitTrigonometricFunctions();
- return MathCosImpl(x);
-}
-
-
var InitTrigonometricFunctions;
@@ -230,8 +214,11 @@ function SetupTrigonometricFunctions() {
// Note that pi_half > pi_half_1 + pi_half_2
var pi_half_1 = 1.570796325802803040; // 0x00000054fb21f93f
var pi_half_2 = 9.920935796805404252e-10; // 0x3326a611460b113e
- var table_sin;
- var table_cos_interval;
+
+ var table_sin = new InternalDoubleArray(samples + 2);
+ var table_cos_interval = new InternalDoubleArray(samples + 2);
+ %PopulateTrigonometricTable(table_sin, table_cos_interval, samples);
+
// This implements sine using the following algorithm.
// 1) Multiplication takes care of to-number conversion.
@@ -283,29 +270,19 @@ function SetupTrigonometricFunctions() {
* (1 - (phase & 2)) + 0;
}
- var MathSinInterpolation = function(x) {
+ MathSin = function(x) {
x = x * 1; // Convert to number and deal with -0.
if (%_IsMinusZero(x)) return x;
return Interpolation(x, 0);
}
// Cosine is sine with a phase offset.
- var MathCosInterpolation = function(x) {
+ MathCos = function(x) {
x = MathAbs(x); // Convert to number and get rid of -0.
return Interpolation(x, 1);
};
%SetInlineBuiltinFlag(Interpolation);
- %SetInlineBuiltinFlag(MathSinInterpolation);
- %SetInlineBuiltinFlag(MathCosInterpolation);
-
- InitTrigonometricFunctions = function() {
- table_sin = new global.Float64Array(samples + 2);
- table_cos_interval = new global.Float64Array(samples + 2);
- %PopulateTrigonometricTable(table_sin, table_cos_interval, samples);
- MathSinImpl = MathSinInterpolation;
- MathCosImpl = MathCosInterpolation;
- }
}
SetupTrigonometricFunctions();
« src/code-stubs.cc ('K') | « src/ia32/code-stubs-ia32.cc ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698