8252505: C1/C2 compiler support for blackholes

Reviewed-by: vlivanov, aph
This commit is contained in:
Aleksey Shipilev 2020-12-06 17:43:34 +00:00
parent 972bc3b408
commit e590618962
30 changed files with 1520 additions and 2 deletions

@ -230,6 +230,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.
}

@ -3415,7 +3415,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()) {

@ -3206,6 +3206,10 @@ void LIRGenerator::do_Intrinsic(Intrinsic* x) {
do_vectorizedMismatch(x);
break;
case vmIntrinsics::_blackhole:
do_blackhole(x);
break;
default: ShouldNotReachHere(); break;
}
}
@ -3625,6 +3629,23 @@ void LIRGenerator::do_RangeCheckPredicate(RangeCheckPredicate *x) {
}
}
void LIRGenerator::do_blackhole(Intrinsic *x) {
// If we have a receiver, then null-check and handle it separately
bool handle_receiver = x->needs_null_check();
if (handle_receiver) {
CodeEmitInfo* info = state_for(x);
LIRItem vitem(x->receiver(), this);
vitem.load_item();
__ null_check(vitem.result(), info);
}
for (int c = (handle_receiver ? 1 : 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);

@ -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);

@ -155,6 +155,10 @@ ciMethod::ciMethod(const methodHandle& h_m, ciInstanceKlass* holder) :
ciReplay::initialize(this);
}
#endif
if (CompilerOracle::should_blackhole(h_m)) {
h_m->set_intrinsic_id(vmIntrinsics::_blackhole);
}
}

@ -201,6 +201,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) {

@ -5295,6 +5295,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

@ -151,6 +151,7 @@ bool vmIntrinsics::should_be_pinned(vmIntrinsics::ID id) {
#endif
case vmIntrinsics::_currentTimeMillis:
case vmIntrinsics::_nanoTime:
case vmIntrinsics::_blackhole:
return true;
default:
return false;

@ -533,6 +533,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") \

@ -282,6 +282,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) */ \
\

@ -409,6 +409,18 @@ bool CompilerOracle::should_break_at(const methodHandle& method) {
return check_predicate(CompileCommand::Break, method);
}
bool CompilerOracle::should_blackhole(const methodHandle& method) {
if (check_predicate(CompileCommand::Blackhole, method)) {
if (method->result_type() == T_VOID) {
return true;
} else {
warning("blackhole compile command only works for methods with void type: %s",
method->name_and_sig_as_C_string());
}
}
return false;
}
static enum CompileCommand parse_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");

@ -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) \
@ -141,6 +142,9 @@ class CompilerOracle : AllStatic {
// Tells whether to break when compiling method
static bool should_break_at(const methodHandle& method);
// Tells whether to blackhole when compiling method
static bool should_blackhole(const methodHandle& method);
// Tells whether there are any methods to print for print_method_statistics()
static bool should_print_methods();

@ -675,6 +675,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)

@ -3466,6 +3466,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);

@ -110,7 +110,7 @@ JVMState* LibraryIntrinsic::generate(JVMState* jvms) {
const int bci = kit.bci();
// 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)";
@ -667,6 +667,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 vmSymbols.hpp without implementing it here.
@ -6848,3 +6851,33 @@ 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() {
// To preserve the semantics of Java call, we need to null-check the receiver,
// if present. Shortcut if receiver is unconditionally null.
Node* receiver = NULL;
bool has_receiver = !callee()->is_static();
if (has_receiver) {
receiver = null_check_receiver();
if (stopped()) {
return true;
}
}
// Bind call arguments as blackhole arguments to keep them alive
Node* bh = insert_mem_bar(Op_Blackhole);
if (has_receiver) {
bh->add_req(receiver);
}
uint nargs = callee()->arg_size();
for (uint i = has_receiver ? 1 : 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();
};

@ -33,6 +33,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"
@ -3221,6 +3222,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;
}
}
@ -3455,6 +3457,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.

@ -1335,6 +1335,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 moving the arguments for the
// call that never happens.
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 ||

