annotate test/compiler/escapeAnalysis/TestEscapeThroughInvoke.java @ 24225:a2dbb6fcc923

Added tag jvmci-0.33 for changeset 3aed4cb813f4
author Doug Simon <doug.simon@oracle.com>
date Fri, 18 Aug 2017 22:47:33 +0200
parents 364f6c28effb
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22876
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
1 /*
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
4 *
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
7 * published by the Free Software Foundation.
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
8 *
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
13 * accompanied this code).
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
14 *
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
18 *
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
21 * questions.
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
22 */
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
23
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
24 /**
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
25 * @test
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
26 * @bug 8073956
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
27 * @summary Tests C2 EA with allocated object escaping through a call.
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
28 * @run main/othervm -XX:CompileCommand=dontinline,TestEscapeThroughInvoke::create TestEscapeThroughInvoke
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
29 */
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
30 public class TestEscapeThroughInvoke {
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
31 private A a;
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
32
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
33 public static void main(String[] args) {
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
34 TestEscapeThroughInvoke test = new TestEscapeThroughInvoke();
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
35 test.a = new A(42);
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
36 // Make sure run gets compiled by C2
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
37 for (int i = 0; i < 100_000; ++i) {
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
38 test.run();
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
39 }
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
40 }
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
41
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
42 private void run() {
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
43 // Allocate something to trigger EA
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
44 new Object();
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
45 // Create a new escaping instance of A and
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
46 // verify that it is always equal to 'a.saved'.
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
47 A escapingA = create(42);
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
48 a.check(escapingA);
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
49 }
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
50
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
51 // Create and return a new instance of A that escaped through 'A::saveInto'.
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
52 // The 'dummy' parameters are needed to avoid EA skipping the methods.
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
53 private A create(Integer dummy) {
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
54 A result = new A(dummy);
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
55 result.saveInto(a, dummy); // result escapes into 'a' here
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
56 return result;
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
57 }
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
58 }
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
59
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
60 class A {
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
61 private A saved;
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
62
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
63 public A(Integer dummy) { }
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
64
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
65 public void saveInto(A other, Integer dummy) {
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
66 other.saved = this;
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
67 }
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
68
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
69 public void check(A other) {
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
70 if (this.saved != other) {
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
71 throw new RuntimeException("TEST FAILED: Objects not equal.");
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
72 }
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
73 }
364f6c28effb 8006960: hotspot, "impossible" assertion failure
thartmann
parents:
diff changeset
74 }