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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
106 function test_adaptation() { | 106 function test_adaptation() { |
107 adapt2to4(1, 2); | 107 adapt2to4(1, 2); |
108 adapt4to2(1, 2, 3, 4); | 108 adapt4to2(1, 2, 3, 4); |
109 } | 109 } |
110 | 110 |
111 test_adaptation(); | 111 test_adaptation(); |
112 test_adaptation(); | 112 test_adaptation(); |
113 %OptimizeFunctionOnNextCall(test_adaptation); | 113 %OptimizeFunctionOnNextCall(test_adaptation); |
114 test_adaptation(); | 114 test_adaptation(); |
115 })(); | 115 })(); |
116 | |
117 // Test arguments access from the inlined function. | |
118 function uninlinable(v) { | |
119 assertEquals(0, v); | |
120 try { } catch (e) { } | |
121 return 0; | |
122 } | |
123 | |
124 function toarr_inner() { | |
125 var a = arguments; | |
126 var marker = a[0]; | |
127 uninlinable(uninlinable(0, 0), marker.x); | |
128 | |
129 var r = new Array(); | |
130 for (var i = a.length - 1; i >= 1; i--) { | |
131 r.push(a[i]); | |
132 } | |
133 | |
134 return r; | |
135 } | |
136 | |
137 function toarr(marker, a, b, c) { | |
138 return toarr_inner(marker, a/2, b/2, c/2); | |
fschneider
2012/03/22 10:30:19
Please also add a test where inlining happens insi
Vyacheslav Egorov (Chromium)
2012/03/22 12:24:53
Done.
| |
139 } | |
140 | |
141 var marker = { x: 0 }; | |
142 assertArrayEquals([3, 2, 1], toarr(marker, 2, 4, 6)); | |
143 assertArrayEquals([3, 2, 1], toarr(marker, 2, 4, 6)); | |
144 %OptimizeFunctionOnNextCall(toarr); | |
145 assertArrayEquals([3, 2, 1], toarr(marker, 2, 4, 6)); | |
146 delete marker.x; | |
147 assertArrayEquals([3, 2, 1], toarr(marker, 2, 4, 6)); | |
OLD | NEW |