@ -356,6 +356,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

@ -1594,6 +1594,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) \

@ -0,0 +1,183 @@
/*
* Copyright (c) 2020, 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 id=c1
* @build compiler.blackhole.BlackholeTarget
*
* @run main/othervm
* -Xmx1g
* -XX:TieredStopAtLevel=1
* -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
* -XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*
* compiler.blackhole.BlackholeInstanceReturnTest
*/
/**
* @test id=c2
* @build compiler.blackhole.BlackholeTarget
*
* @run main/othervm
* -Xmx1g
* -XX:-TieredCompilation
* -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
* -XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*
* compiler.blackhole.BlackholeInstanceReturnTest
*/
/**
* @test id=c1-no-coops
* @requires vm.bits == "64"
* @build compiler.blackhole.BlackholeTarget
*
* @run main/othervm
* -Xmx1g -XX:-UseCompressedOops
* -XX:TieredStopAtLevel=1
* -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
* -XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*
* compiler.blackhole.BlackholeInstanceReturnTest
*/
/**
* @test id=c2-no-coops
* @requires vm.bits == "64"
* @build compiler.blackhole.BlackholeTarget
*
* @run main/othervm
* -Xmx1g -XX:-UseCompressedOops
* -XX:-TieredCompilation
* -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
* -XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*
* compiler.blackhole.BlackholeInstanceReturnTest
*/
package compiler.blackhole;
public class BlackholeInstanceReturnTest {
public static void main(String[] args) {
runTries(BlackholeInstanceReturnTest::test_boolean);
runTries(BlackholeInstanceReturnTest::test_byte);
runTries(BlackholeInstanceReturnTest::test_char);
runTries(BlackholeInstanceReturnTest::test_short);
runTries(BlackholeInstanceReturnTest::test_int);
runTries(BlackholeInstanceReturnTest::test_float);
runTries(BlackholeInstanceReturnTest::test_long);
runTries(BlackholeInstanceReturnTest::test_double);
runTries(BlackholeInstanceReturnTest::test_Object);
}
private static final int CYCLES = 1_000_000;
private static final int TRIES = 10;
public static void runTries(Runnable r) {
for (int t = 0; t < TRIES; t++) {
BlackholeTarget.clear();
r.run();
BlackholeTarget.shouldBeEntered();
}
}
private static void test_boolean() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
if (t.bh_ir_boolean((c & 0x1) == 0) != false) {
throw new AssertionError("Return value error");
}
}
}
private static void test_byte() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
if (t.bh_ir_byte((byte)c) != 0) {
throw new AssertionError("Return value error");
}
}
}
private static void test_char() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
if (t.bh_ir_char((char)c) != 0) {
throw new AssertionError("Return value error");
}
}
}
private static void test_short() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
if (t.bh_ir_short((short)c) != 0) {
throw new AssertionError("Return value error");
}
}
}
private static void test_int() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
if (t.bh_ir_int(c) != 0) {
throw new AssertionError("Return value error");
}
}
}
private static void test_float() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
if (t.bh_ir_float(c) != 0F) {
throw new AssertionError("Return value error");
}
}
}
private static void test_long() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
if (t.bh_ir_long(c) != 0L) {
throw new AssertionError("Return value error");
}
}
}
private static void test_double() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
if (t.bh_ir_double(c) != 0D) {
throw new AssertionError("Return value error");
}
}
}
private static void test_Object() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
Object o = new Object();
if (t.bh_ir_Object(o) != null) {
throw new AssertionError("Return value error");
}
}
}
}

