fpizlo@apple.com | e0480cf | 2012-09-26 02:56:19 +0000 | [diff] [blame] | 1 | description( |
| 2 | "Tests that ArrayPop is known to the DFG to be a side effect." |
| 3 | ); |
| 4 | |
| 5 | function foo(a, b) { |
| 6 | var result = a.f; |
| 7 | result += b.pop(); |
| 8 | result += a.g; |
| 9 | return result; |
| 10 | } |
| 11 | |
oliver@apple.com | 382f562 | 2013-07-25 04:01:50 +0000 | [diff] [blame] | 12 | noInline(foo); |
| 13 | silentTestPass = true; |
| 14 | |
fpizlo@apple.com | e0480cf | 2012-09-26 02:56:19 +0000 | [diff] [blame] | 15 | var ouches = 0; |
oliver@apple.com | 382f562 | 2013-07-25 04:01:50 +0000 | [diff] [blame] | 16 | for (var i = 0; i < 200; i = dfgIncrement({f:foo, i:i + 1, n:100})) { |
fpizlo@apple.com | e0480cf | 2012-09-26 02:56:19 +0000 | [diff] [blame] | 17 | 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 | |
| 42 | shouldBe("ouches", "50"); |