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

Unified Diff: test/mjsunit/optimized-foreach.js

Issue 2803853005: Inline Array.prototype.forEach in TurboFan (Closed)
Patch Set: fix v8heapconst.py 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..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);
+})();
« src/flag-definitions.h ('K') | « src/utils.h ('k') | tools/v8heapconst.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698