blob: 25a76534357b06f9a57dea5824f467ba79bc2146 [file] [log] [blame]
fpizlo@apple.com4c099002012-01-04 00:06:42 +00001description(
2"This tests that inlining a function that does not use this does not result in this being lost entirely."
3);
4
5function foo(a, b) {
6 return a + b;
7}
8
9function bar(a, b) {
10 return this.f + a + b;
11}
12
13function baz(o, a, b) {
14 return o.stuff(a, b);
15}
16
17var functionToCall = foo;
18var offset = 0;
19for (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