| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 assertKind(elements_kind.fast_double, b); | 77 assertKind(elements_kind.fast_double, b); |
| 78 assertOptimized(bar0); | 78 assertOptimized(bar0); |
| 79 // bar0 should deopt | 79 // bar0 should deopt |
| 80 b = bar0(Object); | 80 b = bar0(Object); |
| 81 assertUnoptimized(bar0) | 81 assertUnoptimized(bar0) |
| 82 // When it's re-optimized, we should call through the full stub | 82 // When it's re-optimized, we should call through the full stub |
| 83 bar0(Array); | 83 bar0(Array); |
| 84 %OptimizeFunctionOnNextCall(bar0); | 84 %OptimizeFunctionOnNextCall(bar0); |
| 85 b = bar0(Array); | 85 b = bar0(Array); |
| 86 // This only makes sense to test if we allow crankshafting | 86 // This only makes sense to test if we allow crankshafting |
| 87 if (4 != %GetOptimizationStatus(bar0)) { | 87 var opt_status = %GetOptimizationStatus(bar0); |
| 88 if ((opt_status & V8OptimizationStatus.kNeverOptimize) === 0) { |
| 88 // We also lost our ability to record kind feedback, as the site | 89 // We also lost our ability to record kind feedback, as the site |
| 89 // is megamorphic now. | 90 // is megamorphic now. |
| 90 assertKind(elements_kind.fast_smi_only, b); | 91 assertKind(elements_kind.fast_smi_only, b); |
| 91 assertOptimized(bar0); | 92 assertOptimized(bar0); |
| 92 b[0] = 3.5; | 93 b[0] = 3.5; |
| 93 c = bar0(Array); | 94 c = bar0(Array); |
| 94 assertKind(elements_kind.fast_smi_only, c); | 95 assertKind(elements_kind.fast_smi_only, c); |
| 95 } | 96 } |
| 96 })(); | 97 })(); |
| 97 | 98 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 // change it anymore | 138 // change it anymore |
| 138 (function() { | 139 (function() { |
| 139 function bar() { | 140 function bar() { |
| 140 return new Array(); | 141 return new Array(); |
| 141 } | 142 } |
| 142 a = bar(); | 143 a = bar(); |
| 143 bar(); | 144 bar(); |
| 144 %OptimizeFunctionOnNextCall(bar); | 145 %OptimizeFunctionOnNextCall(bar); |
| 145 b = bar(); | 146 b = bar(); |
| 146 // This only makes sense to test if we allow crankshafting | 147 // This only makes sense to test if we allow crankshafting |
| 147 if (4 != %GetOptimizationStatus(bar)) { | 148 var opt_status = %GetOptimizationStatus(bar); |
| 149 if ((opt_status & V8OptimizationStatus.kNeverOptimize) === 0) { |
| 148 assertOptimized(bar); | 150 assertOptimized(bar); |
| 149 %DebugPrint(3); | 151 %DebugPrint(3); |
| 150 b[0] = 3.5; | 152 b[0] = 3.5; |
| 151 c = bar(); | 153 c = bar(); |
| 152 assertKind(elements_kind.fast_smi_only, c); | 154 assertKind(elements_kind.fast_smi_only, c); |
| 153 assertOptimized(bar); | 155 assertOptimized(bar); |
| 154 } | 156 } |
| 155 })(); | 157 })(); |
| 156 | 158 |
| 157 | 159 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 186 assertFalse(isHoley(a)); | 188 assertFalse(isHoley(a)); |
| 187 a = bar(1); // ouch! | 189 a = bar(1); // ouch! |
| 188 assertOptimized(bar); | 190 assertOptimized(bar); |
| 189 assertTrue(isHoley(a)); | 191 assertTrue(isHoley(a)); |
| 190 a = bar(100); | 192 a = bar(100); |
| 191 assertTrue(isHoley(a)); | 193 assertTrue(isHoley(a)); |
| 192 a = bar(0); | 194 a = bar(0); |
| 193 assertOptimized(bar); | 195 assertOptimized(bar); |
| 194 // Crankshafted functions don't use mementos, so feedback still | 196 // Crankshafted functions don't use mementos, so feedback still |
| 195 // indicates a packed array is desired. (unless --nocrankshaft is in use). | 197 // indicates a packed array is desired. (unless --nocrankshaft is in use). |
| 196 if (4 != %GetOptimizationStatus(bar)) { | 198 var opt_status = %GetOptimizationStatus(bar); |
| 199 if ((opt_status & V8OptimizationStatus.kNeverOptimize) === 0) { |
| 197 assertFalse(isHoley(a)); | 200 assertFalse(isHoley(a)); |
| 198 } | 201 } |
| 199 })(); | 202 })(); |
| 200 | 203 |
| 201 // Test: Make sure that crankshaft continues with feedback for large arrays. | 204 // Test: Make sure that crankshaft continues with feedback for large arrays. |
| 202 (function() { | 205 (function() { |
| 203 function bar(len) { return new Array(len); } | 206 function bar(len) { return new Array(len); } |
| 204 var size = 100001; | 207 var size = 100001; |
| 205 // Perform a gc, because we are allocating a very large array and if a gc | 208 // Perform a gc, because we are allocating a very large array and if a gc |
| 206 // happens during the allocation we could lose our memento. | 209 // happens during the allocation we could lose our memento. |
| 207 gc(); | 210 gc(); |
| 208 bar(size)[0] = 'string'; | 211 bar(size)[0] = 'string'; |
| 209 var res = bar(size); | 212 var res = bar(size); |
| 210 assertKind(elements_kind.fast, bar(size)); | 213 assertKind(elements_kind.fast, bar(size)); |
| 211 %OptimizeFunctionOnNextCall(bar); | 214 %OptimizeFunctionOnNextCall(bar); |
| 212 assertKind(elements_kind.fast, bar(size)); | 215 assertKind(elements_kind.fast, bar(size)); |
| 213 // But there is a limit, based on the size of the old generation, currently | 216 // But there is a limit, based on the size of the old generation, currently |
| 214 // 22937600, but double it to prevent the test being too brittle. | 217 // 22937600, but double it to prevent the test being too brittle. |
| 215 var large_size = 22937600 * 2; | 218 var large_size = 22937600 * 2; |
| 216 assertKind(elements_kind.dictionary, bar(large_size)); | 219 assertKind(elements_kind.dictionary, bar(large_size)); |
| 217 })(); | 220 })(); |
| OLD | NEW |