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 // Flags: --allow-natives-syntax | |
6 | |
7 function A() { | |
8 this.a = "a"; | |
9 } | |
10 var a = new A(); | |
11 | |
12 function B() { | |
13 this.b = "b"; | |
14 } | |
15 B.prototype = a; | |
16 | |
17 function C() { | |
18 this.c = "c"; | |
19 } | |
20 C.prototype = new B(); | |
21 | |
22 var c = new C(); | |
23 | |
24 function f(expected) { | |
25 var result = c.z; | |
26 assertEquals(expected, result); | |
27 } | |
28 f(undefined); | |
29 f(undefined); | |
30 %OptimizeFunctionOnNextCall(f); | |
31 f(undefined); | |
32 a.z = "z"; | |
33 f("z"); | |
34 f("z"); | |
35 | |
36 // Test updating .__proto__ pointers. | |
37 var p1 = {foo: 1.5}; | |
38 var p2 = {}; p2.__proto__ = p1; | |
39 var p3 = {}; p3.__proto__ = p2; | |
40 var o = {}; o.__proto__ = p3; | |
41 | |
42 for (var i = 0; i < 2; i++) o.foo; // Force registration. | |
43 | |
44 var p1a = {foo: 1.7}; | |
45 p2.__proto__ = p1a; | |
46 | |
47 function g(o, expected) { | |
48 var result = o.foo; | |
49 assertEquals(expected, result); | |
50 } | |
51 | |
52 g(o, 1.7); | |
53 g(o, 1.7); | |
54 g(o, 1.7); | |
55 Object.defineProperty(p1a, "foo", {get: function() { return "foo"}}); | |
56 g(o, "foo"); | |
OLD | NEW |