@ -0,0 +1,314 @@
/*
* Copyright (c) 2020, 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 id=c1
* @build compiler.blackhole.BlackholeTarget
*
* @run main/othervm
* -Xmx1g
* -XX:TieredStopAtLevel=1
* -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
* -XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*
* compiler.blackhole.BlackholeInstanceTest
*/
/**
* @test id=c2
* @build compiler.blackhole.BlackholeTarget
*
* @run main/othervm
* -Xmx1g
* -XX:-TieredCompilation
* -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
* -XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*
* compiler.blackhole.BlackholeInstanceTest
*/
/**
* @test id=c1-no-coops
* @requires vm.bits == "64"
* @build compiler.blackhole.BlackholeTarget
*
* @run main/othervm
* -Xmx1g -XX:-UseCompressedOops
* -XX:TieredStopAtLevel=1
* -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
* -XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*
* compiler.blackhole.BlackholeInstanceTest
*/
/**
* @test id=c2-no-coops
* @requires vm.bits == "64"
* @build compiler.blackhole.BlackholeTarget
*
* @run main/othervm
* -Xmx1g -XX:-UseCompressedOops
* -XX:-TieredCompilation
* -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
* -XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*
* compiler.blackhole.BlackholeInstanceTest
*/
package compiler.blackhole;
public class BlackholeInstanceTest {
public static void main(String[] args) {
runTries(BlackholeInstanceTest::test_boolean_0);
runTries(BlackholeInstanceTest::test_byte_0);
runTries(BlackholeInstanceTest::test_char_0);
runTries(BlackholeInstanceTest::test_short_0);
runTries(BlackholeInstanceTest::test_int_0);
runTries(BlackholeInstanceTest::test_float_0);
runTries(BlackholeInstanceTest::test_long_0);
runTries(BlackholeInstanceTest::test_double_0);
runTries(BlackholeInstanceTest::test_Object_0);
runTries(BlackholeInstanceTest::test_boolean_1);
runTries(BlackholeInstanceTest::test_byte_1);
runTries(BlackholeInstanceTest::test_char_1);
runTries(BlackholeInstanceTest::test_short_1);
runTries(BlackholeInstanceTest::test_int_1);
runTries(BlackholeInstanceTest::test_float_1);
runTries(BlackholeInstanceTest::test_long_1);
runTries(BlackholeInstanceTest::test_double_1);
runTries(BlackholeInstanceTest::test_Object_1);
runTries(BlackholeInstanceTest::test_boolean_2);
runTries(BlackholeInstanceTest::test_byte_2);
runTries(BlackholeInstanceTest::test_char_2);
runTries(BlackholeInstanceTest::test_short_2);
runTries(BlackholeInstanceTest::test_int_2);
runTries(BlackholeInstanceTest::test_float_2);
runTries(BlackholeInstanceTest::test_long_2);
runTries(BlackholeInstanceTest::test_double_2);
runTries(BlackholeInstanceTest::test_Object_2);
}
private static final int CYCLES = 1_000_000;
private static final int TRIES = 10;
public static void runTries(Runnable r) {
for (int t = 0; t < TRIES; t++) {
BlackholeTarget.clear();
r.run();
if (t == TRIES - 1) {
BlackholeTarget.shouldNotBeEntered();
}
}
}
private static void test_boolean_0() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_boolean_0();
}
}
private static void test_byte_0() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_byte_0();
}
}
private static void test_char_0() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_char_0();
}
}
private static void test_short_0() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_short_0();
}
}
private static void test_int_0() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_int_0();
}
}
private static void test_float_0() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_float_0();
}
}
private static void test_long_0() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_long_0();
}
}
private static void test_double_0() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_double_0();
}
}
private static void test_Object_0() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_Object_0();
}
}
private static void test_boolean_1() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_boolean_1((c & 0x1) == 0);
}
}
private static void test_byte_1() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_byte_1((byte)c);
}
}
private static void test_char_1() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_char_1((char)c);
}
}
private static void test_short_1() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_short_1((short)c);
}
}
private static void test_int_1() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_int_1(c);
}
}
private static void test_float_1() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_float_1(c);
}
}
private static void test_long_1() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_long_1(c);
}
}
private static void test_double_1() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_double_1(c);
}
}
private static void test_Object_1() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
Object o = new Object();
t.bh_i_Object_1(o);
}
}
private static void test_boolean_2() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_boolean_2((c & 0x1) == 0, (c & 0x2) == 0);
}
}
private static void test_byte_2() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_byte_2((byte)c, (byte)(c + 1));
}
}
private static void test_char_2() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_char_2((char)c, (char)(c + 1));
}
}
private static void test_short_2() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_short_2((short)c, (short)(c + 1));
}
}
private static void test_int_2() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_int_2(c, c + 1);
}
}
private static void test_float_2() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_float_2(c, c + 1);
}
}
private static void test_long_2() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_long_2(c, c + 1);
}
}
private static void test_double_2() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
t.bh_i_double_2(c, c + 1);
}
}
private static void test_Object_2() {
BlackholeTarget t = new BlackholeTarget();
for (int c = 0; c < CYCLES; c++) {
Object o1 = new Object();
Object o2 = new Object();
t.bh_i_Object_2(o1, o2);
}
}
}

