| Index: test/mjsunit/regress/regress-201590.js
|
| diff --git a/test/mjsunit/compiler/multiply-sub.js b/test/mjsunit/regress/regress-201590.js
|
| similarity index 60%
|
| copy from test/mjsunit/compiler/multiply-sub.js
|
| copy to test/mjsunit/regress/regress-201590.js
|
| index 4793181d47a2b4a2b2390f5049758e651ef1ec1c..0e7ba572332eca6f1ccc49d76ade086b411a24da 100644
|
| --- a/test/mjsunit/compiler/multiply-sub.js
|
| +++ b/test/mjsunit/regress/regress-201590.js
|
| @@ -26,31 +26,41 @@
|
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
| // Flags: --allow-natives-syntax
|
| -// Test expressions that can be computed with a multiply-add instruction.
|
|
|
| -function f(a, b, c) {
|
| - return a - b * c;
|
| -}
|
| +var gdpRatio = 16/9;
|
|
|
| -function g(a, b, c) {
|
| - return a * b - c;
|
| +function Foo(initialX, initialY, initialScale, initialMapHeight) {
|
| + this.ORIGIN = { x: initialX, y: initialY };
|
| + this.scale = initialScale;
|
| + this.mapHeight = initialMapHeight;
|
| }
|
|
|
| -function h(a, b, c, d) {
|
| - return a * b - c * d;
|
| +Foo.prototype.bar = function (x, y, xOffset, yOffset) {
|
| + var tileHeight = 64 * 0.25 * this.scale,
|
| + tileWidth = 128 * 0.25 * this.scale,
|
| + xOffset = xOffset * 0.5 || 0,
|
| + yOffset = yOffset * 0.5 || 0;
|
| + var xPos = ((xOffset) * gdpRatio) + this.ORIGIN.x * this.scale -
|
| + ((y * tileWidth ) * gdpRatio) + ((x * tileWidth ) * gdpRatio);
|
| + var yPos = ((yOffset) * gdpRatio) + this.ORIGIN.y * this.scale +
|
| + ((y * tileHeight) * gdpRatio) + ((x * tileHeight) * gdpRatio);
|
| + xPos = xPos - Math.round(((tileWidth) * gdpRatio)) +
|
| + this.mapHeight * Math.round(((tileWidth) * gdpRatio));
|
| + return {
|
| + x: Math.floor(xPos),
|
| + y: Math.floor(yPos)
|
| + };
|
| }
|
|
|
| -assertEquals(-5.41, f(1.1, 2.1, 3.1));
|
| -assertEquals(-5.41, f(1.1, 2.1, 3.1));
|
| -%OptimizeFunctionOnNextCall(f);
|
| -assertEquals(-5.41, f(1.1, 2.1, 3.1));
|
| +var f = new Foo(10, 20, 2.5, 400);
|
|
|
| -assertEquals(8.36, g(2.2, 3.3, -1.1));
|
| -assertEquals(8.36, g(2.2, 3.3, -1.1));
|
| -%OptimizeFunctionOnNextCall(g);
|
| -assertEquals(8.36, g(2.2, 3.3, -1.1));
|
| +function baz() {
|
| + var b = f.bar(1.1, 2.2, 3.3, 4.4);
|
| + assertEquals(56529, b.x);
|
| + assertEquals(288, b.y);
|
| +}
|
|
|
| -assertEquals(-1.5, h(1.5, 3.0, 12, 0.5));
|
| -assertEquals(-1.5, h(1.5, 3.0, 12, 0.5));
|
| -%OptimizeFunctionOnNextCall(h);
|
| -assertEquals(-1.5, h(1.5, 3.0, 12, 0.5));
|
| +baz();
|
| +baz();
|
| +%OptimizeFunctionOnNextCall(Foo.prototype.bar);
|
| +baz();
|
|
|