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 3 // found in the LICENSE file. 4 5 // Flags: --allow-natives-syntax 6 7 8 (function TestProtoDeopt() { 9 var proto = {}; 10 11 function deoptMe() { 12 %DeoptimizeFunction(f); 13 return proto; 14 } 15 16 function checkObject(name, value, o) { 17 assertSame(proto, Object.getPrototypeOf(o)); 18 assertTrue(o.hasOwnProperty(name)); 19 assertEquals(value, o[name]); 20 } 21 22 function f(name, value) { 23 return { [name]: value, __proto__: deoptMe() }; 24 } 25 26 checkObject("a", 1, f("a", 1)); 27 checkObject("b", 2, f("b", 2)); 28 %OptimizeFunctionOnNextCall(f); 29 checkObject("c", 3, f("c", 3)); 30 })(); 31