Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(427)

Side by Side Diff: test/mjsunit/optimized-foreach.js

Issue 2803853005: Inline Array.prototype.forEach in TurboFan (Closed)
Patch Set: Review feedback Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 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];
6 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];
7 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];
8
9 (function() {
10 var result = 0;
11 var eagerDeoptInCalled = function(deopt) {
12 var sum = function(v,i,o) {
13 result += v;
14 if (i == 13 && deopt) {
15 a.length = 25;
16 }
17 }
18 a.forEach(sum);
19 }
20 eagerDeoptInCalled();
21 eagerDeoptInCalled();
22 %OptimizeFunctionOnNextCall(eagerDeoptInCalled);
23 eagerDeoptInCalled();
24 eagerDeoptInCalled(true);
25 eagerDeoptInCalled();
26 assertEquals(1500, result);
27 })();
28
29 (function() {
30 var result = 0;
31 var lazyDeopt = function(deopt) {
32 var sum = function(v,i,o) {
33 result += i;
34 if (i == 13 && deopt) {
35 %DeoptimizeNow();
36 }
37 }
38 b.forEach(sum);
39 }
40 lazyDeopt();
41 lazyDeopt();
42 %OptimizeFunctionOnNextCall(lazyDeopt);
43 lazyDeopt();
44 lazyDeopt(true);
45 lazyDeopt();
46 assertEquals(1500, result);
47 })();
48
49 (function() {
50 var result = 0;
51 var lazyDeopt = function(deopt) {
52 var sum = function(v,i,o) {
53 result += i;
54 if (i == 13 && deopt) {
55 %DeoptimizeNow();
56 gc();
57 gc();
58 gc();
59 }
60 }
61 c.forEach(sum);
62 }
63 lazyDeopt();
64 lazyDeopt();
65 %OptimizeFunctionOnNextCall(lazyDeopt);
66 lazyDeopt();
67 lazyDeopt(true);
68 lazyDeopt();
69 assertEquals(1500, result);
70 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698