@ -0,0 +1,95 @@
/*
* Copyright (c) 2020, 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
* @build compiler.blackhole.BlackholeTarget
* @run driver compiler.blackhole.BlackholeNonVoidWarning
*/
package compiler.blackhole;
import java.io.IOException;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;
public class BlackholeNonVoidWarning {
private static final int CYCLES = 1_000_000;
private static final int TRIES = 10;
public static void main(String[] args) throws IOException {
if (args.length == 0) {
driver();
} else {
runner();
}
}
public static void driver() throws IOException {
final String msg = "blackhole compile command only works for methods with void type: compiler.blackhole.BlackholeTarget.bh_sr_int(I)I";
{
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
"-Xmx128m",
"-XX:CompileCommand=quiet",
"-XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*",
"compiler.blackhole.BlackholeNonVoidWarning",
"run"
);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);
output.shouldContain(msg);
}
{
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
"-Xmx128m",
"-XX:-PrintWarnings",
"-XX:CompileCommand=quiet",
"-XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*",
"compiler.blackhole.BlackholeNonVoidWarning",
"run"
);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);
output.shouldNotContain(msg);
}
}
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");
}
}
}
}

@ -0,0 +1,173 @@
/*
* Copyright (c) 2020, 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 id=c1
* @build compiler.blackhole.BlackholeTarget
*
* @run main/othervm
* -Xmx1g
* -XX:TieredStopAtLevel=1
* -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
* -XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*
* compiler.blackhole.BlackholeNullCheckTest
*/
/**
* @test id=c2
* @build compiler.blackhole.BlackholeTarget
*
* @run main/othervm
* -Xmx1g
* -XX:-TieredCompilation
* -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
* -XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*
* compiler.blackhole.BlackholeNullCheckTest
*/
/**
* @test id=c1-no-coops
* @requires vm.bits == "64"
* @build compiler.blackhole.BlackholeTarget
*
* @run main/othervm
* -Xmx1g -XX:-UseCompressedOops
* -XX:TieredStopAtLevel=1
* -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
* -XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*
* compiler.blackhole.BlackholeNullCheckTest
*/
/**
* @test id=c2-no-coops
* @requires vm.bits == "64"
* @build compiler.blackhole.BlackholeTarget
*
* @run main/othervm
* -Xmx1g -XX:-UseCompressedOops
* -XX:-TieredCompilation
* -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
* -XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*
* compiler.blackhole.BlackholeNullCheckTest
*/
package compiler.blackhole;
public class BlackholeNullCheckTest {
public static void main(String[] args) {
BlackholeNullCheckTest t = new BlackholeNullCheckTest();
runTries(t::test_local_sf);
runTries(t::test_local_s);
runTries(t::test_local);
runTries(t::test_field_sf);
runTries(t::test_field_s);
runTries(t::test_field);
}
private static final int CYCLES = 1_000_000;
private static final int TRIES = 10;
public static void runTries(Runnable r) {
for (int t = 0; t < TRIES; t++) {
r.run();
}
}
static final BlackholeTarget BH_SF_TARGET = null;
static BlackholeTarget BH_S_TARGET = null;
BlackholeTarget BH_TARGET = null;
private void test_local_sf() {
test_with(BH_SF_TARGET);
}
private void test_local_s() {
test_with(BH_S_TARGET);
}
private void test_local() {
test_with(BH_TARGET);
}
private void test_with(BlackholeTarget t) {
try {
t.bh_i_boolean_1(false);
throw new IllegalStateException("Expected NPE");
} catch (NullPointerException npe) {
}
try {
t.call_for_null_check();
throw new IllegalStateException("Expected NPE");
} catch (NullPointerException npe) {
// Expected
}
}
private void test_field_sf() {
try {
BH_SF_TARGET.bh_i_boolean_1(false);
throw new IllegalStateException("Expected NPE");
} catch (NullPointerException npe) {
}
try {
BH_SF_TARGET.call_for_null_check();
throw new IllegalStateException("Expected NPE");
} catch (NullPointerException npe) {
// Expected
}
}
private void test_field_s() {
try {
BH_S_TARGET.bh_i_boolean_1(false);
throw new IllegalStateException("Expected NPE");
} catch (NullPointerException npe) {
}
try {
BH_S_TARGET.call_for_null_check();
throw new IllegalStateException("Expected NPE");
} catch (NullPointerException npe) {
// Expected
}
}
private void test_field() {
try {
BH_TARGET.bh_i_boolean_1(false);
throw new IllegalStateException("Expected NPE");
} catch (NullPointerException npe) {
}
try {
BH_TARGET.call_for_null_check();
throw new IllegalStateException("Expected NPE");
} catch (NullPointerException npe) {
// Expected
}
}
}

