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

Unified Diff: test/mjsunit/es6/instanceof-proxies.js

Issue 1518773003: Turbofan instanceof lowering needs to address proxies. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Missing typer rule. Created 5 years 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/compiler/typer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/es6/instanceof-proxies.js
diff --git a/test/mjsunit/es6/instanceof-proxies.js b/test/mjsunit/es6/instanceof-proxies.js
new file mode 100644
index 0000000000000000000000000000000000000000..2b40873310ff0919a3ff079f145547af1eb813ec
--- /dev/null
+++ b/test/mjsunit/es6/instanceof-proxies.js
@@ -0,0 +1,52 @@
+// 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
+
+// Test instanceof with proxies.
+
+function TestInstanceOfWithProxies() {
+ function foo(x) {
+ return x instanceof Array;
+ }
+ assertTrue(foo([]));
+ assertFalse(foo({}));
+ %OptimizeFunctionOnNextCall(foo);
+ assertTrue(foo([]));
+ assertFalse(foo({}));
+
+ var handler = {
+ getPrototypeOf: function(target) { return Array.prototype; }
+ };
+ var p = new Proxy({}, handler);
+ assertTrue(foo(p));
+ var o = {};
+ o.__proto__ = p;
+ assertTrue(foo(o));
+
+ // Make sure we are also correct if the handler throws.
+ handler.getPrototypeOf = function(target) {
+ throw "uncooperative";
+ }
+ assertThrows("foo(o)");
+
+ // Including if the optimized function has a catch handler.
+ function foo_catch(x) {
+ try {
+ x instanceof Array;
+ } catch(e) {
+ assertEquals("uncooperative", e);
+ return true;
+ }
+ return false;
+ }
+ assertTrue(foo_catch(o));
+ %OptimizeFunctionOnNextCall(foo_catch);
+ assertTrue(foo_catch(o));
+ handler.getPrototypeOf = function(target) { return Array.prototype; }
+ assertFalse(foo_catch(o));
+}
+
+TestInstanceOfWithProxies();
« no previous file with comments | « src/compiler/typer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698