OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 // Check that %NewObjectFromBound looks at correct frame for inlined function. | 49 // Check that %NewObjectFromBound looks at correct frame for inlined function. |
50 function ff(x) { } | 50 function ff(x) { } |
51 function h(z2, y2) { | 51 function h(z2, y2) { |
52 var local_z = z2 >> 1; | 52 var local_z = z2 >> 1; |
53 ff(local_z); | 53 ff(local_z); |
54 var local_y = y2 >> 1; | 54 var local_y = y2 >> 1; |
55 ff(local_y); | 55 ff(local_y); |
56 return f(local_y, local_z); /* f should be inlined into h */ | 56 return f(local_y, local_z); /* f should be inlined into h */ |
57 } | 57 } |
58 | 58 |
59 for (var i = 0; i < 100000; i++) f(2, 3); | 59 for (var i = 0; i < 5; i++) f(2, 3); |
| 60 %OptimizeFunctionOnNextCall(f); |
| 61 f(2, 3); |
60 | 62 |
61 for (var i = 0; i < 100000; i++) g(3, 2); | 63 for (var i = 0; i < 5; i++) g(3, 2); |
| 64 %OptimizeFunctionOnNextCall(g); |
| 65 g(3, 2); |
62 | 66 |
63 for (var i = 0; i < 100000; i++) h(6, 4); | 67 for (var i = 0; i < 5; i++) h(6, 4); |
| 68 %OptimizeFunctionOnNextCall(h); |
| 69 h(6, 4); |
64 | 70 |
65 // Check that %_IsConstructCall returns correct value when inlined | 71 // Check that %_IsConstructCall returns correct value when inlined |
66 var NON_CONSTRUCT_MARKER = {}; | 72 var NON_CONSTRUCT_MARKER = {}; |
67 var CONSTRUCT_MARKER = {}; | 73 var CONSTRUCT_MARKER = {}; |
68 function baz() { | 74 function baz() { |
69 return (!%_IsConstructCall()) ? NON_CONSTRUCT_MARKER : CONSTRUCT_MARKER; | 75 return (!%_IsConstructCall()) ? NON_CONSTRUCT_MARKER : CONSTRUCT_MARKER; |
70 } | 76 } |
71 | 77 |
72 function bar(x, y, z) { | 78 function bar(x, y, z) { |
73 var non_construct = baz(); /* baz should be inlined */ | 79 var non_construct = baz(); /* baz should be inlined */ |
74 assertEquals(non_construct, NON_CONSTRUCT_MARKER); | 80 assertEquals(non_construct, NON_CONSTRUCT_MARKER); |
75 var construct = new baz(); | 81 var construct = new baz(); |
76 assertEquals(construct, CONSTRUCT_MARKER); | 82 assertEquals(construct, CONSTRUCT_MARKER); |
77 } | 83 } |
78 | 84 |
79 for (var i = 0; i < 100000; i++) new bar(1, 2, 3); | 85 for (var i = 0; i < 5; i++) new bar(1, 2, 3); |
| 86 %OptimizeFunctionOnNextCall(bar); |
| 87 bar(1, 2, 3); |
OLD | NEW |