This commit is contained in:
Alejandro Murillo 2015-01-20 10:22:43 -08:00
commit 5aea4e6239
74 changed files with 1651 additions and 415 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

@ -264,11 +264,11 @@ void TemplateInterpreterGenerator::generate_counter_incr(Label* overflow, Label*
__ cmpdi(CCR0, Rmdo, 0);
__ beq(CCR0, no_mdo);
// Increment backedge counter in the MDO.
const int mdo_bc_offs = in_bytes(MethodData::backedge_counter_offset()) + in_bytes(InvocationCounter::counter_offset());
__ lwz(Rscratch2, mdo_bc_offs, Rmdo);
// Increment invocation counter in the MDO.
const int mdo_ic_offs = in_bytes(MethodData::invocation_counter_offset()) + in_bytes(InvocationCounter::counter_offset());
__ lwz(Rscratch2, mdo_ic_offs, Rmdo);
__ addi(Rscratch2, Rscratch2, increment);
__ stw(Rscratch2, mdo_bc_offs, Rmdo);
__ stw(Rscratch2, mdo_ic_offs, Rmdo);
__ load_const_optimized(Rscratch1, mask, R0);
__ and_(Rscratch1, Rscratch2, Rscratch1);
__ bne(CCR0, done);
@ -276,12 +276,12 @@ void TemplateInterpreterGenerator::generate_counter_incr(Label* overflow, Label*
}
// Increment counter in MethodCounters*.
const int mo_bc_offs = in_bytes(MethodCounters::backedge_counter_offset()) + in_bytes(InvocationCounter::counter_offset());
const int mo_ic_offs = in_bytes(MethodCounters::invocation_counter_offset()) + in_bytes(InvocationCounter::counter_offset());
__ bind(no_mdo);
__ get_method_counters(R19_method, R3_counters, done);
__ lwz(Rscratch2, mo_bc_offs, R3_counters);
__ lwz(Rscratch2, mo_ic_offs, R3_counters);
__ addi(Rscratch2, Rscratch2, increment);
__ stw(Rscratch2, mo_bc_offs, R3_counters);
__ stw(Rscratch2, mo_ic_offs, R3_counters);
__ load_const_optimized(Rscratch1, mask, R0);
__ and_(Rscratch1, Rscratch2, Rscratch1);
__ beq(CCR0, *overflow);

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

@ -1,6 +1,6 @@
/*
* Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright 2007, 2008, 2011 Red Hat, Inc.
* Copyright 2007, 2008, 2011, 2015, Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -237,7 +237,13 @@ inline jint Atomic::xchg(jint exchange_value, volatile jint* dest) {
// operation. Note that some platforms only support this with the
// limitation that the only valid value to store is the immediate
// constant 1. There is a test for this in JNI_CreateJavaVM().
return __sync_lock_test_and_set (dest, exchange_value);
jint result = __sync_lock_test_and_set (dest, exchange_value);
// All atomic operations are expected to be full memory barriers
// (see atomic.hpp). However, __sync_lock_test_and_set is not
// a full memory barrier, but an acquire barrier. Hence, this added
// barrier.
__sync_synchronize();
return result;
#endif // M68K
#endif // ARM
}
@ -250,7 +256,9 @@ inline intptr_t Atomic::xchg_ptr(intptr_t exchange_value,
#ifdef M68K
return m68k_lock_test_and_set(dest, exchange_value);
#else
return __sync_lock_test_and_set (dest, exchange_value);
intptr_t result = __sync_lock_test_and_set (dest, exchange_value);
__sync_synchronize();
return result;
#endif // M68K
#endif // ARM
}

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright 2007, 2008, 2011 Red Hat, Inc.
* Copyright 2007, 2008, 2011, 2015, Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -231,7 +231,13 @@ inline jint Atomic::xchg(jint exchange_value, volatile jint* dest) {
// operation. Note that some platforms only support this with the
// limitation that the only valid value to store is the immediate
// constant 1. There is a test for this in JNI_CreateJavaVM().
return __sync_lock_test_and_set (dest, exchange_value);
jint result = __sync_lock_test_and_set (dest, exchange_value);
// All atomic operations are expected to be full memory barriers
// (see atomic.hpp). However, __sync_lock_test_and_set is not
// a full memory barrier, but an acquire barrier. Hence, this added
// barrier.
__sync_synchronize();
return result;
#endif // M68K
#endif // ARM
}
@ -244,7 +250,9 @@ inline intptr_t Atomic::xchg_ptr(intptr_t exchange_value,
#ifdef M68K
return m68k_lock_test_and_set(dest, exchange_value);
#else
return __sync_lock_test_and_set (dest, exchange_value);
intptr_t result = __sync_lock_test_and_set (dest, exchange_value);
__sync_synchronize();
return result;
#endif // M68K
#endif // ARM
}

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

@ -1910,7 +1910,6 @@ public:
}
void work(uint worker_id) {
double start = os::elapsedTime();
FreeRegionList local_cleanup_list("Local Cleanup List");
HRRSCleanupTask hrrs_cleanup_task;
G1NoteEndOfConcMarkClosure g1_note_end(_g1h, &local_cleanup_list,

View File

@ -1229,7 +1229,6 @@ bool G1CollectedHeap::do_collection(bool explicit_gc,
TraceCollectorStats tcs(g1mm()->full_collection_counters());
TraceMemoryManagerStats tms(true /* fullGC */, gc_cause());
double start = os::elapsedTime();
g1_policy()->record_full_collection_start();
// Note: When we have a more flexible GC logging framework that
@ -1436,7 +1435,6 @@ bool G1CollectedHeap::do_collection(bool explicit_gc,
_allocator->init_mutator_alloc_region();
double end = os::elapsedTime();
g1_policy()->record_full_collection_end();
if (G1Log::fine()) {

View File

@ -56,7 +56,6 @@ class HRRSCleanupTask;
class GenerationSpec;
class OopsInHeapRegionClosure;
class G1KlassScanClosure;
class G1ScanHeapEvacClosure;
class ObjectClosure;
class SpaceClosure;
class CompactibleSpaceClosure;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 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
@ -153,14 +153,6 @@ G1CollectorPolicy::G1CollectorPolicy() :
_inc_cset_predicted_elapsed_time_ms(0.0),
_inc_cset_predicted_elapsed_time_ms_diffs(0.0),
#ifdef _MSC_VER // the use of 'this' below gets a warning, make it go away
#pragma warning( disable:4355 ) // 'this' : used in base member initializer list
#endif // _MSC_VER
_short_lived_surv_rate_group(new SurvRateGroup(this, "Short Lived",
G1YoungSurvRateNumRegionsSummary)),
_survivor_surv_rate_group(new SurvRateGroup(this, "Survivor",
G1YoungSurvRateNumRegionsSummary)),
// add here any more surv rate groups
_recorded_survivor_regions(0),
_recorded_survivor_head(NULL),
@ -169,6 +161,22 @@ G1CollectorPolicy::G1CollectorPolicy() :
_gc_overhead_perc(0.0) {
uintx confidence_perc = G1ConfidencePercent;
// Put an artificial ceiling on this so that it's not set to a silly value.
if (confidence_perc > 100) {
confidence_perc = 100;
warning("G1ConfidencePercent is set to a value that is too large, "
"it's been updated to %u", confidence_perc);
}
// '_sigma' must be initialized before the SurvRateGroups below because they
// indirecty access '_sigma' trough the 'this' pointer in their constructor.
_sigma = (double) confidence_perc / 100.0;
_short_lived_surv_rate_group =
new SurvRateGroup(this, "Short Lived", G1YoungSurvRateNumRegionsSummary);
_survivor_surv_rate_group =
new SurvRateGroup(this, "Survivor", G1YoungSurvRateNumRegionsSummary);
// Set up the region size and associated fields. Given that the
// policy is created before the heap, we have to set this up here,
// so it's done as soon as possible.
@ -283,15 +291,6 @@ G1CollectorPolicy::G1CollectorPolicy() :
double time_slice = (double) GCPauseIntervalMillis / 1000.0;
_mmu_tracker = new G1MMUTrackerQueue(time_slice, max_gc_time);
uintx confidence_perc = G1ConfidencePercent;
// Put an artificial ceiling on this so that it's not set to a silly value.
if (confidence_perc > 100) {
confidence_perc = 100;
warning("G1ConfidencePercent is set to a value that is too large, "
"it's been updated to %u", confidence_perc);
}
_sigma = (double) confidence_perc / 100.0;
// start conservatively (around 50ms is about right)
_concurrent_mark_remark_times_ms->add(0.05);
_concurrent_mark_cleanup_times_ms->add(0.20);

View File

@ -46,9 +46,6 @@ class ReferenceProcessor;
class G1PrepareCompactClosure;
class G1MarkSweep : AllStatic {
friend class VM_G1MarkSweep;
friend class Scavenge;
public:
static void invoke_at_safepoint(ReferenceProcessor* rp,

View File

@ -45,7 +45,8 @@
#include "utilities/bitMap.inline.hpp"
G1PageBasedVirtualSpace::G1PageBasedVirtualSpace() : _low_boundary(NULL),
_high_boundary(NULL), _committed(), _page_size(0), _special(false), _executable(false) {
_high_boundary(NULL), _committed(), _page_size(0), _special(false),
_dirty(), _executable(false) {
}
bool G1PageBasedVirtualSpace::initialize_with_granularity(ReservedSpace rs, size_t page_size) {
@ -66,6 +67,9 @@ bool G1PageBasedVirtualSpace::initialize_with_granularity(ReservedSpace rs, size
assert(_committed.size() == 0, "virtual space initialized more than once");
uintx size_in_bits = rs.size() / page_size;
_committed.resize(size_in_bits, /* in_resource_area */ false);
if (_special) {
_dirty.resize(size_in_bits, /* in_resource_area */ false);
}
return true;
}
@ -84,6 +88,7 @@ void G1PageBasedVirtualSpace::release() {
_executable = false;
_page_size = 0;
_committed.resize(0, false);
_dirty.resize(0, false);
}
size_t G1PageBasedVirtualSpace::committed_size() const {
@ -120,34 +125,43 @@ size_t G1PageBasedVirtualSpace::byte_size_for_pages(size_t num) {
return num * _page_size;
}
MemRegion G1PageBasedVirtualSpace::commit(uintptr_t start, size_t size_in_pages) {
bool G1PageBasedVirtualSpace::commit(uintptr_t start, size_t size_in_pages) {
// We need to make sure to commit all pages covered by the given area.
guarantee(is_area_uncommitted(start, size_in_pages), "Specified area is not uncommitted");
if (!_special) {
bool zero_filled = true;
uintptr_t end = start + size_in_pages;
if (_special) {
// Check for dirty pages and update zero_filled if any found.
if (_dirty.get_next_one_offset(start,end) < end) {
zero_filled = false;
_dirty.clear_range(start, end);
}
} else {
os::commit_memory_or_exit(page_start(start), byte_size_for_pages(size_in_pages), _executable,
err_msg("Failed to commit pages from "SIZE_FORMAT" of length "SIZE_FORMAT, start, size_in_pages));
}
_committed.set_range(start, start + size_in_pages);
_committed.set_range(start, end);
MemRegion result((HeapWord*)page_start(start), byte_size_for_pages(size_in_pages) / HeapWordSize);
if (AlwaysPreTouch) {
os::pretouch_memory((char*)result.start(), (char*)result.end());
os::pretouch_memory(page_start(start), page_start(end));
}
return result;
return zero_filled;
}
MemRegion G1PageBasedVirtualSpace::uncommit(uintptr_t start, size_t size_in_pages) {
void G1PageBasedVirtualSpace::uncommit(uintptr_t start, size_t size_in_pages) {
guarantee(is_area_committed(start, size_in_pages), "checking");
if (!_special) {
if (_special) {
// Mark that memory is dirty. If committed again the memory might
// need to be cleared explicitly.
_dirty.set_range(start, start + size_in_pages);
} else {
os::uncommit_memory(page_start(start), byte_size_for_pages(size_in_pages));
}
_committed.clear_range(start, start + size_in_pages);
MemRegion result((HeapWord*)page_start(start), byte_size_for_pages(size_in_pages) / HeapWordSize);
return result;
}
bool G1PageBasedVirtualSpace::contains(const void* p) const {
@ -157,7 +171,7 @@ bool G1PageBasedVirtualSpace::contains(const void* p) const {
#ifndef PRODUCT
void G1PageBasedVirtualSpace::print_on(outputStream* out) {
out->print ("Virtual space:");
if (special()) out->print(" (pinned in memory)");
if (_special) out->print(" (pinned in memory)");
out->cr();
out->print_cr(" - committed: " SIZE_FORMAT, committed_size());
out->print_cr(" - reserved: " SIZE_FORMAT, reserved_size());

View File

@ -49,6 +49,12 @@ class G1PageBasedVirtualSpace VALUE_OBJ_CLASS_SPEC {
// Bitmap used for verification of commit/uncommit operations.
BitMap _committed;
// Bitmap used to keep track of which pages are dirty or not for _special
// spaces. This is needed because for those spaces the underlying memory
// will only be zero filled the first time it is committed. Calls to commit
// will use this bitmap and return whether or not the memory is zero filled.
BitMap _dirty;
// Indicates that the entire space has been committed and pinned in memory,
// os::commit_memory() or os::uncommit_memory() have no function.
bool _special;
@ -71,12 +77,11 @@ class G1PageBasedVirtualSpace VALUE_OBJ_CLASS_SPEC {
public:
// Commit the given area of pages starting at start being size_in_pages large.
MemRegion commit(uintptr_t start, size_t size_in_pages);
// Returns true if the given area is zero filled upon completion.
bool commit(uintptr_t start, size_t size_in_pages);
// Uncommit the given area of pages starting at start being size_in_pages large.
MemRegion uncommit(uintptr_t start, size_t size_in_pages);
bool special() const { return _special; }
void uncommit(uintptr_t start, size_t size_in_pages);
// Initialization
G1PageBasedVirtualSpace();

View File

@ -67,9 +67,9 @@ class G1RegionsLargerThanCommitSizeMapper : public G1RegionToSpaceMapper {
}
virtual void commit_regions(uintptr_t start_idx, size_t num_regions) {
_storage.commit(start_idx * _pages_per_region, num_regions * _pages_per_region);
bool zero_filled = _storage.commit(start_idx * _pages_per_region, num_regions * _pages_per_region);
_commit_map.set_range(start_idx, start_idx + num_regions);
fire_on_commit(start_idx, num_regions, true);
fire_on_commit(start_idx, num_regions, zero_filled);
}
virtual void uncommit_regions(uintptr_t start_idx, size_t num_regions) {
@ -117,8 +117,7 @@ class G1RegionsSmallerThanCommitSizeMapper : public G1RegionToSpaceMapper {
uint old_refcount = _refcounts.get_by_index(idx);
bool zero_filled = false;
if (old_refcount == 0) {
_storage.commit(idx, 1);
zero_filled = true;
zero_filled = _storage.commit(idx, 1);
}
_refcounts.set_by_index(idx, old_refcount + 1);
_commit_map.set_bit(i);

View File

@ -31,7 +31,6 @@
// collection set.
class G1CollectedHeap;
class CardTableModRefBarrierSet;
class ConcurrentG1Refine;
class G1ParPushHeapRSClosure;

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

@ -3170,7 +3170,9 @@ void Metaspace::global_initialize() {
}
// the min_misc_data_size and min_misc_code_size estimates are based on
// MetaspaceShared::generate_vtable_methods()
// MetaspaceShared::generate_vtable_methods().
// The minimum size only accounts for the vtable methods. Any size less than the
// minimum required size would cause vm crash when allocating the vtable methods.
uint min_misc_data_size = align_size_up(
MetaspaceShared::num_virtuals * MetaspaceShared::vtbl_list_size * sizeof(void*), max_alignment);
@ -3336,6 +3338,10 @@ void Metaspace::initialize(Mutex* lock, MetaspaceType type) {
Metachunk* new_chunk = get_initialization_chunk(NonClassType,
word_size,
vsm()->medium_chunk_bunch());
// For dumping shared archive, report error if allocation has failed.
if (DumpSharedSpaces && new_chunk == NULL) {
report_insufficient_metaspace(MetaspaceAux::committed_bytes() + word_size * BytesPerWord);
}
assert(!DumpSharedSpaces || new_chunk != NULL, "should have enough space for both chunks");
if (new_chunk != NULL) {
// Add to this manager's list of chunks in use and current_chunk().
@ -3349,6 +3355,11 @@ void Metaspace::initialize(Mutex* lock, MetaspaceType type) {
class_vsm()->medium_chunk_bunch());
if (class_chunk != NULL) {
class_vsm()->add_chunk(class_chunk, true);
} else {
// For dumping shared archive, report error if allocation has failed.
if (DumpSharedSpaces) {
report_insufficient_metaspace(MetaspaceAux::committed_bytes() + class_word_size * BytesPerWord);
}
}
}
@ -3829,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

@ -2951,10 +2951,6 @@ class CommandLineFlags {
develop(intx, MallocCatchPtr, -1, \
"Hit breakpoint when mallocing/freeing this pointer") \
\
notproduct(intx, AssertRepeat, 1, \
"number of times to evaluate expression in assert " \
"(to estimate overhead); only works with -DUSE_REPEATED_ASSERTS") \
\
notproduct(ccstrlist, SuppressErrorAt, "", \
"List of assertions (file:line) to muzzle") \
\

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -547,20 +547,16 @@ static void verify_memory(void* ptr) {
// This function supports testing of the malloc out of memory
// condition without really running the system out of memory.
//
static u_char* testMalloc(size_t alloc_size) {
assert(MallocMaxTestWords > 0, "sanity check");
static bool has_reached_max_malloc_test_peak(size_t alloc_size) {
if (MallocMaxTestWords > 0) {
jint words = (jint)(alloc_size / BytesPerWord);
if ((cur_malloc_words + (alloc_size / BytesPerWord)) > MallocMaxTestWords) {
return NULL;
if ((cur_malloc_words + words) > MallocMaxTestWords) {
return true;
}
Atomic::add(words, (volatile jint *)&cur_malloc_words);
}
u_char* ptr = (u_char*)::malloc(alloc_size);
if (ptr != NULL) {
Atomic::add(((jint) (alloc_size / BytesPerWord)),
(volatile jint *) &cur_malloc_words);
}
return ptr;
return false;
}
void* os::malloc(size_t size, MEMFLAGS flags) {
@ -608,13 +604,14 @@ void* os::malloc(size_t size, MEMFLAGS memflags, const NativeCallStack& stack) {
NOT_PRODUCT(if (MallocVerifyInterval > 0) check_heap());
u_char* ptr;
if (MallocMaxTestWords > 0) {
ptr = testMalloc(alloc_size);
} else {
ptr = (u_char*)::malloc(alloc_size);
// For the test flag -XX:MallocMaxTestWords
if (has_reached_max_malloc_test_peak(size)) {
return NULL;
}
u_char* ptr;
ptr = (u_char*)::malloc(alloc_size);
#ifdef ASSERT
if (ptr == NULL) {
return NULL;
@ -642,6 +639,11 @@ void* os::realloc(void *memblock, size_t size, MEMFLAGS flags) {
void* os::realloc(void *memblock, size_t size, MEMFLAGS memflags, const NativeCallStack& stack) {
// For the test flag -XX:MallocMaxTestWords
if (has_reached_max_malloc_test_peak(size)) {
return NULL;
}
#ifndef ASSERT
NOT_PRODUCT(inc_stat_counter(&num_mallocs, 1));
NOT_PRODUCT(inc_stat_counter(&alloc_bytes, size));

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright 2008, 2009, 2010 Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -87,30 +87,7 @@
#undef assert
#endif
// from hotspot/src/share/vm/utilities/debug.hpp
#ifdef ASSERT
#ifndef USE_REPEATED_ASSERTS
#define assert(p, msg) \
do { \
if (!(p)) { \
report_vm_error(__FILE__, __LINE__, "assert(" #p ") failed", msg); \
BREAKPOINT; \
} \
} while (0)
#else // #ifndef USE_REPEATED_ASSERTS
#define assert(p, msg)
do { \
for (int __i = 0; __i < AssertRepeat; __i++) { \
if (!(p)) { \
report_vm_error(__FILE__, __LINE__, "assert(" #p ") failed", msg); \
BREAKPOINT; \
} \
} \
} while (0)
#endif // #ifndef USE_REPEATED_ASSERTS
#else
#define assert(p, msg)
#endif
#define assert(p, msg) vmassert(p, msg)
#ifdef DEBUG
#undef DEBUG

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -273,6 +273,14 @@ void report_out_of_shared_space(SharedSpaceType shared_space) {
exit(2);
}
void report_insufficient_metaspace(size_t required_size) {
warning("\nThe MaxMetaspaceSize of " UINTX_FORMAT " bytes is not large enough.\n"
"Either don't specify the -XX:MaxMetaspaceSize=<size>\n"
"or increase the size to at least " SIZE_FORMAT ".\n",
MaxMetaspaceSize, required_size);
exit(2);
}
void report_java_out_of_memory(const char* message) {
static jint out_of_memory_reported = 0;
@ -326,9 +334,9 @@ void test_error_handler() {
// Keep this in sync with test/runtime/6888954/vmerrors.sh.
switch (n) {
case 1: assert(str == NULL, "expected null");
case 2: assert(num == 1023 && *str == 'X',
err_msg("num=" SIZE_FORMAT " str=\"%s\"", num, str));
case 1: vmassert(str == NULL, "expected null");
case 2: vmassert(num == 1023 && *str == 'X',
err_msg("num=" SIZE_FORMAT " str=\"%s\"", num, str));
case 3: guarantee(str == NULL, "expected null");
case 4: guarantee(num == 1023 && *str == 'X',
err_msg("num=" SIZE_FORMAT " str=\"%s\"", num, str));

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -105,58 +105,42 @@ void FormatBuffer<bufsz>::append(const char* format, ...) {
va_end(argp);
}
// Used to format messages for assert(), guarantee(), fatal(), etc.
// Used to format messages for vmassert(), guarantee(), fatal(), etc.
typedef FormatBuffer<> err_msg;
typedef FormatBufferResource err_msg_res;
// assertions
#ifdef ASSERT
#ifndef USE_REPEATED_ASSERTS
#define assert(p, msg) \
#ifndef ASSERT
#define vmassert(p, msg)
#else
// Note: message says "assert" rather than "vmassert" for backward
// compatibility with tools that parse/match the message text.
#define vmassert(p, msg) \
do { \
if (!(p)) { \
report_vm_error(__FILE__, __LINE__, "assert(" #p ") failed", msg); \
BREAKPOINT; \
} \
} while (0)
#else // #ifndef USE_REPEATED_ASSERTS
#define assert(p, msg)
do { \
for (int __i = 0; __i < AssertRepeat; __i++) { \
if (!(p)) { \
report_vm_error(__FILE__, __LINE__, "assert(" #p ") failed", msg); \
BREAKPOINT; \
} \
} \
} while (0)
#endif // #ifndef USE_REPEATED_ASSERTS
#endif
// This version of assert is for use with checking return status from
// For backward compatibility.
#define assert(p, msg) vmassert(p, msg)
// This version of vmassert is for use with checking return status from
// library calls that return actual error values eg. EINVAL,
// ENOMEM etc, rather than returning -1 and setting errno.
// When the status is not what is expected it is very useful to know
// what status was actually returned, so we pass the status variable as
// an extra arg and use strerror to convert it to a meaningful string
// like "Invalid argument", "out of memory" etc
#define assert_status(p, status, msg) \
do { \
if (!(p)) { \
report_vm_error(__FILE__, __LINE__, "assert(" #p ") failed", \
err_msg("error %s(%d) %s", strerror(status), \
status, msg)); \
BREAKPOINT; \
} \
} while (0)
#define vmassert_status(p, status, msg) \
vmassert(p, err_msg("error %s(%d), %s", strerror(status), status, msg))
// Do not assert this condition if there's already another error reported.
#define assert_if_no_error(cond,msg) assert((cond) || is_error_reported(), msg)
#else // #ifdef ASSERT
#define assert(p,msg)
#define assert_status(p,status,msg)
#define assert_if_no_error(cond,msg)
#endif // #ifdef ASSERT
// For backward compatibility.
#define assert_status(p, status, msg) vmassert_status(p, status, msg)
// guarantee is like assert except it's always executed -- use it for
// guarantee is like vmassert except it's always executed -- use it for
// cheap tests that catch errors that would otherwise be hard to find.
// guarantee is also used for Verify options.
#define guarantee(p, msg) \
@ -225,21 +209,22 @@ void report_untested(const char* file, int line, const char* message);
void warning(const char* format, ...) ATTRIBUTE_PRINTF(1, 2);
#ifdef ASSERT
// Compile-time asserts.
template <bool> struct StaticAssert;
template <> struct StaticAssert<true> {};
// Compile-time asserts. Cond must be a compile-time constant expression that
// is convertible to bool. STATIC_ASSERT() can be used anywhere a declaration
// may appear.
//
// Implementation Note: STATIC_ASSERT_FAILURE<true> provides a value member
// rather than type member that could be used directly in the typedef, because
// a type member would require conditional use of "typename", depending on
// whether Cond is dependent or not. The use of a value member leads to the
// use of an array type.
// Only StaticAssert<true> is defined, so if cond evaluates to false we get
// a compile time exception when trying to use StaticAssert<false>.
#define STATIC_ASSERT(cond) \
do { \
StaticAssert<(cond)> DUMMY_STATIC_ASSERT; \
(void)DUMMY_STATIC_ASSERT; /* ignore */ \
} while (false)
#else
#define STATIC_ASSERT(cond)
#endif
template<bool x> struct STATIC_ASSERT_FAILURE;
template<> struct STATIC_ASSERT_FAILURE<true> { enum { value = 1 }; };
#define STATIC_ASSERT(Cond) \
typedef char STATIC_ASSERT_FAILURE_ ## __LINE__ [ \
STATIC_ASSERT_FAILURE< (Cond) >::value ]
// out of shared space reporting
enum SharedSpaceType {
@ -251,6 +236,8 @@ enum SharedSpaceType {
void report_out_of_shared_space(SharedSpaceType space_type);
void report_insufficient_metaspace(size_t required_size);
// out of memory reporting
void report_java_out_of_memory(const char* message);
@ -258,7 +245,7 @@ void report_java_out_of_memory(const char* message);
bool is_error_reported();
void set_error_reported();
/* Test assert(), fatal(), guarantee(), etc. */
/* Test vmassert(), fatal(), guarantee(), etc. */
NOT_PRODUCT(void test_error_handler();)
void pd_ps(frame f);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 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
@ -33,6 +33,10 @@
#include "runtime/vmThread.hpp"
#include "utilities/xmlstream.hpp"
// Do not assert this condition if there's already another error reported.
#define assert_if_no_error(cond, msg) \
vmassert((cond) || is_error_reported(), msg)
void xmlStream::initialize(outputStream* out) {
_out = out;
_last_flush = 0;

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
@ -69,7 +69,6 @@ needs_jdk = \
gc/metaspace/TestPerfCountersAndMemoryPools.java \
runtime/6819213/TestBootNativeLibraryPath.java \
runtime/7158988/FieldMonitor.java \
runtime/7194254/Test7194254.java \
runtime/Metaspace/FragmentMetaspace.java \
runtime/NMT/BaselineWithParameter.java \
runtime/NMT/JcmdBaselineDetail.java \
@ -94,6 +93,7 @@ needs_jdk = \
runtime/NMT/VirtualAllocTestType.java \
runtime/RedefineObject/TestRedefineObject.java \
runtime/Thread/TestThreadDumpMonitorContention.java \
runtime/Thread/ThreadPriorities.java \
runtime/XCheckJniJsig/XCheckJSig.java \
serviceability/attach/AttachWithStalePidFile.java \
serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java \
@ -232,7 +232,8 @@ needs_g1gc = \
gc/g1/ \
gc/metaspace/G1AddMetaspaceDependency.java \
gc/metaspace/TestMetaspacePerfCounters.java \
gc/startup_warnings/TestG1.java
gc/startup_warnings/TestG1.java \
gc/whitebox/TestConcMarkCycleWB.java
# All tests that explicitly set the serial GC
#
@ -357,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

@ -26,6 +26,7 @@
* @bug 8042235
* @summary redefining method used by multiple MethodHandles crashes VM
* @compile -XDignore.symbol.file RedefineMethodUsedByMultipleMethodHandles.java
* @ignore 7076820
* @run main RedefineMethodUsedByMultipleMethodHandles
*/

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

@ -28,6 +28,7 @@ import com.oracle.java.testlibrary.*;
* @bug 8038636
* @library /testlibrary
* @build Agent
* @ignore 7076820
* @run main ClassFileInstaller Agent
* @run main Launcher
* @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation -XX:-UseOnStackReplacement -XX:TypeProfileLevel=222 -XX:ReservedCodeCacheSize=3M Agent

View File

@ -28,6 +28,7 @@ import com.oracle.java.testlibrary.*;
* @bug 8040237
* @library /testlibrary
* @build Agent Test A B
* @ignore 7076820
* @run main ClassFileInstaller Agent
* @run main Launcher
* @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation -XX:-UseOnStackReplacement -XX:TypeProfileLevel=222 -XX:ReservedCodeCacheSize=3M Agent

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

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 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
@ -26,34 +26,46 @@
* @bug 8067438
* @requires vm.gc=="null"
* @summary Verify that starting the VM with a small heap works
* @library /testlibrary
* @run main/othervm -Xmx4m -XX:+UseParallelGC TestSmallHeap
* @run main/othervm -Xmx4m -XX:+UseSerialGC TestSmallHeap
* @run main/othervm -Xmx4m -XX:+UseG1GC TestSmallHeap
* @run main/othervm -Xmx4m -XX:+UseConcMarkSweepGC -XX:CMSMarkStackSizeMax=1032 TestSmallHeap
* @library /testlibrary /../../test/lib
* @build TestSmallHeap
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xmx2m -XX:+UseParallelGC TestSmallHeap
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xmx2m -XX:+UseSerialGC TestSmallHeap
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xmx2m -XX:+UseG1GC TestSmallHeap
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xmx2m -XX:+UseConcMarkSweepGC TestSmallHeap
*
* Note: It would be nice to verify the minimal supported heap size (2m) here,
* but we align the heap size based on the card table size. And the card table
* size is aligned based on the minimal pages size provided by the os. This
* means that on most platforms, where the minimal page size is 4k, we get a
* minimal heap size of 2m but on Solaris/Sparc we have a page size of 8k and
* get a minimal heap size of 4m. And on platforms where the page size is 64k
* we get a minimal heap size of 32m. We never use large pages for the card table.
*
* Note: It would be nice to verify the minimal supported heap size here,
* but that turns out to be quite tricky since we align the heap size based
* on the card table size. And the card table size is aligned based on the
* minimal pages size provided by the os. This means that on most platforms,
* where the minimal page size is 4k, we get a minimal heap size of 2m but
* on Solaris/Sparc we have a page size of 8k and get a minimal heap size
* of 8m.
* There is also no check in the VM for verifying that the maximum heap size
* is larger than the supported minimal heap size. This means that specifying
* -Xmx1m on the command line is fine but will give a heap of 2m (or 4m).
* To work around these rather strange behaviors this test uses 4m for all
* platforms.
* -Xmx1m on the command line is fine but will give a heap of 2m (or 4m or 32m).
*
* To work around these rather strange behaviors this test uses -Xmx2m but then
* calculates what the expected heap size should be. The calculation is a
* simplified version of the code in the VM. We assume that the card table will
* use one page. Each byte in the card table corresponds to 512 bytes on the heap.
* So, the expected heap size is page_size * 512.
*/
import sun.management.ManagementFactoryHelper;
import com.oracle.java.testlibrary.*;
import static com.oracle.java.testlibrary.Asserts.*;
import sun.hotspot.WhiteBox;
import sun.management.ManagementFactoryHelper;
public class TestSmallHeap {
public static void main(String[] args) {
WhiteBox wb = WhiteBox.getWhiteBox();
int pageSize = wb.getVMPageSize();
int heapBytesPerCard = 512;
long expectedMaxHeap = pageSize * heapBytesPerCard;
String maxHeap = ManagementFactoryHelper.getDiagnosticMXBean().getVMOption("MaxHeapSize").getValue();
String expectedMaxHeap = "4194304";
assertEQ(maxHeap, expectedMaxHeap);
assertEQ(Long.parseLong(maxHeap), expectedMaxHeap);
}
}

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

@ -27,6 +27,7 @@
* @summary Test that you can decrease NMT tracking level but not increase it.
* @key nmt
* @library /testlibrary /../../test/lib
* @ignore 8067167
* @build ChangeTrackingLevel
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission

View File

@ -27,6 +27,7 @@
* @bug 8005936 8058606
* @summary Verify PrintNMTStatistics on normal JVM exit for detail and summary tracking level
* @library /testlibrary
* @ignore 8067167
*/
import com.oracle.java.testlibrary.*;

View File

@ -0,0 +1,41 @@
/*
* Copyright (c) 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
* 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 8067187
* @summary Testing CDS dumping with the -XX:MaxMetaspaceSize=<size> option
* @library /testlibrary
*/
import com.oracle.java.testlibrary.*;
public class MaxMetaspaceSize {
public static void main(String[] args) throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
"-XX:MaxMetaspaceSize=20m", "-Xshare:dump");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldContain("is not large enough.\nEither don't specify the -XX:MaxMetaspaceSize=<size>\nor increase the size to at least");
output.shouldHaveExitValue(2);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 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
@ -27,23 +27,21 @@
* @summary Creates several threads with different java priorities and checks
* whether jstack reports correct priorities for them.
*
* @ignore 8060219
* @run main Test7194254
* @library /testlibrary
* @run main ThreadPriorities
*/
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CyclicBarrier;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Test7194254 {
import com.oracle.java.testlibrary.*;
import static com.oracle.java.testlibrary.Asserts.*;
public static void main(String[] args) throws Exception {
public class ThreadPriorities {
public static void main(String[] args) throws Throwable {
final int NUMBER_OF_JAVA_PRIORITIES =
Thread.MAX_PRIORITY - Thread.MIN_PRIORITY + 1;
final CyclicBarrier barrier =
@ -68,53 +66,31 @@ public class Test7194254 {
barrier.await(); // 1st
int matches = 0;
List<String> failed = new ArrayList<>();
try {
String pid = getPid();
String jstack = System.getProperty("java.home") + "/../bin/jstack";
Process process = new ProcessBuilder(jstack, pid)
.redirectErrorStream(true).start();
Pattern pattern = Pattern.compile(
"\\\"Priority=(\\d+)\\\".* prio=(\\d+).*");
try (BufferedReader reader = new BufferedReader(
new InputStreamReader(process.getInputStream()))) {
String line;
while((line = reader.readLine()) != null) {
Matcher matcher = pattern.matcher(line);
if (matcher.matches()) {
matches += 1;
String expected = matcher.group(1);
String actual = matcher.group(2);
if (!expected.equals(actual)) {
failed.add(line);
}
}
ArrayList<String> failed = new ArrayList<>();
ProcessBuilder pb = new ProcessBuilder(
JDKToolFinder.getJDKTool("jstack"),
String.valueOf(ProcessTools.getProcessId()));
String[] output = new OutputAnalyzer(pb.start()).getOutput().split("\\n+");
Pattern pattern = Pattern.compile(
"\\\"Priority=(\\d+)\\\".* prio=(\\d+).*");
for (String line : output) {
Matcher matcher = pattern.matcher(line);
if (matcher.matches()) {
matches += 1;
String expected = matcher.group(1);
String actual = matcher.group(2);
if (!expected.equals(actual)) {
failed.add(line);
}
}
barrier.await(); // 2nd
} finally {
barrier.reset();
}
barrier.await(); // 2nd
barrier.reset();
if (matches != NUMBER_OF_JAVA_PRIORITIES) {
throw new AssertionError("matches: expected " +
NUMBER_OF_JAVA_PRIORITIES + ", but was " + matches);
}
if (!failed.isEmpty()) {
throw new AssertionError(failed.size() + ":" + failed);
}
System.out.println("Test passes.");
assertEquals(matches, NUMBER_OF_JAVA_PRIORITIES);
assertTrue(failed.isEmpty(), failed.size() + ":" + failed);
}
static String getPid() {
RuntimeMXBean runtimebean = ManagementFactory.getRuntimeMXBean();
String vmname = runtimebean.getName();
int i = vmname.indexOf('@');
if (i != -1) {
vmname = vmname.substring(0, i);
}
return vmname;
}
}

View File

@ -0,0 +1,67 @@
/*
* Copyright (c) 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
* 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 8058897
* @library /testlibrary
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:MallocMaxTestWords=100m Reallocate
*/
import com.oracle.java.testlibrary.*;
import sun.misc.Unsafe;
import static com.oracle.java.testlibrary.Asserts.*;
public class Reallocate {
public static void main(String args[]) throws Exception {
Unsafe unsafe = Utils.getUnsafe();
long address = unsafe.allocateMemory(1);
assertNotEquals(address, 0L);
// Make sure we reallocate correctly
unsafe.putByte(address, Byte.MAX_VALUE);
address = unsafe.reallocateMemory(address, 2);
assertNotEquals(address, 0L);
assertEquals(unsafe.getByte(address), Byte.MAX_VALUE);
// Reallocating with a 0 size should return a null pointer
address = unsafe.reallocateMemory(address, 0);
assertEquals(address, 0L);
// Reallocating with a null pointer should result in a normal allocation
address = unsafe.reallocateMemory(0L, 1);
assertNotEquals(address, 0L);
unsafe.putByte(address, Byte.MAX_VALUE);
assertEquals(unsafe.getByte(address), Byte.MAX_VALUE);
// Make sure we can throw an OOME when we fail to reallocate due to OOM
try {
unsafe.reallocateMemory(address, 100 * 1024 * 1024 * 8);
} catch (OutOfMemoryError e) {
// Expected
return;
}
throw new RuntimeException("Did not get expected OOM");
}
}

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