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