hotspot/test/compiler/membars/TestMemBarAcquire.java
author jwilhelm
Thu, 26 Feb 2015 21:00:03 +0100 (2015-02-26)
changeset 29324 8672c9d7ae94
parent 26176 cc5975228236
child 40059 c2304140ed64
permissions -rw-r--r--
8073883: serviceability/dcmd/gc/RunGCTest.java should not run with -XX:+ExplicitGCInvokesConcurrent Summary: Don't run test with -XX:+ExplicitGCInvokesConcurrent Reviewed-by: mgerdin
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26176
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
     1
/*
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
     4
 *
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
     7
 * published by the Free Software Foundation.
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
     8
 *
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    13
 * accompanied this code).
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    14
 *
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    18
 *
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    21
 * questions.
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    22
 */
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    23
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    24
/*
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    25
 * @test TestMemBarAcquire
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    26
 * @bug 8048879
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    27
 * @summary "Tests optimization of MemBarAcquireNodes"
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    28
 * @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation TestMemBarAcquire
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    29
 */
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    30
public class TestMemBarAcquire {
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    31
  private volatile static Object defaultObj = new Object();
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    32
  private Object obj;
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    33
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    34
  public TestMemBarAcquire(Object param) {
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    35
    // Volatile load. MemBarAcquireNode is added after the
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    36
    // load to prevent following loads from floating up past.
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    37
    // StoreNode is added to store result of load in 'obj'.
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    38
    this.obj = defaultObj;
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    39
    // Overrides 'obj' and therefore makes previous StoreNode
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    40
    // and the corresponding LoadNode useless. However, the
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    41
    // LoadNode is still connected to the MemBarAcquireNode
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    42
    // that should now release the reference.
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    43
    this.obj = param;
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    44
  }
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    45
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    46
  public static void main(String[] args) throws Exception {
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    47
    // Make sure TestMemBarAcquire::<init> is compiled
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    48
    for (int i = 0; i < 100000; ++i) {
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    49
      TestMemBarAcquire p = new TestMemBarAcquire(new Object());
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    50
    }
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    51
  }
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    52
}
cc5975228236 8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff changeset
    53