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

Unified 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 side-by-side diff with in-line comments
Download patch
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..76e4531bcb879e45ba5b298c7ff23aec561a1427
--- /dev/null
+++ b/test/mjsunit/optimized-foreach.js
@@ -0,0 +1,70 @@
+// Copyright 2017 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+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);
+})();

Powered by Google App Engine
This is Rietveld 408576698