@ -0,0 +1,174 @@
/*
* Copyright (c) 2020, 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 id=c1
* @build compiler.blackhole.BlackholeTarget
*
* @run main/othervm
* -Xmx1g
* -XX:TieredStopAtLevel=1
* -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
* -XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*
* compiler.blackhole.BlackholeStaticReturnTest
*/
/**
* @test id=c2
* @build compiler.blackhole.BlackholeTarget
*
* @run main/othervm
* -Xmx1g
* -XX:-TieredCompilation
* -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
* -XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*
* compiler.blackhole.BlackholeStaticReturnTest
*/
/**
* @test id=c1-no-coops
* @requires vm.bits == "64"
* @build compiler.blackhole.BlackholeTarget
*
* @run main/othervm
* -Xmx1g -XX:-UseCompressedOops
* -XX:TieredStopAtLevel=1
* -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
* -XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*
* compiler.blackhole.BlackholeStaticReturnTest
*/
/**
* @test id=c2-no-coops
* @requires vm.bits == "64"
* @build compiler.blackhole.BlackholeTarget
*
* @run main/othervm
* -Xmx1g -XX:-UseCompressedOops
* -XX:-TieredCompilation
* -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
* -XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*
* compiler.blackhole.BlackholeStaticReturnTest
*/
package compiler.blackhole;
public class BlackholeStaticReturnTest {
public static void main(String[] args) {
runTries(BlackholeStaticReturnTest::test_boolean);
runTries(BlackholeStaticReturnTest::test_byte);
runTries(BlackholeStaticReturnTest::test_char);
runTries(BlackholeStaticReturnTest::test_short);
runTries(BlackholeStaticReturnTest::test_int);
runTries(BlackholeStaticReturnTest::test_float);
runTries(BlackholeStaticReturnTest::test_long);
runTries(BlackholeStaticReturnTest::test_double);
runTries(BlackholeStaticReturnTest::test_Object);
}
private static final int CYCLES = 1_000_000;
private static final int TRIES = 10;
public static void runTries(Runnable r) {
for (int t = 0; t < TRIES; t++) {
BlackholeTarget.clear();
r.run();
BlackholeTarget.shouldBeEntered();
}
}
private static void test_boolean() {
for (int c = 0; c < CYCLES; c++) {
if (BlackholeTarget.bh_sr_boolean((c & 0x1) == 0) != false) {
throw new AssertionError("Return value error");
}
}
}
private static void test_byte() {
for (int c = 0; c < CYCLES; c++) {
if (BlackholeTarget.bh_sr_byte((byte)c) != 0) {
throw new AssertionError("Return value error");
}
}
}
private static void test_char() {
for (int c = 0; c < CYCLES; c++) {
if (BlackholeTarget.bh_sr_char((char)c) != 0) {
throw new AssertionError("Return value error");
}
}
}
private static void test_short() {
for (int c = 0; c < CYCLES; c++) {
if (BlackholeTarget.bh_sr_short((short)c) != 0) {
throw new AssertionError("Return value error");
}
}
}
private static void test_int() {
for (int c = 0; c < CYCLES; c++) {
if (BlackholeTarget.bh_sr_int(c) != 0) {
throw new AssertionError("Return value error");
}
}
}
private static void test_float() {
for (int c = 0; c < CYCLES; c++) {
if (BlackholeTarget.bh_sr_float(c) != 0F) {
throw new AssertionError("Return value error");
}
}
}
private static void test_long() {
for (int c = 0; c < CYCLES; c++) {
if (BlackholeTarget.bh_sr_long(c) != 0L) {
throw new AssertionError("Return value error");
}
}
}
private static void test_double() {
for (int c = 0; c < CYCLES; c++) {
if (BlackholeTarget.bh_sr_double(c) != 0D) {
throw new AssertionError("Return value error");
}
}
}
private static void test_Object() {
for (int c = 0; c < CYCLES; c++) {
Object o = new Object();
if (BlackholeTarget.bh_sr_Object(o) != null) {
throw new AssertionError("Return value error");
}
}
}
}

