OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 function Receiver() { this.receiver = "receiver"; } | 5 function Receiver() { this.receiver = "receiver"; } |
6 function Proto() { this.proto = "proto"; } | 6 function Proto() { this.proto = "proto"; } |
7 | 7 |
8 function f(a) { | 8 function f(a) { |
9 return a.foo; | 9 return a.foo; |
10 } | 10 } |
11 | 11 |
12 var rec = new Receiver(); | 12 var rec = new Receiver(); |
13 | 13 |
14 var proto = rec.__proto__.__proto__; | 14 // Formerly, this mutated rec.__proto__.__proto__, but |
| 15 // the global object prototype chain is now immutable; |
| 16 // not sure if this test now hits the original hazard case. |
| 17 var proto = rec.__proto__; |
15 | 18 |
16 // Initialize prototype chain dependent IC (nonexistent load). | 19 // Initialize prototype chain dependent IC (nonexistent load). |
17 assertEquals(undefined, f(rec)); | 20 assertEquals(undefined, f(rec)); |
18 assertEquals(undefined, f(rec)); | 21 assertEquals(undefined, f(rec)); |
19 | 22 |
20 // Add a new prototype to the end of the chain. | 23 // Add a new prototype to the end of the chain. |
21 var p2 = new Proto(); | 24 var p2 = new Proto(); |
22 p2.__proto__ = null; | 25 p2.__proto__ = null; |
23 proto.__proto__ = p2; | 26 proto.__proto__ = p2; |
24 | 27 |
25 // Update the IC. | 28 // Update the IC. |
26 assertEquals(undefined, f(rec)); | 29 assertEquals(undefined, f(rec)); |
27 | 30 |
28 // Now modify the most recently added prototype by adding a property... | 31 // Now modify the most recently added prototype by adding a property... |
29 p2.foo = "bar"; | 32 p2.foo = "bar"; |
30 assertEquals("bar", f(rec)); | 33 assertEquals("bar", f(rec)); |
31 | 34 |
32 // ...and removing it again. Due to missing prototype user registrations, | 35 // ...and removing it again. Due to missing prototype user registrations, |
33 // this fails to invalidate the IC. | 36 // this fails to invalidate the IC. |
34 delete p2.foo; | 37 delete p2.foo; |
35 p2.secret = "GAME OVER"; | 38 p2.secret = "GAME OVER"; |
36 assertEquals(undefined, f(rec)); | 39 assertEquals(undefined, f(rec)); |
OLD | NEW |