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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/compiler/typer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5
6 // Flags: --harmony-proxies --allow-natives-syntax
7
8 // Test instanceof with proxies.
9
10 function TestInstanceOfWithProxies() {
11 function foo(x) {
12 return x instanceof Array;
13 }
14 assertTrue(foo([]));
15 assertFalse(foo({}));
16 %OptimizeFunctionOnNextCall(foo);
17 assertTrue(foo([]));
18 assertFalse(foo({}));
19
20 var handler = {
21 getPrototypeOf: function(target) { return Array.prototype; }
22 };
23 var p = new Proxy({}, handler);
24 assertTrue(foo(p));
25 var o = {};
26 o.__proto__ = p;
27 assertTrue(foo(o));
28
29 // Make sure we are also correct if the handler throws.
30 handler.getPrototypeOf = function(target) {
31 throw "uncooperative";
32 }
33 assertThrows("foo(o)");
34
35 // Including if the optimized function has a catch handler.
36 function foo_catch(x) {
37 try {
38 x instanceof Array;
39 } catch(e) {
40 assertEquals("uncooperative", e);
41 return true;
42 }
43 return false;
44 }
45 assertTrue(foo_catch(o));
46 %OptimizeFunctionOnNextCall(foo_catch);
47 assertTrue(foo_catch(o));
48 handler.getPrototypeOf = function(target) { return Array.prototype; }
49 assertFalse(foo_catch(o));
50 }
51
52 TestInstanceOfWithProxies();
OLDNEW
« 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