@ -0,0 +1,287 @@
/*
* Copyright (c) 2020, 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 id=c1
* @build compiler.blackhole.BlackholeTarget
*
* @run main/othervm
* -Xmx1g
* -XX:TieredStopAtLevel=1
* -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
* -XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*
* compiler.blackhole.BlackholeStaticTest
*/
/**
* @test id=c2
* @build compiler.blackhole.BlackholeTarget
*
* @run main/othervm
* -Xmx1g
* -XX:-TieredCompilation
* -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
* -XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*
* compiler.blackhole.BlackholeStaticTest
*/
/**
* @test id=c1-no-coops
* @requires vm.bits == "64"
* @build compiler.blackhole.BlackholeTarget
*
* @run main/othervm
* -Xmx1g -XX:-UseCompressedOops
* -XX:TieredStopAtLevel=1
* -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
* -XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*
* compiler.blackhole.BlackholeStaticTest
*/
/**
* @test id=c2-no-coops
* @requires vm.bits == "64"
* @build compiler.blackhole.BlackholeTarget
*
* @run main/othervm
* -Xmx1g -XX:-UseCompressedOops
* -XX:-TieredCompilation
* -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
* -XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*
* compiler.blackhole.BlackholeStaticTest
*/
package compiler.blackhole;
public class BlackholeStaticTest {
public static void main(String[] args) {
runTries(BlackholeStaticTest::test_boolean_0);
runTries(BlackholeStaticTest::test_byte_0);
runTries(BlackholeStaticTest::test_char_0);
runTries(BlackholeStaticTest::test_short_0);
runTries(BlackholeStaticTest::test_int_0);
runTries(BlackholeStaticTest::test_float_0);
runTries(BlackholeStaticTest::test_long_0);
runTries(BlackholeStaticTest::test_double_0);
runTries(BlackholeStaticTest::test_Object_0);
runTries(BlackholeStaticTest::test_boolean_1);
runTries(BlackholeStaticTest::test_byte_1);
runTries(BlackholeStaticTest::test_char_1);
runTries(BlackholeStaticTest::test_short_1);
runTries(BlackholeStaticTest::test_int_1);
runTries(BlackholeStaticTest::test_float_1);
runTries(BlackholeStaticTest::test_long_1);
runTries(BlackholeStaticTest::test_double_1);
runTries(BlackholeStaticTest::test_Object_1);
runTries(BlackholeStaticTest::test_boolean_2);
runTries(BlackholeStaticTest::test_byte_2);
runTries(BlackholeStaticTest::test_char_2);
runTries(BlackholeStaticTest::test_short_2);
runTries(BlackholeStaticTest::test_int_2);
runTries(BlackholeStaticTest::test_float_2);
runTries(BlackholeStaticTest::test_long_2);
runTries(BlackholeStaticTest::test_double_2);
runTries(BlackholeStaticTest::test_Object_2);
}
private static final int CYCLES = 1_000_000;
private static final int TRIES = 10;
public static void runTries(Runnable r) {
for (int t = 0; t < TRIES; t++) {
BlackholeTarget.clear();
r.run();
if (t == TRIES - 1) {
BlackholeTarget.shouldNotBeEntered();
}
}
}
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,136 @@
/*
* Copyright (c) 2020, 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 {
private static String entered;
private static void registerEntered(String label) {
if (entered == null) {
entered = label;
} else if (!entered.equals(label)) {
throw new IllegalStateException("Trying to register enter with overwrite: " + entered + " -> " + label);
}
}
public static void clear() {
entered = null;
}
public static void shouldBeEntered() {
if (entered == null) {
throw new IllegalStateException("Should have been entered");
}
}
public static void shouldNotBeEntered() {
if (entered != null) {
throw new IllegalStateException("Should not have been entered: " + entered);
}
}
public void call_for_null_check() {}
public static void bh_s_boolean_0() { registerEntered("bh_s_boolean_0"); }
public static void bh_s_byte_0() { registerEntered("bh_s_byte_0"); }
public static void bh_s_short_0() { registerEntered("bh_s_short_0"); }
public static void bh_s_char_0() { registerEntered("bh_s_char_0"); }
public static void bh_s_int_0() { registerEntered("bh_s_int_0"); }
public static void bh_s_float_0() { registerEntered("bh_s_float_0"); }
public static void bh_s_long_0() { registerEntered("bh_s_long_0"); }
public static void bh_s_double_0() { registerEntered("bh_s_double_0"); }
public static void bh_s_Object_0() { registerEntered("bh_s_Object_0"); }
public void bh_i_boolean_0() { registerEntered("bh_i_boolean_0"); }
public void bh_i_byte_0() { registerEntered("bh_i_byte_0"); }
public void bh_i_short_0() { registerEntered("bh_i_short_0"); }
public void bh_i_char_0() { registerEntered("bh_i_char_0"); }
public void bh_i_int_0() { registerEntered("bh_i_int_0"); }
public void bh_i_float_0() { registerEntered("bh_i_float_0"); }
public void bh_i_long_0() { registerEntered("bh_i_long_0"); }
public void bh_i_double_0() { registerEntered("bh_i_double_0"); }
public void bh_i_Object_0() { registerEntered("bh_i_Object_0"); }
public static void bh_s_boolean_1(boolean v) { registerEntered("bh_s_boolean_1"); }
public static void bh_s_byte_1(byte v) { registerEntered("bh_s_byte_1"); }
public static void bh_s_short_1(short v) { registerEntered("bh_s_short_1"); }
public static void bh_s_char_1(char v) { registerEntered("bh_s_char_1"); }
public static void bh_s_int_1(int v) { registerEntered("bh_s_int_1"); }
public static void bh_s_float_1(float v) { registerEntered("bh_s_float_1"); }
public static void bh_s_long_1(long v) { registerEntered("bh_s_long_1"); }
public static void bh_s_double_1(double v) { registerEntered("bh_s_double_1"); }
public static void bh_s_Object_1(Object v) { registerEntered("bh_s_Object_1"); }
public void bh_i_boolean_1(boolean v) { registerEntered("bh_i_boolean_1"); }
public void bh_i_byte_1(byte v) { registerEntered("bh_i_byte_1"); }
public void bh_i_short_1(short v) { registerEntered("bh_i_short_1"); }
public void bh_i_char_1(char v) { registerEntered("bh_i_char_1"); }
public void bh_i_int_1(int v) { registerEntered("bh_i_int_1"); }
public void bh_i_float_1(float v) { registerEntered("bh_i_float_1"); }
public void bh_i_long_1(long v) { registerEntered("bh_i_long_1"); }
public void bh_i_double_1(double v) { registerEntered("bh_i_double_1"); }
public void bh_i_Object_1(Object v) { registerEntered("bh_i_Object_1"); }
public static void bh_s_boolean_2(boolean v1, boolean v2) { registerEntered("bh_s_boolean_2"); }
public static void bh_s_byte_2(byte v1, byte v2) { registerEntered("bh_s_byte_2"); }
public static void bh_s_short_2(short v1, short v2) { registerEntered("bh_s_short_2"); }
public static void bh_s_char_2(char v1, char v2) { registerEntered("bh_s_char_2"); }
public static void bh_s_int_2(int v1, int v2) { registerEntered("bh_s_int_2"); }
public static void bh_s_float_2(float v1, float v2) { registerEntered("bh_s_float_2"); }
public static void bh_s_long_2(long v1, long v2) { registerEntered("bh_s_long_2"); }
public static void bh_s_double_2(double v1, double v2) { registerEntered("bh_s_double_2"); }
public static void bh_s_Object_2(Object v1, Object v2) { registerEntered("bh_s_Object_2"); }
public void bh_i_boolean_2(boolean v1, boolean v2) { registerEntered("bh_i_boolean_2"); }
public void bh_i_byte_2(byte v1, byte v2) { registerEntered("bh_i_byte_2"); }
public void bh_i_short_2(short v1, short v2) { registerEntered("bh_i_short_2"); }
public void bh_i_char_2(char v1, char v2) { registerEntered("bh_i_char_2"); }
public void bh_i_int_2(int v1, int v2) { registerEntered("bh_i_int_2"); }
public void bh_i_float_2(float v1, float v2) { registerEntered("bh_i_float_2"); }
public void bh_i_long_2(long v1, long v2) { registerEntered("bh_i_long_2"); }
public void bh_i_double_2(double v1, double v2) { registerEntered("bh_i_double_2"); }
public void bh_i_Object_2(Object v1, Object v2) { registerEntered("bh_i_Object_2"); }
public static boolean bh_sr_boolean(boolean v) { registerEntered("bh_sr_boolean"); return false; }
public static byte bh_sr_byte(byte v) { registerEntered("bh_sr_byte"); return 0; }
public static short bh_sr_short(short v) { registerEntered("bh_sr_short"); return 0; }
public static char bh_sr_char(char v) { registerEntered("bh_sr_char"); return 0; }
public static int bh_sr_int(int v) { registerEntered("bh_sr_int"); return 0; }
public static float bh_sr_float(float v) { registerEntered("bh_sr_float"); return 0; }
public static long bh_sr_long(long v) { registerEntered("bh_sr_long"); return 0; }
public static double bh_sr_double(double v) { registerEntered("bh_sr_double"); return 0; }
public static Object bh_sr_Object(Object v) { registerEntered("bh_sr_Object"); return null; }
public boolean bh_ir_boolean(boolean v) { registerEntered("bh_ir_boolean"); return false; }
public byte bh_ir_byte(byte v) { registerEntered("bh_ir_byte"); return 0; }
public short bh_ir_short(short v) { registerEntered("bh_ir_short"); return 0; }
public char bh_ir_char(char v) { registerEntered("bh_ir_char"); return 0; }
public int bh_ir_int(int v) { registerEntered("bh_ir_int"); return 0; }
public float bh_ir_float(float v) { registerEntered("bh_ir_float"); return 0; }
public long bh_ir_long(long v) { registerEntered("bh_ir_long"); return 0; }
public double bh_ir_double(double v) { registerEntered("bh_ir_double"); return 0; }
public Object bh_ir_Object(Object v) { registerEntered("bh_ir_Object"); return null; }
}