8330153: C2: dump barrier information for all Mach nodes
Reviewed-by: kvn, thartmann
This commit is contained in:
parent
58ad399d19
commit
57ebd045ea
@ -548,6 +548,11 @@ void MachNode::dump_spec(outputStream *st) const {
|
||||
if( C->alias_type(t)->is_volatile() )
|
||||
st->print(" Volatile!");
|
||||
}
|
||||
if (barrier_data() != 0) {
|
||||
st->print(" barrier(");
|
||||
BarrierSet::barrier_set()->barrier_set_c2()->dump_barrier_data(this, st);
|
||||
st->print(") ");
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------dump_format------------------------------------
|
||||
@ -560,16 +565,12 @@ void MachNode::dump_format(PhaseRegAlloc *ra, outputStream *st) const {
|
||||
//=============================================================================
|
||||
#ifndef PRODUCT
|
||||
void MachTypeNode::dump_spec(outputStream *st) const {
|
||||
MachNode::dump_spec(st);
|
||||
if (_bottom_type != nullptr) {
|
||||
_bottom_type->dump_on(st);
|
||||
} else {
|
||||
st->print(" null");
|
||||
}
|
||||
if (barrier_data() != 0) {
|
||||
st->print(" barrier(");
|
||||
BarrierSet::barrier_set()->barrier_set_c2()->dump_barrier_data(this, st);
|
||||
st->print(")");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -2076,6 +2076,12 @@ public class IRNode {
|
||||
machOnly(Z_STORE_P_WITH_BARRIER_FLAG, regex);
|
||||
}
|
||||
|
||||
public static final String Z_COMPARE_AND_SWAP_P_WITH_BARRIER_FLAG = COMPOSITE_PREFIX + "Z_COMPARE_AND_SWAP_P_WITH_BARRIER_FLAG" + POSTFIX;
|
||||
static {
|
||||
String regex = START + "zCompareAndSwapP" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
|
||||
machOnly(Z_COMPARE_AND_SWAP_P_WITH_BARRIER_FLAG, regex);
|
||||
}
|
||||
|
||||
public static final String Z_GET_AND_SET_P_WITH_BARRIER_FLAG = COMPOSITE_PREFIX + "Z_GET_AND_SET_P_WITH_BARRIER_FLAG" + POSTFIX;
|
||||
static {
|
||||
String regex = START + "(zXChgP)|(zGetAndSetP\\S*)" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
|
||||
|
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package ir_framework.examples;
|
||||
|
||||
import compiler.lib.ir_framework.*;
|
||||
import java.lang.invoke.VarHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8330153
|
||||
* @summary Example test that illustrates the use of the IR test framework for
|
||||
* verification of late-expanded GC barriers.
|
||||
* @library /test/lib /
|
||||
* @run driver ir_framework.examples.GCBarrierIRExample
|
||||
*/
|
||||
|
||||
public class GCBarrierIRExample {
|
||||
|
||||
static class Outer {
|
||||
Object f;
|
||||
}
|
||||
|
||||
static final VarHandle fVarHandle;
|
||||
static {
|
||||
MethodHandles.Lookup l = MethodHandles.lookup();
|
||||
try {
|
||||
fVarHandle = l.findVarHandle(Outer.class, "f", Object.class);
|
||||
} catch (Exception e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
static Outer o = new Outer();
|
||||
static Object oldVal = new Object();
|
||||
static Object newVal = new Object();
|
||||
|
||||
public static void main(String[] args) {
|
||||
// These rules apply only to collectors that expand barriers at code
|
||||
// emission, such as ZGC. Because the collector selection flags are not
|
||||
// whitelisted (see IR framework's README.md file), the user (as opposed
|
||||
// to jtreg) needs to set these flags here.
|
||||
TestFramework.runWithFlags("-XX:+UseZGC", "-XX:+ZGenerational");
|
||||
}
|
||||
|
||||
@Test
|
||||
// IR rules can be used to verify collector-specific barrier info (in this
|
||||
// case, that a ZGC barrier corresponds to a strong OOP reference). Barrier
|
||||
// info can only be verified after matching, e.g. at the FINAL_CODE phase.
|
||||
@IR(counts = {IRNode.Z_COMPARE_AND_SWAP_P_WITH_BARRIER_FLAG, "strong", "1"},
|
||||
phase = CompilePhase.FINAL_CODE)
|
||||
static boolean testBarrierOfCompareAndSwap() {
|
||||
return fVarHandle.compareAndSet(o, oldVal, newVal);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user