blob: aea781a09a50c0f383c5ff751f22296647e9476a [file] [log] [blame]
fpizlo@apple.come0480cf2012-09-26 02:56:19 +00001description(
2"Tests that ArrayPop is known to the DFG to be a side effect."
3);
4
5function foo(a, b) {
6 var result = a.f;
7 result += b.pop();
8 result += a.g;
9 return result;
10}
11
oliver@apple.com382f5622013-07-25 04:01:50 +000012noInline(foo);
13silentTestPass = true;
14
fpizlo@apple.come0480cf2012-09-26 02:56:19 +000015var ouches = 0;
oliver@apple.com382f5622013-07-25 04:01:50 +000016for (var i = 0; i < 200; i = dfgIncrement({f:foo, i:i + 1, n:100})) {
fpizlo@apple.come0480cf2012-09-26 02:56:19 +000017 var a = {f:1, g:2};
18 var b = [];
19 var expected;
20 if (i < 150) {
21 // Ensure that we always transition the array's structure to one that indicates
22 // that we have array storage.
23 b.__defineGetter__("0", function() {
24 testFailed("Should never get here");
25 });
26 b.length = 0;
27 b[0] = 42;
28 expected = "45";
29 } else {
30 b.__defineGetter__("0", function() {
31 debug("Ouch!");
32 ouches++;
33 delete a.g;
34 a.h = 43;
35 return 5;
36 });
37 expected = "0/0";
38 }
39 shouldBe("foo(a, b)", expected);
40}
41
42shouldBe("ouches", "50");