blob: 03bf76cb5e36924f8d4b15b6c0515fc7715f369e [file] [log] [blame]
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001// 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
5function Receiver() { this.receiver = "receiver"; }
6function Proto() { this.proto = "proto"; }
7
8function f(a) {
9 return a.foo;
10}
11
12var rec = new Receiver();
13
14var proto = rec.__proto__.__proto__;
15
16// Initialize prototype chain dependent IC (nonexistent load).
17assertEquals(undefined, f(rec));
18assertEquals(undefined, f(rec));
19
20// Add a new prototype to the end of the chain.
21var p2 = new Proto();
22p2.__proto__ = null;
23proto.__proto__ = p2;
24
25// Update the IC.
26assertEquals(undefined, f(rec));
27
28// Now modify the most recently added prototype by adding a property...
29p2.foo = "bar";
30assertEquals("bar", f(rec));
31
32// ...and removing it again. Due to missing prototype user registrations,
33// this fails to invalidate the IC.
34delete p2.foo;
35p2.secret = "GAME OVER";
36assertEquals(undefined, f(rec));