Chromium Code Reviews| Index: test/mjsunit/optimized-foreach.js |
| diff --git a/test/mjsunit/optimized-foreach.js b/test/mjsunit/optimized-foreach.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..dd7ed753c46dce84760df84eceb637694bec0895 |
| --- /dev/null |
| +++ b/test/mjsunit/optimized-foreach.js |
| @@ -0,0 +1,72 @@ |
| +// Copyright 2017 the V8 project authors. All rights reserved. |
|
Michael Starzinger
2017/05/24 13:54:59
We should add test coverage for the following:
- C
danno
2017/06/06 12:04:53
Done.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +// Flags: --allow-natives-syntax --expose-gc |
| + |
| +var a = [0, 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,0,0]; |
| +var b = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]; |
| +var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]; |
| + |
| +(function() { |
| + var result = 0; |
| + var eagerDeoptInCalled = function(deopt) { |
| + var sum = function(v,i,o) { |
| + result += v; |
| + if (i == 13 && deopt) { |
| + a.length = 25; |
| + } |
| + } |
| + a.forEach(sum); |
| + } |
| + eagerDeoptInCalled(); |
| + eagerDeoptInCalled(); |
| + %OptimizeFunctionOnNextCall(eagerDeoptInCalled); |
| + eagerDeoptInCalled(); |
| + eagerDeoptInCalled(true); |
| + eagerDeoptInCalled(); |
| + assertEquals(1500, result); |
| +})(); |
| + |
| +(function() { |
| + var result = 0; |
| + var lazyDeopt = function(deopt) { |
| + var sum = function(v,i,o) { |
| + result += i; |
| + if (i == 13 && deopt) { |
| + %DeoptimizeNow(); |
| + } |
| + } |
| + b.forEach(sum); |
| + } |
| + lazyDeopt(); |
| + lazyDeopt(); |
| + %OptimizeFunctionOnNextCall(lazyDeopt); |
| + lazyDeopt(); |
| + lazyDeopt(true); |
| + lazyDeopt(); |
| + assertEquals(1500, result); |
| +})(); |
| + |
| +(function() { |
| + var result = 0; |
| + var lazyDeopt = function(deopt) { |
| + var sum = function(v,i,o) { |
| + result += i; |
| + if (i == 13 && deopt) { |
| + %DeoptimizeNow(); |
| + gc(); |
| + gc(); |
| + gc(); |
| + } |
| + } |
| + c.forEach(sum); |
| + } |
| + lazyDeopt(); |
| + lazyDeopt(); |
| + %OptimizeFunctionOnNextCall(lazyDeopt); |
| + lazyDeopt(); |
| + lazyDeopt(true); |
| + lazyDeopt(); |
| + assertEquals(1500, result); |
| +})(); |