fpizlo@apple.com | 3aef57f | 2012-06-30 19:28:26 +0000 | [diff] [blame] | 1 | description( |
| 2 | "Tests that attempts by the DFG simplification to short-circuit a Phantom to a GetLocal on a variable that is SetLocal'd in the same block, and where the predecessor block(s) make no mention of that variable, do not result in crashes." |
| 3 | ); |
| 4 | |
| 5 | function baz() { |
| 6 | // Do something that prevents inlining. |
| 7 | return function() { } |
| 8 | } |
| 9 | |
| 10 | function stuff(z) { } |
| 11 | |
| 12 | function foo(x, y) { |
| 13 | var a = arguments; // Force arguments to be captured, so that x is captured. |
| 14 | baz(); |
| 15 | var z = x; |
| 16 | stuff(z); // Force a Flush, and then a Phantom on the GetLocal of x. |
| 17 | return 42; |
| 18 | } |
| 19 | |
| 20 | var o = { |
| 21 | g: function(x) { } |
| 22 | }; |
| 23 | |
| 24 | function thingy(o) { |
| 25 | var p = {}; |
| 26 | var result; |
| 27 | // Trick to delay control flow graph simplification until after the flush of x above gets turned into a phantom. |
| 28 | if (o.g) |
| 29 | p.f = true; |
| 30 | if (p.f) { |
| 31 | // Basic block that stores to x in foo(), which is a captured variable, with |
| 32 | // the predecessor block making no mention of x. |
| 33 | result = foo("hello", 2); |
| 34 | } |
| 35 | return result; |
| 36 | } |
| 37 | |
fpizlo@apple.com | 299a8ee | 2013-09-05 15:54:07 +0000 | [diff] [blame] | 38 | dfgShouldBe(thingy, "thingy(o)", "42"); |