fpizlo@apple.com | 4c09900 | 2012-01-04 00:06:42 +0000 | [diff] [blame] | 1 | description( |
| 2 | "This tests that inlining a function that does not use this does not result in this being lost entirely." |
| 3 | ); |
| 4 | |
| 5 | function foo(a, b) { |
| 6 | return a + b; |
| 7 | } |
| 8 | |
| 9 | function bar(a, b) { |
| 10 | return this.f + a + b; |
| 11 | } |
| 12 | |
| 13 | function baz(o, a, b) { |
| 14 | return o.stuff(a, b); |
| 15 | } |
| 16 | |
| 17 | var functionToCall = foo; |
| 18 | var offset = 0; |
| 19 | for (var i = 0; i < 1000; ++i) { |
| 20 | if (i == 600) { |
| 21 | functionToCall = bar; |
| 22 | offset = 42; |
| 23 | } |
| 24 | |
| 25 | // Create some bizzare object to prevent method_check optimizations, since those will result in |
| 26 | // a failure while the function is still live. |
| 27 | var object = {}; |
| 28 | object["a" + i] = i; |
| 29 | object.stuff = functionToCall; |
| 30 | object.f = 42; |
| 31 | |
| 32 | shouldBe("baz(object, " + i + ", " + (i * 2) + ")", "" + (offset + i + i * 2)); |
| 33 | } |
| 34 | |