OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 112 |
113 // If the argument isn't a smi, things should still work. | 113 // If the argument isn't a smi, things should still work. |
114 a = bar("oops"); | 114 a = bar("oops"); |
115 assertOptimized(bar); | 115 assertOptimized(bar); |
116 assertKind(elements_kind.fast, a); | 116 assertKind(elements_kind.fast, a); |
117 | 117 |
118 function barn(one, two, three) { | 118 function barn(one, two, three) { |
119 return new Array(one, two, three); | 119 return new Array(one, two, three); |
120 } | 120 } |
121 | 121 |
122 barn(1, 2, 3); | 122 a = barn(1, 2, 3); |
123 barn(1, 2, 3); | 123 a[1] = "a string"; |
| 124 a = barn(1, 2, 3); |
| 125 assertKind(elements_kind.fast, a); |
124 %OptimizeFunctionOnNextCall(barn); | 126 %OptimizeFunctionOnNextCall(barn); |
125 barn(1, 2, 3); | 127 a = barn(1, 2, 3); |
| 128 assertKind(elements_kind.fast, a); |
126 assertOptimized(barn); | 129 assertOptimized(barn); |
127 a = barn(1, "oops", 3); | 130 a = barn(1, "oops", 3); |
128 assertOptimized(barn); | 131 assertOptimized(barn); |
129 })(); | 132 })(); |
130 | 133 |
131 | 134 |
132 // Test: When a method with array constructor is crankshafted, the type | 135 // Test: When a method with array constructor is crankshafted, the type |
133 // feedback for elements kind is baked in. Verify that transitions don't | 136 // feedback for elements kind is baked in. Verify that transitions don't |
134 // change it anymore | 137 // change it anymore |
135 (function() { | 138 (function() { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 bar(size)[0] = 'string'; | 203 bar(size)[0] = 'string'; |
201 var res = bar(size); | 204 var res = bar(size); |
202 assertKind(elements_kind.fast, bar(size)); | 205 assertKind(elements_kind.fast, bar(size)); |
203 %OptimizeFunctionOnNextCall(bar); | 206 %OptimizeFunctionOnNextCall(bar); |
204 assertKind(elements_kind.fast, bar(size)); | 207 assertKind(elements_kind.fast, bar(size)); |
205 // But there is a limit, based on the size of the old generation, currently | 208 // But there is a limit, based on the size of the old generation, currently |
206 // 22937600, but double it to prevent the test being too brittle. | 209 // 22937600, but double it to prevent the test being too brittle. |
207 var large_size = 22937600 * 2; | 210 var large_size = 22937600 * 2; |
208 assertKind(elements_kind.dictionary, bar(large_size)); | 211 assertKind(elements_kind.dictionary, bar(large_size)); |
209 })(); | 212 })(); |
OLD | NEW |