OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 // Flags: --harmony-computed-property-names --allow-natives-syntax | 5 // Flags: --allow-natives-syntax |
6 | 6 |
7 | 7 |
8 (function TestProtoDeopt() { | 8 (function TestProtoDeopt() { |
9 var proto = {}; | 9 var proto = {}; |
10 | 10 |
11 function deoptMe() { | 11 function deoptMe() { |
12 %DeoptimizeFunction(f); | 12 %DeoptimizeFunction(f); |
13 return proto; | 13 return proto; |
14 } | 14 } |
15 | 15 |
16 function checkObject(name, value, o) { | 16 function checkObject(name, value, o) { |
17 assertSame(proto, Object.getPrototypeOf(o)); | 17 assertSame(proto, Object.getPrototypeOf(o)); |
18 assertTrue(o.hasOwnProperty(name)); | 18 assertTrue(o.hasOwnProperty(name)); |
19 assertEquals(value, o[name]); | 19 assertEquals(value, o[name]); |
20 } | 20 } |
21 | 21 |
22 function f(name, value) { | 22 function f(name, value) { |
23 return { [name]: value, __proto__: deoptMe() }; | 23 return { [name]: value, __proto__: deoptMe() }; |
24 } | 24 } |
25 | 25 |
26 checkObject("a", 1, f("a", 1)); | 26 checkObject("a", 1, f("a", 1)); |
27 checkObject("b", 2, f("b", 2)); | 27 checkObject("b", 2, f("b", 2)); |
28 %OptimizeFunctionOnNextCall(f); | 28 %OptimizeFunctionOnNextCall(f); |
29 checkObject("c", 3, f("c", 3)); | 29 checkObject("c", 3, f("c", 3)); |
30 })(); | 30 })(); |
OLD | NEW |