This commit is contained in:
Dean Long 2015-01-15 16:51:09 -05:00
commit e2bf1cd30d
47 changed files with 1302 additions and 178 deletions

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright 2012, 2013 SAP AG. All rights reserved.
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright 2012, 2015 SAP AG. 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
@ -284,19 +284,20 @@ class Assembler : public AbstractAssembler {
MTCTR_OPCODE = (MTSPR_OPCODE | 9 << SPR_0_4_SHIFT),
MFCTR_OPCODE = (MFSPR_OPCODE | 9 << SPR_0_4_SHIFT),
MTTFHAR_OPCODE = (MTSPR_OPCODE | 128 << SPR_0_4_SHIFT),
MFTFHAR_OPCODE = (MFSPR_OPCODE | 128 << SPR_0_4_SHIFT),
MTTFIAR_OPCODE = (MTSPR_OPCODE | 129 << SPR_0_4_SHIFT),
MFTFIAR_OPCODE = (MFSPR_OPCODE | 129 << SPR_0_4_SHIFT),
MTTEXASR_OPCODE = (MTSPR_OPCODE | 130 << SPR_0_4_SHIFT),
MFTEXASR_OPCODE = (MFSPR_OPCODE | 130 << SPR_0_4_SHIFT),
MTTEXASRU_OPCODE = (MTSPR_OPCODE | 131 << SPR_0_4_SHIFT),
MFTEXASRU_OPCODE = (MFSPR_OPCODE | 131 << SPR_0_4_SHIFT),
// Attention: Higher and lower half are inserted in reversed order.
MTTFHAR_OPCODE = (MTSPR_OPCODE | 4 << SPR_5_9_SHIFT | 0 << SPR_0_4_SHIFT),
MFTFHAR_OPCODE = (MFSPR_OPCODE | 4 << SPR_5_9_SHIFT | 0 << SPR_0_4_SHIFT),
MTTFIAR_OPCODE = (MTSPR_OPCODE | 4 << SPR_5_9_SHIFT | 1 << SPR_0_4_SHIFT),
MFTFIAR_OPCODE = (MFSPR_OPCODE | 4 << SPR_5_9_SHIFT | 1 << SPR_0_4_SHIFT),
MTTEXASR_OPCODE = (MTSPR_OPCODE | 4 << SPR_5_9_SHIFT | 2 << SPR_0_4_SHIFT),
MFTEXASR_OPCODE = (MFSPR_OPCODE | 4 << SPR_5_9_SHIFT | 2 << SPR_0_4_SHIFT),
MTTEXASRU_OPCODE = (MTSPR_OPCODE | 4 << SPR_5_9_SHIFT | 3 << SPR_0_4_SHIFT),
MFTEXASRU_OPCODE = (MFSPR_OPCODE | 4 << SPR_5_9_SHIFT | 3 << SPR_0_4_SHIFT),
MTVRSAVE_OPCODE = (MTSPR_OPCODE | 256 << SPR_0_4_SHIFT),
MFVRSAVE_OPCODE = (MFSPR_OPCODE | 256 << SPR_0_4_SHIFT),
MTVRSAVE_OPCODE = (MTSPR_OPCODE | 8 << SPR_5_9_SHIFT | 0 << SPR_0_4_SHIFT),
MFVRSAVE_OPCODE = (MFSPR_OPCODE | 8 << SPR_5_9_SHIFT | 0 << SPR_0_4_SHIFT),
MFTB_OPCODE = (MFSPR_OPCODE | 268 << SPR_0_4_SHIFT),
MFTB_OPCODE = (MFSPR_OPCODE | 8 << SPR_5_9_SHIFT | 12 << SPR_0_4_SHIFT),
MTCRF_OPCODE = (31u << OPCODE_SHIFT | 144u << 1),
MFCR_OPCODE = (31u << OPCODE_SHIFT | 19u << 1),
@ -1494,6 +1495,26 @@ class Assembler : public AbstractAssembler {
inline void mftexasr(Register d);
inline void mftexasru(Register d);
// TEXASR bit description
enum transaction_failure_reason {
// Upper half (TEXASRU):
tm_failure_persistent = 7, // The failure is likely to recur on each execution.
tm_disallowed = 8, // The instruction is not permitted.
tm_nesting_of = 9, // The maximum transaction level was exceeded.
tm_footprint_of = 10, // The tracking limit for transactional storage accesses was exceeded.
tm_self_induced_cf = 11, // A self-induced conflict occurred in Suspended state.
tm_non_trans_cf = 12, // A conflict occurred with a non-transactional access by another processor.
tm_trans_cf = 13, // A conflict occurred with another transaction.
tm_translation_cf = 14, // A conflict occurred with a TLB invalidation.
tm_inst_fetch_cf = 16, // An instruction fetch was performed from a block that was previously written transactionally.
tm_tabort = 31, // Termination was caused by the execution of an abort instruction.
// Lower half:
tm_suspended = 32, // Failure was recorded in Suspended state.
tm_failure_summary = 36, // Failure has been detected and recorded.
tm_tfiar_exact = 37, // Value in the TFIAR is exact.
tm_rot = 38, // Rollback-only transaction.
};
// PPC 1, section 2.4.1 Branch Instructions
inline void b( address a, relocInfo::relocType rt = relocInfo::none);
inline void b( Label& L);
@ -1581,6 +1602,7 @@ class Assembler : public AbstractAssembler {
inline void bnectrl(ConditionRegister crx, relocInfo::relocType rt = relocInfo::none);
// condition register logic instructions
// NOTE: There's a preferred form: d and s2 should point into the same condition register.
inline void crand( int d, int s1, int s2);
inline void crnand(int d, int s1, int s2);
inline void cror( int d, int s1, int s2);
@ -1590,6 +1612,19 @@ class Assembler : public AbstractAssembler {
inline void crandc(int d, int s1, int s2);
inline void crorc( int d, int s1, int s2);
// More convenient version.
int condition_register_bit(ConditionRegister cr, Condition c) {
return 4 * (int)(intptr_t)cr + c;
}
void crand( ConditionRegister crdst, Condition cdst, ConditionRegister crsrc, Condition csrc);
void crnand(ConditionRegister crdst, Condition cdst, ConditionRegister crsrc, Condition csrc);
void cror( ConditionRegister crdst, Condition cdst, ConditionRegister crsrc, Condition csrc);
void crxor( ConditionRegister crdst, Condition cdst, ConditionRegister crsrc, Condition csrc);
void crnor( ConditionRegister crdst, Condition cdst, ConditionRegister crsrc, Condition csrc);
void creqv( ConditionRegister crdst, Condition cdst, ConditionRegister crsrc, Condition csrc);
void crandc(ConditionRegister crdst, Condition cdst, ConditionRegister crsrc, Condition csrc);
void crorc( ConditionRegister crdst, Condition cdst, ConditionRegister crsrc, Condition csrc);
// icache and dcache related instructions
inline void icbi( Register s1, Register s2);
//inline void dcba(Register s1, Register s2); // Instruction for embedded processor only.
@ -1673,6 +1708,10 @@ class Assembler : public AbstractAssembler {
inline void smt_prio_low();
inline void smt_prio_medium_low();
inline void smt_prio_medium();
// >= Power7
inline void smt_yield();
inline void smt_mdoio();
inline void smt_mdoom();
// trap instructions
inline void twi_0(Register a); // for load with acquire semantics use load+twi_0+isync (trap can't occur)
@ -1958,6 +1997,7 @@ class Assembler : public AbstractAssembler {
inline void tbeginrot_(); // R=1 Rollback-Only Transaction
inline void tend_(); // A=0
inline void tendall_(); // A=1
inline void tabort_();
inline void tabort_(Register a);
inline void tabortwc_(int t, Register a, Register b);
inline void tabortwci_(int t, Register a, int si);
@ -1967,6 +2007,10 @@ class Assembler : public AbstractAssembler {
inline void tresume_(); // tsr with L=1
inline void tcheck(int f);
static bool is_tbegin(int x) {
return TBEGIN_OPCODE == (x & (0x3f << OPCODE_SHIFT | 0x3ff << 1));
}
// The following encoders use r0 as second operand. These instructions
// read r0 as '0'.
inline void lwzx( Register d, Register s2);

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright 2012, 2014 SAP AG. All rights reserved.
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright 2012, 2015 SAP AG. 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
@ -453,6 +453,48 @@ inline void Assembler::creqv( int d, int s1, int s2) { emit_int32(CREQV_OPCODE
inline void Assembler::crandc(int d, int s1, int s2) { emit_int32(CRANDC_OPCODE | bt(d) | ba(s1) | bb(s2)); }
inline void Assembler::crorc( int d, int s1, int s2) { emit_int32(CRORC_OPCODE | bt(d) | ba(s1) | bb(s2)); }
// More convenient version.
inline void Assembler::crand( ConditionRegister crdst, Condition cdst, ConditionRegister crsrc, Condition csrc) {
int dst_bit = condition_register_bit(crdst, cdst),
src_bit = condition_register_bit(crsrc, csrc);
crand(dst_bit, src_bit, dst_bit);
}
inline void Assembler::crnand(ConditionRegister crdst, Condition cdst, ConditionRegister crsrc, Condition csrc) {
int dst_bit = condition_register_bit(crdst, cdst),
src_bit = condition_register_bit(crsrc, csrc);
crnand(dst_bit, src_bit, dst_bit);
}
inline void Assembler::cror( ConditionRegister crdst, Condition cdst, ConditionRegister crsrc, Condition csrc) {
int dst_bit = condition_register_bit(crdst, cdst),
src_bit = condition_register_bit(crsrc, csrc);
cror(dst_bit, src_bit, dst_bit);
}
inline void Assembler::crxor( ConditionRegister crdst, Condition cdst, ConditionRegister crsrc, Condition csrc) {
int dst_bit = condition_register_bit(crdst, cdst),
src_bit = condition_register_bit(crsrc, csrc);
crxor(dst_bit, src_bit, dst_bit);
}
inline void Assembler::crnor( ConditionRegister crdst, Condition cdst, ConditionRegister crsrc, Condition csrc) {
int dst_bit = condition_register_bit(crdst, cdst),
src_bit = condition_register_bit(crsrc, csrc);
crnor(dst_bit, src_bit, dst_bit);
}
inline void Assembler::creqv( ConditionRegister crdst, Condition cdst, ConditionRegister crsrc, Condition csrc) {
int dst_bit = condition_register_bit(crdst, cdst),
src_bit = condition_register_bit(crsrc, csrc);
creqv(dst_bit, src_bit, dst_bit);
}
inline void Assembler::crandc(ConditionRegister crdst, Condition cdst, ConditionRegister crsrc, Condition csrc) {
int dst_bit = condition_register_bit(crdst, cdst),
src_bit = condition_register_bit(crsrc, csrc);
crandc(dst_bit, src_bit, dst_bit);
}
inline void Assembler::crorc( ConditionRegister crdst, Condition cdst, ConditionRegister crsrc, Condition csrc) {
int dst_bit = condition_register_bit(crdst, cdst),
src_bit = condition_register_bit(crsrc, csrc);
crorc(dst_bit, src_bit, dst_bit);
}
// Conditional move (>= Power7)
inline void Assembler::isel(Register d, ConditionRegister cr, Condition cc, bool inv, Register a, Register b) {
if (b == noreg) {
@ -516,6 +558,10 @@ inline void Assembler::smt_prio_medium_low() { Assembler::or_unchecked(R6, R6,
inline void Assembler::smt_prio_medium() { Assembler::or_unchecked(R2, R2, R2); }
inline void Assembler::smt_prio_medium_high() { Assembler::or_unchecked(R5, R5, R5); }
inline void Assembler::smt_prio_high() { Assembler::or_unchecked(R3, R3, R3); }
// >= Power7
inline void Assembler::smt_yield() { Assembler::or_unchecked(R27, R27, R27); }
inline void Assembler::smt_mdoio() { Assembler::or_unchecked(R29, R29, R29); }
inline void Assembler::smt_mdoom() { Assembler::or_unchecked(R30, R30, R30); }
inline void Assembler::twi_0(Register a) { twi_unchecked(0, a, 0);}
@ -778,7 +824,8 @@ inline void Assembler::tbegin_() { emit_int32( TB
inline void Assembler::tbeginrot_() { emit_int32( TBEGIN_OPCODE | /*R=1*/ 1u << (31-10) | rc(1)); }
inline void Assembler::tend_() { emit_int32( TEND_OPCODE | rc(1)); }
inline void Assembler::tendall_() { emit_int32( TEND_OPCODE | /*A=1*/ 1u << (31-6) | rc(1)); }
inline void Assembler::tabort_(Register a) { emit_int32( TABORT_OPCODE | ra(a) | rc(1)); }
inline void Assembler::tabort_() { emit_int32( TABORT_OPCODE | rc(1)); }
inline void Assembler::tabort_(Register a) { assert(a != R0, "r0 not allowed"); emit_int32( TABORT_OPCODE | ra(a) | rc(1)); }
inline void Assembler::tabortwc_(int t, Register a, Register b) { emit_int32( TABORTWC_OPCODE | to(t) | ra(a) | rb(b) | rc(1)); }
inline void Assembler::tabortwci_(int t, Register a, int si) { emit_int32( TABORTWCI_OPCODE | to(t) | ra(a) | sh1620(si) | rc(1)); }
inline void Assembler::tabortdc_(int t, Register a, Register b) { emit_int32( TABORTDC_OPCODE | to(t) | ra(a) | rb(b) | rc(1)); }

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright 2012, 2014 SAP AG. All rights reserved.
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright 2012, 2015 SAP AG. 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
@ -1712,7 +1712,7 @@ void InterpreterMacroAssembler::profile_obj_type(Register obj, Register mdo_addr
andi_(R0, klass, TypeEntries::type_unknown);
// Already unknown. Nothing to do anymore.
//bne(CCR0, do_nothing);
crorc(/*CCR0 eq*/2, /*CCR1 eq*/4+2, /*CCR0 eq*/2); // cr0 eq = cr1 eq or cr0 ne
crorc(CCR0, Assembler::equal, CCR1, Assembler::equal); // cr0 eq = cr1 eq or cr0 ne
beq(CCR0, do_nothing);
clrrdi_(R0, tmp, exact_log2(-TypeEntries::type_mask));
@ -1826,9 +1826,9 @@ void InterpreterMacroAssembler::profile_return_type(Register ret, Register tmp1,
lbz(tmp2, Method::intrinsic_id_offset_in_bytes(), R19_method);
cmpwi(CCR0, tmp1, Bytecodes::_invokedynamic);
cmpwi(CCR1, tmp1, Bytecodes::_invokehandle);
cror(/*CR0 eq*/2, /*CR1 eq*/4+2, /*CR0 eq*/2);
cror(CCR0, Assembler::equal, CCR1, Assembler::equal);
cmpwi(CCR1, tmp2, vmIntrinsics::_compiledLambdaForm);
cror(/*CR0 eq*/2, /*CR1 eq*/4+2, /*CR0 eq*/2);
cror(CCR0, Assembler::equal, CCR1, Assembler::equal);
bne(CCR0, profile_continue);
}

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright 2012, 2014 SAP AG. All rights reserved.
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright 2012, 2015 SAP AG. 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
@ -1079,7 +1079,7 @@ class StubGenerator: public StubCodeGenerator {
__ sldi(tmp2, R5_ARG3, log2_elem_size); // size in bytes
__ cmpld(CCR0, R3_ARG1, R4_ARG2); // Use unsigned comparison!
__ cmpld(CCR1, tmp1, tmp2);
__ crand(/*CCR0 lt*/0, /*CCR1 lt*/4+0, /*CCR0 lt*/0);
__ crand(CCR0, Assembler::less, CCR1, Assembler::less);
__ blt(CCR0, l_overlap); // Src before dst and distance smaller than size.
// need to copy forwards

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright 2013, 2014 SAP AG. All rights reserved.
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright 2013, 2015 SAP AG. 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
@ -335,11 +335,11 @@ void TemplateTable::ldc(bool wide) {
__ cmpwi(CCR0, Rscratch2, JVM_CONSTANT_UnresolvedClass); // Unresolved class?
__ cmpwi(CCR1, Rscratch2, JVM_CONSTANT_UnresolvedClassInError); // Unresolved class in error state?
__ cror(/*CR0 eq*/2, /*CR1 eq*/4+2, /*CR0 eq*/2);
__ cror(CCR0, Assembler::equal, CCR1, Assembler::equal);
// Resolved class - need to call vm to get java mirror of the class.
__ cmpwi(CCR1, Rscratch2, JVM_CONSTANT_Class);
__ crnor(/*CR0 eq*/2, /*CR1 eq*/4+2, /*CR0 eq*/2); // Neither resolved class nor unresolved case from above?
__ crnor(CCR0, Assembler::equal, CCR1, Assembler::equal); // Neither resolved class nor unresolved case from above?
__ beq(CCR0, notClass);
__ li(R4, wide ? 1 : 0);
@ -2611,7 +2611,7 @@ void TemplateTable::jvmti_post_field_mod(Register Rcache, Register Rscratch, boo
__ cmpwi(CCR0, Rflags, ltos);
__ cmpwi(CCR1, Rflags, dtos);
__ addi(base, R15_esp, Interpreter::expr_offset_in_bytes(1));
__ crnor(/*CR0 eq*/2, /*CR1 eq*/4+2, /*CR0 eq*/2);
__ crnor(CCR0, Assembler::equal, CCR1, Assembler::equal);
__ beq(CCR0, is_one_slot);
__ addi(base, R15_esp, Interpreter::expr_offset_in_bytes(2));
__ bind(is_one_slot);
@ -3563,7 +3563,7 @@ void TemplateTable::_new() {
// Make sure klass does not have has_finalizer, or is abstract, or interface or java/lang/Class.
__ andi_(R0, Rinstance_size, Klass::_lh_instance_slow_path_bit); // slow path bit equals 0?
__ crnand(/*CR0 eq*/2, /*CR1 eq*/4+2, /*CR0 eq*/2); // slow path bit set or not fully initialized?
__ crnand(CCR0, Assembler::equal, CCR1, Assembler::equal); // slow path bit set or not fully initialized?
__ beq(CCR0, Lslow_case);
// --------------------------------------------------------------------------

View File

@ -3184,7 +3184,24 @@ void MacroAssembler::pow_or_exp(bool is_exp, int num_fpu_regs_in_use) {
jmp(done);
} else {
// Stack: X Y
Label x_negative, y_odd;
Label x_negative, y_not_2;
static double two = 2.0;
ExternalAddress two_addr((address)&two);
// constant maybe too far on 64 bit
lea(tmp2, two_addr);
fld_d(Address(tmp2, 0)); // Stack: 2 X Y
fcmp(tmp, 2, true, false); // Stack: X Y
jcc(Assembler::parity, y_not_2);
jcc(Assembler::notEqual, y_not_2);
fxch(); fpop(); // Stack: X
fmul(0); // Stack: X*X
jmp(done);
bind(y_not_2);
fldz(); // Stack: 0 X Y
fcmp(tmp, 1, true, false); // Stack: X Y

View File

@ -252,7 +252,7 @@ CompileTask* CompileTask::allocate() {
} else {
task = new CompileTask();
DEBUG_ONLY(_num_allocated_tasks++;)
assert (_num_allocated_tasks < 10000, "Leaking compilation tasks?");
assert (WhiteBoxAPI || _num_allocated_tasks < 10000, "Leaking compilation tasks?");
task->set_next(NULL);
task->set_is_free(true);
}

View File

@ -105,7 +105,6 @@ class MethodMatcher : public CHeapObj<mtCompiler> {
tty->print(".");
print_symbol(method_name(), _method_mode);
if (signature() != NULL) {
tty->print(" ");
signature()->print_symbol_on(tty);
}
}
@ -467,43 +466,85 @@ static OracleCommand parse_command_name(const char * line, int* bytes_read) {
return UnknownCommand;
}
static void usage() {
tty->print_cr(" CompileCommand and the CompilerOracle allows simple control over");
tty->print_cr(" what's allowed to be compiled. The standard supported directives");
tty->print_cr(" are exclude and compileonly. The exclude directive stops a method");
tty->print_cr(" from being compiled and compileonly excludes all methods except for");
tty->print_cr(" the ones mentioned by compileonly directives. The basic form of");
tty->print_cr(" all commands is a command name followed by the name of the method");
tty->print_cr(" in one of two forms: the standard class file format as in");
tty->print_cr(" class/name.methodName or the PrintCompilation format");
tty->print_cr(" class.name::methodName. The method name can optionally be followed");
tty->print_cr(" by a space then the signature of the method in the class file");
tty->print_cr(" format. Otherwise the directive applies to all methods with the");
tty->print_cr(" same name and class regardless of signature. Leading and trailing");
tty->print_cr(" *'s in the class and/or method name allows a small amount of");
tty->print_cr(" wildcarding. ");
tty->cr();
tty->print_cr(" Examples:");
tty->print_cr("The CompileCommand option enables the user of the JVM to control specific");
tty->print_cr("behavior of the dynamic compilers. Many commands require a pattern that defines");
tty->print_cr("the set of methods the command shall be applied to. The CompileCommand");
tty->print_cr("option provides the following commands:");
tty->cr();
tty->print_cr(" exclude java/lang/StringBuffer.append");
tty->print_cr(" compileonly java/lang/StringBuffer.toString ()Ljava/lang/String;");
tty->print_cr(" exclude java/lang/String*.*");
tty->print_cr(" exclude *.toString");
}
tty->print_cr(" break,<pattern> - debug breakpoint in compiler and in generated code");
tty->print_cr(" print,<pattern> - print assembly");
tty->print_cr(" exclude,<pattern> - don't compile or inline");
tty->print_cr(" inline,<pattern> - always inline");
tty->print_cr(" dontinline,<pattern> - don't inline");
tty->print_cr(" compileonly,<pattern> - compile only");
tty->print_cr(" log,<pattern> - log compilation");
tty->print_cr(" option,<pattern>,<option type>,<option name>,<value>");
tty->print_cr(" - set value of custom option");
tty->print_cr(" option,<pattern>,<bool option name>");
tty->print_cr(" - shorthand for setting boolean flag");
tty->print_cr(" quiet - silence the compile command output");
tty->print_cr(" help - print this text");
tty->cr();
tty->print_cr("The preferred format for the method matching pattern is:");
tty->print_cr(" package/Class.method()");
tty->cr();
tty->print_cr("For backward compatibility this form is also allowed:");
tty->print_cr(" package.Class::method()");
tty->cr();
tty->print_cr("The signature can be separated by an optional whitespace or comma:");
tty->print_cr(" package/Class.method ()");
tty->cr();
tty->print_cr("The class and method identifier can be used together with leading or");
tty->print_cr("trailing *'s for a small amount of wildcarding:");
tty->print_cr(" *ackage/Clas*.*etho*()");
tty->cr();
tty->print_cr("It is possible to use more than one CompileCommand on the command line:");
tty->print_cr(" -XX:CompileCommand=exclude,java/*.* -XX:CompileCommand=log,java*.*");
tty->cr();
tty->print_cr("The CompileCommands can be loaded from a file with the flag");
tty->print_cr("-XX:CompileCommandFile=<file> or be added to the file '.hotspot_compiler'");
tty->print_cr("Use the same format in the file as the argument to the CompileCommand flag.");
tty->print_cr("Add one command on each line.");
tty->print_cr(" exclude java/*.*");
tty->print_cr(" option java/*.* ReplayInline");
tty->cr();
tty->print_cr("The following commands have conflicting behavior: 'exclude', 'inline', 'dontinline',");
tty->print_cr("and 'compileonly'. There is no priority of commands. Applying (a subset of) these");
tty->print_cr("commands to the same method results in undefined behavior.");
tty->cr();
};
// The JVM specification defines the allowed characters.
// Tokens that are disallowed by the JVM specification can have
// a meaning to the parser so we need to include them here.
// The parser does not enforce all rules of the JVMS - a successful parse
// does not mean that it is an allowed name. Illegal names will
// be ignored since they never can match a class or method.
//
// '\0' and 0xf0-0xff are disallowed in constant string values
// 0x20 ' ', 0x09 '\t' and, 0x2c ',' are used in the matching
// 0x5b '[' and 0x5d ']' can not be used because of the matcher
// 0x28 '(' and 0x29 ')' are used for the signature
// 0x2e '.' is always replaced before the matching
// 0x2f '/' is only used in the class name as package separator
// The characters allowed in a class or method name. All characters > 0x7f
// are allowed in order to handle obfuscated class files (e.g. Volano)
#define RANGEBASE "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789$_<>" \
"\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f" \
"\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f" \
"\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf" \
"\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf" \
"\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf" \
"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" \
"\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef" \
"\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
#define RANGEBASE "\x1\x2\x3\x4\x5\x6\x7\x8\xa\xb\xc\xd\xe\xf" \
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" \
"\x21\x22\x23\x24\x25\x26\x27\x2a\x2b\x2c\x2d" \
"\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f" \
"\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f" \
"\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5c\x5e\x5f" \
"\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f" \
"\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f" \
"\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f" \
"\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f" \
"\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf" \
"\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf" \
"\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf" \
"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" \
"\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef"
#define RANGE0 "[*" RANGEBASE "]"
#define RANGESLASH "[*" RANGEBASE "/]"
@ -681,8 +722,9 @@ void CompilerOracle::parse_from_line(char* line) {
if (command == UnknownCommand) {
ttyLocker ttyl;
tty->print_cr("CompilerOracle: unrecognized line");
tty->print_cr("CompileCommand: unrecognized command");
tty->print_cr(" \"%s\"", original_line);
CompilerOracle::print_tip();
return;
}
@ -712,9 +754,17 @@ void CompilerOracle::parse_from_line(char* line) {
Symbol* signature = NULL;
line += bytes_read;
// Skip any leading spaces before signature
int whitespace_read = 0;
sscanf(line, "%*[ \t]%n", &whitespace_read);
if (whitespace_read > 0) {
line += whitespace_read;
}
// there might be a signature following the method.
// signatures always begin with ( so match that by hand
if (1 == sscanf(line, "%*[ \t](%254[[);/" RANGEBASE "]%n", sig + 1, &bytes_read)) {
if (1 == sscanf(line, "(%254[[);/" RANGEBASE "]%n", sig + 1, &bytes_read)) {
sig[0] = '(';
line += bytes_read;
signature = SymbolTable::new_symbol(sig, CHECK);
@ -740,7 +790,7 @@ void CompilerOracle::parse_from_line(char* line) {
if (match != NULL && !_quiet) {
// Print out the last match added
ttyLocker ttyl;
tty->print("CompilerOracle: %s ", command_names[command]);
tty->print("CompileCommand: %s ", command_names[command]);
match->print();
}
line += bytes_read;
@ -775,26 +825,36 @@ void CompilerOracle::parse_from_line(char* line) {
ttyLocker ttyl;
if (error_msg != NULL) {
// an error has happened
tty->print_cr("CompilerOracle: unrecognized line");
tty->print_cr("CompileCommand: An error occured during parsing");
tty->print_cr(" \"%s\"", original_line);
if (error_msg != NULL) {
tty->print_cr("%s", error_msg);
}
CompilerOracle::print_tip();
} else {
// check for remaining characters
bytes_read = 0;
sscanf(line, "%*[ \t]%n", &bytes_read);
if (line[bytes_read] != '\0') {
tty->print_cr("CompilerOracle: unrecognized line");
tty->print_cr("CompileCommand: Bad pattern");
tty->print_cr(" \"%s\"", original_line);
tty->print_cr(" Unrecognized text %s after command ", line);
CompilerOracle::print_tip();
} else if (match != NULL && !_quiet) {
tty->print("CompilerOracle: %s ", command_names[command]);
tty->print("CompileCommand: %s ", command_names[command]);
match->print();
}
}
}
void CompilerOracle::print_tip() {
tty->cr();
tty->print_cr("Usage: '-XX:CompileCommand=command,\"package/Class.method()\"'");
tty->print_cr("Use: '-XX:CompileCommand=help' for more information.");
tty->cr();
}
static const char* default_cc_file = ".hotspot_compiler";
static const char* cc_file() {

View File

@ -34,6 +34,7 @@
class CompilerOracle : AllStatic {
private:
static bool _quiet;
static void print_tip();
public:

View File

@ -279,10 +279,12 @@ size_t CodeHeap::alignment_offset() const {
return sizeof(HeapBlock) & (_segment_size - 1);
}
// Finds the next free heapblock. If the current one is free, that it returned
void* CodeHeap::next_free(HeapBlock* b) const {
// Since free blocks are merged, there is max. on free block
// between two used ones
// Returns the current block if available and used.
// If not, it returns the subsequent block (if available), NULL otherwise.
// Free blocks are merged, therefore there is at most one free block
// between two used ones. As a result, the subsequent block (if available) is
// guaranteed to be used.
void* CodeHeap::next_used(HeapBlock* b) const {
if (b != NULL && b->free()) b = next_block(b);
assert(b == NULL || !b->free(), "must be in use or at end of heap");
return (b == NULL) ? NULL : b->allocated_space();

View File

@ -123,7 +123,7 @@ class CodeHeap : public CHeapObj<mtCode> {
FreeBlock* search_freelist(size_t length);
// Iteration helpers
void* next_free(HeapBlock* b) const;
void* next_used(HeapBlock* b) const;
HeapBlock* first_block() const;
HeapBlock* next_block(HeapBlock* b) const;
HeapBlock* block_start(void* p) const;
@ -158,9 +158,9 @@ class CodeHeap : public CHeapObj<mtCode> {
int freelist_length() const { return _freelist_length; } // number of elements in the freelist
// returns the first block or NULL
void* first() const { return next_free(first_block()); }
void* first() const { return next_used(first_block()); }
// returns the next block given a block p or NULL
void* next(void* p) const { return next_free(next_block(block_start(p))); }
void* next(void* p) const { return next_used(next_block(block_start(p))); }
// Statistics
size_t capacity() const;

View File

@ -3840,11 +3840,13 @@ class TestVirtualSpaceNodeTest {
assert(cm.sum_free_chunks() == 2*MediumChunk, "sizes should add up");
}
{ // 4 pages of VSN is committed, some is used by chunks
const size_t page_chunks = 4 * (size_t)os::vm_page_size() / BytesPerWord;
// This doesn't work for systems with vm_page_size >= 16K.
if (page_chunks < MediumChunk) {
// 4 pages of VSN is committed, some is used by chunks
ChunkManager cm(SpecializedChunk, SmallChunk, MediumChunk);
VirtualSpaceNode vsn(vsn_test_size_bytes);
const size_t page_chunks = 4 * (size_t)os::vm_page_size() / BytesPerWord;
assert(page_chunks < MediumChunk, "Test expects medium chunks to be at least 4*page_size");
vsn.initialize();
vsn.expand_by(page_chunks, page_chunks);
vsn.get_chunk_vs(SmallChunk);

View File

@ -361,22 +361,36 @@ public:
#endif
};
class IfTrueNode : public CProjNode {
class IfProjNode : public CProjNode {
public:
IfTrueNode( IfNode *ifnode ) : CProjNode(ifnode,1) {
IfProjNode(IfNode *ifnode, uint idx) : CProjNode(ifnode,idx) {}
virtual Node *Identity(PhaseTransform *phase);
protected:
// Type of If input when this branch is always taken
virtual bool always_taken(const TypeTuple* t) const = 0;
};
class IfTrueNode : public IfProjNode {
public:
IfTrueNode( IfNode *ifnode ) : IfProjNode(ifnode,1) {
init_class_id(Class_IfTrue);
}
virtual int Opcode() const;
virtual Node *Identity( PhaseTransform *phase );
protected:
virtual bool always_taken(const TypeTuple* t) const { return t == TypeTuple::IFTRUE; }
};
class IfFalseNode : public CProjNode {
class IfFalseNode : public IfProjNode {
public:
IfFalseNode( IfNode *ifnode ) : CProjNode(ifnode,0) {
IfFalseNode( IfNode *ifnode ) : IfProjNode(ifnode,0) {
init_class_id(Class_IfFalse);
}
virtual int Opcode() const;
virtual Node *Identity( PhaseTransform *phase );
protected:
virtual bool always_taken(const TypeTuple* t) const { return t == TypeTuple::IFFALSE; }
};

View File

@ -1122,12 +1122,21 @@ void IfNode::dominated_by( Node *prev_dom, PhaseIterGVN *igvn ) {
//------------------------------Identity---------------------------------------
// If the test is constant & we match, then we are the input Control
Node *IfTrueNode::Identity( PhaseTransform *phase ) {
Node *IfProjNode::Identity(PhaseTransform *phase) {
// Can only optimize if cannot go the other way
const TypeTuple *t = phase->type(in(0))->is_tuple();
return ( t == TypeTuple::IFNEITHER || t == TypeTuple::IFTRUE )
? in(0)->in(0) // IfNode control
: this; // no progress
if (t == TypeTuple::IFNEITHER ||
// kill dead branch first otherwise the IfNode's control will
// have 2 control uses (the IfNode that doesn't go away because
// it still has uses and this branch of the
// If). Node::has_special_unique_user() will cause this node to
// be reprocessed once the dead branch is killed.
(always_taken(t) && in(0)->outcnt() == 1)) {
// IfNode control
return in(0)->in(0);
}
// no progress
return this;
}
//------------------------------dump_spec--------------------------------------
@ -1195,13 +1204,3 @@ static IfNode* idealize_test(PhaseGVN* phase, IfNode* iff) {
// Progress
return iff;
}
//------------------------------Identity---------------------------------------
// If the test is constant & we match, then we are the input Control
Node *IfFalseNode::Identity( PhaseTransform *phase ) {
// Can only optimize if cannot go the other way
const TypeTuple *t = phase->type(in(0))->is_tuple();
return ( t == TypeTuple::IFNEITHER || t == TypeTuple::IFFALSE )
? in(0)->in(0) // IfNode control
: this; // no progress
}

View File

@ -1080,18 +1080,21 @@ bool Node::has_special_unique_user() const {
assert(outcnt() == 1, "match only for unique out");
Node* n = unique_out();
int op = Opcode();
if( this->is_Store() ) {
if (this->is_Store()) {
// Condition for back-to-back stores folding.
return n->Opcode() == op && n->in(MemNode::Memory) == this;
} else if (this->is_Load()) {
// Condition for removing an unused LoadNode from the MemBarAcquire precedence input
return n->Opcode() == Op_MemBarAcquire;
} else if( op == Op_AddL ) {
} else if (op == Op_AddL) {
// Condition for convL2I(addL(x,y)) ==> addI(convL2I(x),convL2I(y))
return n->Opcode() == Op_ConvL2I && n->in(1) == this;
} else if( op == Op_SubI || op == Op_SubL ) {
} else if (op == Op_SubI || op == Op_SubL) {
// Condition for subI(x,subI(y,z)) ==> subI(addI(x,z),y)
return n->Opcode() == op && n->in(2) == this;
} else if (is_If() && (n->is_IfFalse() || n->is_IfTrue())) {
// See IfProjNode::Identity()
return true;
}
return false;
};

View File

@ -358,7 +358,8 @@ hotspot_compiler_2 = \
compiler/inlining/ \
compiler/integerArithmetic/ \
compiler/interpreter/ \
-compiler/codegen/7184394
-compiler/codegen/7184394 \
-compiler/codecache/stress
hotspot_compiler_3 = \
compiler/intrinsics/ \

View File

@ -37,6 +37,7 @@ import sun.hotspot.code.BlobType;
/*
* @test PoolsIndependenceTest
* @ignore 8068385
* @library /testlibrary /../../test/lib
* @build PoolsIndependenceTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox

View File

@ -0,0 +1,52 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
import com.oracle.java.testlibrary.TimeLimitedRunner;
import com.oracle.java.testlibrary.Utils;
public class CodeCacheStressRunner {
private final Runnable action;
public CodeCacheStressRunner(Runnable action) {
this.action = action;
}
protected final void runTest() {
Helper.startInfiniteLoopThread(action);
try {
// adjust timeout and substract vm init and exit time
long timeout = Utils.adjustTimeout(Utils.DEFAULT_TEST_TIMEOUT);
timeout *= 0.9;
new TimeLimitedRunner(timeout, 2.0d, this::test).call();
} catch (Exception e) {
throw new Error("Exception occurred during test execution", e);
}
}
private boolean test() {
Helper.TestCase obj = Helper.TestCase.get();
Helper.callMethod(obj.getCallable(), obj.expectedValue());
return true;
}
}

View File

@ -0,0 +1,141 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.concurrent.Callable;
import java.util.Random;
import com.oracle.java.testlibrary.Asserts;
import com.oracle.java.testlibrary.ByteCodeLoader;
import com.oracle.java.testlibrary.InfiniteLoop;
import com.oracle.java.testlibrary.Utils;
import sun.hotspot.WhiteBox;
public final class Helper {
public static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
public static final Random RNG = Utils.getRandomInstance();
private static final long THRESHOLD = WHITE_BOX.getIntxVMFlag("CompileThreshold");
private static final String TEST_CASE_IMPL_CLASS_NAME = "Helper$TestCaseImpl";
private static byte[] CLASS_DATA;
static {
try {
CLASS_DATA = loadClassData(TEST_CASE_IMPL_CLASS_NAME);
} catch (IOException e) {
throw new Error("TESTBUG: cannot load class byte code", e);
}
}
private Helper() {
}
public static void startInfiniteLoopThread(Runnable action) {
startInfiniteLoopThread(action, 0L);
}
public static void startInfiniteLoopThread(Runnable action, long millis) {
Thread t = new Thread(new InfiniteLoop(action, millis));
t.setDaemon(true);
t.start();
}
public static int callMethod(Callable<Integer> callable, int expected) {
int result = 0;
for (int i = 0; i < THRESHOLD; ++i) {
try {
result = callable.call();
} catch (Exception e) {
throw new AssertionError(
"Exception occurred during test method execution", e);
}
Asserts.assertEQ(result, expected, "Method returns unexpected value");
}
return result;
}
private static byte[] loadClassData(String name) throws IOException {
try (BufferedInputStream in = new BufferedInputStream(
ClassLoader.getSystemResourceAsStream(name.replace(".", "/")
+ ".class"))) {
ByteArrayOutputStream result = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int read;
while ((read = in.read(buffer)) != -1) {
result.write(buffer, 0, read);
}
return result.toByteArray();
}
}
public interface TestCase {
public static TestCase get() {
try {
Class clazz = ByteCodeLoader.load(
TEST_CASE_IMPL_CLASS_NAME, CLASS_DATA);
return (TestCase) clazz.newInstance();
} catch (ReflectiveOperationException e) {
throw new Error(String.format(
"TESTBUG: error while creating %s instance from reloaded class",
TEST_CASE_IMPL_CLASS_NAME), e);
}
}
Callable<Integer> getCallable();
int method();
int expectedValue();
}
public static class TestCaseImpl implements TestCase {
private static final int RETURN_VALUE = 42;
private static final int RECURSION_DEPTH = 10;
private volatile int i;
@Override
public Callable<Integer> getCallable() {
return () -> {
i = 0;
return method();
};
}
@Override
public int method() {
++i;
int result = RETURN_VALUE;
if (i < RECURSION_DEPTH) {
return result + method();
}
return result;
}
@Override
public int expectedValue() {
return RETURN_VALUE * RECURSION_DEPTH;
}
}
}

View File

@ -0,0 +1,111 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
import java.lang.reflect.Method;
import java.util.stream.IntStream;
import com.oracle.java.testlibrary.Platform;
/*
* @test OverloadCompileQueueTest
* @library /testlibrary /../../test/lib
* @build OverloadCompileQueueTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
* -XX:CompileCommand=dontinline,Helper$TestCase::method
* -XX:+WhiteBoxAPI -XX:-SegmentedCodeCache OverloadCompileQueueTest
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
* -XX:CompileCommand=dontinline,Helper$TestCase::method
* -XX:+WhiteBoxAPI -XX:+SegmentedCodeCache OverloadCompileQueueTest
* @summary stressing code cache by overloading compile queues
*/
public class OverloadCompileQueueTest implements Runnable {
private static final int MAX_SLEEP = 10000;
private static final String METHOD_TO_ENQUEUE = "method";
private static final int LEVEL_SIMPLE = 1;
private static final int LEVEL_FULL_OPTIMIZATION = 4;
private static final boolean INTERPRETED
= System.getProperty("java.vm.info").startsWith("interpreted ");
private static final boolean TIERED_COMPILATION
= Helper.WHITE_BOX.getBooleanVMFlag("TieredCompilation");
private static final int TIERED_STOP_AT_LEVEL
= Helper.WHITE_BOX.getIntxVMFlag("TieredStopAtLevel").intValue();
private static final int[] AVAILABLE_LEVELS;
static {
if (TIERED_COMPILATION) {
AVAILABLE_LEVELS = IntStream
.rangeClosed(LEVEL_SIMPLE, TIERED_STOP_AT_LEVEL)
.toArray();
} else if (Platform.isServer()) {
AVAILABLE_LEVELS = new int[] { LEVEL_FULL_OPTIMIZATION };
} else if (Platform.isClient() || Platform.isMinimal()) {
AVAILABLE_LEVELS = new int[] { LEVEL_SIMPLE };
} else {
throw new Error(String.format(
"TESTBUG: unknown VM: %s", System.getProperty("java.vm.name")));
}
}
public static void main(String[] args) {
if (INTERPRETED) {
System.err.println("Test isn't applicable for interpreter. Skip test.");
return;
}
new CodeCacheStressRunner(new OverloadCompileQueueTest()).runTest();
}
public OverloadCompileQueueTest() {
Helper.startInfiniteLoopThread(this::lockUnlock);
}
@Override
public void run() {
Helper.TestCase obj = Helper.TestCase.get();
Class clazz = obj.getClass();
Method mEnqueue;
try {
mEnqueue = clazz.getMethod(METHOD_TO_ENQUEUE);
} catch (NoSuchMethodException | SecurityException e) {
throw new Error(String.format(
"TESTBUG: cannot get method '%s' of class %s",
METHOD_TO_ENQUEUE, clazz.getName()), e);
}
for (int compLevel : AVAILABLE_LEVELS) {
Helper.WHITE_BOX.enqueueMethodForCompilation(mEnqueue, compLevel);
}
}
private void lockUnlock() {
try {
Helper.WHITE_BOX.lockCompilation();
Thread.sleep(Helper.RNG.nextInt(MAX_SLEEP));
} catch (InterruptedException e) {
throw new Error("TESTBUG: lockUnlocker thread was unexpectedly interrupted", e);
} finally {
Helper.WHITE_BOX.unlockCompilation();
}
}
}

View File

@ -0,0 +1,71 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
import java.util.ArrayList;
import sun.hotspot.code.BlobType;
/*
* @test RandomAllocationTest
* @library /testlibrary /../../test/lib
* @build RandomAllocationTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
* -XX:CompileCommand=dontinline,Helper$TestCase::method
* -XX:+WhiteBoxAPI -XX:-SegmentedCodeCache RandomAllocationTest
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
* -XX:CompileCommand=dontinline,Helper$TestCase::method
* -XX:+WhiteBoxAPI -XX:+SegmentedCodeCache RandomAllocationTest
* @summary stressing code cache by allocating randomly sized "dummy" code blobs
*/
public class RandomAllocationTest implements Runnable {
private static final long CODE_CACHE_SIZE
= Helper.WHITE_BOX.getUintxVMFlag("ReservedCodeCacheSize");
private static final int MAX_BLOB_SIZE = (int) (CODE_CACHE_SIZE >> 7);
private static final BlobType[] BLOB_TYPES
= BlobType.getAvailable().toArray(new BlobType[0]);
public static void main(String[] args) {
new CodeCacheStressRunner(new RandomAllocationTest()).runTest();
}
private final ArrayList<Long> blobs = new ArrayList<>();
@Override
public void run() {
boolean allocate = blobs.isEmpty() || Helper.RNG.nextBoolean();
if (allocate) {
int type = Helper.RNG.nextInt(BLOB_TYPES.length);
long addr = Helper.WHITE_BOX.allocateCodeBlob(
Helper.RNG.nextInt(MAX_BLOB_SIZE), BLOB_TYPES[type].id);
if (addr != 0) {
blobs.add(addr);
}
} else {
int index = Helper.RNG.nextInt(blobs.size());
Helper.WHITE_BOX.freeCodeBlob(blobs.remove(index));
}
}
}

View File

@ -0,0 +1,52 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
/*
* @test UnexpectedDeoptimizationTest
* @library /testlibrary /../../test/lib
* @build UnexpectedDeoptimizationTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
* -XX:CompileCommand=dontinline,Helper$TestCase::method
* -XX:+WhiteBoxAPI -XX:-SegmentedCodeCache -XX:-DeoptimizeRandom
* UnexpectedDeoptimizationTest
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
* -XX:CompileCommand=dontinline,Helper$TestCase::method
* -XX:+WhiteBoxAPI -XX:+SegmentedCodeCache -XX:-DeoptimizeRandom
* UnexpectedDeoptimizationTest
* @summary stressing code cache by forcing unexpected deoptimizations
*/
public class UnexpectedDeoptimizationTest implements Runnable {
public static void main(String[] args) {
new CodeCacheStressRunner(new UnexpectedDeoptimizationTest()).runTest();
}
@Override
public void run() {
Helper.WHITE_BOX.deoptimizeFrames(Helper.RNG.nextBoolean());
}
}

View File

@ -25,7 +25,7 @@
* @test
* @bug 8054224
* @summary Recursive method compiled by C1 is unable to catch StackOverflowError
* @run main/othervm -Xcomp -XX:CompileOnly=Test.run -XX:+TieredCompilation -XX:TieredStopAtLevel=2 -Xss256K TestRecursiveReplacedException
* @run main/othervm -Xcomp -XX:CompileOnly=Test.run -XX:+TieredCompilation -XX:TieredStopAtLevel=2 -Xss392K TestRecursiveReplacedException
*
*/

View File

@ -0,0 +1,73 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8063086
* @summary X^2 special case for C2 yields different result than interpreter
* @library /testlibrary /../../test/lib /compiler/whitebox
* @build TestPow2
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
* -XX:-BackgroundCompilation -XX:-UseOnStackReplacement TestPow2
*
*/
import java.lang.reflect.*;
import sun.hotspot.WhiteBox;
public class TestPow2 {
private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
private static final double base = 5350.456329377186;
private static final double exp = 2.0;
static double m() {
return Math.pow(base, exp);
}
static public void main(String[] args) throws NoSuchMethodException {
Method test_method = TestPow2.class.getDeclaredMethod("m");
double interpreter_result = m();
// Compile with C1 if possible
WHITE_BOX.enqueueMethodForCompilation(test_method, CompilerWhiteBoxTest.COMP_LEVEL_SIMPLE);
double c1_result = m();
WHITE_BOX.deoptimizeMethod(test_method);
// Compile it with C2 if possible
WHITE_BOX.enqueueMethodForCompilation(test_method, CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION);
double c2_result = m();
if (interpreter_result != c1_result || interpreter_result != c2_result ||
c1_result != c2_result) {
System.out.println("interpreter = " + interpreter_result + " c1 = " + c1_result + " c2 = " + c2_result);
throw new RuntimeException("Test Failed");
}
}
}

View File

@ -172,7 +172,7 @@ public class CheckCompileCommandOption {
out.shouldContain(expected_output);
}
out.shouldNotContain("CompilerOracle: unrecognized line");
out.shouldNotContain("CompileCommand: unrecognized line");
out.shouldHaveExitValue(0);
}
@ -183,7 +183,7 @@ public class CheckCompileCommandOption {
pb = ProcessTools.createJavaProcessBuilder(arguments);
out = new OutputAnalyzer(pb.start());
out.shouldContain("CompilerOracle: unrecognized line");
out.shouldContain("CompileCommand: unrecognized line");
out.shouldHaveExitValue(0);
}

View File

@ -53,6 +53,7 @@ import sun.misc.Unsafe;
*/
public class TestRTMDeoptOnLowAbortRatio extends CommandLineOptionTest {
private static final long LOCKING_THRESHOLD = 100L;
private static final long ABORT_THRESHOLD = LOCKING_THRESHOLD / 2L;
private TestRTMDeoptOnLowAbortRatio() {
super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
@ -77,7 +78,8 @@ public class TestRTMDeoptOnLowAbortRatio extends CommandLineOptionTest {
useStackLock),
CommandLineOptionTest.prepareNumericFlag("RTMLockingThreshold",
TestRTMDeoptOnLowAbortRatio.LOCKING_THRESHOLD),
"-XX:RTMAbortThreshold=1",
CommandLineOptionTest.prepareNumericFlag("RTMAbortThreshold",
TestRTMDeoptOnLowAbortRatio.ABORT_THRESHOLD),
"-XX:RTMAbortRatio=100",
"-XX:CompileThreshold=1",
"-XX:RTMRetryCount=0",
@ -107,7 +109,7 @@ public class TestRTMDeoptOnLowAbortRatio extends CommandLineOptionTest {
for (RTMLockingStatistics s : statistics) {
if (s.getTotalLocks()
== TestRTMDeoptOnLowAbortRatio.LOCKING_THRESHOLD + 1L) {
== TestRTMDeoptOnLowAbortRatio.LOCKING_THRESHOLD) {
Asserts.assertNull(statisticsBeforeDeopt,
"Only one abort was expected during test run");
statisticsBeforeDeopt = s;
@ -154,8 +156,7 @@ public class TestRTMDeoptOnLowAbortRatio extends CommandLineOptionTest {
}
for (int i = 0; i < AbortProvoker.DEFAULT_ITERATIONS; i++) {
AbortProvoker.verifyMonitorState(t.monitor, shouldBeInflated);
t.forceAbort(
i == TestRTMDeoptOnLowAbortRatio.LOCKING_THRESHOLD);
t.forceAbort(i >= TestRTMDeoptOnLowAbortRatio.ABORT_THRESHOLD);
}
}
}

View File

@ -58,7 +58,7 @@ public class TestRTMLockingThreshold extends CommandLineOptionTest {
* interrupts, VMM calls, etc. during first lock attempt.
*
*/
private static final int ABORT_THRESHOLD = 10;
private static final int MIN_ABORT_THRESHOLD = 10;
@Override
protected void runTestCases() throws Throwable {
@ -75,6 +75,9 @@ public class TestRTMLockingThreshold extends CommandLineOptionTest {
boolean useStackLock) throws Throwable {
CompilableTest test = new Test();
int abortThreshold = Math.max(lockingThreshold / 2,
TestRTMLockingThreshold.MIN_ABORT_THRESHOLD);
OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
test,
"-XX:CompileThreshold=1",
@ -84,7 +87,7 @@ public class TestRTMLockingThreshold extends CommandLineOptionTest {
"-XX:RTMTotalCountIncrRate=1",
"-XX:RTMRetryCount=0",
CommandLineOptionTest.prepareNumericFlag("RTMAbortThreshold",
TestRTMLockingThreshold.ABORT_THRESHOLD),
abortThreshold),
CommandLineOptionTest.prepareNumericFlag("RTMLockingThreshold",
lockingThreshold),
"-XX:RTMAbortRatio=100",
@ -103,16 +106,12 @@ public class TestRTMLockingThreshold extends CommandLineOptionTest {
+ "RTM locking statistics entries.");
/**
* We force abort on each odd iteration, so if RTMLockingThreshold==0,
* then we have to make 1 call without abort to avoid rtm state
* transition to NoRTM (otherwise actual abort ratio will be 100%),
* and after that make 1 call with abort to force deoptimization.
* This leads us to two locks for threshold 0.
* For other threshold values we have to make RTMLockingThreshold + 1
* locks if locking threshold is even, or + 0 if odd.
* If RTMLockingThreshold==0, then we have to make at least 1 call.
*/
long expectedValue = lockingThreshold +
(lockingThreshold == 0L ? 2L : lockingThreshold % 2L);
long expectedValue = lockingThreshold;
if (expectedValue == 0) {
expectedValue++;
}
RTMLockingStatistics statBeforeDeopt = null;
for (RTMLockingStatistics s : statistics) {
@ -159,15 +158,16 @@ public class TestRTMLockingThreshold extends CommandLineOptionTest {
* Test &lt;inflate monitor&gt;
*/
public static void main(String args[]) throws Throwable {
Asserts.assertGTE(args.length, 1, "One argument required.");
Asserts.assertGTE(args.length, 2, "Two arguments required.");
Test t = new Test();
boolean shouldBeInflated = Boolean.valueOf(args[0]);
int lockingThreshold = Integer.valueOf(args[1]);
if (shouldBeInflated) {
AbortProvoker.inflateMonitor(t.monitor);
}
for (int i = 0; i < Test.TOTAL_ITERATIONS; i++) {
AbortProvoker.verifyMonitorState(t.monitor, shouldBeInflated);
t.lock(i % 2 == 1);
t.lock(i >= lockingThreshold / 2);
}
}
}

View File

@ -35,6 +35,7 @@
* -XX:+WhiteBoxAPI TestRTMTotalCountIncrRate
*/
import sun.misc.Unsafe;
import java.util.List;
import com.oracle.java.testlibrary.*;
@ -97,14 +98,12 @@ public class TestRTMTotalCountIncrRate extends CommandLineOptionTest {
Asserts.assertEQ(lock.getTotalLocks(), Test.TOTAL_ITERATIONS,
"Total locks should be exactly the same as amount of "
+ "iterations.");
} else {
Asserts.assertGT(lock.getTotalLocks(), 0L, "RTM statistics "
+ "should contain information for at least on lock.");
}
}
public static class Test implements CompilableTest {
private static final long TOTAL_ITERATIONS = 10000L;
private static final Unsafe UNSAFE = Utils.getUnsafe();
private final Object monitor = new Object();
// Following field have to be static in order to avoid escape analysis.
@SuppressWarnings("UnsuedDeclaration")
@ -120,8 +119,17 @@ public class TestRTMTotalCountIncrRate extends CommandLineOptionTest {
return new String[] { getMethodWithLockName() };
}
public void lock() {
public void lock(booleab forceAbort) {
synchronized(monitor) {
if (forceAbort) {
// We're calling native method in order to force
// abort. It's done by explicit xabort call emitted
// in SharedRuntime::generate_native_wrapper.
// If an actuall JNI call will be replaced by
// intrinsic - we'll be in trouble, since xabort
// will be no longer called and test may fail.
UNSAFE.addressSize();
}
Test.field++;
}
}
@ -140,7 +148,11 @@ public class TestRTMTotalCountIncrRate extends CommandLineOptionTest {
for (long i = 0L; i < Test.TOTAL_ITERATIONS; i++) {
AbortProvoker.verifyMonitorState(test.monitor,
shouldBeInflated);
test.lock();
// Force abort on first iteration to avoid rare case when
// there were no aborts and locks count was not incremented
// with RTMTotalCountIncrRate > 1 (in such case JVM won't
// print JVM locking statistics).
test.lock(i == 0);
}
}
}

View File

@ -125,9 +125,6 @@ public class TestPrintPreciseRTMLockingStatistics
RTMLockingStatistics lock = statistics.get(0);
Asserts.assertGT(lock.getTotalLocks(), 0L, "RTM locking statistics "
+ "should contain non zero total locks count");
Asserts.assertGT(lock.getTotalAborts(), 0L,
"RTM locking statistics should contain non zero total aborts "
+ "count");

View File

@ -28,7 +28,7 @@
* @summary JVM crashes with "missing exception handler" error
* @author volker.simonis@sap.com
*
* @run main/othervm -XX:CompileThreshold=100 -Xbatch -Xss248k StackOverflowBug
* @run main/othervm -XX:CompileThreshold=100 -Xbatch -Xss392k StackOverflowBug
*/

View File

@ -0,0 +1,145 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package uncommontrap;
import java.io.FileReader;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import java.util.regex.Pattern;
import com.oracle.java.testlibrary.Asserts;
/**
* Utility tool aimed to verify presence or absence of specified uncommon trap
* in compilation log.
*/
public class Verifier {
public static final String PROPERTIES_FILE_SUFFIX = ".verify.properties";
public static final String VERIFICATION_SHOULD_BE_SKIPPED
= "uncommon.trap.verification.skipped";
public static final String UNCOMMON_TRAP_NAME = "uncommon.trap.name";
public static final String UNCOMMON_TRAP_BCI = "uncommon.trap.bci";
public static final String UNCOMMON_TRAP_COMMENT = "uncommon.trap.comment";
public static final String UNCOMMON_TRAP_ACTION = "uncommon.trap.action";
public static final String UNCOMMON_TRAP_SHOULD_EMITTED
= "uncommon.trap.emitted";
public static final String UNCOMMON_TRAP_SHOULD_FIRED
= "uncommon.trap.fired";
private static final String EMITTED_TRAP_PATTERN
= "<uncommon_trap bci='%s' reason='%s' action='%s' "
+ "comment='%s'";
private static final String FIRED_TRAP_PATTERN
= "<uncommon_trap thread='[0-9]*' reason='%s' action='%s'";
private static final String JVMS_PATTERN = "<jvms bci='%s'";
public static void main(String args[]) {
if (args.length == 0) {
throw new Error("At least one argument containing name of "
+ "compilation log file is expected");
}
for (String compLogFile : args) {
try {
verify(Paths.get(compLogFile));
} catch (IOException e) {
throw new Error("Unable to process compilation log.", e);
}
}
}
private static void verify(Path compLogFile) throws IOException {
Path propertiesFile = Paths.get(compLogFile.toString() +
PROPERTIES_FILE_SUFFIX);
Properties properties = new Properties();
properties.load(new FileReader(propertiesFile.toFile()));
if (Boolean.valueOf(properties.getProperty(
VERIFICATION_SHOULD_BE_SKIPPED, "false"))) {
System.out.println("Skipping verification for log file: "
+ compLogFile.toString());
return;
}
System.out.println("Verifying log file: " + compLogFile.toString());
List<String> compLogContent = Files.readAllLines(compLogFile);
verifyUncommonTrapEmitted(properties, compLogContent);
verifyUncommonTrapFired(properties, compLogContent);
}
private static void verifyUncommonTrapEmitted(Properties properties,
List<String> compLogContent) {
String emittedTrapRE = String.format(EMITTED_TRAP_PATTERN,
properties.getProperty(UNCOMMON_TRAP_BCI, ".*"),
properties.getProperty(UNCOMMON_TRAP_NAME, ".*"),
properties.getProperty(UNCOMMON_TRAP_ACTION, ".*"),
properties.getProperty(UNCOMMON_TRAP_COMMENT, ".*"));
Pattern pattern = Pattern.compile(emittedTrapRE);
long trapsCount = compLogContent.stream()
.filter(line -> pattern.matcher(line).find())
.count();
boolean shouldBeEmitted = Boolean.valueOf(
properties.getProperty(UNCOMMON_TRAP_SHOULD_EMITTED));
Asserts.assertEQ(shouldBeEmitted, trapsCount > 0, String.format(
"Uncommon trap that matches following string in compilation log"
+ " should %sbe emitted: %s.",
(shouldBeEmitted ? " " : "not "), emittedTrapRE));
}
private static void verifyUncommonTrapFired(Properties properties,
List<String> compLogContent) {
String firedTrapRE = String.format(FIRED_TRAP_PATTERN,
properties.getProperty(UNCOMMON_TRAP_NAME, ".*"),
properties.getProperty(UNCOMMON_TRAP_ACTION, ".*"));
String jvmsRE = String.format(JVMS_PATTERN,
properties.getProperty(UNCOMMON_TRAP_BCI, ".*"));
boolean trapFired = false;
Pattern firedTrapPattern = Pattern.compile(firedTrapRE);
Pattern jvmsPattern = Pattern.compile(jvmsRE);
Iterator<String> iterator = compLogContent.iterator();
while (iterator.hasNext() && !trapFired) {
trapFired = firedTrapPattern.matcher(iterator.next()).find()
&& jvmsPattern.matcher(iterator.next()).find();
}
boolean shouldBeFired = Boolean.valueOf(
properties.getProperty(UNCOMMON_TRAP_SHOULD_FIRED));
Asserts.assertEQ(shouldBeFired, trapFired, String.format(
"Uncommon trap that matches following string in compilation log"
+ " should %sbe fired: %s.",
(shouldBeFired ? "" : "not "), firedTrapRE));
}
}

View File

@ -32,7 +32,7 @@ import java.lang.reflect.Method;
* @build Test8009761
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=exclude,Test8009761::m2 -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -Xss256K Test8009761
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=exclude,Test8009761::m2 -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -Xss392K Test8009761
*/
public class Test8009761 {

View File

@ -25,7 +25,7 @@
* @test
* @bug 8029383
* @summary stack overflow if callee is marked for deoptimization causes crash
* @run main/othervm -XX:TieredStopAtLevel=1 -XX:-BackgroundCompilation -XX:CompileCommand=dontinline,StackOverflowGuardPagesOff::m1 -XX:CompileCommand=exclude,StackOverflowGuardPagesOff::m2 -Xss256K -XX:-UseOnStackReplacement StackOverflowGuardPagesOff
* @run main/othervm -XX:TieredStopAtLevel=1 -XX:-BackgroundCompilation -XX:CompileCommand=dontinline,StackOverflowGuardPagesOff::m1 -XX:CompileCommand=exclude,StackOverflowGuardPagesOff::m2 -Xss392K -XX:-UseOnStackReplacement StackOverflowGuardPagesOff
*
*/

View File

@ -25,7 +25,7 @@
* @test
* @bug 8032410
* @summary Stack overflow at deoptimization doesn't release owned monitors
* @run main/othervm -XX:-BackgroundCompilation -XX:CompileCommand=dontinline,TestStackBangMonitorOwned::m1 -XX:CompileCommand=exclude,TestStackBangMonitorOwned::m2 -Xss256K -XX:-UseOnStackReplacement TestStackBangMonitorOwned
* @run main/othervm -XX:-BackgroundCompilation -XX:CompileCommand=dontinline,TestStackBangMonitorOwned::m1 -XX:CompileCommand=exclude,TestStackBangMonitorOwned::m2 -Xss392K -XX:-UseOnStackReplacement TestStackBangMonitorOwned
*
*/
public class TestStackBangMonitorOwned {

View File

@ -25,7 +25,7 @@
* @test
* @bug 8028308
* @summary rbp not restored when stack overflow is thrown from deopt/uncommon trap blobs
* @run main/othervm -XX:-BackgroundCompilation -XX:CompileCommand=dontinline,TestStackBangRbp::m1 -XX:CompileCommand=exclude,TestStackBangRbp::m2 -Xss256K -XX:-UseOnStackReplacement TestStackBangRbp
* @run main/othervm -XX:-BackgroundCompilation -XX:CompileCommand=dontinline,TestStackBangRbp::m1 -XX:CompileCommand=exclude,TestStackBangRbp::m2 -Xss392K -XX:-UseOnStackReplacement TestStackBangRbp
*
*/
public class TestStackBangRbp {

View File

@ -0,0 +1,257 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.lang.reflect.Method;
import java.util.Properties;
import com.oracle.java.testlibrary.ByteCodeLoader;
import com.oracle.java.testlibrary.Platform;
import jdk.internal.org.objectweb.asm.ClassVisitor;
import jdk.internal.org.objectweb.asm.ClassWriter;
import jdk.internal.org.objectweb.asm.Label;
import jdk.internal.org.objectweb.asm.MethodVisitor;
import static jdk.internal.org.objectweb.asm.Opcodes.*;
import sun.hotspot.WhiteBox;
import uncommontrap.Verifier;
/*
* @test
* @bug 8030976 8059226
* @library /testlibrary /compiler/testlibrary /../../test/lib
* @build TestUnstableIfTrap com.oracle.java.testlibrary.* uncommontrap.Verifier
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
* @run main/othervm -Xbatch -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
* -XX:+WhiteBoxAPI -XX:+LogCompilation
* -XX:CompileCommand=compileonly,UnstableIfExecutable.test
* -XX:LogFile=always_taken_not_fired.xml
* TestUnstableIfTrap ALWAYS_TAKEN false
* @run main/othervm -Xbatch -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
* -XX:+WhiteBoxAPI -XX:+LogCompilation
* -XX:CompileCommand=compileonly,UnstableIfExecutable.test
* -XX:LogFile=always_taken_fired.xml
* TestUnstableIfTrap ALWAYS_TAKEN true
* @run main/othervm -Xbatch -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
* -XX:+WhiteBoxAPI -XX:+LogCompilation
* -XX:CompileCommand=compileonly,UnstableIfExecutable.test
* -XX:LogFile=never_taken_not_fired.xml
* TestUnstableIfTrap NEVER_TAKEN false
* @run main/othervm -Xbatch -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
* -XX:+WhiteBoxAPI -XX:+LogCompilation
* -XX:CompileCommand=compileonly,UnstableIfExecutable.test
* -XX:LogFile=never_taken_fired.xml
* TestUnstableIfTrap NEVER_TAKEN true
* @run main uncommontrap.Verifier always_taken_not_fired.xml
* always_taken_fired.xml
* never_taken_not_fired.xml
* never_taken_fired.xml
*/
public class TestUnstableIfTrap {
private static final WhiteBox WB = WhiteBox.getWhiteBox();
private static final String CLASS_NAME = "UnstableIfExecutable";
private static final String METHOD_NAME = "test";
private static final String FIELD_NAME = "field";
private static final int ITERATIONS = 1_000_000;
// There is no dependency on particular class file version, so it could be
// set to any version (if you're updating this test for Java 42).
private static final int CLASS_FILE_VERSION = 49;
private static final int MAX_TIER = 4;
// This test aimed to verify that uncommon trap with reason "unstable_if"
// is emitted when method that contain control-flow divergence such that
// one of two branches is never taken (and other one is taken always).
// C2 will made a decision whether or not the branch was ever taken
// depending on method's profile.
// If profile was collected for a few method's invocations, then C2 will not
// trust in branches' probabilities and the tested trap won't be emitted.
// In fact, a method has to be invoked at least 40 time at the day when this
// comment was written (see Parse::dynamic_branch_prediction for an actual
// value). It would be to implementation dependent to use "40" as
// a threshold value in the test, so in order to improve test's robustness
// the threshold value is 1000: if the tested method was compiled by C2
// before it was invoked 1000 times, then we won't verify that trap was
// emitted and fired.
private static final int MIN_INVOCATIONS_BEFORE_C2_COMPILATION = 1000;
/**
* Description of test case parameters and uncommon trap that will
* be emitted during tested method compilation.
*/
private static enum TestCaseName {
ALWAYS_TAKEN(false, "taken always"),
NEVER_TAKEN(true, "taken never");
TestCaseName(boolean predicate, String comment) {
this.predicate = predicate;
this.comment = comment;
}
public final boolean predicate;
public final String name = "unstable_if";
public final String comment;
}
public static void main(String args[]) {
if (args.length != 2) {
throw new Error("Expected two arguments: test case name and a "
+ "boolean determining if uncommon trap should be fired.");
}
test(TestCaseName.valueOf(args[0]), Boolean.valueOf(args[1]));
}
private static void test(TestCaseName testCase, boolean shouldBeFired) {
Method testMethod;
Label unstableIfLocation = new Label();
boolean shouldBeEmitted;
boolean compiledToEarly = false;
try {
Class testClass = ByteCodeLoader.load(CLASS_NAME,
generateTest(unstableIfLocation));
testMethod = testClass.getDeclaredMethod(METHOD_NAME,
boolean.class);
for (int i = 0; i < ITERATIONS; i++) {
testMethod.invoke(null, testCase.predicate);
if (i < MIN_INVOCATIONS_BEFORE_C2_COMPILATION
&& isMethodCompiledByC2(testMethod)) {
compiledToEarly = true;
// There is no sense in further invocations: we already
// decided to avoid verification.
break;
}
}
// We're checking that trap should be emitted (i.e. it was compiled
// by C2) before the trap is fired, because otherwise the nmethod
// will be deoptimized and isMethodCompiledByC2 will return false.
shouldBeEmitted = isMethodCompiledByC2(testMethod)
&& !compiledToEarly;
if (shouldBeFired) {
testMethod.invoke(null, !testCase.predicate);
}
} catch (ReflectiveOperationException e) {
throw new Error("Test case should be generated, loaded and executed"
+ " without any issues.", e);
}
shouldBeFired &= shouldBeEmitted;
Properties properties = new Properties();
properties.setProperty(Verifier.VERIFICATION_SHOULD_BE_SKIPPED,
Boolean.toString(compiledToEarly));
properties.setProperty(Verifier.UNCOMMON_TRAP_SHOULD_EMITTED,
Boolean.toString(shouldBeEmitted));
properties.setProperty(Verifier.UNCOMMON_TRAP_SHOULD_FIRED,
Boolean.toString(shouldBeFired));
properties.setProperty(Verifier.UNCOMMON_TRAP_NAME, testCase.name);
properties.setProperty(Verifier.UNCOMMON_TRAP_COMMENT,
testCase.comment);
properties.setProperty(Verifier.UNCOMMON_TRAP_BCI,
Integer.toString(unstableIfLocation.getOffset()));
properties.list(System.out);
File f = new File(WB.getStringVMFlag("LogFile") +
Verifier.PROPERTIES_FILE_SUFFIX);
try (FileWriter wr = new FileWriter(f)) {
properties.store(wr, "");
} catch (IOException e) {
throw new Error("Unable to store test properties.", e);
}
}
private static boolean isMethodCompiledByC2(Method m) {
boolean isTiered = WB.getBooleanVMFlag("TieredCompilation");
boolean isMethodCompiled = WB.isMethodCompiled(m);
boolean isMethodCompiledAtMaxTier
= WB.getMethodCompilationLevel(m) == MAX_TIER;
return Platform.isServer() && isMethodCompiled
&& (!isTiered || isMethodCompiledAtMaxTier);
}
/**
* Generates class with name {@code CLASS_NAME}, which will contain a
* static method {@code METHOD_NAME}:
*
* <pre>{@code
* public abstract class UnstableIfExecutable {
* private static int field = 0;
*
* public static void test(boolean alwaysTrue) {
* if (alwaysTrue) {
* field++;
* } else {
* field--;
* }
* }
* }
* }</pre>
*
* @return generated bytecode.
*/
private static byte[] generateTest(Label unstableIfLocation) {
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
cw.visit(CLASS_FILE_VERSION, ACC_PUBLIC | ACC_ABSTRACT, CLASS_NAME,
null, "java/lang/Object", null);
cw.visitField(ACC_PUBLIC | ACC_STATIC | ACC_VOLATILE, FIELD_NAME,
"I", null, Integer.valueOf(0));
generateTestMethod(cw, unstableIfLocation);
return cw.toByteArray();
}
private static void generateTestMethod(ClassVisitor cv,
Label unstableIfLocation) {
MethodVisitor mv = cv.visitMethod(ACC_PUBLIC | ACC_STATIC, METHOD_NAME,
"(Z)V", null, null);
mv.visitCode();
Label end = new Label();
Label falseBranch = new Label();
// push "field" field's value and 1 to stack
mv.visitFieldInsn(GETSTATIC, CLASS_NAME, FIELD_NAME, "I");
mv.visitInsn(ICONST_1);
// load argument's value
mv.visitVarInsn(ILOAD, 0); // alwaysTrue
// here is our unstable if
mv.visitLabel(unstableIfLocation);
mv.visitJumpInsn(IFEQ, falseBranch);
// increment on "true"
mv.visitInsn(IADD);
mv.visitJumpInsn(GOTO, end);
// decrement on "false"
mv.visitLabel(falseBranch);
mv.visitInsn(ISUB);
mv.visitLabel(end);
// bye bye
mv.visitInsn(RETURN);
mv.visitMaxs(0, 0);
mv.visitEnd();
}
}

View File

@ -34,6 +34,7 @@ import com.oracle.java.testlibrary.InfiniteLoop;
/*
* @test
* @bug 8059624 8064669
* @ignore 8066998
* @library /testlibrary /../../test/lib
* @build ForceNMethodSweepTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox

View File

@ -112,7 +112,7 @@ class TestMaxHeapSizeTools {
}
private static void checkInvalidMinInitialHeapCombinations(String gcflag) throws Exception {
expectError(new String[] { gcflag, "-Xms8M", "-XX:InitialHeapSize=4M", "-version" });
expectError(new String[] { gcflag, "-Xms64M", "-XX:InitialHeapSize=32M", "-version" });
}
private static void checkValidMinInitialHeapCombinations(String gcflag) throws Exception {

View File

@ -107,8 +107,8 @@ public class TestGCLogMessages {
private static void testWithToSpaceExhaustionLogs() throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
"-Xmx10M",
"-Xmn5M",
"-Xmx32M",
"-Xmn16M",
"-XX:+PrintGCDetails",
GCTestWithToSpaceExhaustion.class.getName());
@ -120,8 +120,8 @@ public class TestGCLogMessages {
output.shouldHaveExitValue(0);
pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
"-Xmx10M",
"-Xmn5M",
"-Xmx32M",
"-Xmn16M",
"-XX:+PrintGCDetails",
"-XX:+UnlockExperimentalVMOptions",
"-XX:G1LogLevel=finest",
@ -151,7 +151,7 @@ public class TestGCLogMessages {
private static byte[] garbage;
private static byte[] largeObject;
public static void main(String [] args) {
largeObject = new byte[5*1024*1024];
largeObject = new byte[16*1024*1024];
System.out.println("Creating garbage");
// create 128MB of garbage. This should result in at least one GC,
// some of them with to-space exhaustion.

View File

@ -31,7 +31,9 @@
import com.oracle.java.testlibrary.*;
public class TestHumongousAllocInitialMark {
private static final int heapSize = 200; // MB
// Heap sizes < 224 MB are increased to 224 MB if vm_page_size == 64K to
// fulfill alignment constraints.
private static final int heapSize = 224; // MB
private static final int heapRegionSize = 1; // MB
private static final int initiatingHeapOccupancyPercent = 50; // %

View File

@ -1,4 +1,4 @@
# Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2013, 2015, 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
@ -71,11 +71,12 @@ bad_data_ptr_re='(SIGILL|SIGSEGV|EXCEPTION_ACCESS_VIOLATION).* at pc='
# EXCEPTION_ACCESS_VIOLATION - Win-*
# SIGBUS - Solaris SPARC-64
# SIGSEGV - Linux-*, Solaris SPARC-32, Solaris X86-*
# SIGILL - Aix
#
# Note: would like to use "pc=0x00*0f," in the pattern, but Solaris SPARC-*
# gets its signal at a PC in test_error_handler().
#
bad_func_ptr_re='(SIGBUS|SIGSEGV|EXCEPTION_ACCESS_VIOLATION).* at pc='
bad_func_ptr_re='(SIGBUS|SIGSEGV|SIGILL|EXCEPTION_ACCESS_VIOLATION).* at pc='
guarantee_re='guarantee[(](str|num).*failed: *'
fatal_re='fatal error: *'
tail_1='.*expected null'

View File

@ -43,7 +43,7 @@ public class CompilerConfigFileWarning {
pb = ProcessTools.createJavaProcessBuilder("-XX:CompileCommandFile=hs_comp.txt", "-version");
output = new OutputAnalyzer(pb.start());
output.shouldContain("CompilerOracle: unrecognized line");
output.shouldContain("CompileCommand: unrecognized command");
output.shouldContain("aaa aaa");
// Skip on debug builds since we'll always read the file there

View File

@ -47,7 +47,7 @@ public class WBStackSize {
static final long K = 1024;
static final long MIN_STACK_SIZE = 8 * K;
static final long MAX_STACK_SIZE_ALLOCATED_IN_MAIN = 200 * K; // current value is about 130k on 64-bit platforms
static final long MAX_STACK_SIZE_ALLOCATED_IN_MAIN = 150 * K; // current value is about 130k on 64-bit platforms
static final WhiteBox wb = WhiteBox.getWhiteBox();
@ -82,9 +82,11 @@ public class WBStackSize {
public static void main(String[] args) {
long configStackSize = wb.getIntxVMFlag("ThreadStackSize") * K;
System.out.println("ThreadStackSize VM option: " + configStackSize);
long stackProtectionSize = wb.getIntxVMFlag("StackShadowPages") * wb.getVMPageSize();
System.out.println("Size of protected shadow pages: " + stackProtectionSize);
long actualStackSize = wb.getThreadStackSize();
System.out.println("Full stack size: " + actualStackSize);
@ -96,14 +98,16 @@ public class WBStackSize {
long remainingStackSize = wb.getThreadRemainingStackSize();
System.out.println("Remaining stack size in main(): " + remainingStackSize);
// Up to 200k can be already allocated by VM
// Up to 150k can be already allocated by VM and some space is used for stack protection.
long spaceAlreadyOccupied = MAX_STACK_SIZE_ALLOCATED_IN_MAIN + stackProtectionSize;
if (remainingStackSize > configStackSize
|| (configStackSize > MAX_STACK_SIZE_ALLOCATED_IN_MAIN
&& remainingStackSize < configStackSize - MAX_STACK_SIZE_ALLOCATED_IN_MAIN)) {
|| (configStackSize > spaceAlreadyOccupied
&& remainingStackSize < configStackSize - spaceAlreadyOccupied)) {
throw new RuntimeException("getThreadRemainingStackSize value [" + remainingStackSize
+ "] should be at least ThreadStackSize value [" + configStackSize + "] minus ["
+ MAX_STACK_SIZE_ALLOCATED_IN_MAIN + "]");
+ spaceAlreadyOccupied + "]");
}
testStackOverflow();

View File

@ -3,7 +3,7 @@ import java.util.Set;
import com.oracle.java.testlibrary.Platform;
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2015, 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
@ -39,14 +39,16 @@ public class DynLibDcmdTest {
String result = DcmdUtil.executeDcmd("VM.dynlibs");
String osDependentBaseString = null;
if (Platform.isSolaris()) {
if (Platform.isAix()) {
osDependentBaseString = "lib%s.so";
} else if (Platform.isLinux()) {
osDependentBaseString = "lib%s.so";
} else if (Platform.isOSX()) {
osDependentBaseString = "lib%s.dylib";
} else if (Platform.isSolaris()) {
osDependentBaseString = "lib%s.so";
} else if (Platform.isWindows()) {
osDependentBaseString = "%s.dll";
} else if (Platform.isOSX()) {
osDependentBaseString = "lib%s.dylib";
} else if (Platform.isLinux()) {
osDependentBaseString = "lib%s.so";
}
if (osDependentBaseString == null) {

View File

@ -1,6 +1,6 @@
#!/bin/sh
#
# Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2013, 2015, 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
@ -56,7 +56,7 @@ echo "TESTOPTS=${TESTOPTS}"
# set platform-dependent variables
OS=`uname -s`
case "$OS" in
SunOS | Linux | Darwin )
AIX | Darwin | Linux | SunOS )
NULL=/dev/null
PS=":"
FS="/"
@ -133,26 +133,31 @@ then
fi
VM_OS="unknown"
grep "solaris" vm_version.out > ${NULL}
grep "aix" vm_version.out > ${NULL}
if [ $? = 0 ]
then
VM_OS="solaris"
VM_OS="aix"
fi
grep "bsd" vm_version.out > ${NULL}
if [ $? = 0 ]
then
VM_OS="bsd"
fi
grep "linux" vm_version.out > ${NULL}
if [ $? = 0 ]
then
VM_OS="linux"
fi
grep "solaris" vm_version.out > ${NULL}
if [ $? = 0 ]
then
VM_OS="solaris"
fi
grep "windows" vm_version.out > ${NULL}
if [ $? = 0 ]
then
VM_OS="windows"
fi
grep "bsd" vm_version.out > ${NULL}
if [ $? = 0 ]
then
VM_OS="bsd"
fi
VM_CPU="unknown"
grep "sparc" vm_version.out > ${NULL}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2015, 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
@ -68,20 +68,24 @@ public class Platform {
return dataModel.equals("64");
}
public static boolean isSolaris() {
return isOs("sunos");
public static boolean isAix() {
return isOs("aix");
}
public static boolean isWindows() {
return isOs("win");
public static boolean isLinux() {
return isOs("linux");
}
public static boolean isOSX() {
return isOs("mac");
}
public static boolean isLinux() {
return isOs("linux");
public static boolean isSolaris() {
return isOs("sunos");
}
public static boolean isWindows() {
return isOs("win");
}
private static boolean isOs(String osname) {
@ -140,7 +144,9 @@ public class Platform {
*/
public static boolean shouldSAAttach() throws Exception {
if (isLinux()) {
if (isAix()) {
return false; // SA not implemented.
} else if (isLinux()) {
return canPtraceAttachLinux();
} else if (isOSX()) {
return canAttachOSX();

View File

@ -45,7 +45,7 @@ public class TestMutuallyExclusivePlatformPredicates {
private static enum MethodGroup {
ARCH("isARM", "isPPC", "isSparc", "isX86", "isX64"),
BITNESS("is32bit", "is64bit"),
OS("isLinux", "isSolaris", "isWindows", "isOSX"),
OS("isAix", "isLinux", "isOSX", "isSolaris", "isWindows"),
VM_TYPE("isClient", "isServer", "isGraal", "isMinimal"),
IGNORED("isEmbedded", "isDebugBuild", "shouldSAAttach",
"canPtraceAttachLinux", "canAttachOSX", "isTieredSupported");