| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Flags: --allow-natives-syntax --noverify-heap --noenable-slow-asserts | 5 // Flags: --allow-natives-syntax --noverify-heap --noenable-slow-asserts |
| 6 // Flags: --no-always-opt --crankshaft | |
| 7 | 6 |
| 8 // --noverify-heap and --noenable-slow-asserts are set because the test is too | 7 // --noverify-heap and --noenable-slow-asserts are set because the test is too |
| 9 // slow with it on. | 8 // slow with it on. |
| 10 | 9 |
| 11 assertFalse(isNeverOptimize()); | 10 // Ensure that keyed stores work, and optimized functions learn if the |
| 12 assertFalse(isAlwaysOptimize()); | 11 // store required change to dictionary mode. Verify that stores that grow |
| 13 | 12 // the array into large object space don't cause a deopt. |
| 14 // Ensure that keyed stores work, and optimized functions learn if the | |
| 15 // store required change to dictionary mode. Verify that stores that grow | |
| 16 // the array into large object space don't cause a deopt. | |
| 17 (function() { | 13 (function() { |
| 18 var a = []; | 14 var a = []; |
| 19 | 15 |
| 20 function foo(a, i) { | 16 function foo(a, i) { |
| 21 a[i] = 5.3; | 17 a[i] = 5.3; |
| 22 } | 18 } |
| 23 | 19 |
| 24 foo(a, 1); | 20 foo(a, 1); |
| 25 foo(a, 2); | 21 foo(a, 2); |
| 26 foo(a, 3); | 22 foo(a, 3); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 57 a[i] = 50; | 53 a[i] = 50; |
| 58 } | 54 } |
| 59 | 55 |
| 60 // The KeyedStoreIC will learn GROW_MODE. | 56 // The KeyedStoreIC will learn GROW_MODE. |
| 61 foo2(a, 10); | 57 foo2(a, 10); |
| 62 foo2(a, 12); | 58 foo2(a, 12); |
| 63 foo2(a, 31); | 59 foo2(a, 31); |
| 64 %OptimizeFunctionOnNextCall(foo2); | 60 %OptimizeFunctionOnNextCall(foo2); |
| 65 foo2(a, 40); | 61 foo2(a, 40); |
| 66 | 62 |
| 67 assertOptimized(foo2); | 63 // This test is way too slow without crankshaft. |
| 68 assertTrue(%HasFastSmiElements(a)); | 64 if (4 != %GetOptimizationStatus(foo2)) { |
| 65 assertOptimized(foo2); |
| 66 assertTrue(%HasFastSmiElements(a)); |
| 69 | 67 |
| 70 // Grow a large array into large object space through the keyed store | 68 // Grow a large array into large object space through the keyed store |
| 71 // without deoptimizing. Grow by 10s. If we set elements too sparsely, the | 69 // without deoptimizing. Grow by 10s. If we set elements too sparsely, the |
| 72 // array will convert to dictionary mode. | 70 // array will convert to dictionary mode. |
| 73 a = new Array(99999); | 71 a = new Array(99999); |
| 74 assertTrue(%HasFastSmiElements(a)); | 72 assertTrue(%HasFastSmiElements(a)); |
| 75 for (var i = 0; i < 263000; i += 10) { | 73 for (var i = 0; i < 263000; i += 10) { |
| 76 foo2(a, i); | 74 foo2(a, i); |
| 75 } |
| 76 |
| 77 // Verify that we are over 1 page in size, and foo2 remains optimized. |
| 78 // This means we've smoothly transitioned to allocating in large object |
| 79 // space. |
| 80 assertTrue(%HasFastSmiElements(a)); |
| 81 assertTrue(a.length * 4 > (1024 * 1024)); |
| 82 assertOptimized(foo2); |
| 77 } | 83 } |
| 78 | 84 |
| 79 // Verify that we are over 1 page in size, and foo2 remains optimized. | |
| 80 // This means we've smoothly transitioned to allocating in large object | |
| 81 // space. | |
| 82 assertTrue(%HasFastSmiElements(a)); | |
| 83 assertTrue(a.length * 4 > (1024 * 1024)); | |
| 84 assertOptimized(foo2); | |
| 85 | |
| 86 %ClearFunctionTypeFeedback(foo2); | 85 %ClearFunctionTypeFeedback(foo2); |
| 87 })(); | 86 })(); |
| OLD | NEW |