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

Side by Side Diff: test/mjsunit/regress/regress-crbug-571517.js

Issue 2108203002: Implement immutable prototype chains (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: IsImmutableProto Created 4 years, 5 months 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 | « test/mjsunit/regress/regress-1403.js ('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
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));
OLDNEW
« no previous file with comments | « test/mjsunit/regress/regress-1403.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698