8259316: [REDO] C1/C2 compiler support for blackholes
Reviewed-by: vlivanov, kvn, iignatyev
This commit is contained in:
parent
f07bb2f4b9
commit
6018336fc5
@ -229,6 +229,8 @@ bool Compiler::is_intrinsic_supported(const methodHandle& method) {
|
||||
break;
|
||||
case vmIntrinsics::_getObjectSize:
|
||||
break;
|
||||
case vmIntrinsics::_blackhole:
|
||||
break;
|
||||
default:
|
||||
return false; // Intrinsics not on the previous list are not available.
|
||||
}
|
||||
|
@ -3419,7 +3419,7 @@ bool GraphBuilder::try_inline(ciMethod* callee, bool holder_known, bool ignore_r
|
||||
|
||||
// handle intrinsics
|
||||
if (callee->intrinsic_id() != vmIntrinsics::_none &&
|
||||
(CheckIntrinsics ? callee->intrinsic_candidate() : true)) {
|
||||
callee->check_intrinsic_candidate()) {
|
||||
if (try_inline_intrinsics(callee, ignore_return)) {
|
||||
print_inlining(callee, "intrinsic");
|
||||
if (callee->has_reserved_stack_access()) {
|
||||
|
@ -3202,6 +3202,10 @@ void LIRGenerator::do_Intrinsic(Intrinsic* x) {
|
||||
do_vectorizedMismatch(x);
|
||||
break;
|
||||
|
||||
case vmIntrinsics::_blackhole:
|
||||
do_blackhole(x);
|
||||
break;
|
||||
|
||||
default: ShouldNotReachHere(); break;
|
||||
}
|
||||
}
|
||||
@ -3621,6 +3625,15 @@ void LIRGenerator::do_RangeCheckPredicate(RangeCheckPredicate *x) {
|
||||
}
|
||||
}
|
||||
|
||||
void LIRGenerator::do_blackhole(Intrinsic *x) {
|
||||
assert(!x->has_receiver(), "Should have been checked before: only static methods here");
|
||||
for (int c = 0; c < x->number_of_arguments(); c++) {
|
||||
// Load the argument
|
||||
LIRItem vitem(x->argument_at(c), this);
|
||||
vitem.load_item();
|
||||
// ...and leave it unused.
|
||||
}
|
||||
}
|
||||
|
||||
LIR_Opr LIRGenerator::call_runtime(Value arg1, address entry, ValueType* result_type, CodeEmitInfo* info) {
|
||||
LIRItemList args(1);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2021, 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
|
||||
@ -265,6 +265,7 @@ class LIRGenerator: public InstructionVisitor, public BlockClosure {
|
||||
void do_update_CRC32(Intrinsic* x);
|
||||
void do_update_CRC32C(Intrinsic* x);
|
||||
void do_vectorizedMismatch(Intrinsic* x);
|
||||
void do_blackhole(Intrinsic* x);
|
||||
|
||||
public:
|
||||
LIR_Opr call_runtime(BasicTypeArray* signature, LIRItemList* args, address entry, ValueType* result_type, CodeEmitInfo* info);
|
||||
|
@ -154,6 +154,8 @@ ciMethod::ciMethod(const methodHandle& h_m, ciInstanceKlass* holder) :
|
||||
ciReplay::initialize(this);
|
||||
}
|
||||
#endif
|
||||
|
||||
CompilerOracle::tag_blackhole_if_possible(h_m);
|
||||
}
|
||||
|
||||
|
||||
@ -1214,6 +1216,7 @@ bool ciMethod::is_getter () const { FETCH_FLAG_FROM_VM(is_getter);
|
||||
bool ciMethod::is_setter () const { FETCH_FLAG_FROM_VM(is_setter); }
|
||||
bool ciMethod::is_accessor () const { FETCH_FLAG_FROM_VM(is_accessor); }
|
||||
bool ciMethod::is_initializer () const { FETCH_FLAG_FROM_VM(is_initializer); }
|
||||
bool ciMethod::is_empty () const { FETCH_FLAG_FROM_VM(is_empty_method); }
|
||||
|
||||
bool ciMethod::is_boxing_method() const {
|
||||
if (intrinsic_id() != vmIntrinsics::_none && holder()->is_box_klass()) {
|
||||
|
@ -204,6 +204,15 @@ class ciMethod : public ciMetadata {
|
||||
bool intrinsic_candidate() const { return get_Method()->intrinsic_candidate(); }
|
||||
bool is_static_initializer() const { return get_Method()->is_static_initializer(); }
|
||||
|
||||
bool check_intrinsic_candidate() const {
|
||||
if (intrinsic_id() == vmIntrinsics::_blackhole) {
|
||||
// This is the intrinsic without an associated method, so no intrinsic_candidate
|
||||
// flag is set. The intrinsic is still correct.
|
||||
return true;
|
||||
}
|
||||
return (CheckIntrinsics ? intrinsic_candidate() : true);
|
||||
}
|
||||
|
||||
int highest_osr_comp_level();
|
||||
|
||||
Bytecodes::Code java_code_at_bci(int bci) {
|
||||
@ -346,6 +355,7 @@ class ciMethod : public ciMetadata {
|
||||
bool is_setter () const;
|
||||
bool is_accessor () const;
|
||||
bool is_initializer () const;
|
||||
bool is_empty () const;
|
||||
bool can_be_statically_bound() const { return _can_be_statically_bound; }
|
||||
bool has_reserved_stack_access() const { return _has_reserved_stack_access; }
|
||||
bool is_boxing_method() const;
|
||||
|
@ -5304,6 +5304,11 @@ static void check_methods_for_intrinsics(const InstanceKlass* ik,
|
||||
// is defined for it.
|
||||
continue;
|
||||
}
|
||||
if (vmIntrinsics::_blackhole == id) {
|
||||
// The _blackhole intrinsic is a special marker. No explicit method
|
||||
// is defined for it.
|
||||
continue;
|
||||
}
|
||||
|
||||
if (vmIntrinsics::class_for(id) == klass_id) {
|
||||
// Check if the current class contains a method with the same
|
||||
|
@ -153,6 +153,7 @@ bool vmIntrinsics::should_be_pinned(vmIntrinsics::ID id) {
|
||||
#endif
|
||||
case vmIntrinsics::_currentTimeMillis:
|
||||
case vmIntrinsics::_nanoTime:
|
||||
case vmIntrinsics::_blackhole:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
@ -534,6 +534,9 @@ class methodHandle;
|
||||
do_name( getObjectSize_name, "getObjectSize0") \
|
||||
do_alias( getObjectSize_signature, long_object_long_signature) \
|
||||
\
|
||||
/* special marker for blackholed methods: */ \
|
||||
do_intrinsic(_blackhole, java_lang_Object, blackhole_name, star_name, F_S) \
|
||||
\
|
||||
/* unsafe memory references (there are a lot of them...) */ \
|
||||
do_signature(getReference_signature, "(Ljava/lang/Object;J)Ljava/lang/Object;") \
|
||||
do_signature(putReference_signature, "(Ljava/lang/Object;JLjava/lang/Object;)V") \
|
||||
|
@ -283,6 +283,7 @@
|
||||
template(signature_name, "signature") \
|
||||
template(slot_name, "slot") \
|
||||
template(trusted_final_name, "trustedFinal") \
|
||||
template(blackhole_name, "<blackhole>") /*fake name*/ \
|
||||
\
|
||||
/* Support for annotations (JDK 1.5 and above) */ \
|
||||
\
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2021, 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
|
||||
@ -306,6 +306,11 @@ static void register_command(TypedMethodOptionMatcher* matcher,
|
||||
}
|
||||
assert(CompilerOracle::option_matches_type(option, value), "Value must match option type");
|
||||
|
||||
if (option == CompileCommand::Blackhole && !UnlockExperimentalVMOptions) {
|
||||
warning("Blackhole compile option is experimental and must be enabled via -XX:+UnlockExperimentalVMOptions");
|
||||
return;
|
||||
}
|
||||
|
||||
matcher->init(option, option_list);
|
||||
matcher->set_value<T>(value);
|
||||
option_list = matcher;
|
||||
@ -417,6 +422,37 @@ bool CompilerOracle::should_break_at(const methodHandle& method) {
|
||||
return check_predicate(CompileCommand::Break, method);
|
||||
}
|
||||
|
||||
void CompilerOracle::tag_blackhole_if_possible(const methodHandle& method) {
|
||||
if (!check_predicate(CompileCommand::Blackhole, method)) {
|
||||
return;
|
||||
}
|
||||
guarantee(UnlockExperimentalVMOptions, "Checked during initial parsing");
|
||||
if (method->result_type() != T_VOID) {
|
||||
warning("Blackhole compile option only works for methods with void type: %s",
|
||||
method->name_and_sig_as_C_string());
|
||||
return;
|
||||
}
|
||||
if (!method->is_empty_method()) {
|
||||
warning("Blackhole compile option only works for empty methods: %s",
|
||||
method->name_and_sig_as_C_string());
|
||||
return;
|
||||
}
|
||||
if (!method->is_static()) {
|
||||
warning("Blackhole compile option only works for static methods: %s",
|
||||
method->name_and_sig_as_C_string());
|
||||
return;
|
||||
}
|
||||
if (method->intrinsic_id() == vmIntrinsics::_blackhole) {
|
||||
return;
|
||||
}
|
||||
if (method->intrinsic_id() != vmIntrinsics::_none) {
|
||||
warning("Blackhole compile option only works for methods that do not have intrinsic set: %s, %s",
|
||||
method->name_and_sig_as_C_string(), vmIntrinsics::name_at(method->intrinsic_id()));
|
||||
return;
|
||||
}
|
||||
method->set_intrinsic_id(vmIntrinsics::_blackhole);
|
||||
}
|
||||
|
||||
static enum CompileCommand match_option_name(const char* line, int* bytes_read, char* errorbuf, int bufsize) {
|
||||
assert(ARRAY_SIZE(option_names) == static_cast<int>(CompileCommand::Count), "option_names size mismatch");
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2021, 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
|
||||
@ -51,6 +51,7 @@ class methodHandle;
|
||||
option(Print, "print", Bool) \
|
||||
option(Inline, "inline", Bool) \
|
||||
option(DontInline, "dontinline", Bool) \
|
||||
option(Blackhole, "blackhole", Bool) \
|
||||
option(CompileOnly, "compileonly", Bool)\
|
||||
option(Exclude, "exclude", Bool) \
|
||||
option(Break, "break", Bool) \
|
||||
@ -144,6 +145,9 @@ class CompilerOracle : AllStatic {
|
||||
// Tells whether there are any methods to print for print_method_statistics()
|
||||
static bool should_print_methods();
|
||||
|
||||
// Tags the method as blackhole candidate, if possible.
|
||||
static void tag_blackhole_if_possible(const methodHandle& method);
|
||||
|
||||
// A wrapper for checking bool options
|
||||
static bool has_option(const methodHandle& method, enum CompileCommand option);
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "classfile/symbolTable.hpp"
|
||||
#include "classfile/systemDictionary.hpp"
|
||||
#include "code/codeCache.hpp"
|
||||
#include "compiler/compilerOracle.hpp"
|
||||
#include "compiler/compileTask.hpp"
|
||||
#include "memory/oopFactory.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
@ -991,6 +992,7 @@ JVMCIObject JVMCIEnv::get_jvmci_method(const methodHandle& method, JVMCI_TRAPS)
|
||||
jmetadata handle = _runtime->allocate_handle(method);
|
||||
jboolean exception = false;
|
||||
if (is_hotspot()) {
|
||||
CompilerOracle::tag_blackhole_if_possible(method);
|
||||
JavaValue result(T_OBJECT);
|
||||
JavaCallArguments args;
|
||||
args.push_long((jlong) handle);
|
||||
|
@ -677,6 +677,8 @@ bool C2Compiler::is_intrinsic_supported(const methodHandle& method, bool is_virt
|
||||
case vmIntrinsics::_VectorInsert:
|
||||
case vmIntrinsics::_VectorExtract:
|
||||
return EnableVectorSupport;
|
||||
case vmIntrinsics::_blackhole:
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
|
@ -44,6 +44,7 @@ macro(ArrayCopy)
|
||||
macro(AryEq)
|
||||
macro(AtanD)
|
||||
macro(Binary)
|
||||
macro(Blackhole)
|
||||
macro(Bool)
|
||||
macro(BoxLock)
|
||||
macro(ReverseBytesI)
|
||||
|
@ -3519,6 +3519,8 @@ void Compile::final_graph_reshaping_main_switch(Node* n, Final_Reshape_Counts& f
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Op_Blackhole:
|
||||
break;
|
||||
case Op_RangeCheck: {
|
||||
RangeCheckNode* rc = n->as_RangeCheck();
|
||||
Node* iff = new IfNode(rc->in(0), rc->in(1), rc->_prob, rc->_fcnt);
|
||||
|
@ -111,7 +111,7 @@ JVMState* LibraryIntrinsic::generate(JVMState* jvms) {
|
||||
Node* ctrl = kit.control();
|
||||
#endif
|
||||
// Try to inline the intrinsic.
|
||||
if ((CheckIntrinsics ? callee->intrinsic_candidate() : true) &&
|
||||
if (callee->check_intrinsic_candidate() &&
|
||||
kit.try_to_inline(_last_predicate)) {
|
||||
const char *inline_msg = is_virtual() ? "(intrinsic, virtual)"
|
||||
: "(intrinsic)";
|
||||
@ -669,6 +669,9 @@ bool LibraryCallKit::try_to_inline(int predicate) {
|
||||
case vmIntrinsics::_getObjectSize:
|
||||
return inline_getObjectSize();
|
||||
|
||||
case vmIntrinsics::_blackhole:
|
||||
return inline_blackhole();
|
||||
|
||||
default:
|
||||
// If you get here, it may be that someone has added a new intrinsic
|
||||
// to the list in vmIntrinsics.hpp without implementing it here.
|
||||
@ -6911,3 +6914,23 @@ bool LibraryCallKit::inline_getObjectSize() {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------- inline_blackhole --------------------------------------
|
||||
//
|
||||
// Make sure all arguments to this node are alive.
|
||||
// This matches methods that were requested to be blackholed through compile commands.
|
||||
//
|
||||
bool LibraryCallKit::inline_blackhole() {
|
||||
assert(callee()->is_static(), "Should have been checked before: only static methods here");
|
||||
assert(callee()->is_empty(), "Should have been checked before: only empty methods here");
|
||||
assert(callee()->holder()->is_loaded(), "Should have been checked before: only methods for loaded classes here");
|
||||
|
||||
// Bind call arguments as blackhole arguments to keep them alive
|
||||
Node* bh = insert_mem_bar(Op_Blackhole);
|
||||
uint nargs = callee()->arg_size();
|
||||
for (uint i = 0; i < nargs; i++) {
|
||||
bh->add_req(argument(i));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -344,5 +344,7 @@ class LibraryCallKit : public GraphKit {
|
||||
}
|
||||
|
||||
bool inline_getObjectSize();
|
||||
|
||||
bool inline_blackhole();
|
||||
};
|
||||
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "opto/addnode.hpp"
|
||||
#include "opto/arraycopynode.hpp"
|
||||
#include "opto/cfgnode.hpp"
|
||||
#include "opto/regalloc.hpp"
|
||||
#include "opto/compile.hpp"
|
||||
#include "opto/connode.hpp"
|
||||
#include "opto/convertnode.hpp"
|
||||
@ -3305,6 +3306,7 @@ MemBarNode* MemBarNode::make(Compile* C, int opcode, int atp, Node* pn) {
|
||||
case Op_OnSpinWait: return new OnSpinWaitNode(C, atp, pn);
|
||||
case Op_Initialize: return new InitializeNode(C, atp, pn);
|
||||
case Op_MemBarStoreStore: return new MemBarStoreStoreNode(C, atp, pn);
|
||||
case Op_Blackhole: return new BlackholeNode(C, atp, pn);
|
||||
default: ShouldNotReachHere(); return NULL;
|
||||
}
|
||||
}
|
||||
@ -3539,6 +3541,27 @@ MemBarNode* MemBarNode::leading_membar() const {
|
||||
return mb;
|
||||
}
|
||||
|
||||
#ifndef PRODUCT
|
||||
void BlackholeNode::format(PhaseRegAlloc* ra, outputStream* st) const {
|
||||
st->print("blackhole ");
|
||||
bool first = true;
|
||||
for (uint i = 0; i < req(); i++) {
|
||||
Node* n = in(i);
|
||||
if (n != NULL && OptoReg::is_valid(ra->get_reg_first(n))) {
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
st->print(", ");
|
||||
}
|
||||
char buf[128];
|
||||
ra->dump_register(n, buf);
|
||||
st->print("%s", buf);
|
||||
}
|
||||
}
|
||||
st->cr();
|
||||
}
|
||||
#endif
|
||||
|
||||
//===========================InitializeNode====================================
|
||||
// SUMMARY:
|
||||
// This node acts as a memory barrier on raw memory, after some raw stores.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2021, 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
|
||||
@ -1337,6 +1337,26 @@ public:
|
||||
virtual int Opcode() const;
|
||||
};
|
||||
|
||||
//------------------------------BlackholeNode----------------------------
|
||||
// Blackhole all arguments. This node would survive through the compiler
|
||||
// the effects on its arguments, and would be finally matched to nothing.
|
||||
class BlackholeNode : public MemBarNode {
|
||||
public:
|
||||
BlackholeNode(Compile* C, int alias_idx, Node* precedent)
|
||||
: MemBarNode(C, alias_idx, precedent) {}
|
||||
virtual int Opcode() const;
|
||||
virtual uint ideal_reg() const { return 0; } // not matched in the AD file
|
||||
const RegMask &in_RegMask(uint idx) const {
|
||||
// Fake the incoming arguments mask for blackholes: accept all registers
|
||||
// and all stack slots. This would avoid any redundant register moves
|
||||
// for blackhole inputs.
|
||||
return RegMask::All;
|
||||
}
|
||||
#ifndef PRODUCT
|
||||
virtual void format(PhaseRegAlloc* ra, outputStream* st) const;
|
||||
#endif
|
||||
};
|
||||
|
||||
// Isolation of object setup after an AllocateNode and before next safepoint.
|
||||
// (See comment in memnode.cpp near InitializeNode::InitializeNode for semantics.)
|
||||
class InitializeNode: public MemBarNode {
|
||||
|
@ -44,6 +44,7 @@ class AllocateNode;
|
||||
class ArrayCopyNode;
|
||||
class BaseCountedLoopNode;
|
||||
class BaseCountedLoopEndNode;
|
||||
class BlackholeNode;
|
||||
class Block;
|
||||
class BoolNode;
|
||||
class BoxLockNode;
|
||||
|
@ -51,6 +51,13 @@ void OptoReg::dump(int r, outputStream *st) {
|
||||
//=============================================================================
|
||||
const RegMask RegMask::Empty;
|
||||
|
||||
const RegMask RegMask::All(
|
||||
# define BODY(I) -1,
|
||||
FORALL_BODY
|
||||
# undef BODY
|
||||
0
|
||||
);
|
||||
|
||||
//=============================================================================
|
||||
bool RegMask::is_vector(uint ireg) {
|
||||
return (ireg == Op_VecA || ireg == Op_VecS || ireg == Op_VecD ||
|
||||
|
@ -357,6 +357,7 @@ class RegMask {
|
||||
#endif
|
||||
|
||||
static const RegMask Empty; // Common empty mask
|
||||
static const RegMask All; // Common all mask
|
||||
|
||||
static bool can_represent(OptoReg::Name reg) {
|
||||
// NOTE: -1 in computation reflects the usage of the last
|
||||
|
@ -1596,6 +1596,7 @@ typedef HashtableEntry<InstanceKlass*, mtClass> KlassHashtableEntry;
|
||||
declare_c2_type(MemBarVolatileNode, MemBarNode) \
|
||||
declare_c2_type(MemBarCPUOrderNode, MemBarNode) \
|
||||
declare_c2_type(OnSpinWaitNode, MemBarNode) \
|
||||
declare_c2_type(BlackholeNode, MemBarNode) \
|
||||
declare_c2_type(InitializeNode, MemBarNode) \
|
||||
declare_c2_type(ThreadLocalNode, Node) \
|
||||
declare_c2_type(Opaque1Node, Node) \
|
||||
|
@ -95,6 +95,7 @@ hotspot_slow_compiler = \
|
||||
|
||||
tier1_compiler_1 = \
|
||||
compiler/arraycopy/ \
|
||||
compiler/blackhole/ \
|
||||
compiler/c1/ \
|
||||
compiler/c2/ \
|
||||
-compiler/c2/Test6850611.java \
|
||||
|
@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Red Hat, Inc. 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @library /test/lib /
|
||||
* @requires vm.flagless
|
||||
* @run driver compiler.blackhole.BlackholeExistingIntrinsicWarningTest
|
||||
*/
|
||||
|
||||
package compiler.blackhole;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
import java.util.ArrayList;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
|
||||
public class BlackholeExistingIntrinsicWarningTest {
|
||||
|
||||
private static final int CYCLES = 100_000;
|
||||
private static final int TRIES = 10;
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
if (args.length == 0) {
|
||||
driver();
|
||||
} else {
|
||||
runner();
|
||||
}
|
||||
}
|
||||
|
||||
private static final String MSG =
|
||||
"Blackhole compile option only works for methods that do not have intrinsic set: java.lang.Thread.onSpinWait()V, _onSpinWait";
|
||||
|
||||
private static List<String> cmdline(String[] args) {
|
||||
List<String> r = new ArrayList();
|
||||
r.add("-Xmx128m");
|
||||
r.add("-Xbatch");
|
||||
r.addAll(Arrays.asList(args));
|
||||
r.add("compiler.blackhole.BlackholeExistingIntrinsicWarningTest");
|
||||
r.add("run");
|
||||
return r;
|
||||
}
|
||||
|
||||
public static void shouldFail(String... args) throws IOException {
|
||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmdline(args));
|
||||
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||
output.shouldHaveExitValue(0);
|
||||
output.shouldContain(MSG);
|
||||
}
|
||||
|
||||
public static void shouldPass(String... args) throws IOException {
|
||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmdline(args));
|
||||
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||
output.shouldHaveExitValue(0);
|
||||
output.shouldNotContain(MSG);
|
||||
}
|
||||
|
||||
public static void driver() throws IOException {
|
||||
// Should print the warning
|
||||
shouldFail(
|
||||
"-XX:+UnlockExperimentalVMOptions",
|
||||
"-XX:CompileCommand=quiet",
|
||||
"-XX:CompileCommand=blackhole,java/lang/Thread.onSpinWait"
|
||||
);
|
||||
shouldFail(
|
||||
"-XX:+UnlockExperimentalVMOptions",
|
||||
"-XX:CompileCommand=quiet",
|
||||
"-XX:CompileCommand=option,java/lang/Thread.onSpinWait,Blackhole"
|
||||
);
|
||||
|
||||
// Should be able to shun the warning
|
||||
shouldPass(
|
||||
"-XX:-PrintWarnings",
|
||||
"-XX:+UnlockExperimentalVMOptions",
|
||||
"-XX:CompileCommand=quiet",
|
||||
"-XX:CompileCommand=blackhole,java/lang/Thread.onSpinWait"
|
||||
);
|
||||
shouldPass(
|
||||
"-XX:-PrintWarnings",
|
||||
"-XX:+UnlockExperimentalVMOptions",
|
||||
"-XX:CompileCommand=quiet",
|
||||
"-XX:CompileCommand=option,java/lang/Thread.onSpinWait,Blackhole"
|
||||
);
|
||||
}
|
||||
|
||||
public static void runner() {
|
||||
for (int t = 0; t < TRIES; t++) {
|
||||
run();
|
||||
}
|
||||
}
|
||||
|
||||
public static void run() {
|
||||
for (int c = 0; c < CYCLES; c++) {
|
||||
Thread.onSpinWait();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Red Hat, Inc. 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @library /test/lib /
|
||||
* @requires vm.flagless
|
||||
* @run driver compiler.blackhole.BlackholeExperimentalUnlockTest
|
||||
*/
|
||||
|
||||
package compiler.blackhole;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
import java.util.ArrayList;
|
||||
import jdk.test.lib.Platform;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
|
||||
public class BlackholeExperimentalUnlockTest {
|
||||
|
||||
private static final int CYCLES = 100_000;
|
||||
private static final int TRIES = 10;
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
if (args.length == 0) {
|
||||
driver();
|
||||
} else {
|
||||
runner();
|
||||
}
|
||||
}
|
||||
|
||||
private static final String MSG = "Blackhole compile option is experimental and must be enabled via -XX:+UnlockExperimentalVMOptions";
|
||||
|
||||
private static List<String> cmdline(String[] args) {
|
||||
List<String> r = new ArrayList();
|
||||
r.add("-Xmx128m");
|
||||
r.add("-Xbatch");
|
||||
r.addAll(Arrays.asList(args));
|
||||
r.add("compiler.blackhole.BlackholeExperimentalUnlockTest");
|
||||
r.add("run");
|
||||
return r;
|
||||
}
|
||||
|
||||
public static void shouldFail(String... args) throws IOException {
|
||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmdline(args));
|
||||
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||
output.shouldHaveExitValue(0);
|
||||
output.shouldContain(MSG);
|
||||
}
|
||||
|
||||
public static void shouldPass(String... args) throws IOException {
|
||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmdline(args));
|
||||
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||
output.shouldHaveExitValue(0);
|
||||
output.shouldNotContain(MSG);
|
||||
}
|
||||
|
||||
public static void driver() throws IOException {
|
||||
// Option is disabled by default, should fail:
|
||||
shouldFail(
|
||||
"-XX:CompileCommand=quiet",
|
||||
"-XX:CompileCommand=option,compiler/blackhole/BlackholeTarget.bh_*,Blackhole"
|
||||
);
|
||||
shouldFail(
|
||||
"-XX:CompileCommand=quiet",
|
||||
"-XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*"
|
||||
);
|
||||
|
||||
// Option should be enabled by UnlockExperimentalVMOptions
|
||||
shouldPass(
|
||||
"-XX:+UnlockExperimentalVMOptions",
|
||||
"-XX:CompileCommand=quiet",
|
||||
"-XX:CompileCommand=option,compiler/blackhole/BlackholeTarget.bh_*,Blackhole"
|
||||
);
|
||||
shouldPass(
|
||||
"-XX:+UnlockExperimentalVMOptions",
|
||||
"-XX:CompileCommand=quiet",
|
||||
"-XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*"
|
||||
);
|
||||
|
||||
// Should be able to shun the warning
|
||||
shouldPass(
|
||||
"-XX:-PrintWarnings",
|
||||
"-XX:CompileCommand=quiet",
|
||||
"-XX:CompileCommand=option,compiler/blackhole/BlackholeTarget.bh_*,Blackhole"
|
||||
);
|
||||
shouldPass(
|
||||
"-XX:-PrintWarnings",
|
||||
"-XX:CompileCommand=quiet",
|
||||
"-XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*"
|
||||
);
|
||||
}
|
||||
|
||||
public static void runner() {
|
||||
for (int t = 0; t < TRIES; t++) {
|
||||
run();
|
||||
}
|
||||
}
|
||||
|
||||
public static void run() {
|
||||
for (int c = 0; c < CYCLES; c++) {
|
||||
BlackholeTarget.bh_s_int_1(c);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,298 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Red Hat, Inc. 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @library /test/lib /
|
||||
* @requires vm.flagless
|
||||
* @run driver compiler.blackhole.BlackholeIntrinsicTest
|
||||
*/
|
||||
|
||||
package compiler.blackhole;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import jdk.test.lib.Platform;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
|
||||
public class BlackholeIntrinsicTest {
|
||||
|
||||
private static final Map<String, Runnable> TESTS;
|
||||
|
||||
static {
|
||||
TESTS = new LinkedHashMap<>();
|
||||
TESTS.put("bh_s_boolean_0", BlackholeIntrinsicTest::test_boolean_0);
|
||||
TESTS.put("bh_s_byte_0", BlackholeIntrinsicTest::test_byte_0);
|
||||
TESTS.put("bh_s_char_0", BlackholeIntrinsicTest::test_char_0);
|
||||
TESTS.put("bh_s_short_0", BlackholeIntrinsicTest::test_short_0);
|
||||
TESTS.put("bh_s_int_0", BlackholeIntrinsicTest::test_int_0);
|
||||
TESTS.put("bh_s_float_0", BlackholeIntrinsicTest::test_float_0);
|
||||
TESTS.put("bh_s_long_0", BlackholeIntrinsicTest::test_long_0);
|
||||
TESTS.put("bh_s_double_0", BlackholeIntrinsicTest::test_double_0);
|
||||
TESTS.put("bh_s_Object_0", BlackholeIntrinsicTest::test_Object_0);
|
||||
|
||||
TESTS.put("bh_s_boolean_1", BlackholeIntrinsicTest::test_boolean_1);
|
||||
TESTS.put("bh_s_byte_1", BlackholeIntrinsicTest::test_byte_1);
|
||||
TESTS.put("bh_s_char_1", BlackholeIntrinsicTest::test_char_1);
|
||||
TESTS.put("bh_s_short_1", BlackholeIntrinsicTest::test_short_1);
|
||||
TESTS.put("bh_s_int_1", BlackholeIntrinsicTest::test_int_1);
|
||||
TESTS.put("bh_s_float_1", BlackholeIntrinsicTest::test_float_1);
|
||||
TESTS.put("bh_s_long_1", BlackholeIntrinsicTest::test_long_1);
|
||||
TESTS.put("bh_s_double_1", BlackholeIntrinsicTest::test_double_1);
|
||||
TESTS.put("bh_s_Object_1", BlackholeIntrinsicTest::test_Object_1);
|
||||
|
||||
TESTS.put("bh_s_boolean_2", BlackholeIntrinsicTest::test_boolean_2);
|
||||
TESTS.put("bh_s_byte_2", BlackholeIntrinsicTest::test_byte_2);
|
||||
TESTS.put("bh_s_char_2", BlackholeIntrinsicTest::test_char_2);
|
||||
TESTS.put("bh_s_short_2", BlackholeIntrinsicTest::test_short_2);
|
||||
TESTS.put("bh_s_int_2", BlackholeIntrinsicTest::test_int_2);
|
||||
TESTS.put("bh_s_float_2", BlackholeIntrinsicTest::test_float_2);
|
||||
TESTS.put("bh_s_long_2", BlackholeIntrinsicTest::test_long_2);
|
||||
TESTS.put("bh_s_double_2", BlackholeIntrinsicTest::test_double_2);
|
||||
TESTS.put("bh_s_Object_2", BlackholeIntrinsicTest::test_Object_2);
|
||||
}
|
||||
|
||||
private static final int CYCLES = 100_000;
|
||||
private static final int TRIES = 10;
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
if (args.length == 0) {
|
||||
driver();
|
||||
} else {
|
||||
test(args[0]);
|
||||
}
|
||||
}
|
||||
|
||||
public static void driver() throws IOException {
|
||||
for (String test : TESTS.keySet()) {
|
||||
check(test, "-XX:TieredStopAtLevel=1");
|
||||
check(test, "-XX:-TieredCompilation");
|
||||
if (Platform.is64bit()) {
|
||||
check(test, "-XX:-UseCompressedOops", "-XX:TieredStopAtLevel=1");
|
||||
check(test, "-XX:-UseCompressedOops", "-XX:-TieredCompilation");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void test(String test) {
|
||||
Runnable r = TESTS.get(test);
|
||||
if (r == null) {
|
||||
throw new IllegalArgumentException("Cannot find test " + test);
|
||||
}
|
||||
for (int t = 0; t < TRIES; t++) {
|
||||
r.run();
|
||||
}
|
||||
}
|
||||
|
||||
public static void check(String test, String... args) throws IOException {
|
||||
List<String> cmdline = new ArrayList();
|
||||
cmdline.add("-Xmx128m");
|
||||
cmdline.add("-Xbatch");
|
||||
cmdline.add("-XX:+UnlockDiagnosticVMOptions");
|
||||
cmdline.add("-XX:+AbortVMOnCompilationFailure");
|
||||
cmdline.add("-XX:+PrintCompilation");
|
||||
cmdline.add("-XX:+PrintInlining");
|
||||
cmdline.add("-XX:+UnlockExperimentalVMOptions");
|
||||
cmdline.add("-XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*");
|
||||
cmdline.addAll(Arrays.asList(args));
|
||||
cmdline.add("compiler.blackhole.BlackholeIntrinsicTest");
|
||||
cmdline.add(test);
|
||||
|
||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmdline);
|
||||
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||
output.shouldHaveExitValue(0);
|
||||
output.stderrShouldBeEmpty();
|
||||
output.stdoutShouldMatch("compiler.blackhole.BlackholeTarget::" + test + ".*intrinsic.*");
|
||||
}
|
||||
|
||||
private static void test_boolean_0() {
|
||||
for (int c = 0; c < CYCLES; c++) {
|
||||
BlackholeTarget.bh_s_boolean_0();
|
||||
}
|
||||
}
|
||||
|
||||
private static void test_byte_0() {
|
||||
for (int c = 0; c < CYCLES; c++) {
|
||||
BlackholeTarget.bh_s_byte_0();
|
||||
}
|
||||
}
|
||||
|
||||
private static void test_char_0() {
|
||||
for (int c = 0; c < CYCLES; c++) {
|
||||
BlackholeTarget.bh_s_char_0();
|
||||
}
|
||||
}
|
||||
|
||||
private static void test_short_0() {
|
||||
for (int c = 0; c < CYCLES; c++) {
|
||||
BlackholeTarget.bh_s_short_0();
|
||||
}
|
||||
}
|
||||
|
||||
private static void test_int_0() {
|
||||
for (int c = 0; c < CYCLES; c++) {
|
||||
BlackholeTarget.bh_s_int_0();
|
||||
}
|
||||
}
|
||||
|
||||
private static void test_float_0() {
|
||||
for (int c = 0; c < CYCLES; c++) {
|
||||
BlackholeTarget.bh_s_float_0();
|
||||
}
|
||||
}
|
||||
|
||||
private static void test_long_0() {
|
||||
for (int c = 0; c < CYCLES; c++) {
|
||||
BlackholeTarget.bh_s_long_0();
|
||||
}
|
||||
}
|
||||
|
||||
private static void test_double_0() {
|
||||
for (int c = 0; c < CYCLES; c++) {
|
||||
BlackholeTarget.bh_s_double_0();
|
||||
}
|
||||
}
|
||||
|
||||
private static void test_Object_0() {
|
||||
for (int c = 0; c < CYCLES; c++) {
|
||||
BlackholeTarget.bh_s_Object_0();
|
||||
}
|
||||
}
|
||||
|
||||
private static void test_boolean_1() {
|
||||
for (int c = 0; c < CYCLES; c++) {
|
||||
BlackholeTarget.bh_s_boolean_1((c & 0x1) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
private static void test_byte_1() {
|
||||
for (int c = 0; c < CYCLES; c++) {
|
||||
BlackholeTarget.bh_s_byte_1((byte)c);
|
||||
}
|
||||
}
|
||||
|
||||
private static void test_char_1() {
|
||||
for (int c = 0; c < CYCLES; c++) {
|
||||
BlackholeTarget.bh_s_char_1((char)c);
|
||||
}
|
||||
}
|
||||
|
||||
private static void test_short_1() {
|
||||
for (int c = 0; c < CYCLES; c++) {
|
||||
BlackholeTarget.bh_s_short_1((short)c);
|
||||
}
|
||||
}
|
||||
|
||||
private static void test_int_1() {
|
||||
for (int c = 0; c < CYCLES; c++) {
|
||||
BlackholeTarget.bh_s_int_1(c);
|
||||
}
|
||||
}
|
||||
|
||||
private static void test_float_1() {
|
||||
for (int c = 0; c < CYCLES; c++) {
|
||||
BlackholeTarget.bh_s_float_1(c);
|
||||
}
|
||||
}
|
||||
|
||||
private static void test_long_1() {
|
||||
for (int c = 0; c < CYCLES; c++) {
|
||||
BlackholeTarget.bh_s_long_1(c);
|
||||
}
|
||||
}
|
||||
|
||||
private static void test_double_1() {
|
||||
for (int c = 0; c < CYCLES; c++) {
|
||||
BlackholeTarget.bh_s_double_1(c);
|
||||
}
|
||||
}
|
||||
|
||||
private static void test_Object_1() {
|
||||
for (int c = 0; c < CYCLES; c++) {
|
||||
Object o = new Object();
|
||||
BlackholeTarget.bh_s_Object_1(o);
|
||||
}
|
||||
}
|
||||
|
||||
private static void test_boolean_2() {
|
||||
for (int c = 0; c < CYCLES; c++) {
|
||||
BlackholeTarget.bh_s_boolean_2((c & 0x1) == 0, (c & 0x2) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
private static void test_byte_2() {
|
||||
for (int c = 0; c < CYCLES; c++) {
|
||||
BlackholeTarget.bh_s_byte_2((byte)c, (byte)(c + 1));
|
||||
}
|
||||
}
|
||||
|
||||
private static void test_char_2() {
|
||||
for (int c = 0; c < CYCLES; c++) {
|
||||
BlackholeTarget.bh_s_char_2((char)c, (char)(c + 1));
|
||||
}
|
||||
}
|
||||
|
||||
private static void test_short_2() {
|
||||
for (int c = 0; c < CYCLES; c++) {
|
||||
BlackholeTarget.bh_s_short_2((short)c, (short)(c + 1));
|
||||
}
|
||||
}
|
||||
|
||||
private static void test_int_2() {
|
||||
for (int c = 0; c < CYCLES; c++) {
|
||||
BlackholeTarget.bh_s_int_2(c, c + 1);
|
||||
}
|
||||
}
|
||||
|
||||
private static void test_float_2() {
|
||||
for (int c = 0; c < CYCLES; c++) {
|
||||
BlackholeTarget.bh_s_float_2(c, c + 1);
|
||||
}
|
||||
}
|
||||
|
||||
private static void test_long_2() {
|
||||
for (int c = 0; c < CYCLES; c++) {
|
||||
BlackholeTarget.bh_s_long_2(c, c + 1);
|
||||
}
|
||||
}
|
||||
|
||||
private static void test_double_2() {
|
||||
for (int c = 0; c < CYCLES; c++) {
|
||||
BlackholeTarget.bh_s_double_2(c, c + 1);
|
||||
}
|
||||
}
|
||||
|
||||
private static void test_Object_2() {
|
||||
for (int c = 0; c < CYCLES; c++) {
|
||||
Object o1 = new Object();
|
||||
Object o2 = new Object();
|
||||
BlackholeTarget.bh_s_Object_2(o1, o2);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Red Hat, Inc. 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @library /test/lib /
|
||||
* @requires vm.flagless
|
||||
* @run driver compiler.blackhole.BlackholeNonEmptyWarningTest
|
||||
*/
|
||||
|
||||
package compiler.blackhole;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
import java.util.ArrayList;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
|
||||
public class BlackholeNonEmptyWarningTest {
|
||||
|
||||
private static final int CYCLES = 100_000;
|
||||
private static final int TRIES = 10;
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
if (args.length == 0) {
|
||||
driver();
|
||||
} else {
|
||||
runner();
|
||||
}
|
||||
}
|
||||
|
||||
private static final String MSG = "Blackhole compile option only works for empty methods: compiler.blackhole.BlackholeTarget.bh_s_int_1_delegate(I)V";
|
||||
|
||||
private static List<String> cmdline(String[] args) {
|
||||
List<String> r = new ArrayList();
|
||||
r.add("-Xmx128m");
|
||||
r.add("-Xbatch");
|
||||
r.addAll(Arrays.asList(args));
|
||||
r.add("compiler.blackhole.BlackholeNonEmptyWarningTest");
|
||||
r.add("run");
|
||||
return r;
|
||||
}
|
||||
|
||||
public static void shouldFail(String... args) throws IOException {
|
||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmdline(args));
|
||||
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||
output.shouldHaveExitValue(0);
|
||||
output.shouldContain(MSG);
|
||||
}
|
||||
|
||||
public static void shouldPass(String... args) throws IOException {
|
||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmdline(args));
|
||||
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||
output.shouldHaveExitValue(0);
|
||||
output.shouldNotContain(MSG);
|
||||
}
|
||||
|
||||
public static void driver() throws IOException {
|
||||
// Should print the warning
|
||||
shouldFail(
|
||||
"-XX:+UnlockExperimentalVMOptions",
|
||||
"-XX:CompileCommand=quiet",
|
||||
"-XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*"
|
||||
);
|
||||
shouldFail(
|
||||
"-XX:+UnlockExperimentalVMOptions",
|
||||
"-XX:CompileCommand=quiet",
|
||||
"-XX:CompileCommand=option,compiler/blackhole/BlackholeTarget.bh_*,Blackhole"
|
||||
);
|
||||
|
||||
// Should be able to shun the warning
|
||||
shouldPass(
|
||||
"-XX:-PrintWarnings",
|
||||
"-XX:+UnlockExperimentalVMOptions",
|
||||
"-XX:CompileCommand=quiet",
|
||||
"-XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*"
|
||||
);
|
||||
shouldPass(
|
||||
"-XX:-PrintWarnings",
|
||||
"-XX:+UnlockExperimentalVMOptions",
|
||||
"-XX:CompileCommand=quiet",
|
||||
"-XX:CompileCommand=option,compiler/blackhole/BlackholeTarget.bh_*,Blackhole"
|
||||
);
|
||||
}
|
||||
|
||||
public static void runner() {
|
||||
for (int t = 0; t < TRIES; t++) {
|
||||
run();
|
||||
}
|
||||
}
|
||||
|
||||
public static void run() {
|
||||
for (int c = 0; c < CYCLES; c++) {
|
||||
BlackholeTarget.bh_s_int_1_delegate(c);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Red Hat, Inc. 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @library /test/lib /
|
||||
* @requires vm.flagless
|
||||
* @run driver compiler.blackhole.BlackholeNonStaticWarningTest
|
||||
*/
|
||||
|
||||
package compiler.blackhole;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
import java.util.ArrayList;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
|
||||
public class BlackholeNonStaticWarningTest {
|
||||
|
||||
private static final int CYCLES = 100_000;
|
||||
private static final int TRIES = 10;
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
if (args.length == 0) {
|
||||
driver();
|
||||
} else {
|
||||
runner();
|
||||
}
|
||||
}
|
||||
|
||||
private static final String MSG = "Blackhole compile option only works for static methods: compiler.blackhole.BlackholeTarget.bh_i_int_0()V";
|
||||
|
||||
private static List<String> cmdline(String[] args) {
|
||||
List<String> r = new ArrayList();
|
||||
r.add("-Xmx128m");
|
||||
r.add("-Xbatch");
|
||||
r.addAll(Arrays.asList(args));
|
||||
r.add("compiler.blackhole.BlackholeNonStaticWarningTest");
|
||||
r.add("run");
|
||||
return r;
|
||||
}
|
||||
|
||||
public static void shouldFail(String... args) throws IOException {
|
||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmdline(args));
|
||||
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||
output.shouldHaveExitValue(0);
|
||||
output.shouldContain(MSG);
|
||||
}
|
||||
|
||||
public static void shouldPass(String... args) throws IOException {
|
||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmdline(args));
|
||||
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||
output.shouldHaveExitValue(0);
|
||||
output.shouldNotContain(MSG);
|
||||
}
|
||||
|
||||
public static void driver() throws IOException {
|
||||
// Should print the warning
|
||||
shouldFail(
|
||||
"-XX:+UnlockExperimentalVMOptions",
|
||||
"-XX:CompileCommand=quiet",
|
||||
"-XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*"
|
||||
);
|
||||
shouldFail(
|
||||
"-XX:+UnlockExperimentalVMOptions",
|
||||
"-XX:CompileCommand=quiet",
|
||||
"-XX:CompileCommand=option,compiler/blackhole/BlackholeTarget.bh_*,Blackhole"
|
||||
);
|
||||
|
||||
// Should be able to shun the warning
|
||||
shouldPass(
|
||||
"-XX:-PrintWarnings",
|
||||
"-XX:+UnlockExperimentalVMOptions",
|
||||
"-XX:CompileCommand=quiet",
|
||||
"-XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*"
|
||||
);
|
||||
shouldPass(
|
||||
"-XX:-PrintWarnings",
|
||||
"-XX:+UnlockExperimentalVMOptions",
|
||||
"-XX:CompileCommand=quiet",
|
||||
"-XX:CompileCommand=option,compiler/blackhole/BlackholeTarget.bh_*,Blackhole"
|
||||
);
|
||||
}
|
||||
|
||||
public static void runner() {
|
||||
for (int t = 0; t < TRIES; t++) {
|
||||
run();
|
||||
}
|
||||
}
|
||||
|
||||
public static void run() {
|
||||
BlackholeTarget t = new BlackholeTarget();
|
||||
for (int c = 0; c < CYCLES; c++) {
|
||||
t.bh_i_int_0();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Red Hat, Inc. 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @library /test/lib /
|
||||
* @requires vm.flagless
|
||||
* @run driver compiler.blackhole.BlackholeNonVoidWarningTest
|
||||
*/
|
||||
|
||||
package compiler.blackhole;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
import java.util.ArrayList;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
|
||||
public class BlackholeNonVoidWarningTest {
|
||||
|
||||
private static final int CYCLES = 100_000;
|
||||
private static final int TRIES = 10;
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
if (args.length == 0) {
|
||||
driver();
|
||||
} else {
|
||||
runner();
|
||||
}
|
||||
}
|
||||
|
||||
private static final String MSG = "Blackhole compile option only works for methods with void type: compiler.blackhole.BlackholeTarget.bh_sr_int(I)I";
|
||||
|
||||
private static List<String> cmdline(String[] args) {
|
||||
List<String> r = new ArrayList();
|
||||
r.add("-Xmx128m");
|
||||
r.add("-Xbatch");
|
||||
r.addAll(Arrays.asList(args));
|
||||
r.add("compiler.blackhole.BlackholeNonVoidWarningTest");
|
||||
r.add("run");
|
||||
return r;
|
||||
}
|
||||
|
||||
public static void shouldFail(String... args) throws IOException {
|
||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmdline(args));
|
||||
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||
output.shouldHaveExitValue(0);
|
||||
output.shouldContain(MSG);
|
||||
}
|
||||
|
||||
public static void shouldPass(String... args) throws IOException {
|
||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmdline(args));
|
||||
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||
output.shouldHaveExitValue(0);
|
||||
output.shouldNotContain(MSG);
|
||||
}
|
||||
|
||||
public static void driver() throws IOException {
|
||||
// Should print the warning
|
||||
shouldFail(
|
||||
"-XX:+UnlockExperimentalVMOptions",
|
||||
"-XX:CompileCommand=quiet",
|
||||
"-XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*"
|
||||
);
|
||||
shouldFail(
|
||||
"-XX:+UnlockExperimentalVMOptions",
|
||||
"-XX:CompileCommand=quiet",
|
||||
"-XX:CompileCommand=option,compiler/blackhole/BlackholeTarget.bh_*,Blackhole"
|
||||
);
|
||||
|
||||
// Should be able to shun the warning
|
||||
shouldPass(
|
||||
"-XX:-PrintWarnings",
|
||||
"-XX:+UnlockExperimentalVMOptions",
|
||||
"-XX:CompileCommand=quiet",
|
||||
"-XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*"
|
||||
);
|
||||
shouldPass(
|
||||
"-XX:-PrintWarnings",
|
||||
"-XX:+UnlockExperimentalVMOptions",
|
||||
"-XX:CompileCommand=quiet",
|
||||
"-XX:CompileCommand=option,compiler/blackhole/BlackholeTarget.bh_*,Blackhole"
|
||||
);
|
||||
}
|
||||
|
||||
public static void runner() {
|
||||
for (int t = 0; t < TRIES; t++) {
|
||||
run();
|
||||
}
|
||||
}
|
||||
|
||||
public static void run() {
|
||||
for (int c = 0; c < CYCLES; c++) {
|
||||
if (BlackholeTarget.bh_sr_int(c) != 0) {
|
||||
throw new AssertionError("Return value error");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
90
test/hotspot/jtreg/compiler/blackhole/BlackholeTarget.java
Normal file
90
test/hotspot/jtreg/compiler/blackhole/BlackholeTarget.java
Normal file
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Red Hat, Inc. 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 compiler.blackhole;
|
||||
|
||||
import java.lang.reflect.*;
|
||||
|
||||
public class BlackholeTarget {
|
||||
public void call_for_null_check() {}
|
||||
|
||||
public void bh_i_boolean_0() {}
|
||||
public void bh_i_byte_0() {}
|
||||
public void bh_i_short_0() {}
|
||||
public void bh_i_char_0() {}
|
||||
public void bh_i_int_0() {}
|
||||
public void bh_i_float_0() {}
|
||||
public void bh_i_long_0() {}
|
||||
public void bh_i_double_0() {}
|
||||
public void bh_i_Object_0() {}
|
||||
|
||||
public static void bh_s_boolean_0() {}
|
||||
public static void bh_s_byte_0() {}
|
||||
public static void bh_s_short_0() {}
|
||||
public static void bh_s_char_0() {}
|
||||
public static void bh_s_int_0() {}
|
||||
public static void bh_s_float_0() {}
|
||||
public static void bh_s_long_0() {}
|
||||
public static void bh_s_double_0() {}
|
||||
public static void bh_s_Object_0() {}
|
||||
|
||||
public static void bh_s_boolean_1(boolean v) {}
|
||||
public static void bh_s_byte_1(byte v) {}
|
||||
public static void bh_s_short_1(short v) {}
|
||||
public static void bh_s_char_1(char v) {}
|
||||
public static void bh_s_int_1(int v) {}
|
||||
public static void bh_s_float_1(float v) {}
|
||||
public static void bh_s_long_1(long v) {}
|
||||
public static void bh_s_double_1(double v) {}
|
||||
public static void bh_s_Object_1(Object v) {}
|
||||
|
||||
public static void bh_s_boolean_1_delegate(boolean v) { bh_s_boolean_1(v); }
|
||||
public static void bh_s_byte_1_delegate(byte v) { bh_s_byte_1(v); }
|
||||
public static void bh_s_short_1_delegate(short v) { bh_s_short_1(v); }
|
||||
public static void bh_s_char_1_delegate(char v) { bh_s_char_1(v); }
|
||||
public static void bh_s_int_1_delegate(int v) { bh_s_int_1(v); }
|
||||
public static void bh_s_float_1_delegate(float v) { bh_s_float_1(v); }
|
||||
public static void bh_s_long_1_delegate(long v) { bh_s_long_1(v); }
|
||||
public static void bh_s_double_1_delegate(double v) { bh_s_double_1(v); }
|
||||
public static void bh_s_Object_1_delegate(Object v) { bh_s_Object_1(v); }
|
||||
|
||||
public static void bh_s_boolean_2(boolean v1, boolean v2) {}
|
||||
public static void bh_s_byte_2(byte v1, byte v2) {}
|
||||
public static void bh_s_short_2(short v1, short v2) {}
|
||||
public static void bh_s_char_2(char v1, char v2) {}
|
||||
public static void bh_s_int_2(int v1, int v2) {}
|
||||
public static void bh_s_float_2(float v1, float v2) {}
|
||||
public static void bh_s_long_2(long v1, long v2) {}
|
||||
public static void bh_s_double_2(double v1, double v2) {}
|
||||
public static void bh_s_Object_2(Object v1, Object v2) {}
|
||||
|
||||
public static boolean bh_sr_boolean(boolean v) { return false; }
|
||||
public static byte bh_sr_byte(byte v) { return 0; }
|
||||
public static short bh_sr_short(short v) { return 0; }
|
||||
public static char bh_sr_char(char v) { return 0; }
|
||||
public static int bh_sr_int(int v) { return 0; }
|
||||
public static float bh_sr_float(float v) { return 0; }
|
||||
public static long bh_sr_long(long v) { return 0; }
|
||||
public static double bh_sr_double(double v) { return 0; }
|
||||
public static Object bh_sr_Object(Object v) { return null; }
|
||||
}
|
Loading…
Reference in New Issue
Block a user