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

Unified Diff: test/mjsunit/for-in-opt.js

Issue 1075933003: Add basic crankshaft support for slow-mode for-in to avoid disabling optimizations (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Disable for-in-opt for turbofan Created 5 years, 8 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/hydrogen.cc ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/for-in-opt.js
diff --git a/test/mjsunit/for-in-opt.js b/test/mjsunit/for-in-opt.js
new file mode 100644
index 0000000000000000000000000000000000000000..58344e4dc1bcfcb66b6bb789a992993c0b1ed036
--- /dev/null
+++ b/test/mjsunit/for-in-opt.js
@@ -0,0 +1,75 @@
+// Copyright 2015 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: --harmony-proxies --allow-natives-syntax
+
+"use strict";
+
+// Test non-JSObject receiver.
+function f(o) {
+ var result = [];
+ for (var i in o) {
+ result.push(i);
+ }
+ return result;
+}
+
+assertEquals(["0"], f("a"));
+assertEquals(["0"], f("a"));
+%OptimizeFunctionOnNextCall(f);
+assertEquals(["0","1","2"], f("bla"));
+
+// Test the lazy deopt points.
+var keys = ["a", "b", "c", "d"];
+var has_keys = [];
+var deopt_has = false;
+var deopt_enum = false;
+
+var handler = {
+ enumerate: function(target) {
+ if (deopt_enum) {
+ %DeoptimizeFunction(f2);
+ deopt_enum = false;
+ }
+ return keys;
+ },
+
+ getPropertyDescriptor: function(k) {
+ if (deopt_has) {
+ %DeoptimizeFunction(f2);
+ deopt_has = false;
+ }
+ has_keys.push(k);
+ return {value: 10, configurable: true, writable: false, enumerable: true};
+ }
+};
+
+
+var proxy = Proxy.create(handler);
+var o = {__proto__: proxy};
+
+function f2(o) {
+ var result = [];
+ for (var i in o) {
+ result.push(i);
+ }
+ return result;
+}
+
+function check_f2() {
+ assertEquals(keys, f2(o));
+ assertEquals(keys, has_keys);
+ has_keys.length = 0;
+}
+
+check_f2();
+check_f2();
+// Test lazy deopt after GetPropertyNamesFast
+%OptimizeFunctionOnNextCall(f2);
+deopt_enum = true;
+check_f2();
+// Test lazy deopt after FILTER_KEY
+%OptimizeFunctionOnNextCall(f2);
+deopt_has = true;
+check_f2();
« no previous file with comments | « src/hydrogen.cc ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698