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

Unified Diff: test/mjsunit/regress/regress-4715.js

Issue 1650493002: [crankshaft] Make the for-in slow path compatible with the other compilers. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « src/crankshaft/hydrogen.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/regress/regress-4715.js
diff --git a/test/mjsunit/regress/regress-4715.js b/test/mjsunit/regress/regress-4715.js
new file mode 100644
index 0000000000000000000000000000000000000000..0e38cdc27de85f6c98bbcc5d1f77c11fc57a1d81
--- /dev/null
+++ b/test/mjsunit/regress/regress-4715.js
@@ -0,0 +1,48 @@
+// Copyright 2016 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.
+
+// Flags: --allow-natives-syntax --dead-code-elimination --expose-gc
+
+var training = {};
+training.a = "nop";
+training.slow = "nop";
+delete training.slow; // Dictionary-mode properties => slow-mode for-in.
+
+var keepalive = {};
+keepalive.a = "nop"; // Keep a map early in the transition chain alive.
+
+function GetReal() {
+ var r = {};
+ r.a = "nop";
+ r.b = "nop";
+ r.c = "dictionarize",
+ r.d = "gc";
+ r.e = "result";
+ return r;
+};
+
+function SideEffect(object, action) {
+ if (action === "dictionarize") {
+ delete object.a;
+ } else if (action === "gc") {
+ gc();
+ }
+}
+
+function foo(object) {
+ for (var key in object) {
+ SideEffect(object, object[key]);
+ }
+ return key;
+}
+
+// Collect type feedback for slow-mode for-in.
+foo(training);
+SideEffect({a: 0}, "dictionarize");
+SideEffect({}, "gc");
+
+// Compile for slow-mode objects...
+%OptimizeFunctionOnNextCall(foo);
+// ...and pass in a fast-mode object.
+assertEquals("e", foo(GetReal()));
« no previous file with comments | « src/crankshaft/hydrogen.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698