hannesw@1547: /* hannesw@1547: * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. hannesw@1547: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. hannesw@1547: * hannesw@1547: * This code is free software; you can redistribute it and/or modify it hannesw@1547: * under the terms of the GNU General Public License version 2 only, as hannesw@1547: * published by the Free Software Foundation. hannesw@1547: * hannesw@1547: * This code is distributed in the hope that it will be useful, but WITHOUT hannesw@1547: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or hannesw@1547: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License hannesw@1547: * version 2 for more details (a copy is included in the LICENSE file that hannesw@1547: * accompanied this code). hannesw@1547: * hannesw@1547: * You should have received a copy of the GNU General Public License version hannesw@1547: * 2 along with this work; if not, write to the Free Software Foundation, hannesw@1547: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. hannesw@1547: * hannesw@1547: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA hannesw@1547: * or visit www.oracle.com if you need additional information or have any hannesw@1547: * questions. hannesw@1547: */ hannesw@1547: hannesw@1547: /** hannesw@1547: * JDK-8134569: Add tests for prototype callsites hannesw@1547: * hannesw@1547: * @test hannesw@1547: * @run hannesw@1547: */ hannesw@1547: hannesw@1547: function create() { hannesw@1547: function C() { hannesw@1547: this.i1 = 1; hannesw@1547: this.i2 = 2; hannesw@1547: this.i3 = 3; hannesw@1547: return this; hannesw@1547: } hannesw@1547: return new C(); hannesw@1547: } hannesw@1547: hannesw@1547: function createEmpty() { hannesw@1547: function C() { hannesw@1547: return this; hannesw@1547: } hannesw@1547: return new C(); hannesw@1547: } hannesw@1547: hannesw@1547: function createDeep() { hannesw@1547: function C() { hannesw@1547: this.i1 = 1; hannesw@1547: this.i2 = 2; hannesw@1547: this.i3 = 3; hannesw@1547: return this; hannesw@1547: } hannesw@1547: function D() { hannesw@1547: this.p1 = 1; hannesw@1547: this.p2 = 2; hannesw@1547: this.p3 = 3; hannesw@1547: return this; hannesw@1547: } hannesw@1547: C.prototype = new D(); hannesw@1547: return new C(); hannesw@1547: } hannesw@1547: hannesw@1548: function createDeeper() { hannesw@1548: function C() { hannesw@1548: this.i1 = 1; hannesw@1548: this.i2 = 2; hannesw@1548: this.i3 = 3; hannesw@1548: return this; hannesw@1548: } hannesw@1548: function D() { hannesw@1548: this.p1 = 1; hannesw@1548: this.p2 = 2; hannesw@1548: this.p3 = 3; hannesw@1548: return this; hannesw@1548: } hannesw@1548: function E() { hannesw@1548: this.e1 = 1; hannesw@1548: this.e2 = 2; hannesw@1548: this.e3 = 3; hannesw@1548: return this; hannesw@1548: } hannesw@1548: D.prototype = new E(); hannesw@1548: C.prototype = new D(); hannesw@1548: return new C(); hannesw@1548: } hannesw@1548: hannesw@1547: function createEval() { hannesw@1547: return eval("Object.create({})"); hannesw@1547: } hannesw@1547: hannesw@1547: function p(o) { print(o.x) } hannesw@1547: hannesw@1548: function e(o) { print(o.e1) } hannesw@1548: hannesw@1548: var a, b, c; hannesw@1547: hannesw@1547: create(); hannesw@1547: a = create(); hannesw@1547: b = create(); hannesw@1548: c = create(); hannesw@1547: a.__proto__.x = 123; hannesw@1547: hannesw@1547: p(a); hannesw@1547: p(b); hannesw@1548: p(c); hannesw@1547: hannesw@1547: a = create(); hannesw@1547: b = create(); hannesw@1548: c = create(); hannesw@1547: b.__proto__.x = 123; hannesw@1547: hannesw@1547: p(a); hannesw@1547: p(b); hannesw@1548: p(c); hannesw@1547: hannesw@1547: a = createEmpty(); hannesw@1547: b = createEmpty(); hannesw@1548: c = createEmpty(); hannesw@1547: a.__proto__.x = 123; hannesw@1547: hannesw@1547: p(a); hannesw@1547: p(b); hannesw@1548: p(c); hannesw@1547: hannesw@1547: a = createEmpty(); hannesw@1547: b = createEmpty(); hannesw@1548: c = createEmpty(); hannesw@1547: b.__proto__.x = 123; hannesw@1547: hannesw@1547: p(a); hannesw@1547: p(b); hannesw@1548: p(c); hannesw@1547: hannesw@1547: a = createDeep(); hannesw@1547: b = createDeep(); hannesw@1548: c = createDeep(); hannesw@1547: a.__proto__.__proto__.x = 123; hannesw@1547: hannesw@1547: p(a); hannesw@1547: p(b); hannesw@1548: p(c); hannesw@1547: hannesw@1547: a = createDeep(); hannesw@1547: b = createDeep(); hannesw@1548: c = createDeep(); hannesw@1547: b.__proto__.__proto__.x = 123; hannesw@1547: hannesw@1547: p(a); hannesw@1547: p(b); hannesw@1548: p(c); hannesw@1548: hannesw@1548: a = createDeeper(); hannesw@1548: b = createDeeper(); hannesw@1548: c = createDeeper(); hannesw@1548: a.__proto__.__proto__.__proto__.x = 123; hannesw@1548: hannesw@1548: p(a); hannesw@1548: p(b); hannesw@1548: p(c); hannesw@1548: hannesw@1548: a = createDeeper(); hannesw@1548: b = createDeeper(); hannesw@1548: c = createDeeper(); hannesw@1548: b.__proto__.__proto__.__proto__.x = 123; hannesw@1548: hannesw@1548: p(a); hannesw@1548: p(b); hannesw@1548: p(c); hannesw@1548: hannesw@1548: a = createDeeper(); hannesw@1548: b = createDeeper(); hannesw@1548: c = createDeeper(); hannesw@1548: a.__proto__.__proto__ = null; hannesw@1548: hannesw@1548: e(a); hannesw@1548: e(b); hannesw@1548: e(c); hannesw@1548: hannesw@1548: a = createDeeper(); hannesw@1548: b = createDeeper(); hannesw@1548: c = createDeeper(); hannesw@1548: b.__proto__.__proto__ = null; hannesw@1548: hannesw@1548: e(a); hannesw@1548: e(b); hannesw@1548: e(c); hannesw@1548: hannesw@1547: hannesw@1547: a = createEval(); hannesw@1547: b = createEval(); hannesw@1548: c = createEval(); hannesw@1547: a.__proto__.x = 123; hannesw@1547: hannesw@1547: p(a); hannesw@1547: p(b); hannesw@1548: p(c); hannesw@1547: hannesw@1547: a = createEval(); hannesw@1547: b = createEval(); hannesw@1548: c = createEval(); hannesw@1547: b.__proto__.x = 123; hannesw@1547: hannesw@1547: p(a); hannesw@1547: p(b); hannesw@1548: p(c);