4 ms·
The claim that IE is legit hinges on the diffs causing a valid bug in IE's optimization code (e.g. deadcode inside deadcode prevents the latter being optimized
by moconnor 16y ago
The claim that IE is legit hinges on the diffs causing a valid bug in IE's optimization code (e.g. deadcode inside deadcode prevents the latter being optimized out), versus foul play in the engine (a hard-coded case for this benchmark).
Can you find any variation on the benchmark code that still allows IE to optimize it, or does it only optimize the exact form of the code used in the benchmark suite?
- cheald 16y agoI changed variable names and declaration order, the number of loops in that inner for loop, and other such things that could possibly change the bytecode (to what effect, I don't know - I'm not a JS VM engineer, obviously) without changing the operations actually performed. I don't have an explanation for this, though (maybe variable initialization counts as "run up until here"?): Runs fast (11ms): --- tests/sunspider-0.9.1/math-cordic.js 2010-11-17 00:55:29.000000000 -0700 +++ tests/sunspider-0.9.1-deadcode/math-cordic.js 2010-11-17 01:42:43.000000000 -0700 @@ -56,12 +56,14 @@ var TargetAngle; var CurrAngle; var Step; + var foo; X = FIXED(AG_CONST); /* AG_CONST * cos(0) */ Y = 0; /* AG_CONST * sin(0) */ TargetAngle = FIXED(28.027); CurrAngle = 0; + foo = 1; for (Step = 0; Step < 12; Step++) { var NewX; if (TargetAngle > CurrAngle) { But if I assign foo after the for loop, it runs slow: --- tests/sunspider-0.9.1/math-cordic.js 2010-11-17 00:55:29.000000000 -0700 +++ tests/sunspider-0.9.1-deadcode/math-cordic.js 2010-11-17 01:43:20.000000000 -0700 @@ -56,6 +56,7 @@ var TargetAngle; var CurrAngle; var Step; + var foo; X = FIXED(AG_CONST); /* AG_CONST * cos(0) */ Y = 0; /* AG_CONST * sin(0) */ @@ -76,6 +77,7 @@ CurrAngle -= Angles[Step]; } } + foo = 1; } If I assign foo inside the for loop, it runs fast: --- tests/sunspider-0.9.1/math-cordic.js 2010-11-17 00:55:29.000000000 -0700 +++ tests/sunspider-0.9.1-deadcode/math-cordic.js 2010-11-17 01:44:41.000000000 -0700 @@ -56,6 +56,7 @@ var TargetAngle; var CurrAngle; var Step; + var foo; X = FIXED(AG_CONST); /* AG_CONST * cos(0) */ Y = 0; /* AG_CONST * sin(0) */ @@ -63,6 +64,7 @@ TargetAngle = FIXED(28.027); CurrAngle = 0; for (Step = 0; Step < 12; Step++) { + foo = 1; var NewX; if (TargetAngle > CurrAngle) { NewX = X - (Y >> Step); Color me boggled.