Merge

Wed, 16 Apr 2014 18:40:25 -0400

author
coleenp
date
Wed, 16 Apr 2014 18:40:25 -0400
changeset 6629
7e6c20c85ccf
parent 6628
bd58c9e40d0a
parent 6625
0af0caeb6a3a
child 6630
cd3c534f8f4a

Merge

src/share/vm/classfile/classFileParser.cpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/cpu/sparc/vm/assembler_sparc.hpp	Mon Mar 03 13:58:52 2014 -0500
     1.2 +++ b/src/cpu/sparc/vm/assembler_sparc.hpp	Wed Apr 16 18:40:25 2014 -0400
     1.3 @@ -630,11 +630,20 @@
     1.4    }
     1.5  
     1.6   protected:
     1.7 +  // Insert a nop if the previous is cbcond
     1.8 +  void insert_nop_after_cbcond() {
     1.9 +    if (UseCBCond && cbcond_before()) {
    1.10 +      nop();
    1.11 +    }
    1.12 +  }
    1.13    // Delay slot helpers
    1.14    // cti is called when emitting control-transfer instruction,
    1.15    // BEFORE doing the emitting.
    1.16    // Only effective when assertion-checking is enabled.
    1.17    void cti() {
    1.18 +    // A cbcond instruction immediately followed by a CTI
    1.19 +    // instruction introduces pipeline stalls, we need to avoid that.
    1.20 +    no_cbcond_before();
    1.21  #ifdef CHECK_DELAY
    1.22      assert_not_delayed("cti should not be in delay slot");
    1.23  #endif
    1.24 @@ -658,7 +667,6 @@
    1.25    void no_cbcond_before() {
    1.26      assert(offset() == 0 || !cbcond_before(), "cbcond should not follow an other cbcond");
    1.27    }
    1.28 -
    1.29  public:
    1.30  
    1.31    bool use_cbcond(Label& L) {
     2.1 --- a/src/cpu/sparc/vm/assembler_sparc.inline.hpp	Mon Mar 03 13:58:52 2014 -0500
     2.2 +++ b/src/cpu/sparc/vm/assembler_sparc.inline.hpp	Wed Apr 16 18:40:25 2014 -0400
     2.3 @@ -54,33 +54,33 @@
     2.4  inline void Assembler::add(Register s1, Register s2, Register d ) { emit_int32( op(arith_op) | rd(d) | op3(add_op3) | rs1(s1) | rs2(s2) ); }
     2.5  inline void Assembler::add(Register s1, int simm13a, Register d ) { emit_int32( op(arith_op) | rd(d) | op3(add_op3) | rs1(s1) | immed(true) | simm(simm13a, 13) ); }
     2.6  
     2.7 -inline void Assembler::bpr( RCondition c, bool a, Predict p, Register s1, address d, relocInfo::relocType rt ) { v9_only();  cti();  emit_data( op(branch_op) | annul(a) | cond(c) | op2(bpr_op2) | wdisp16(intptr_t(d), intptr_t(pc())) | predict(p) | rs1(s1), rt);  has_delay_slot(); }
     2.8 -inline void Assembler::bpr( RCondition c, bool a, Predict p, Register s1, Label& L) { bpr( c, a, p, s1, target(L)); }
     2.9 +inline void Assembler::bpr( RCondition c, bool a, Predict p, Register s1, address d, relocInfo::relocType rt ) { v9_only(); insert_nop_after_cbcond(); cti();  emit_data( op(branch_op) | annul(a) | cond(c) | op2(bpr_op2) | wdisp16(intptr_t(d), intptr_t(pc())) | predict(p) | rs1(s1), rt);  has_delay_slot(); }
    2.10 +inline void Assembler::bpr( RCondition c, bool a, Predict p, Register s1, Label& L) { insert_nop_after_cbcond(); bpr( c, a, p, s1, target(L)); }
    2.11  
    2.12 -inline void Assembler::fb( Condition c, bool a, address d, relocInfo::relocType rt ) { v9_dep();  cti();  emit_data( op(branch_op) | annul(a) | cond(c) | op2(fb_op2) | wdisp(intptr_t(d), intptr_t(pc()), 22), rt);  has_delay_slot(); }
    2.13 -inline void Assembler::fb( Condition c, bool a, Label& L ) { fb(c, a, target(L)); }
    2.14 +inline void Assembler::fb( Condition c, bool a, address d, relocInfo::relocType rt ) { v9_dep();  insert_nop_after_cbcond(); cti();  emit_data( op(branch_op) | annul(a) | cond(c) | op2(fb_op2) | wdisp(intptr_t(d), intptr_t(pc()), 22), rt);  has_delay_slot(); }
    2.15 +inline void Assembler::fb( Condition c, bool a, Label& L ) { insert_nop_after_cbcond(); fb(c, a, target(L)); }
    2.16  
    2.17 -inline void Assembler::fbp( Condition c, bool a, CC cc, Predict p, address d, relocInfo::relocType rt ) { v9_only();  cti();  emit_data( op(branch_op) | annul(a) | cond(c) | op2(fbp_op2) | branchcc(cc) | predict(p) | wdisp(intptr_t(d), intptr_t(pc()), 19), rt);  has_delay_slot(); }
    2.18 -inline void Assembler::fbp( Condition c, bool a, CC cc, Predict p, Label& L ) { fbp(c, a, cc, p, target(L)); }
    2.19 +inline void Assembler::fbp( Condition c, bool a, CC cc, Predict p, address d, relocInfo::relocType rt ) { v9_only(); insert_nop_after_cbcond(); cti();  emit_data( op(branch_op) | annul(a) | cond(c) | op2(fbp_op2) | branchcc(cc) | predict(p) | wdisp(intptr_t(d), intptr_t(pc()), 19), rt);  has_delay_slot(); }
    2.20 +inline void Assembler::fbp( Condition c, bool a, CC cc, Predict p, Label& L ) { insert_nop_after_cbcond(); fbp(c, a, cc, p, target(L)); }
    2.21  
    2.22 -inline void Assembler::br( Condition c, bool a, address d, relocInfo::relocType rt ) { v9_dep();  cti();   emit_data( op(branch_op) | annul(a) | cond(c) | op2(br_op2) | wdisp(intptr_t(d), intptr_t(pc()), 22), rt);  has_delay_slot(); }
    2.23 -inline void Assembler::br( Condition c, bool a, Label& L ) { br(c, a, target(L)); }
    2.24 +inline void Assembler::br( Condition c, bool a, address d, relocInfo::relocType rt ) { v9_dep(); insert_nop_after_cbcond(); cti();   emit_data( op(branch_op) | annul(a) | cond(c) | op2(br_op2) | wdisp(intptr_t(d), intptr_t(pc()), 22), rt);  has_delay_slot(); }
    2.25 +inline void Assembler::br( Condition c, bool a, Label& L ) { insert_nop_after_cbcond(); br(c, a, target(L)); }
    2.26  
    2.27 -inline void Assembler::bp( Condition c, bool a, CC cc, Predict p, address d, relocInfo::relocType rt ) { v9_only();  cti();  emit_data( op(branch_op) | annul(a) | cond(c) | op2(bp_op2) | branchcc(cc) | predict(p) | wdisp(intptr_t(d), intptr_t(pc()), 19), rt);  has_delay_slot(); }
    2.28 -inline void Assembler::bp( Condition c, bool a, CC cc, Predict p, Label& L ) { bp(c, a, cc, p, target(L)); }
    2.29 +inline void Assembler::bp( Condition c, bool a, CC cc, Predict p, address d, relocInfo::relocType rt ) { v9_only();  insert_nop_after_cbcond(); cti();  emit_data( op(branch_op) | annul(a) | cond(c) | op2(bp_op2) | branchcc(cc) | predict(p) | wdisp(intptr_t(d), intptr_t(pc()), 19), rt);  has_delay_slot(); }
    2.30 +inline void Assembler::bp( Condition c, bool a, CC cc, Predict p, Label& L ) { insert_nop_after_cbcond(); bp(c, a, cc, p, target(L)); }
    2.31  
    2.32  // compare and branch
    2.33  inline void Assembler::cbcond(Condition c, CC cc, Register s1, Register s2, Label& L) { cti();  no_cbcond_before();  emit_data(op(branch_op) | cond_cbcond(c) | op2(bpr_op2) | branchcc(cc) | wdisp10(intptr_t(target(L)), intptr_t(pc())) | rs1(s1) | rs2(s2)); }
    2.34  inline void Assembler::cbcond(Condition c, CC cc, Register s1, int simm5, Label& L)   { cti();  no_cbcond_before();  emit_data(op(branch_op) | cond_cbcond(c) | op2(bpr_op2) | branchcc(cc) | wdisp10(intptr_t(target(L)), intptr_t(pc())) | rs1(s1) | immed(true) | simm(simm5, 5)); }
    2.35  
    2.36 -inline void Assembler::call( address d,  relocInfo::relocType rt ) { cti();  emit_data( op(call_op) | wdisp(intptr_t(d), intptr_t(pc()), 30), rt);  has_delay_slot(); assert(rt != relocInfo::virtual_call_type, "must use virtual_call_Relocation::spec"); }
    2.37 -inline void Assembler::call( Label& L,   relocInfo::relocType rt ) { call( target(L), rt); }
    2.38 +inline void Assembler::call( address d,  relocInfo::relocType rt ) { insert_nop_after_cbcond(); cti();  emit_data( op(call_op) | wdisp(intptr_t(d), intptr_t(pc()), 30), rt);  has_delay_slot(); assert(rt != relocInfo::virtual_call_type, "must use virtual_call_Relocation::spec"); }
    2.39 +inline void Assembler::call( Label& L,   relocInfo::relocType rt ) { insert_nop_after_cbcond(); call( target(L), rt); }
    2.40  
    2.41  inline void Assembler::flush( Register s1, Register s2) { emit_int32( op(arith_op) | op3(flush_op3) | rs1(s1) | rs2(s2)); }
    2.42  inline void Assembler::flush( Register s1, int simm13a) { emit_data( op(arith_op) | op3(flush_op3) | rs1(s1) | immed(true) | simm(simm13a, 13)); }
    2.43  
    2.44 -inline void Assembler::jmpl( Register s1, Register s2, Register d ) { cti();  emit_int32( op(arith_op) | rd(d) | op3(jmpl_op3) | rs1(s1) | rs2(s2));  has_delay_slot(); }
    2.45 -inline void Assembler::jmpl( Register s1, int simm13a, Register d, RelocationHolder const& rspec ) { cti();  emit_data( op(arith_op) | rd(d) | op3(jmpl_op3) | rs1(s1) | immed(true) | simm(simm13a, 13), rspec);  has_delay_slot(); }
    2.46 +inline void Assembler::jmpl( Register s1, Register s2, Register d ) { insert_nop_after_cbcond(); cti();  emit_int32( op(arith_op) | rd(d) | op3(jmpl_op3) | rs1(s1) | rs2(s2));  has_delay_slot(); }
    2.47 +inline void Assembler::jmpl( Register s1, int simm13a, Register d, RelocationHolder const& rspec ) { insert_nop_after_cbcond(); cti();  emit_data( op(arith_op) | rd(d) | op3(jmpl_op3) | rs1(s1) | immed(true) | simm(simm13a, 13), rspec);  has_delay_slot(); }
    2.48  
    2.49  inline void Assembler::ldf(FloatRegisterImpl::Width w, Register s1, Register s2, FloatRegister d) { emit_int32( op(ldst_op) | fd(d, w) | alt_op3(ldf_op3, w) | rs1(s1) | rs2(s2) ); }
    2.50  inline void Assembler::ldf(FloatRegisterImpl::Width w, Register s1, int simm13a, FloatRegister d, RelocationHolder const& rspec) { emit_data( op(ldst_op) | fd(d, w) | alt_op3(ldf_op3, w) | rs1(s1) | immed(true) | simm(simm13a, 13), rspec); }
     3.1 --- a/src/cpu/sparc/vm/macroAssembler_sparc.inline.hpp	Mon Mar 03 13:58:52 2014 -0500
     3.2 +++ b/src/cpu/sparc/vm/macroAssembler_sparc.inline.hpp	Wed Apr 16 18:40:25 2014 -0400
     3.3 @@ -233,6 +233,7 @@
     3.4  }
     3.5  
     3.6  inline void MacroAssembler::br( Condition c, bool a, Predict p, Label& L ) {
     3.7 +  insert_nop_after_cbcond();
     3.8    br(c, a, p, target(L));
     3.9  }
    3.10  
    3.11 @@ -248,6 +249,7 @@
    3.12  }
    3.13  
    3.14  inline void MacroAssembler::brx( Condition c, bool a, Predict p, Label& L ) {
    3.15 +  insert_nop_after_cbcond();
    3.16    brx(c, a, p, target(L));
    3.17  }
    3.18  
    3.19 @@ -269,6 +271,7 @@
    3.20  }
    3.21  
    3.22  inline void MacroAssembler::fb( Condition c, bool a, Predict p, Label& L ) {
    3.23 +  insert_nop_after_cbcond();
    3.24    fb(c, a, p, target(L));
    3.25  }
    3.26  
    3.27 @@ -318,6 +321,7 @@
    3.28  }
    3.29  
    3.30  inline void MacroAssembler::call( Label& L,   relocInfo::relocType rt ) {
    3.31 +  insert_nop_after_cbcond();
    3.32    MacroAssembler::call( target(L), rt);
    3.33  }
    3.34  
     4.1 --- a/src/cpu/sparc/vm/sparc.ad	Mon Mar 03 13:58:52 2014 -0500
     4.2 +++ b/src/cpu/sparc/vm/sparc.ad	Wed Apr 16 18:40:25 2014 -0400
     4.3 @@ -1268,7 +1268,7 @@
     4.4  void MachEpilogNode::format( PhaseRegAlloc *ra_, outputStream *st ) const {
     4.5    Compile* C = ra_->C;
     4.6  
     4.7 -  if( do_polling() && ra_->C->is_method_compilation() ) {
     4.8 +  if(do_polling() && ra_->C->is_method_compilation()) {
     4.9      st->print("SETHI  #PollAddr,L0\t! Load Polling address\n\t");
    4.10  #ifdef _LP64
    4.11      st->print("LDX    [L0],G0\t!Poll for Safepointing\n\t");
    4.12 @@ -1277,8 +1277,12 @@
    4.13  #endif
    4.14    }
    4.15  
    4.16 -  if( do_polling() )
    4.17 +  if(do_polling()) {
    4.18 +    if (UseCBCond && !ra_->C->is_method_compilation()) {
    4.19 +      st->print("NOP\n\t");
    4.20 +    }
    4.21      st->print("RET\n\t");
    4.22 +  }
    4.23  
    4.24    st->print("RESTORE");
    4.25  }
    4.26 @@ -1291,15 +1295,20 @@
    4.27    __ verify_thread();
    4.28  
    4.29    // If this does safepoint polling, then do it here
    4.30 -  if( do_polling() && ra_->C->is_method_compilation() ) {
    4.31 +  if(do_polling() && ra_->C->is_method_compilation()) {
    4.32      AddressLiteral polling_page(os::get_polling_page());
    4.33      __ sethi(polling_page, L0);
    4.34      __ relocate(relocInfo::poll_return_type);
    4.35 -    __ ld_ptr( L0, 0, G0 );
    4.36 +    __ ld_ptr(L0, 0, G0);
    4.37    }
    4.38  
    4.39    // If this is a return, then stuff the restore in the delay slot
    4.40 -  if( do_polling() ) {
    4.41 +  if(do_polling()) {
    4.42 +    if (UseCBCond && !ra_->C->is_method_compilation()) {
    4.43 +      // Insert extra padding for the case when the epilogue is preceded by
    4.44 +      // a cbcond jump, which can't be followed by a CTI instruction
    4.45 +      __ nop();
    4.46 +    }
    4.47      __ ret();
    4.48      __ delayed()->restore();
    4.49    } else {
    4.50 @@ -3330,7 +3339,18 @@
    4.51  //----------Instruction Attributes---------------------------------------------
    4.52  ins_attrib ins_cost(DEFAULT_COST); // Required cost attribute
    4.53  ins_attrib ins_size(32);           // Required size attribute (in bits)
    4.54 -ins_attrib ins_avoid_back_to_back(0); // instruction should not be generated back to back
    4.55 +
    4.56 +// avoid_back_to_back attribute is an expression that must return
    4.57 +// one of the following values defined in MachNode:
    4.58 +// AVOID_NONE   - instruction can be placed anywhere
    4.59 +// AVOID_BEFORE - instruction cannot be placed after an
    4.60 +//                instruction with MachNode::AVOID_AFTER
    4.61 +// AVOID_AFTER  - the next instruction cannot be the one 
    4.62 +//                with MachNode::AVOID_BEFORE
    4.63 +// AVOID_BEFORE_AND_AFTER - BEFORE and AFTER attributes at 
    4.64 +//                          the same time                                
    4.65 +ins_attrib ins_avoid_back_to_back(MachNode::AVOID_NONE);
    4.66 +
    4.67  ins_attrib ins_short_branch(0);    // Required flag: is this instruction a
    4.68                                     // non-matching short branch variant of some
    4.69                                                              // long branch?
    4.70 @@ -6630,6 +6650,7 @@
    4.71    ins_encode %{
    4.72      __ encode_heap_oop($src$$Register, $dst$$Register);
    4.73    %}
    4.74 +  ins_avoid_back_to_back(Universe::narrow_oop_base() == NULL ? AVOID_NONE : AVOID_BEFORE);
    4.75    ins_pipe(ialu_reg);
    4.76  %}
    4.77  
    4.78 @@ -9199,6 +9220,7 @@
    4.79      __ ba(*L);
    4.80      __ delayed()->nop();
    4.81    %}
    4.82 +  ins_avoid_back_to_back(AVOID_BEFORE);
    4.83    ins_pipe(br);
    4.84  %}
    4.85  
    4.86 @@ -9217,7 +9239,7 @@
    4.87      __ ba_short(*L);
    4.88    %}
    4.89    ins_short_branch(1);
    4.90 -  ins_avoid_back_to_back(1);
    4.91 +  ins_avoid_back_to_back(AVOID_BEFORE_AND_AFTER);
    4.92    ins_pipe(cbcond_reg_imm);
    4.93  %}
    4.94  
    4.95 @@ -9231,6 +9253,7 @@
    4.96    format %{ "BP$cmp   $icc,$labl" %}
    4.97    // Prim = bits 24-22, Secnd = bits 31-30
    4.98    ins_encode( enc_bp( labl, cmp, icc ) );
    4.99 +  ins_avoid_back_to_back(AVOID_BEFORE);
   4.100    ins_pipe(br_cc);
   4.101  %}
   4.102  
   4.103 @@ -9242,6 +9265,7 @@
   4.104    format %{ "BP$cmp  $icc,$labl" %}
   4.105    // Prim = bits 24-22, Secnd = bits 31-30
   4.106    ins_encode( enc_bp( labl, cmp, icc ) );
   4.107 +  ins_avoid_back_to_back(AVOID_BEFORE);
   4.108    ins_pipe(br_cc);
   4.109  %}
   4.110  
   4.111 @@ -9260,6 +9284,7 @@
   4.112      __ bp( (Assembler::Condition)($cmp$$cmpcode), false, Assembler::ptr_cc, predict_taken, *L);
   4.113      __ delayed()->nop();
   4.114    %}
   4.115 +  ins_avoid_back_to_back(AVOID_BEFORE);
   4.116    ins_pipe(br_cc);
   4.117  %}
   4.118  
   4.119 @@ -9278,6 +9303,7 @@
   4.120      __ fbp( (Assembler::Condition)($cmp$$cmpcode), false, (Assembler::CC)($fcc$$reg), predict_taken, *L);
   4.121      __ delayed()->nop();
   4.122    %}
   4.123 +  ins_avoid_back_to_back(AVOID_BEFORE);
   4.124    ins_pipe(br_fcc);
   4.125  %}
   4.126  
   4.127 @@ -9290,6 +9316,7 @@
   4.128    format %{ "BP$cmp   $icc,$labl\t! Loop end" %}
   4.129    // Prim = bits 24-22, Secnd = bits 31-30
   4.130    ins_encode( enc_bp( labl, cmp, icc ) );
   4.131 +  ins_avoid_back_to_back(AVOID_BEFORE);
   4.132    ins_pipe(br_cc);
   4.133  %}
   4.134  
   4.135 @@ -9302,6 +9329,7 @@
   4.136    format %{ "BP$cmp  $icc,$labl\t! Loop end" %}
   4.137    // Prim = bits 24-22, Secnd = bits 31-30
   4.138    ins_encode( enc_bp( labl, cmp, icc ) );
   4.139 +  ins_avoid_back_to_back(AVOID_BEFORE);
   4.140    ins_pipe(br_cc);
   4.141  %}
   4.142  
   4.143 @@ -9552,7 +9580,7 @@
   4.144      __ cbcond((Assembler::Condition)($cmp$$cmpcode), Assembler::icc, $op1$$Register, $op2$$Register, *L);
   4.145    %}
   4.146    ins_short_branch(1);
   4.147 -  ins_avoid_back_to_back(1);
   4.148 +  ins_avoid_back_to_back(AVOID_BEFORE_AND_AFTER);
   4.149    ins_pipe(cbcond_reg_reg);
   4.150  %}
   4.151  
   4.152 @@ -9570,7 +9598,7 @@
   4.153      __ cbcond((Assembler::Condition)($cmp$$cmpcode), Assembler::icc, $op1$$Register, $op2$$constant, *L);
   4.154    %}
   4.155    ins_short_branch(1);
   4.156 -  ins_avoid_back_to_back(1);
   4.157 +  ins_avoid_back_to_back(AVOID_BEFORE_AND_AFTER);
   4.158    ins_pipe(cbcond_reg_imm);
   4.159  %}
   4.160  
   4.161 @@ -9588,7 +9616,7 @@
   4.162      __ cbcond((Assembler::Condition)($cmp$$cmpcode), Assembler::icc, $op1$$Register, $op2$$Register, *L);
   4.163    %}
   4.164    ins_short_branch(1);
   4.165 -  ins_avoid_back_to_back(1);
   4.166 +  ins_avoid_back_to_back(AVOID_BEFORE_AND_AFTER);
   4.167    ins_pipe(cbcond_reg_reg);
   4.168  %}
   4.169  
   4.170 @@ -9606,7 +9634,7 @@
   4.171      __ cbcond((Assembler::Condition)($cmp$$cmpcode), Assembler::icc, $op1$$Register, $op2$$constant, *L);
   4.172    %}
   4.173    ins_short_branch(1);
   4.174 -  ins_avoid_back_to_back(1);
   4.175 +  ins_avoid_back_to_back(AVOID_BEFORE_AND_AFTER);
   4.176    ins_pipe(cbcond_reg_imm);
   4.177  %}
   4.178  
   4.179 @@ -9624,7 +9652,7 @@
   4.180      __ cbcond((Assembler::Condition)($cmp$$cmpcode), Assembler::xcc, $op1$$Register, $op2$$Register, *L);
   4.181    %}
   4.182    ins_short_branch(1);
   4.183 -  ins_avoid_back_to_back(1);
   4.184 +  ins_avoid_back_to_back(AVOID_BEFORE_AND_AFTER);
   4.185    ins_pipe(cbcond_reg_reg);
   4.186  %}
   4.187  
   4.188 @@ -9642,7 +9670,7 @@
   4.189      __ cbcond((Assembler::Condition)($cmp$$cmpcode), Assembler::xcc, $op1$$Register, $op2$$constant, *L);
   4.190    %}
   4.191    ins_short_branch(1);
   4.192 -  ins_avoid_back_to_back(1);
   4.193 +  ins_avoid_back_to_back(AVOID_BEFORE_AND_AFTER);
   4.194    ins_pipe(cbcond_reg_imm);
   4.195  %}
   4.196  
   4.197 @@ -9665,7 +9693,7 @@
   4.198      __ cbcond((Assembler::Condition)($cmp$$cmpcode), Assembler::ptr_cc, $op1$$Register, $op2$$Register, *L);
   4.199    %}
   4.200    ins_short_branch(1);
   4.201 -  ins_avoid_back_to_back(1);
   4.202 +  ins_avoid_back_to_back(AVOID_BEFORE_AND_AFTER);
   4.203    ins_pipe(cbcond_reg_reg);
   4.204  %}
   4.205  
   4.206 @@ -9687,7 +9715,7 @@
   4.207      __ cbcond((Assembler::Condition)($cmp$$cmpcode), Assembler::ptr_cc, $op1$$Register, G0, *L);
   4.208    %}
   4.209    ins_short_branch(1);
   4.210 -  ins_avoid_back_to_back(1);
   4.211 +  ins_avoid_back_to_back(AVOID_BEFORE_AND_AFTER);
   4.212    ins_pipe(cbcond_reg_reg);
   4.213  %}
   4.214  
   4.215 @@ -9705,7 +9733,7 @@
   4.216      __ cbcond((Assembler::Condition)($cmp$$cmpcode), Assembler::icc, $op1$$Register, $op2$$Register, *L);
   4.217    %}
   4.218    ins_short_branch(1);
   4.219 -  ins_avoid_back_to_back(1);
   4.220 +  ins_avoid_back_to_back(AVOID_BEFORE_AND_AFTER);
   4.221    ins_pipe(cbcond_reg_reg);
   4.222  %}
   4.223  
   4.224 @@ -9723,7 +9751,7 @@
   4.225      __ cbcond((Assembler::Condition)($cmp$$cmpcode), Assembler::icc, $op1$$Register, G0, *L);
   4.226    %}
   4.227    ins_short_branch(1);
   4.228 -  ins_avoid_back_to_back(1);
   4.229 +  ins_avoid_back_to_back(AVOID_BEFORE_AND_AFTER);
   4.230    ins_pipe(cbcond_reg_reg);
   4.231  %}
   4.232  
   4.233 @@ -9742,7 +9770,7 @@
   4.234      __ cbcond((Assembler::Condition)($cmp$$cmpcode), Assembler::icc, $op1$$Register, $op2$$Register, *L);
   4.235    %}
   4.236    ins_short_branch(1);
   4.237 -  ins_avoid_back_to_back(1);
   4.238 +  ins_avoid_back_to_back(AVOID_BEFORE_AND_AFTER);
   4.239    ins_pipe(cbcond_reg_reg);
   4.240  %}
   4.241  
   4.242 @@ -9760,7 +9788,7 @@
   4.243      __ cbcond((Assembler::Condition)($cmp$$cmpcode), Assembler::icc, $op1$$Register, $op2$$constant, *L);
   4.244    %}
   4.245    ins_short_branch(1);
   4.246 -  ins_avoid_back_to_back(1);
   4.247 +  ins_avoid_back_to_back(AVOID_BEFORE_AND_AFTER);
   4.248    ins_pipe(cbcond_reg_imm);
   4.249  %}
   4.250  
   4.251 @@ -9777,6 +9805,7 @@
   4.252    ins_cost(BRANCH_COST);
   4.253    format %{ "BR$cmp   $op1,$labl" %}
   4.254    ins_encode( enc_bpr( labl, cmp, op1 ) );
   4.255 +  ins_avoid_back_to_back(AVOID_BEFORE);
   4.256    ins_pipe(br_reg);
   4.257  %}
   4.258  
   4.259 @@ -9789,6 +9818,7 @@
   4.260    ins_cost(BRANCH_COST);
   4.261    format %{ "BR$cmp   $op1,$labl" %}
   4.262    ins_encode( enc_bpr( labl, cmp, op1 ) );
   4.263 +  ins_avoid_back_to_back(AVOID_BEFORE);
   4.264    ins_pipe(br_reg);
   4.265  %}
   4.266  
   4.267 @@ -9801,6 +9831,7 @@
   4.268    ins_cost(BRANCH_COST);
   4.269    format %{ "BR$cmp   $op1,$labl" %}
   4.270    ins_encode( enc_bpr( labl, cmp, op1 ) );
   4.271 +  ins_avoid_back_to_back(AVOID_BEFORE);
   4.272    ins_pipe(br_reg);
   4.273  %}
   4.274  
   4.275 @@ -9841,6 +9872,7 @@
   4.276      __ bp( (Assembler::Condition)($cmp$$cmpcode), false, Assembler::xcc, predict_taken, *L);
   4.277      __ delayed()->nop();
   4.278    %}
   4.279 +  ins_avoid_back_to_back(AVOID_BEFORE);
   4.280    ins_pipe(br_cc);
   4.281  %}
   4.282  
   4.283 @@ -9968,6 +10000,7 @@
   4.284    ins_cost(CALL_COST);
   4.285    format %{ "CALL,static  ; NOP ==> " %}
   4.286    ins_encode( Java_Static_Call( meth ), call_epilog );
   4.287 +  ins_avoid_back_to_back(AVOID_BEFORE);
   4.288    ins_pipe(simple_call);
   4.289  %}
   4.290  
   4.291 @@ -10004,6 +10037,7 @@
   4.292    format %{ "CALL,runtime" %}
   4.293    ins_encode( Java_To_Runtime( meth ),
   4.294                call_epilog, adjust_long_from_native_call );
   4.295 +  ins_avoid_back_to_back(AVOID_BEFORE);
   4.296    ins_pipe(simple_call);
   4.297  %}
   4.298  
   4.299 @@ -10016,6 +10050,7 @@
   4.300    ins_encode( Java_To_Runtime( meth ),
   4.301                call_epilog,
   4.302                adjust_long_from_native_call );
   4.303 +  ins_avoid_back_to_back(AVOID_BEFORE);
   4.304    ins_pipe(simple_call);
   4.305  %}
   4.306  
   4.307 @@ -10028,6 +10063,7 @@
   4.308    ins_encode( Java_To_Runtime( meth ),
   4.309                call_epilog,
   4.310                adjust_long_from_native_call );
   4.311 +  ins_avoid_back_to_back(AVOID_BEFORE);
   4.312    ins_pipe(simple_call);
   4.313  %}
   4.314  
   4.315 @@ -10041,6 +10077,7 @@
   4.316    ins_cost(CALL_COST);
   4.317    format %{ "Jmp     $jump_target  ; NOP \t! $method_oop holds method oop" %}
   4.318    ins_encode(form_jmpl(jump_target));
   4.319 +  ins_avoid_back_to_back(AVOID_BEFORE);
   4.320    ins_pipe(tail_call);
   4.321  %}
   4.322  
   4.323 @@ -10072,6 +10109,7 @@
   4.324    // opcode(Assembler::jmpl_op3, Assembler::arith_op);
   4.325    // The hack duplicates the exception oop into G3, so that CreateEx can use it there.
   4.326    // ins_encode( form3_rs1_simm13_rd( jump_target, 0x00, R_G0 ), move_return_pc_to_o1() );
   4.327 +  ins_avoid_back_to_back(AVOID_BEFORE);
   4.328    ins_pipe(tail_call);
   4.329  %}
   4.330  
   4.331 @@ -10102,6 +10140,7 @@
   4.332    // use the following format syntax
   4.333    format %{ "Jmp    rethrow_stub" %}
   4.334    ins_encode(enc_rethrow);
   4.335 +  ins_avoid_back_to_back(AVOID_BEFORE);
   4.336    ins_pipe(tail_call);
   4.337  %}
   4.338  
   4.339 @@ -10130,6 +10169,7 @@
   4.340    ins_cost(DEFAULT_COST*10);
   4.341    format %{ "CALL   PartialSubtypeCheck\n\tNOP" %}
   4.342    ins_encode( enc_PartialSubtypeCheck() );
   4.343 +  ins_avoid_back_to_back(AVOID_BEFORE);
   4.344    ins_pipe(partial_subtype_check_pipe);
   4.345  %}
   4.346  
   4.347 @@ -10139,6 +10179,7 @@
   4.348    ins_cost(DEFAULT_COST*10);
   4.349    format %{ "CALL   PartialSubtypeCheck\n\tNOP\t# (sets condition codes)" %}
   4.350    ins_encode( enc_PartialSubtypeCheck() );
   4.351 +  ins_avoid_back_to_back(AVOID_BEFORE);
   4.352    ins_pipe(partial_subtype_check_pipe);
   4.353  %}
   4.354  
     5.1 --- a/src/share/vm/adlc/output_h.cpp	Mon Mar 03 13:58:52 2014 -0500
     5.2 +++ b/src/share/vm/adlc/output_h.cpp	Wed Apr 16 18:40:25 2014 -0400
     5.3 @@ -1613,21 +1613,20 @@
     5.4      // Each instruction attribute results in a virtual call of same name.
     5.5      // The ins_cost is not handled here.
     5.6      Attribute *attr = instr->_attribs;
     5.7 -    bool avoid_back_to_back = false;
     5.8 +    Attribute *avoid_back_to_back_attr = NULL;
     5.9      while (attr != NULL) {
    5.10 -      if (strcmp (attr->_ident, "ins_cost") != 0 &&
    5.11 +      if (strcmp (attr->_ident, "ins_is_TrapBasedCheckNode") == 0) {
    5.12 +        fprintf(fp, "  virtual bool           is_TrapBasedCheckNode() const { return %s; }\n", attr->_val);
    5.13 +      } else if (strcmp (attr->_ident, "ins_cost") != 0 &&
    5.14            strncmp(attr->_ident, "ins_field_", 10) != 0 &&
    5.15            // Must match function in node.hpp: return type bool, no prefix "ins_".
    5.16            strcmp (attr->_ident, "ins_is_TrapBasedCheckNode") != 0 &&
    5.17            strcmp (attr->_ident, "ins_short_branch") != 0) {
    5.18          fprintf(fp, "  virtual int            %s() const { return %s; }\n", attr->_ident, attr->_val);
    5.19        }
    5.20 -      // Check value for ins_avoid_back_to_back, and if it is true (1), set the flag
    5.21 -      if (!strcmp(attr->_ident, "ins_avoid_back_to_back") != 0 && attr->int_val(*this) != 0)
    5.22 -        avoid_back_to_back = true;
    5.23 -      if (strcmp (attr->_ident, "ins_is_TrapBasedCheckNode") == 0)
    5.24 -        fprintf(fp, "  virtual bool           is_TrapBasedCheckNode() const { return %s; }\n", attr->_val);
    5.25 -
    5.26 +      if (strcmp(attr->_ident, "ins_avoid_back_to_back") == 0) {
    5.27 +        avoid_back_to_back_attr = attr;
    5.28 +      }
    5.29        attr = (Attribute *)attr->_next;
    5.30      }
    5.31  
    5.32 @@ -1799,11 +1798,11 @@
    5.33      }
    5.34  
    5.35      // flag: if this instruction should not be generated back to back.
    5.36 -    if ( avoid_back_to_back ) {
    5.37 -      if ( node_flags_set ) {
    5.38 -        fprintf(fp," | Flag_avoid_back_to_back");
    5.39 +    if (avoid_back_to_back_attr != NULL) {
    5.40 +      if (node_flags_set) {
    5.41 +        fprintf(fp," | (%s)", avoid_back_to_back_attr->_val);
    5.42        } else {
    5.43 -        fprintf(fp,"init_flags(Flag_avoid_back_to_back");
    5.44 +        fprintf(fp,"init_flags((%s)", avoid_back_to_back_attr->_val);
    5.45          node_flags_set = true;
    5.46        }
    5.47      }
     6.1 --- a/src/share/vm/classfile/classFileParser.cpp	Mon Mar 03 13:58:52 2014 -0500
     6.2 +++ b/src/share/vm/classfile/classFileParser.cpp	Wed Apr 16 18:40:25 2014 -0400
     6.3 @@ -3746,18 +3746,24 @@
     6.4        Exceptions::fthrow(
     6.5          THREAD_AND_LOCATION,
     6.6          vmSymbols::java_lang_UnsupportedClassVersionError(),
     6.7 -        "Unsupported major.minor version %u.%u",
     6.8 +        "Unsupported class file version %u.%u, "
     6.9 +        "this version of the Java Runtime only recognizes class file versions up to %u.%u",
    6.10          major_version,
    6.11 -        minor_version);
    6.12 +        minor_version,
    6.13 +        JAVA_MAX_SUPPORTED_VERSION,
    6.14 +        JAVA_MAX_SUPPORTED_MINOR_VERSION);
    6.15      } else {
    6.16        ResourceMark rm(THREAD);
    6.17        Exceptions::fthrow(
    6.18          THREAD_AND_LOCATION,
    6.19          vmSymbols::java_lang_UnsupportedClassVersionError(),
    6.20 -        "%s : Unsupported major.minor version %u.%u",
    6.21 +        "%s has been compiled by a more recent version of the Java Runtime (class file version %u.%u), "
    6.22 +        "this version of the Java Runtime only recognizes class file versions up to %u.%u",
    6.23          name->as_C_string(),
    6.24          major_version,
    6.25 -        minor_version);
    6.26 +        minor_version,
    6.27 +        JAVA_MAX_SUPPORTED_VERSION,
    6.28 +        JAVA_MAX_SUPPORTED_MINOR_VERSION);
    6.29      }
    6.30      return nullHandle;
    6.31    }
     7.1 --- a/src/share/vm/opto/machnode.hpp	Mon Mar 03 13:58:52 2014 -0500
     7.2 +++ b/src/share/vm/opto/machnode.hpp	Wed Apr 16 18:40:25 2014 -0400
     7.3 @@ -210,7 +210,14 @@
     7.4    bool may_be_short_branch() const { return (flags() & Flag_may_be_short_branch) != 0; }
     7.5  
     7.6    // Avoid back to back some instructions on some CPUs.
     7.7 -  bool avoid_back_to_back() const { return (flags() & Flag_avoid_back_to_back) != 0; }
     7.8 +  enum AvoidBackToBackFlag { AVOID_NONE = 0,
     7.9 +                             AVOID_BEFORE = Flag_avoid_back_to_back_before,
    7.10 +                             AVOID_AFTER = Flag_avoid_back_to_back_after,
    7.11 +                             AVOID_BEFORE_AND_AFTER = AVOID_BEFORE | AVOID_AFTER };
    7.12 +
    7.13 +  bool avoid_back_to_back(AvoidBackToBackFlag flag_value) const {
    7.14 +    return (flags() & flag_value) == flag_value;
    7.15 +  }
    7.16  
    7.17    // instruction implemented with a call
    7.18    bool has_call() const { return (flags() & Flag_has_call) != 0; }
     8.1 --- a/src/share/vm/opto/node.hpp	Mon Mar 03 13:58:52 2014 -0500
     8.2 +++ b/src/share/vm/opto/node.hpp	Wed Apr 16 18:40:25 2014 -0400
     8.3 @@ -645,17 +645,18 @@
     8.4  
     8.5    // Flags are sorted by usage frequency.
     8.6    enum NodeFlags {
     8.7 -    Flag_is_Copy             = 0x01, // should be first bit to avoid shift
     8.8 -    Flag_rematerialize       = Flag_is_Copy << 1,
     8.9 +    Flag_is_Copy                     = 0x01, // should be first bit to avoid shift
    8.10 +    Flag_rematerialize               = Flag_is_Copy << 1,
    8.11      Flag_needs_anti_dependence_check = Flag_rematerialize << 1,
    8.12 -    Flag_is_macro            = Flag_needs_anti_dependence_check << 1,
    8.13 -    Flag_is_Con              = Flag_is_macro << 1,
    8.14 -    Flag_is_cisc_alternate   = Flag_is_Con << 1,
    8.15 -    Flag_is_dead_loop_safe   = Flag_is_cisc_alternate << 1,
    8.16 -    Flag_may_be_short_branch = Flag_is_dead_loop_safe << 1,
    8.17 -    Flag_avoid_back_to_back  = Flag_may_be_short_branch << 1,
    8.18 -    Flag_has_call            = Flag_avoid_back_to_back << 1,
    8.19 -    Flag_is_expensive        = Flag_has_call << 1,
    8.20 +    Flag_is_macro                    = Flag_needs_anti_dependence_check << 1,
    8.21 +    Flag_is_Con                      = Flag_is_macro << 1,
    8.22 +    Flag_is_cisc_alternate           = Flag_is_Con << 1,
    8.23 +    Flag_is_dead_loop_safe           = Flag_is_cisc_alternate << 1,
    8.24 +    Flag_may_be_short_branch         = Flag_is_dead_loop_safe << 1,
    8.25 +    Flag_avoid_back_to_back_before   = Flag_may_be_short_branch << 1,
    8.26 +    Flag_avoid_back_to_back_after    = Flag_avoid_back_to_back_before << 1,
    8.27 +    Flag_has_call                    = Flag_avoid_back_to_back_after << 1,
    8.28 +    Flag_is_expensive                = Flag_has_call << 1,
    8.29      _max_flags = (Flag_is_expensive << 1) - 1 // allow flags combination
    8.30    };
    8.31  
     9.1 --- a/src/share/vm/opto/output.cpp	Mon Mar 03 13:58:52 2014 -0500
     9.2 +++ b/src/share/vm/opto/output.cpp	Wed Apr 16 18:40:25 2014 -0400
     9.3 @@ -411,7 +411,7 @@
     9.4              blk_size += nop_size;
     9.5            }
     9.6          }
     9.7 -        if (mach->avoid_back_to_back()) {
     9.8 +        if (mach->avoid_back_to_back(MachNode::AVOID_BEFORE)) {
     9.9            // Nop is inserted between "avoid back to back" instructions.
    9.10            // ScheduleAndBundle() can rearrange nodes in a block,
    9.11            // check for all offsets inside this block.
    9.12 @@ -439,7 +439,7 @@
    9.13          last_call_adr = blk_starts[i]+blk_size;
    9.14        }
    9.15        // Remember end of avoid_back_to_back offset
    9.16 -      if (nj->is_Mach() && nj->as_Mach()->avoid_back_to_back()) {
    9.17 +      if (nj->is_Mach() && nj->as_Mach()->avoid_back_to_back(MachNode::AVOID_AFTER)) {
    9.18          last_avoid_back_to_back_adr = blk_starts[i]+blk_size;
    9.19        }
    9.20      }
    9.21 @@ -525,11 +525,11 @@
    9.22            int new_size = replacement->size(_regalloc);
    9.23            int diff     = br_size - new_size;
    9.24            assert(diff >= (int)nop_size, "short_branch size should be smaller");
    9.25 -          // Conservatively take into accound padding between
    9.26 +          // Conservatively take into account padding between
    9.27            // avoid_back_to_back branches. Previous branch could be
    9.28            // converted into avoid_back_to_back branch during next
    9.29            // rounds.
    9.30 -          if (needs_padding && replacement->avoid_back_to_back()) {
    9.31 +          if (needs_padding && replacement->avoid_back_to_back(MachNode::AVOID_BEFORE)) {
    9.32              jmp_offset[i] += nop_size;
    9.33              diff -= nop_size;
    9.34            }
    9.35 @@ -548,7 +548,7 @@
    9.36          }
    9.37        } // (mach->may_be_short_branch())
    9.38        if (mach != NULL && (mach->may_be_short_branch() ||
    9.39 -                           mach->avoid_back_to_back())) {
    9.40 +                           mach->avoid_back_to_back(MachNode::AVOID_AFTER))) {
    9.41          last_may_be_short_branch_adr = blk_starts[i] + jmp_offset[i] + jmp_size[i];
    9.42        }
    9.43        blk_starts[i+1] -= adjust_block_start;
    9.44 @@ -1313,7 +1313,7 @@
    9.45          if (is_sfn && !is_mcall && padding == 0 && current_offset == last_call_offset) {
    9.46            padding = nop_size;
    9.47          }
    9.48 -        if (padding == 0 && mach->avoid_back_to_back() &&
    9.49 +        if (padding == 0 && mach->avoid_back_to_back(MachNode::AVOID_BEFORE) &&
    9.50              current_offset == last_avoid_back_to_back_offset) {
    9.51            // Avoid back to back some instructions.
    9.52            padding = nop_size;
    9.53 @@ -1407,7 +1407,7 @@
    9.54                int new_size = replacement->size(_regalloc);
    9.55                assert((br_size - new_size) >= (int)nop_size, "short_branch size should be smaller");
    9.56                // Insert padding between avoid_back_to_back branches.
    9.57 -              if (needs_padding && replacement->avoid_back_to_back()) {
    9.58 +              if (needs_padding && replacement->avoid_back_to_back(MachNode::AVOID_BEFORE)) {
    9.59                  MachNode *nop = new (this) MachNopNode();
    9.60                  block->insert_node(nop, j++);
    9.61                  _cfg->map_node_to_block(nop, block);
    9.62 @@ -1515,7 +1515,7 @@
    9.63          last_call_offset = current_offset;
    9.64        }
    9.65  
    9.66 -      if (n->is_Mach() && n->as_Mach()->avoid_back_to_back()) {
    9.67 +      if (n->is_Mach() && n->as_Mach()->avoid_back_to_back(MachNode::AVOID_AFTER)) {
    9.68          // Avoid back to back some instructions.
    9.69          last_avoid_back_to_back_offset = current_offset;
    9.70        }
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/test/compiler/rtm/cli/TestRTMRetryCountOption.java	Wed Apr 16 18:40:25 2014 -0400
    10.3 @@ -0,0 +1,46 @@
    10.4 +/*
    10.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    10.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    10.7 + *
    10.8 + * This code is free software; you can redistribute it and/or modify it
    10.9 + * under the terms of the GNU General Public License version 2 only, as
   10.10 + * published by the Free Software Foundation.
   10.11 + *
   10.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   10.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   10.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   10.15 + * version 2 for more details (a copy is included in the LICENSE file that
   10.16 + * accompanied this code).
   10.17 + *
   10.18 + * You should have received a copy of the GNU General Public License version
   10.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   10.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   10.21 + *
   10.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   10.23 + * or visit www.oracle.com if you need additional information or have any
   10.24 + * questions.
   10.25 + *
   10.26 + */
   10.27 +
   10.28 +/**
   10.29 + * @test
   10.30 + * @bug 8031320
   10.31 + * @summary Verify processing of RTMRetryCount option.
   10.32 + * @library /testlibrary
   10.33 + * @build TestRTMRetryCountOption
   10.34 + * @run main/othervm TestRTMRetryCountOption
   10.35 + */
   10.36 +
   10.37 +public class TestRTMRetryCountOption extends RTMGenericCommandLineOptionTest {
   10.38 +    private static final String DEFAULT_VALUE = "5";
   10.39 +
   10.40 +    private TestRTMRetryCountOption() {
   10.41 +        super(Boolean.TRUE::booleanValue, "RTMRetryCount", false, true,
   10.42 +                TestRTMRetryCountOption.DEFAULT_VALUE,
   10.43 +                "0", "10", "100", "1000");
   10.44 +    }
   10.45 +
   10.46 +    public static void main(String args[]) throws Throwable {
   10.47 +        new TestRTMRetryCountOption().test();
   10.48 +    }
   10.49 +}
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/test/compiler/types/correctness/CorrectnessTest.java	Wed Apr 16 18:40:25 2014 -0400
    11.3 @@ -0,0 +1,159 @@
    11.4 +/*
    11.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    11.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    11.7 + *
    11.8 + * This code is free software; you can redistribute it and/or modify it
    11.9 + * under the terms of the GNU General Public License version 2 only, as
   11.10 + * published by the Free Software Foundation.
   11.11 + *
   11.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   11.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   11.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   11.15 + * version 2 for more details (a copy is included in the LICENSE file that
   11.16 + * accompanied this code).
   11.17 + *
   11.18 + * You should have received a copy of the GNU General Public License version
   11.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   11.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   11.21 + *
   11.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   11.23 + * or visit www.oracle.com if you need additional information or have any
   11.24 + * questions.
   11.25 + */
   11.26 +
   11.27 +/*
   11.28 + * @test CorrectnessTest
   11.29 + * @bug 8038418
   11.30 + * @library /testlibrary /testlibrary/whitebox
   11.31 + * @compile execution/TypeConflict.java execution/TypeProfile.java
   11.32 + *          execution/MethodHandleDelegate.java
   11.33 + * @build CorrectnessTest
   11.34 + * @run main ClassFileInstaller sun.hotspot.WhiteBox
   11.35 + * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions
   11.36 + *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
   11.37 + *                   -XX:TypeProfileLevel=222 -XX:+UseTypeSpeculation
   11.38 + *                   -XX:CompileCommand=exclude,execution/*::methodNotToCompile
   11.39 + *                   -XX:CompileCommand=dontinline,scenarios/Scenario::collectReturnType
   11.40 + *                   CorrectnessTest RETURN
   11.41 + * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions
   11.42 + *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
   11.43 + *                   -XX:TypeProfileLevel=222 -XX:+UseTypeSpeculation
   11.44 + *                   -XX:CompileCommand=exclude,execution/*::methodNotToCompile
   11.45 + *                   -XX:CompileCommand=dontinline,scenarios/Scenario::collectReturnType
   11.46 + *                   CorrectnessTest PARAMETERS
   11.47 + * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions
   11.48 + *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
   11.49 + *                   -XX:TypeProfileLevel=222 -XX:+UseTypeSpeculation
   11.50 + *                   -XX:CompileCommand=exclude,execution/*::methodNotToCompile
   11.51 + *                   -XX:CompileCommand=dontinline,scenarios/Scenario::collectReturnType
   11.52 + *                   CorrectnessTest ARGUMENTS
   11.53 + * @summary Tests correctness of type usage with type profiling and speculations
   11.54 + */
   11.55 +
   11.56 +import com.oracle.java.testlibrary.Asserts;
   11.57 +import com.oracle.java.testlibrary.Platform;
   11.58 +import execution.Execution;
   11.59 +import execution.MethodHandleDelegate;
   11.60 +import execution.TypeConflict;
   11.61 +import execution.TypeProfile;
   11.62 +import hierarchies.*;
   11.63 +import scenarios.*;
   11.64 +import sun.hotspot.WhiteBox;
   11.65 +
   11.66 +import java.lang.reflect.Constructor;
   11.67 +import java.lang.reflect.Method;
   11.68 +import java.util.ArrayList;
   11.69 +import java.util.List;
   11.70 +import java.util.function.BiFunction;
   11.71 +
   11.72 +public class CorrectnessTest {
   11.73 +    private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
   11.74 +
   11.75 +    public static void main(String[] args) {
   11.76 +        if (!Platform.isServer()) {
   11.77 +            System.out.println("ALL TESTS SKIPPED");
   11.78 +        }
   11.79 +        Asserts.assertGTE(args.length, 1);
   11.80 +        ProfilingType profilingType = ProfilingType.valueOf(args[0]);
   11.81 +        if (runTests(profilingType)) {
   11.82 +            System.out.println("ALL TESTS PASSED");
   11.83 +        } else {
   11.84 +            throw new RuntimeException("SOME TESTS FAILED");
   11.85 +        }
   11.86 +    }
   11.87 +
   11.88 +    @SuppressWarnings("unchecked")
   11.89 +    public static boolean runTests(ProfilingType profilingType) {
   11.90 +        boolean result = true;
   11.91 +
   11.92 +        List<Execution> executionList = new ArrayList<>();
   11.93 +        executionList.add(new TypeConflict());
   11.94 +        executionList.add(new TypeProfile());
   11.95 +        for (int i = 0, n = executionList.size(); i < n; i++) {
   11.96 +            executionList.add(new MethodHandleDelegate(executionList.get(i)));
   11.97 +        }
   11.98 +
   11.99 +        List<TypeHierarchy> hierarchyList = new ArrayList<>();
  11.100 +        hierarchyList.add(new DefaultMethodInterface.Hierarchy());
  11.101 +        hierarchyList.add(new DefaultMethodInterface2.Hierarchy());
  11.102 +        hierarchyList.add(new Linear.Hierarchy());
  11.103 +        hierarchyList.add(new Linear2.Hierarchy());
  11.104 +        hierarchyList.add(new OneRank.Hierarchy());
  11.105 +        for (int i = 0, n = hierarchyList.size(); i < n; i++) {
  11.106 +            hierarchyList.add(new NullableType(hierarchyList.get(i)));
  11.107 +        }
  11.108 +
  11.109 +        List<BiFunction<ProfilingType, TypeHierarchy, Scenario<?, ?>>> testCasesConstructors
  11.110 +                = new ArrayList<>();
  11.111 +        testCasesConstructors.add(ArrayCopy::new);
  11.112 +        testCasesConstructors.add(ArrayReferenceStore::new);
  11.113 +        testCasesConstructors.add(ClassIdentity::new);
  11.114 +        testCasesConstructors.add(ClassInstanceOf::new);
  11.115 +        testCasesConstructors.add(ClassIsInstance::new);
  11.116 +        testCasesConstructors.add(ReceiverAtInvokes::new);
  11.117 +        testCasesConstructors.add(CheckCast::new);
  11.118 +
  11.119 +        for (TypeHierarchy hierarchy : hierarchyList) {
  11.120 +            for (BiFunction<ProfilingType, TypeHierarchy, Scenario<?, ?>> constructor : testCasesConstructors) {
  11.121 +                for (Execution execution : executionList) {
  11.122 +                    Scenario<?, ?> scenario = constructor.apply(profilingType, hierarchy);
  11.123 +                    if (scenario.isApplicable()) {
  11.124 +                        result &= executeTest(hierarchy, execution, scenario);
  11.125 +                    }
  11.126 +                }
  11.127 +            }
  11.128 +        }
  11.129 +        return result;
  11.130 +    }
  11.131 +
  11.132 +    /**
  11.133 +     * Executes test case
  11.134 +     *
  11.135 +     * @param hierarchy type hierarchy for the test
  11.136 +     * @param execution execution scenario
  11.137 +     * @param scenario  test scenario executed with given Execution
  11.138 +     */
  11.139 +    private static boolean executeTest(TypeHierarchy hierarchy, Execution execution, Scenario<?, ?> scenario) {
  11.140 +        boolean testCaseResult = false;
  11.141 +        String testName = hierarchy.getClass().getName() + " :: " + scenario.getName() + " @ " + execution.getName();
  11.142 +        clearAllMethodsState(scenario.getClass());
  11.143 +        try {
  11.144 +            execution.execute(scenario);
  11.145 +            testCaseResult = true;
  11.146 +        } catch (Exception e) {
  11.147 +            System.err.println(testName + " failed with exception " + e);
  11.148 +            e.printStackTrace();
  11.149 +        }
  11.150 +        System.out.println((testCaseResult ? "PASSED: " : "FAILED: ") + testName);
  11.151 +        return testCaseResult;
  11.152 +    }
  11.153 +
  11.154 +    private static void clearAllMethodsState(Class aClass) {
  11.155 +        while (aClass != null) {
  11.156 +            for (Method m : aClass.getDeclaredMethods()) {
  11.157 +                WHITE_BOX.clearMethodState(m);
  11.158 +            }
  11.159 +            aClass = aClass.getSuperclass();
  11.160 +        }
  11.161 +    }
  11.162 +}
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/test/compiler/types/correctness/OffTest.java	Wed Apr 16 18:40:25 2014 -0400
    12.3 @@ -0,0 +1,108 @@
    12.4 +/*
    12.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    12.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    12.7 + *
    12.8 + * This code is free software; you can redistribute it and/or modify it
    12.9 + * under the terms of the GNU General Public License version 2 only, as
   12.10 + * published by the Free Software Foundation.
   12.11 + *
   12.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   12.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   12.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   12.15 + * version 2 for more details (a copy is included in the LICENSE file that
   12.16 + * accompanied this code).
   12.17 + *
   12.18 + * You should have received a copy of the GNU General Public License version
   12.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   12.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   12.21 + *
   12.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   12.23 + * or visit www.oracle.com if you need additional information or have any
   12.24 + * questions.
   12.25 + */
   12.26 +
   12.27 +/*
   12.28 + * @test CorrectnessTest
   12.29 + * @bug 8038418
   12.30 + * @library /testlibrary /testlibrary/whitebox
   12.31 + * @compile execution/TypeConflict.java execution/TypeProfile.java
   12.32 + *          execution/MethodHandleDelegate.java
   12.33 + * @build CorrectnessTest
   12.34 + * @build OffTest
   12.35 + * @run main ClassFileInstaller sun.hotspot.WhiteBox
   12.36 + * @run main/timeout=1200 OffTest
   12.37 + */
   12.38 +
   12.39 +import com.oracle.java.testlibrary.OutputAnalyzer;
   12.40 +import com.oracle.java.testlibrary.ProcessTools;
   12.41 +import scenarios.ProfilingType;
   12.42 +
   12.43 +import java.util.Random;
   12.44 +
   12.45 +public class OffTest {
   12.46 +    private static final String[] OPTIONS = {
   12.47 +            "-Xbootclasspath/a:.",
   12.48 +            "-XX:+IgnoreUnrecognizedVMOptions",
   12.49 +            "-XX:+UnlockExperimentalVMOptions",
   12.50 +            "-XX:+UnlockDiagnosticVMOptions",
   12.51 +            "-XX:+WhiteBoxAPI",
   12.52 +            "-XX:CompileCommand=exclude,execution/*::methodNotToCompile",
   12.53 +            "-XX:CompileCommand=dontinline,scenarios/Scenario::collectReturnType",
   12.54 +            "", // -XX:TypeProfileLevel=?
   12.55 +            "", // -XX:?UseTypeSpeculation
   12.56 +            CorrectnessTest.class.getName(),
   12.57 +            "", // ProfilingType.name()
   12.58 +    };
   12.59 +
   12.60 +    private static final String TYPE_PROFILE_LEVEL = "TypeProfileLevel";
   12.61 +    private static final String USE_TYPE_SPECULATION = "UseTypeSpeculation";
   12.62 +    private static final int TYPE_PROFILE_LEVEL_LENGTH = 3;
   12.63 +    private static final int TYPE_PROFILE_LEVEL_BOUND = 3;
   12.64 +    private static final int DEFAULT_COUNT = 10;
   12.65 +    private static final int PROFILING_TYPE_INDEX = OPTIONS.length - 1;
   12.66 +    private static final int TYPE_PROFILE_INDEX = OPTIONS.length - 4;
   12.67 +    private static final int USE_TYPE_SPECULATION_INDEX = OPTIONS.length - 3;
   12.68 +    private static final Random RNG;
   12.69 +
   12.70 +    static {
   12.71 +        String str = System.getProperty("seed");
   12.72 +        long seed = str != null ? Long.parseLong(str) : new Random().nextLong();
   12.73 +        RNG = new Random(seed);
   12.74 +        System.out.printf("-Dseed=%d%n", seed);
   12.75 +    }
   12.76 +
   12.77 +    public static void main(String[] args) throws Exception {
   12.78 +        int count = DEFAULT_COUNT;
   12.79 +        if (args.length > 0) {
   12.80 +            count = Integer.parseInt(args[0]) ;
   12.81 +        }
   12.82 +        for (int i = 0; i < count; ++i) {
   12.83 +            runTest();
   12.84 +        }
   12.85 +    }
   12.86 +
   12.87 +    private static void runTest() throws Exception {
   12.88 +        String useTypeSpeculation = "-XX:" + (RNG.nextBoolean() ? "+" : "-") +  USE_TYPE_SPECULATION;
   12.89 +        String typeProfileLevel = "-XX:" + TYPE_PROFILE_LEVEL + "=" + randomTypeProfileLevel();
   12.90 +        ProfilingType type = randomProfileType();
   12.91 +        OPTIONS[TYPE_PROFILE_INDEX] = typeProfileLevel;
   12.92 +        OPTIONS[USE_TYPE_SPECULATION_INDEX] = useTypeSpeculation;
   12.93 +        OPTIONS[PROFILING_TYPE_INDEX] = type.name();
   12.94 +        ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder(/* addTestVmOptions= */ true, OPTIONS);
   12.95 +        OutputAnalyzer outputAnalyzer = new OutputAnalyzer(processBuilder.start());
   12.96 +        outputAnalyzer.shouldHaveExitValue(0);
   12.97 +    }
   12.98 +
   12.99 +    private static ProfilingType randomProfileType() {
  12.100 +        ProfilingType[] value = ProfilingType.values();
  12.101 +        return value[RNG.nextInt(value.length)];
  12.102 +    }
  12.103 +
  12.104 +    private static String randomTypeProfileLevel() {
  12.105 +        StringBuilder stringBuilder = new StringBuilder();
  12.106 +        for (int i = 0; i < TYPE_PROFILE_LEVEL_LENGTH; ++i) {
  12.107 +            stringBuilder.append(RNG.nextInt(TYPE_PROFILE_LEVEL_BOUND));
  12.108 +        }
  12.109 +        return stringBuilder.toString();
  12.110 +    }
  12.111 +}
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/test/compiler/types/correctness/execution/Execution.java	Wed Apr 16 18:40:25 2014 -0400
    13.3 @@ -0,0 +1,45 @@
    13.4 +/*
    13.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    13.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    13.7 + *
    13.8 + * This code is free software; you can redistribute it and/or modify it
    13.9 + * under the terms of the GNU General Public License version 2 only, as
   13.10 + * published by the Free Software Foundation.
   13.11 + *
   13.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   13.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   13.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   13.15 + * version 2 for more details (a copy is included in the LICENSE file that
   13.16 + * accompanied this code).
   13.17 + *
   13.18 + * You should have received a copy of the GNU General Public License version
   13.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   13.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   13.21 + *
   13.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   13.23 + * or visit www.oracle.com if you need additional information or have any
   13.24 + * questions.
   13.25 + */
   13.26 +package execution;
   13.27 +
   13.28 +import hierarchies.TypeHierarchy;
   13.29 +import scenarios.Scenario;
   13.30 +
   13.31 +/**
   13.32 + * Execution scenario represents test methods execution type.
   13.33 + * @param <T> parameter type
   13.34 + * @param <R> result Type
   13.35 + */
   13.36 +public interface Execution<T extends TypeHierarchy.I, R> {
   13.37 +    /**
   13.38 +     * Executes the test code of the given scenario
   13.39 +     * See {@link scenarios.Scenario#run(T)}
   13.40 +     *
   13.41 +     * @param scenario test scenario
   13.42 +     */
   13.43 +    void execute(Scenario<T, R> scenario);
   13.44 +
   13.45 +    default String getName() {
   13.46 +        return this.getClass().getName();
   13.47 +    }
   13.48 +}
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/test/compiler/types/correctness/execution/MethodHandleDelegate.java	Wed Apr 16 18:40:25 2014 -0400
    14.3 @@ -0,0 +1,105 @@
    14.4 +/*
    14.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    14.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    14.7 + *
    14.8 + * This code is free software; you can redistribute it and/or modify it
    14.9 + * under the terms of the GNU General Public License version 2 only, as
   14.10 + * published by the Free Software Foundation.
   14.11 + *
   14.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   14.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   14.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   14.15 + * version 2 for more details (a copy is included in the LICENSE file that
   14.16 + * accompanied this code).
   14.17 + *
   14.18 + * You should have received a copy of the GNU General Public License version
   14.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   14.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   14.21 + *
   14.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   14.23 + * or visit www.oracle.com if you need additional information or have any
   14.24 + * questions.
   14.25 + */
   14.26 +
   14.27 +package execution;
   14.28 +
   14.29 +import hierarchies.TypeHierarchy;
   14.30 +import scenarios.Scenario;
   14.31 +
   14.32 +import java.lang.invoke.MethodHandle;
   14.33 +import java.lang.invoke.MethodHandles;
   14.34 +import java.lang.invoke.MethodType;
   14.35 +
   14.36 +/**
   14.37 + * Executes test scenario using {@link MethodHandle#invoke(Object...)}.
   14.38 + * Delegates execution to the given {@link Execution} by creating
   14.39 + * new test scenario, see {@link Scenario}
   14.40 + */
   14.41 +public class MethodHandleDelegate<T  extends TypeHierarchy.I, R> implements Execution<T, R> {
   14.42 +    private final Execution<T, R> delegate;
   14.43 +
   14.44 +    public MethodHandleDelegate(Execution<T, R> delegate) {
   14.45 +        this.delegate = delegate;
   14.46 +    }
   14.47 +
   14.48 +    @Override
   14.49 +    public void execute(Scenario<T, R> scenario) {
   14.50 +        delegate.execute(new MHScenario<T, R>(scenario));
   14.51 +    }
   14.52 +
   14.53 +    @Override
   14.54 +    public String getName() {
   14.55 +        return "MethodHandleDelegate # " + delegate.getName();
   14.56 +    }
   14.57 +
   14.58 +    private static class MHScenario<T extends TypeHierarchy.I, R> extends Scenario<T, R> {
   14.59 +        private final Scenario<T, R> scenario;
   14.60 +        private static final MethodHandle METHOD_HANDLE_RUN;
   14.61 +
   14.62 +        static {
   14.63 +            MethodHandles.Lookup lookup = MethodHandles.lookup();
   14.64 +            MethodType methodType = MethodType.methodType(Object.class, TypeHierarchy.I.class);
   14.65 +
   14.66 +            try {
   14.67 +                METHOD_HANDLE_RUN = lookup.findVirtual(Scenario.class, "run", methodType);
   14.68 +            } catch (NoSuchMethodException | IllegalAccessException e) {
   14.69 +                System.err.println("Failed to get target method run() with " + e);
   14.70 +                e.printStackTrace();
   14.71 +                throw new RuntimeException(e);
   14.72 +            }
   14.73 +        }
   14.74 +
   14.75 +        /**
   14.76 +         * Constructor
   14.77 +         *
   14.78 +         * @param scenario test scenario to be executed
   14.79 +         */
   14.80 +        private MHScenario(Scenario<T, R> scenario) {
   14.81 +            super("MethodHandle::" + scenario.getName(), scenario.profilingType, scenario.hierarchy);
   14.82 +            this.scenario = scenario;
   14.83 +        }
   14.84 +
   14.85 +        /**
   14.86 +         * Runs {@link Scenario#run(T)} with {@link MethodHandle#invoke(Object...)}
   14.87 +         *
   14.88 +         * @param t subject of the test
   14.89 +         * @return  result of the underlying {@link Scenario#run(T)} invocation
   14.90 +         */
   14.91 +        @SuppressWarnings("unchecked")
   14.92 +        @Override
   14.93 +        public R run(T t) {
   14.94 +            try {
   14.95 +                return (R) METHOD_HANDLE_RUN.invoke(scenario, t);
   14.96 +            } catch (Throwable thr) {
   14.97 +                System.err.println(scenario.getName()
   14.98 +                        + " failed to invoke target method run() with " + thr);
   14.99 +                throw new RuntimeException("Invocation failed", thr);
  14.100 +            }
  14.101 +        }
  14.102 +
  14.103 +        @Override
  14.104 +        public void check(R r, T t) {
  14.105 +            scenario.check(r, t);
  14.106 +        }
  14.107 +    }
  14.108 +}
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/test/compiler/types/correctness/execution/TypeConflict.java	Wed Apr 16 18:40:25 2014 -0400
    15.3 @@ -0,0 +1,74 @@
    15.4 +/*
    15.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    15.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    15.7 + *
    15.8 + * This code is free software; you can redistribute it and/or modify it
    15.9 + * under the terms of the GNU General Public License version 2 only, as
   15.10 + * published by the Free Software Foundation.
   15.11 + *
   15.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   15.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   15.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   15.15 + * version 2 for more details (a copy is included in the LICENSE file that
   15.16 + * accompanied this code).
   15.17 + *
   15.18 + * You should have received a copy of the GNU General Public License version
   15.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   15.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   15.21 + *
   15.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   15.23 + * or visit www.oracle.com if you need additional information or have any
   15.24 + * questions.
   15.25 + */
   15.26 +
   15.27 +package execution;
   15.28 +
   15.29 +import hierarchies.TypeHierarchy;
   15.30 +import scenarios.Scenario;
   15.31 +
   15.32 +/**
   15.33 + *  Type profiling conflict execution scenario. The main goal is
   15.34 + *  to make compiler profile and compile methods with different types.
   15.35 + *  Scenario tests guards by passing conflicting types (incompatible
   15.36 + *  for the profiled data).
   15.37 + */
   15.38 +public class TypeConflict<T extends TypeHierarchy.I, R> implements Execution<T, R> {
   15.39 +    /** Test methods execution number to make profile  */
   15.40 +    private final static int POLLUTION_THRESHOLD = 5000;
   15.41 +    /** Test methods execution number to make it profiled and compiled*/
   15.42 +    private final static int PROFILE_THRESHOLD = 20000;
   15.43 +
   15.44 +    @Override
   15.45 +    public void execute(Scenario<T, R> scenario) {
   15.46 +        T base = scenario.getProfiled();
   15.47 +        T incompatible = scenario.getConflict();
   15.48 +
   15.49 +        // pollute profile by passing different types
   15.50 +        R baseResult = null;
   15.51 +        R incResult = null;
   15.52 +        for (int i = 0; i < POLLUTION_THRESHOLD; i++) {
   15.53 +            baseResult = methodNotToCompile(scenario, base);
   15.54 +            incResult = methodNotToCompile(scenario, incompatible);
   15.55 +        }
   15.56 +        scenario.check(baseResult, base);
   15.57 +        scenario.check(incResult, incompatible);
   15.58 +
   15.59 +        // profile and compile
   15.60 +        R result = null;
   15.61 +        for (int i = 0; i < PROFILE_THRESHOLD; i++) {
   15.62 +            result = methodNotToCompile(scenario, base);
   15.63 +        }
   15.64 +        scenario.check(result, base);
   15.65 +
   15.66 +        // pass another type to make guard work and recompile
   15.67 +        for (int i = 0; i < PROFILE_THRESHOLD; i++) {
   15.68 +            result = methodNotToCompile(scenario, incompatible);
   15.69 +        }
   15.70 +        scenario.check(result, incompatible);
   15.71 +    }
   15.72 +
   15.73 +    private R methodNotToCompile(Scenario<T, R> scenario, T t) {
   15.74 +        return scenario.run(t);
   15.75 +    }
   15.76 +}
   15.77 +
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/test/compiler/types/correctness/execution/TypeProfile.java	Wed Apr 16 18:40:25 2014 -0400
    16.3 @@ -0,0 +1,59 @@
    16.4 +/*
    16.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    16.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    16.7 + *
    16.8 + * This code is free software; you can redistribute it and/or modify it
    16.9 + * under the terms of the GNU General Public License version 2 only, as
   16.10 + * published by the Free Software Foundation.
   16.11 + *
   16.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   16.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   16.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   16.15 + * version 2 for more details (a copy is included in the LICENSE file that
   16.16 + * accompanied this code).
   16.17 + *
   16.18 + * You should have received a copy of the GNU General Public License version
   16.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   16.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   16.21 + *
   16.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   16.23 + * or visit www.oracle.com if you need additional information or have any
   16.24 + * questions.
   16.25 + */
   16.26 +
   16.27 +package execution;
   16.28 +
   16.29 +import hierarchies.TypeHierarchy;
   16.30 +import scenarios.Scenario;
   16.31 +
   16.32 +/**
   16.33 + * Profile type execution scenario. Executes tester method
   16.34 + * in a loop without any manipulation with types or instances.
   16.35 + */
   16.36 +public class TypeProfile<T extends TypeHierarchy.I, R> implements Execution<T, R> {
   16.37 +    /** Number of test method execution to make it profiled and compiled */
   16.38 +    private final static int PROFILE_THRESHOLD = 100000;
   16.39 +
   16.40 +    /**
   16.41 +     * Makes scenario code be profiled and compiled
   16.42 +     * @param scenario Test scenario
   16.43 +     */
   16.44 +    @Override
   16.45 +    public void execute(Scenario<T, R> scenario) {
   16.46 +        R result = null;
   16.47 +        T prof = scenario.getProfiled();
   16.48 +        T confl = scenario.getConflict();
   16.49 +
   16.50 +        for (int i = 0; i < PROFILE_THRESHOLD; i++) {
   16.51 +            result = methodNotToCompile(scenario, prof);
   16.52 +        }
   16.53 +        scenario.check(result, prof);
   16.54 +
   16.55 +        result = methodNotToCompile(scenario, confl);
   16.56 +        scenario.check(result, confl);
   16.57 +    }
   16.58 +
   16.59 +    protected R methodNotToCompile(Scenario<T, R> scenario, T t) {
   16.60 +        return scenario.run(t);
   16.61 +    }
   16.62 +}
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/test/compiler/types/correctness/hierarchies/DefaultMethodInterface.java	Wed Apr 16 18:40:25 2014 -0400
    17.3 @@ -0,0 +1,54 @@
    17.4 +/*
    17.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    17.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    17.7 + *
    17.8 + * This code is free software; you can redistribute it and/or modify it
    17.9 + * under the terms of the GNU General Public License version 2 only, as
   17.10 + * published by the Free Software Foundation.
   17.11 + *
   17.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   17.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   17.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   17.15 + * version 2 for more details (a copy is included in the LICENSE file that
   17.16 + * accompanied this code).
   17.17 + *
   17.18 + * You should have received a copy of the GNU General Public License version
   17.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   17.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   17.21 + *
   17.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   17.23 + * or visit www.oracle.com if you need additional information or have any
   17.24 + * questions.
   17.25 + */
   17.26 +
   17.27 +package hierarchies;
   17.28 +
   17.29 +public class DefaultMethodInterface {
   17.30 +    private DefaultMethodInterface() {
   17.31 +    }
   17.32 +
   17.33 +    public static class Hierarchy
   17.34 +            extends TypeHierarchy<DefaultMethodInterface.A, DefaultMethodInterface.B> {
   17.35 +        public Hierarchy() {
   17.36 +            super(new DefaultMethodInterface.A(), new DefaultMethodInterface.B(),
   17.37 +                    DefaultMethodInterface.A.class, DefaultMethodInterface.B.class);
   17.38 +        }
   17.39 +    }
   17.40 +
   17.41 +    public static interface I2 extends TypeHierarchy.I {
   17.42 +        default int m() {
   17.43 +            return TypeHierarchy.ANSWER;
   17.44 +        }
   17.45 +    }
   17.46 +
   17.47 +    public static class A implements I2 {
   17.48 +        // use default method from I2
   17.49 +    }
   17.50 +
   17.51 +    public static class B extends A {
   17.52 +        @Override
   17.53 +        public int m() {
   17.54 +            return TypeHierarchy.YEAR;
   17.55 +        }
   17.56 +    }
   17.57 +}
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/test/compiler/types/correctness/hierarchies/DefaultMethodInterface2.java	Wed Apr 16 18:40:25 2014 -0400
    18.3 @@ -0,0 +1,47 @@
    18.4 +/*
    18.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    18.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    18.7 + *
    18.8 + * This code is free software; you can redistribute it and/or modify it
    18.9 + * under the terms of the GNU General Public License version 2 only, as
   18.10 + * published by the Free Software Foundation.
   18.11 + *
   18.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   18.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   18.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   18.15 + * version 2 for more details (a copy is included in the LICENSE file that
   18.16 + * accompanied this code).
   18.17 + *
   18.18 + * You should have received a copy of the GNU General Public License version
   18.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   18.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   18.21 + *
   18.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   18.23 + * or visit www.oracle.com if you need additional information or have any
   18.24 + * questions.
   18.25 + */
   18.26 +
   18.27 +package hierarchies;
   18.28 +
   18.29 +public class DefaultMethodInterface2 {
   18.30 +    private DefaultMethodInterface2() {
   18.31 +    }
   18.32 +
   18.33 +    public static class Hierarchy
   18.34 +            extends TypeHierarchy<TypeHierarchy.A, DefaultMethodInterface2.B> {
   18.35 +        public Hierarchy() {
   18.36 +            super(new TypeHierarchy.A(), new DefaultMethodInterface2.B(),
   18.37 +                    TypeHierarchy.A.class, DefaultMethodInterface2.B.class);
   18.38 +        }
   18.39 +    }
   18.40 +
   18.41 +    public static interface I2 extends TypeHierarchy.I {
   18.42 +        default int m() {
   18.43 +            return TypeHierarchy.ANSWER;
   18.44 +        }
   18.45 +    }
   18.46 +
   18.47 +    public static class B implements I2 {
   18.48 +        // default method I2.m()
   18.49 +    }
   18.50 +}
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/test/compiler/types/correctness/hierarchies/Linear.java	Wed Apr 16 18:40:25 2014 -0400
    19.3 @@ -0,0 +1,43 @@
    19.4 +/*
    19.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    19.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    19.7 + *
    19.8 + * This code is free software; you can redistribute it and/or modify it
    19.9 + * under the terms of the GNU General Public License version 2 only, as
   19.10 + * published by the Free Software Foundation.
   19.11 + *
   19.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   19.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   19.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   19.15 + * version 2 for more details (a copy is included in the LICENSE file that
   19.16 + * accompanied this code).
   19.17 + *
   19.18 + * You should have received a copy of the GNU General Public License version
   19.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   19.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   19.21 + *
   19.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   19.23 + * or visit www.oracle.com if you need additional information or have any
   19.24 + * questions.
   19.25 + */
   19.26 +
   19.27 +package hierarchies;
   19.28 +
   19.29 +public class Linear {
   19.30 +    private Linear() {
   19.31 +    }
   19.32 +
   19.33 +    public static class Hierarchy extends TypeHierarchy<TypeHierarchy.A, Linear.B> {
   19.34 +        public Hierarchy() {
   19.35 +            super(new TypeHierarchy.A(), new Linear.B(),
   19.36 +                    TypeHierarchy.A.class, Linear.B.class);
   19.37 +        }
   19.38 +    }
   19.39 +
   19.40 +    public static class B extends TypeHierarchy.A {
   19.41 +        @Override
   19.42 +        public int m() {
   19.43 +            return TypeHierarchy.YEAR;
   19.44 +        }
   19.45 +    }
   19.46 +}
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/test/compiler/types/correctness/hierarchies/Linear2.java	Wed Apr 16 18:40:25 2014 -0400
    20.3 @@ -0,0 +1,47 @@
    20.4 +/*
    20.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    20.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    20.7 + *
    20.8 + * This code is free software; you can redistribute it and/or modify it
    20.9 + * under the terms of the GNU General Public License version 2 only, as
   20.10 + * published by the Free Software Foundation.
   20.11 + *
   20.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   20.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   20.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   20.15 + * version 2 for more details (a copy is included in the LICENSE file that
   20.16 + * accompanied this code).
   20.17 + *
   20.18 + * You should have received a copy of the GNU General Public License version
   20.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   20.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   20.21 + *
   20.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   20.23 + * or visit www.oracle.com if you need additional information or have any
   20.24 + * questions.
   20.25 + */
   20.26 +
   20.27 +package hierarchies;
   20.28 +
   20.29 +public class Linear2 {
   20.30 +    private Linear2() {
   20.31 +    }
   20.32 +
   20.33 +    public static class Hierarchy extends TypeHierarchy<TypeHierarchy.A, Linear2.B> {
   20.34 +        public Hierarchy() {
   20.35 +            super(new A(), new Linear2.B(),
   20.36 +                    A.class, Linear2.B.class);
   20.37 +        }
   20.38 +    }
   20.39 +
   20.40 +    public static interface I2 {
   20.41 +        int m();
   20.42 +    }
   20.43 +
   20.44 +    public static class B extends TypeHierarchy.A implements Linear2.I2 {
   20.45 +        @Override
   20.46 +        public int m() {
   20.47 +            return TypeHierarchy.YEAR;
   20.48 +        }
   20.49 +    }
   20.50 +}
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/test/compiler/types/correctness/hierarchies/NullableType.java	Wed Apr 16 18:40:25 2014 -0400
    21.3 @@ -0,0 +1,33 @@
    21.4 +/*
    21.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    21.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    21.7 + *
    21.8 + * This code is free software; you can redistribute it and/or modify it
    21.9 + * under the terms of the GNU General Public License version 2 only, as
   21.10 + * published by the Free Software Foundation.
   21.11 + *
   21.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   21.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   21.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   21.15 + * version 2 for more details (a copy is included in the LICENSE file that
   21.16 + * accompanied this code).
   21.17 + *
   21.18 + * You should have received a copy of the GNU General Public License version
   21.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   21.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   21.21 + *
   21.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   21.23 + * or visit www.oracle.com if you need additional information or have any
   21.24 + * questions.
   21.25 + */
   21.26 +
   21.27 +package hierarchies;
   21.28 +
   21.29 +public class NullableType<M extends TypeHierarchy.I, N extends TypeHierarchy.I>
   21.30 +        extends TypeHierarchy<M, N> {
   21.31 +
   21.32 +    public NullableType(TypeHierarchy<M, N> delegate) {
   21.33 +        super(delegate.getM(), null,
   21.34 +                delegate.getClassM(), delegate.getClassN());
   21.35 +    }
   21.36 +}
    22.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.2 +++ b/test/compiler/types/correctness/hierarchies/OneRank.java	Wed Apr 16 18:40:25 2014 -0400
    22.3 @@ -0,0 +1,44 @@
    22.4 +/*
    22.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    22.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    22.7 + *
    22.8 + * This code is free software; you can redistribute it and/or modify it
    22.9 + * under the terms of the GNU General Public License version 2 only, as
   22.10 + * published by the Free Software Foundation.
   22.11 + *
   22.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   22.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   22.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   22.15 + * version 2 for more details (a copy is included in the LICENSE file that
   22.16 + * accompanied this code).
   22.17 + *
   22.18 + * You should have received a copy of the GNU General Public License version
   22.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   22.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   22.21 + *
   22.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   22.23 + * or visit www.oracle.com if you need additional information or have any
   22.24 + * questions.
   22.25 + */
   22.26 +
   22.27 +package hierarchies;
   22.28 +
   22.29 +public class OneRank {
   22.30 +    private OneRank() {
   22.31 +    }
   22.32 +
   22.33 +    public static class Hierarchy extends TypeHierarchy<TypeHierarchy.A, OneRank.B> {
   22.34 +        public Hierarchy() {
   22.35 +            super(new TypeHierarchy.A(), new OneRank.B(),
   22.36 +                    TypeHierarchy.A.class, OneRank.B.class);
   22.37 +        }
   22.38 +    }
   22.39 +
   22.40 +    public static class B implements TypeHierarchy.I {
   22.41 +        @Override
   22.42 +        public int m() {
   22.43 +            return TypeHierarchy.YEAR;
   22.44 +        }
   22.45 +    }
   22.46 +
   22.47 +}
    23.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.2 +++ b/test/compiler/types/correctness/hierarchies/TypeHierarchy.java	Wed Apr 16 18:40:25 2014 -0400
    23.3 @@ -0,0 +1,73 @@
    23.4 +/*
    23.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    23.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    23.7 + *
    23.8 + * This code is free software; you can redistribute it and/or modify it
    23.9 + * under the terms of the GNU General Public License version 2 only, as
   23.10 + * published by the Free Software Foundation.
   23.11 + *
   23.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   23.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   23.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   23.15 + * version 2 for more details (a copy is included in the LICENSE file that
   23.16 + * accompanied this code).
   23.17 + *
   23.18 + * You should have received a copy of the GNU General Public License version
   23.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   23.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   23.21 + *
   23.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   23.23 + * or visit www.oracle.com if you need additional information or have any
   23.24 + * questions.
   23.25 + */
   23.26 +
   23.27 +package hierarchies;
   23.28 +
   23.29 +/**
   23.30 + * Type hierarchy contains classes the type profiling and speculation are tested with
   23.31 + */
   23.32 +public abstract class TypeHierarchy<M extends TypeHierarchy.I, N extends TypeHierarchy.I> {
   23.33 +    // Magic numbers
   23.34 +    public static final int ANSWER = 42;
   23.35 +    public static final int TEMP = 451;
   23.36 +    public static final int YEAR = 1984;
   23.37 +
   23.38 +    private final M m;
   23.39 +    private final N n;
   23.40 +    private final Class<M> classM;
   23.41 +    private final Class<N> classN;
   23.42 +
   23.43 +    protected TypeHierarchy(M m, N n, Class<M> classM, Class<N> classN) {
   23.44 +        this.m = m;
   23.45 +        this.n = n;
   23.46 +        this.classM = classM;
   23.47 +        this.classN = classN;
   23.48 +    }
   23.49 +
   23.50 +    public final M getM() {
   23.51 +        return m;
   23.52 +    }
   23.53 +
   23.54 +    public final N getN() {
   23.55 +        return n;
   23.56 +    }
   23.57 +
   23.58 +    public final Class<M> getClassM() {
   23.59 +        return classM;
   23.60 +    }
   23.61 +
   23.62 +    public final Class<N> getClassN() {
   23.63 +        return classN;
   23.64 +    }
   23.65 +
   23.66 +    public interface I {
   23.67 +        int m();
   23.68 +    }
   23.69 +
   23.70 +    public static class A implements I {
   23.71 +        @Override
   23.72 +        public int m() {
   23.73 +            return TypeHierarchy.ANSWER;
   23.74 +        }
   23.75 +    }
   23.76 +}
    24.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.2 +++ b/test/compiler/types/correctness/scenarios/ArrayCopy.java	Wed Apr 16 18:40:25 2014 -0400
    24.3 @@ -0,0 +1,63 @@
    24.4 +/*
    24.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    24.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    24.7 + *
    24.8 + * This code is free software; you can redistribute it and/or modify it
    24.9 + * under the terms of the GNU General Public License version 2 only, as
   24.10 + * published by the Free Software Foundation.
   24.11 + *
   24.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   24.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   24.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   24.15 + * version 2 for more details (a copy is included in the LICENSE file that
   24.16 + * accompanied this code).
   24.17 + *
   24.18 + * You should have received a copy of the GNU General Public License version
   24.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   24.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   24.21 + *
   24.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   24.23 + * or visit www.oracle.com if you need additional information or have any
   24.24 + * questions.
   24.25 + */
   24.26 +
   24.27 +package scenarios;
   24.28 +
   24.29 +import hierarchies.TypeHierarchy;
   24.30 +
   24.31 +import java.util.Arrays;
   24.32 +
   24.33 +/**
   24.34 + * Tests System.arraycopy()
   24.35 + */
   24.36 +public class ArrayCopy extends ArrayScenario {
   24.37 +    public ArrayCopy(ProfilingType profilingType,
   24.38 +                     TypeHierarchy<? extends TypeHierarchy.I, ? extends TypeHierarchy.I> hierarchy) {
   24.39 +        super("ArrayCopy", profilingType, hierarchy);
   24.40 +    }
   24.41 +
   24.42 +    /**
   24.43 +     * @param obj is used to fill arrays
   24.44 +     * @return the same obj
   24.45 +     */
   24.46 +    @Override
   24.47 +    public TypeHierarchy.I run(TypeHierarchy.I obj) {
   24.48 +        switch (profilingType) {
   24.49 +            case RETURN:
   24.50 +                TypeHierarchy.I t = collectReturnType(obj);
   24.51 +                Arrays.fill(array, t);
   24.52 +                System.arraycopy(array, 0, matrix[0], 0, array.length);
   24.53 +                return array[0];
   24.54 +            case ARGUMENTS:
   24.55 +                field = obj;
   24.56 +                Arrays.fill(array, field);
   24.57 +                System.arraycopy(array, 0, matrix[0], 0, array.length);
   24.58 +                return array[0];
   24.59 +            case PARAMETERS:
   24.60 +                Arrays.fill(array, obj);
   24.61 +                System.arraycopy(array, 0, matrix[0], 0, array.length);
   24.62 +                return array[0];
   24.63 +        }
   24.64 +        throw new RuntimeException("Should not reach here");
   24.65 +    }
   24.66 +}
    25.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.2 +++ b/test/compiler/types/correctness/scenarios/ArrayReferenceStore.java	Wed Apr 16 18:40:25 2014 -0400
    25.3 @@ -0,0 +1,63 @@
    25.4 +/*
    25.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    25.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    25.7 + *
    25.8 + * This code is free software; you can redistribute it and/or modify it
    25.9 + * under the terms of the GNU General Public License version 2 only, as
   25.10 + * published by the Free Software Foundation.
   25.11 + *
   25.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   25.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   25.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   25.15 + * version 2 for more details (a copy is included in the LICENSE file that
   25.16 + * accompanied this code).
   25.17 + *
   25.18 + * You should have received a copy of the GNU General Public License version
   25.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   25.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   25.21 + *
   25.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   25.23 + * or visit www.oracle.com if you need additional information or have any
   25.24 + * questions.
   25.25 + */
   25.26 +
   25.27 +package scenarios;
   25.28 +
   25.29 +import hierarchies.TypeHierarchy;
   25.30 +
   25.31 +import java.util.Arrays;
   25.32 +
   25.33 +/**
   25.34 + * Tests aastore bytecode
   25.35 + */
   25.36 +public class ArrayReferenceStore extends ArrayScenario {
   25.37 +    public ArrayReferenceStore(ProfilingType profilingType,
   25.38 +                               TypeHierarchy<? extends TypeHierarchy.I, ? extends TypeHierarchy.I> hierarchy) {
   25.39 +        super("ArrayReferenceStore", profilingType, hierarchy);
   25.40 +    }
   25.41 +
   25.42 +    /**
   25.43 +     * @param obj is used to fill arrays
   25.44 +     * @return obj
   25.45 +     */
   25.46 +    @Override
   25.47 +    public TypeHierarchy.I run(TypeHierarchy.I obj) {
   25.48 +        switch (profilingType) {
   25.49 +            case RETURN:
   25.50 +                TypeHierarchy.I t = collectReturnType(obj);
   25.51 +                Arrays.fill(array, t);
   25.52 +                matrix[0] = array;
   25.53 +                return matrix[0][0];
   25.54 +            case ARGUMENTS:
   25.55 +                field = obj;
   25.56 +                Arrays.fill(array, field);
   25.57 +                matrix[0] = array;
   25.58 +                return matrix[0][0];
   25.59 +            case PARAMETERS:
   25.60 +                Arrays.fill(array, obj);
   25.61 +                matrix[0] = array;
   25.62 +                return matrix[0][0];
   25.63 +        }
   25.64 +        throw new RuntimeException("Should not reach here");
   25.65 +    }
   25.66 +}
    26.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.2 +++ b/test/compiler/types/correctness/scenarios/ArrayScenario.java	Wed Apr 16 18:40:25 2014 -0400
    26.3 @@ -0,0 +1,68 @@
    26.4 +/*
    26.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    26.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    26.7 + *
    26.8 + * This code is free software; you can redistribute it and/or modify it
    26.9 + * under the terms of the GNU General Public License version 2 only, as
   26.10 + * published by the Free Software Foundation.
   26.11 + *
   26.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   26.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   26.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   26.15 + * version 2 for more details (a copy is included in the LICENSE file that
   26.16 + * accompanied this code).
   26.17 + *
   26.18 + * You should have received a copy of the GNU General Public License version
   26.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   26.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   26.21 + *
   26.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   26.23 + * or visit www.oracle.com if you need additional information or have any
   26.24 + * questions.
   26.25 + */
   26.26 +
   26.27 +package scenarios;
   26.28 +
   26.29 +import com.oracle.java.testlibrary.Asserts;
   26.30 +import hierarchies.TypeHierarchy;
   26.31 +
   26.32 +import java.lang.reflect.Array;
   26.33 +import java.util.Arrays;
   26.34 +
   26.35 +/**
   26.36 + *  Base class for array scenarios
   26.37 + */
   26.38 +public abstract class ArrayScenario extends Scenario<TypeHierarchy.I, TypeHierarchy.I> {
   26.39 +    protected final TypeHierarchy.I[] array;
   26.40 +    protected final TypeHierarchy.I[][] matrix;
   26.41 +
   26.42 +    protected ArrayScenario(String name, ProfilingType profilingType,
   26.43 +                            TypeHierarchy<? extends TypeHierarchy.I, ? extends TypeHierarchy.I> hierarchy) {
   26.44 +        super(name, profilingType, hierarchy);
   26.45 +        final int x = 20;
   26.46 +        final int y = 10;
   26.47 +
   26.48 +        TypeHierarchy.I prof = hierarchy.getM();
   26.49 +        TypeHierarchy.I confl = hierarchy.getN();
   26.50 +
   26.51 +        this.array = (TypeHierarchy.I[]) Array.newInstance(hierarchy.getClassM(), y);
   26.52 +        Arrays.fill(array, prof);
   26.53 +
   26.54 +        this.matrix = (TypeHierarchy.I[][]) Array.newInstance(hierarchy.getClassM(), x, y);
   26.55 +        for (int i = 0; i < x; i++) {
   26.56 +            this.matrix[i] = this.array;
   26.57 +        }
   26.58 +
   26.59 +        Asserts.assertEquals(array.length, matrix[0].length, "Invariant");
   26.60 +    }
   26.61 +
   26.62 +    @Override
   26.63 +    public boolean isApplicable() {
   26.64 +        return hierarchy.getClassM().isAssignableFrom(hierarchy.getClassN());
   26.65 +    }
   26.66 +
   26.67 +    @Override
   26.68 +    public void check(TypeHierarchy.I res, TypeHierarchy.I orig) {
   26.69 +        Asserts.assertEquals(res, orig, "Check failed");
   26.70 +    }
   26.71 +}
    27.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.2 +++ b/test/compiler/types/correctness/scenarios/CheckCast.java	Wed Apr 16 18:40:25 2014 -0400
    27.3 @@ -0,0 +1,77 @@
    27.4 +/*
    27.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    27.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    27.7 + *
    27.8 + * This code is free software; you can redistribute it and/or modify it
    27.9 + * under the terms of the GNU General Public License version 2 only, as
   27.10 + * published by the Free Software Foundation.
   27.11 + *
   27.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   27.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   27.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   27.15 + * version 2 for more details (a copy is included in the LICENSE file that
   27.16 + * accompanied this code).
   27.17 + *
   27.18 + * You should have received a copy of the GNU General Public License version
   27.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   27.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   27.21 + *
   27.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   27.23 + * or visit www.oracle.com if you need additional information or have any
   27.24 + * questions.
   27.25 + */
   27.26 +
   27.27 +package scenarios;
   27.28 +
   27.29 +import com.oracle.java.testlibrary.Asserts;
   27.30 +import hierarchies.TypeHierarchy;
   27.31 +
   27.32 +import java.util.Objects;
   27.33 +
   27.34 +/**
   27.35 + * Checkcast scenario
   27.36 + * @param <T> profiling parameter
   27.37 + */
   27.38 +public class CheckCast<T extends TypeHierarchy.I> extends Scenario<T, Integer> {
   27.39 +    public CheckCast(ProfilingType profilingType, TypeHierarchy<? extends T, ? extends T> hierarchy) {
   27.40 +        super("CheckCast", profilingType, hierarchy);
   27.41 +    }
   27.42 +
   27.43 +    /**
   27.44 +     * Returns type profiling.
   27.45 +     * @param obj is a profiled parameter for the test
   27.46 +     * @return parameter casted to the type R
   27.47 +     */
   27.48 +    @Override
   27.49 +    public Integer run(T obj) {
   27.50 +        switch (profilingType) {
   27.51 +            case RETURN:
   27.52 +                T t = collectReturnType(obj);
   27.53 +                if (t != null) {
   27.54 +                    return t.m();
   27.55 +                }
   27.56 +                return null;
   27.57 +            case ARGUMENTS:
   27.58 +                field = obj;
   27.59 +                if (field != null) {
   27.60 +                    return field.m();
   27.61 +                }
   27.62 +                return null;
   27.63 +            case PARAMETERS:
   27.64 +                if (obj != null) {
   27.65 +                    return obj.m();
   27.66 +                }
   27.67 +                return null;
   27.68 +        }
   27.69 +        throw new RuntimeException("Should not reach here");
   27.70 +    }
   27.71 +
   27.72 +    @Override
   27.73 +    public void check(Integer result, T orig) {
   27.74 +        if (result != null || orig != null) {
   27.75 +            Objects.requireNonNull(result);
   27.76 +            Objects.requireNonNull(orig);
   27.77 +            Asserts.assertEquals(result, orig.m(), "Results mismatch");
   27.78 +        }
   27.79 +    }
   27.80 +}
    28.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.2 +++ b/test/compiler/types/correctness/scenarios/ClassIdentity.java	Wed Apr 16 18:40:25 2014 -0400
    28.3 @@ -0,0 +1,80 @@
    28.4 +/*
    28.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    28.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    28.7 + *
    28.8 + * This code is free software; you can redistribute it and/or modify it
    28.9 + * under the terms of the GNU General Public License version 2 only, as
   28.10 + * published by the Free Software Foundation.
   28.11 + *
   28.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   28.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   28.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   28.15 + * version 2 for more details (a copy is included in the LICENSE file that
   28.16 + * accompanied this code).
   28.17 + *
   28.18 + * You should have received a copy of the GNU General Public License version
   28.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   28.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   28.21 + *
   28.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   28.23 + * or visit www.oracle.com if you need additional information or have any
   28.24 + * questions.
   28.25 + */
   28.26 +
   28.27 +package scenarios;
   28.28 +
   28.29 +import com.oracle.java.testlibrary.Asserts;
   28.30 +import hierarchies.TypeHierarchy;
   28.31 +
   28.32 +/**
   28.33 + * Tests pattern: if (a.getClass() == D.class)
   28.34 + */
   28.35 +public class ClassIdentity<T extends TypeHierarchy.I> extends Scenario<T, Integer> {
   28.36 +    public ClassIdentity(ProfilingType profilingType,
   28.37 +                         TypeHierarchy<? extends T, ? extends T> hierarchy) {
   28.38 +        super("ClassIdentity", profilingType, hierarchy);
   28.39 +    }
   28.40 +
   28.41 +    @Override
   28.42 +    public boolean isApplicable() {
   28.43 +        return hierarchy.getM() != null && hierarchy.getN() != null;
   28.44 +    }
   28.45 +
   28.46 +    @Override
   28.47 +    public Integer run(T obj) {
   28.48 +        switch (profilingType) {
   28.49 +            case RETURN:
   28.50 +                T t = collectReturnType(obj);
   28.51 +                if (t.getClass() == TypeHierarchy.A.class) {
   28.52 +                    return inlinee(t);
   28.53 +                }
   28.54 +                return TypeHierarchy.TEMP;
   28.55 +            case ARGUMENTS:
   28.56 +                field = obj;
   28.57 +                if (field.getClass() == TypeHierarchy.A.class) {
   28.58 +                    return inlinee(field);
   28.59 +                }
   28.60 +                return TypeHierarchy.TEMP;
   28.61 +            case PARAMETERS:
   28.62 +                if (obj.getClass() == TypeHierarchy.A.class) {
   28.63 +                    return inlinee(obj);
   28.64 +                }
   28.65 +                return TypeHierarchy.TEMP;
   28.66 +        }
   28.67 +        throw new RuntimeException("Should not reach here");
   28.68 +    }
   28.69 +
   28.70 +    public int inlinee(T obj) {
   28.71 +        return obj.m();
   28.72 +    }
   28.73 +
   28.74 +    @Override
   28.75 +    public void check(Integer result, T orig) {
   28.76 +        if (orig.getClass() == TypeHierarchy.A.class) {
   28.77 +            Asserts.assertEquals(result, orig.m(),
   28.78 +                    "Results are not equal for TypeHierarchy.A.class");
   28.79 +        } else {
   28.80 +            Asserts.assertEquals(result, TypeHierarchy.TEMP, "Result differs from expected");
   28.81 +        }
   28.82 +    }
   28.83 +}
    29.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.2 +++ b/test/compiler/types/correctness/scenarios/ClassInstanceOf.java	Wed Apr 16 18:40:25 2014 -0400
    29.3 @@ -0,0 +1,74 @@
    29.4 +/*
    29.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    29.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    29.7 + *
    29.8 + * This code is free software; you can redistribute it and/or modify it
    29.9 + * under the terms of the GNU General Public License version 2 only, as
   29.10 + * published by the Free Software Foundation.
   29.11 + *
   29.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   29.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   29.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   29.15 + * version 2 for more details (a copy is included in the LICENSE file that
   29.16 + * accompanied this code).
   29.17 + *
   29.18 + * You should have received a copy of the GNU General Public License version
   29.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   29.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   29.21 + *
   29.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   29.23 + * or visit www.oracle.com if you need additional information or have any
   29.24 + * questions.
   29.25 + */
   29.26 +
   29.27 +package scenarios;
   29.28 +
   29.29 +import com.oracle.java.testlibrary.Asserts;
   29.30 +import hierarchies.TypeHierarchy;
   29.31 +
   29.32 +/**
   29.33 + * Tests instanceof
   29.34 + */
   29.35 +public class ClassInstanceOf<T extends TypeHierarchy.I> extends Scenario<T, Integer> {
   29.36 +    public ClassInstanceOf(ProfilingType profilingType,
   29.37 +                           TypeHierarchy<? extends T, ? extends T> hierarchy) {
   29.38 +        super("ClassInstanceOf", profilingType, hierarchy);
   29.39 +    }
   29.40 +
   29.41 +    @Override
   29.42 +    public Integer run(T obj) {
   29.43 +        switch (profilingType) {
   29.44 +            case RETURN:
   29.45 +                T t = collectReturnType(obj);
   29.46 +                if (t instanceof TypeHierarchy.A) {
   29.47 +                    return inlinee(t);
   29.48 +                }
   29.49 +                return TypeHierarchy.TEMP;
   29.50 +            case ARGUMENTS:
   29.51 +                field = obj;
   29.52 +                if (field instanceof TypeHierarchy.A) {
   29.53 +                    return inlinee(field);
   29.54 +                }
   29.55 +                return TypeHierarchy.TEMP;
   29.56 +            case PARAMETERS:
   29.57 +                if (obj instanceof TypeHierarchy.A) {
   29.58 +                    return inlinee(obj);
   29.59 +                }
   29.60 +                return TypeHierarchy.TEMP;
   29.61 +        }
   29.62 +        throw new RuntimeException("Should not reach here");
   29.63 +    }
   29.64 +
   29.65 +    public int inlinee(T obj) {
   29.66 +        return obj.m();
   29.67 +    }
   29.68 +
   29.69 +    @Override
   29.70 +    public void check(Integer result, T orig) {
   29.71 +        if (orig instanceof TypeHierarchy.A) {
   29.72 +            Asserts.assertEquals(result, orig.m(), "Results are not equal for TypeHierarchy.A");
   29.73 +        } else {
   29.74 +            Asserts.assertEquals(result, TypeHierarchy.TEMP, "Result differs from expected");
   29.75 +        }
   29.76 +    }
   29.77 +}
    30.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.2 +++ b/test/compiler/types/correctness/scenarios/ClassIsInstance.java	Wed Apr 16 18:40:25 2014 -0400
    30.3 @@ -0,0 +1,77 @@
    30.4 +/*
    30.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    30.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    30.7 + *
    30.8 + * This code is free software; you can redistribute it and/or modify it
    30.9 + * under the terms of the GNU General Public License version 2 only, as
   30.10 + * published by the Free Software Foundation.
   30.11 + *
   30.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   30.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   30.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   30.15 + * version 2 for more details (a copy is included in the LICENSE file that
   30.16 + * accompanied this code).
   30.17 + *
   30.18 + * You should have received a copy of the GNU General Public License version
   30.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   30.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   30.21 + *
   30.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   30.23 + * or visit www.oracle.com if you need additional information or have any
   30.24 + * questions.
   30.25 + */
   30.26 +
   30.27 +package scenarios;
   30.28 +
   30.29 +import com.oracle.java.testlibrary.Asserts;
   30.30 +import hierarchies.TypeHierarchy;
   30.31 +
   30.32 +/**
   30.33 + * Tests {@link Class#isInstance(Object)}
   30.34 + */
   30.35 +public class ClassIsInstance<T extends TypeHierarchy.I> extends Scenario<T, Integer> {
   30.36 +    private final Class<?> baseClass;
   30.37 +
   30.38 +    public ClassIsInstance(ProfilingType profilingType,
   30.39 +                           TypeHierarchy<? extends T, ? extends T> hierarchy) {
   30.40 +        super("ClassIsInstance", profilingType, hierarchy);
   30.41 +        this.baseClass = hierarchy.getClassM();
   30.42 +    }
   30.43 +
   30.44 +    @Override
   30.45 +    public Integer run(T obj) {
   30.46 +        switch (profilingType) {
   30.47 +            case RETURN:
   30.48 +                T t = collectReturnType(obj);
   30.49 +                if (baseClass.isInstance(t)) {
   30.50 +                    return inlinee(t);
   30.51 +                }
   30.52 +                return TypeHierarchy.TEMP;
   30.53 +            case ARGUMENTS:
   30.54 +                field = obj;
   30.55 +                if (baseClass.isInstance(field)) {
   30.56 +                    return inlinee(field);
   30.57 +                }
   30.58 +                return TypeHierarchy.TEMP;
   30.59 +            case PARAMETERS:
   30.60 +                if (baseClass.isInstance(obj)) {
   30.61 +                    return inlinee(obj);
   30.62 +                }
   30.63 +                return TypeHierarchy.TEMP;
   30.64 +        }
   30.65 +        throw new RuntimeException("Should not reach here");
   30.66 +    }
   30.67 +
   30.68 +    public int inlinee(T obj) {
   30.69 +        return obj.m();
   30.70 +    }
   30.71 +
   30.72 +    @Override
   30.73 +    public void check(Integer result, T orig) {
   30.74 +        if (baseClass.isInstance(orig)) {
   30.75 +            Asserts.assertEquals(result, orig.m(), "Results are not equal for base class");
   30.76 +        } else {
   30.77 +            Asserts.assertEquals(result, TypeHierarchy.TEMP, "Result differs from expected");
   30.78 +        }
   30.79 +    }
   30.80 +}
    31.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.2 +++ b/test/compiler/types/correctness/scenarios/ProfilingType.java	Wed Apr 16 18:40:25 2014 -0400
    31.3 @@ -0,0 +1,33 @@
    31.4 +/*
    31.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    31.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    31.7 + *
    31.8 + * This code is free software; you can redistribute it and/or modify it
    31.9 + * under the terms of the GNU General Public License version 2 only, as
   31.10 + * published by the Free Software Foundation.
   31.11 + *
   31.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   31.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   31.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   31.15 + * version 2 for more details (a copy is included in the LICENSE file that
   31.16 + * accompanied this code).
   31.17 + *
   31.18 + * You should have received a copy of the GNU General Public License version
   31.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   31.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   31.21 + *
   31.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   31.23 + * or visit www.oracle.com if you need additional information or have any
   31.24 + * questions.
   31.25 + */
   31.26 +
   31.27 +package scenarios;
   31.28 +
   31.29 +public enum ProfilingType {
   31.30 +    /** type profiling of return values of reference types from an invoke */
   31.31 +    RETURN,
   31.32 +    /** type profiling for reference parameters on method entries */
   31.33 +    PARAMETERS,
   31.34 +    /** type profiling for reference arguments at an invoke */
   31.35 +    ARGUMENTS,
   31.36 +}
    32.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.2 +++ b/test/compiler/types/correctness/scenarios/ReceiverAtInvokes.java	Wed Apr 16 18:40:25 2014 -0400
    32.3 @@ -0,0 +1,74 @@
    32.4 +/*
    32.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    32.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    32.7 + *
    32.8 + * This code is free software; you can redistribute it and/or modify it
    32.9 + * under the terms of the GNU General Public License version 2 only, as
   32.10 + * published by the Free Software Foundation.
   32.11 + *
   32.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   32.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   32.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   32.15 + * version 2 for more details (a copy is included in the LICENSE file that
   32.16 + * accompanied this code).
   32.17 + *
   32.18 + * You should have received a copy of the GNU General Public License version
   32.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   32.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   32.21 + *
   32.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   32.23 + * or visit www.oracle.com if you need additional information or have any
   32.24 + * questions.
   32.25 + */
   32.26 +
   32.27 +package scenarios;
   32.28 +
   32.29 +import com.oracle.java.testlibrary.Asserts;
   32.30 +import hierarchies.TypeHierarchy;
   32.31 +
   32.32 +/**
   32.33 + * Receiver at invokes profiling and speculation
   32.34 + *
   32.35 + * @param <T> parameter to be returned
   32.36 + */
   32.37 +public class ReceiverAtInvokes<T extends TypeHierarchy.I> extends Scenario<T, Integer> {
   32.38 +    public ReceiverAtInvokes(ProfilingType profilingType,
   32.39 +                             TypeHierarchy<? extends T, ? extends T> hierarchy) {
   32.40 +        super("ReceiverAtInvokes", profilingType, hierarchy);
   32.41 +    }
   32.42 +
   32.43 +    @Override
   32.44 +    public boolean isApplicable() {
   32.45 +        return hierarchy.getM() != null && hierarchy.getN() != null;
   32.46 +    }
   32.47 +
   32.48 +    /**
   32.49 +     * Receiver profiling
   32.50 +     *
   32.51 +     * @param obj is a profiled parameter for the test
   32.52 +     * @return parameter casted to the type R
   32.53 +     */
   32.54 +    @Override
   32.55 +    public Integer run(T obj) {
   32.56 +        switch (profilingType) {
   32.57 +            case RETURN:
   32.58 +                T t = collectReturnType(obj);
   32.59 +                return inlinee(t);
   32.60 +            case ARGUMENTS:
   32.61 +                field = obj;
   32.62 +                return inlinee(field);
   32.63 +            case PARAMETERS:
   32.64 +                return inlinee(obj);
   32.65 +        }
   32.66 +        throw new RuntimeException("Should not reach here");
   32.67 +    }
   32.68 +
   32.69 +    private Integer inlinee(T obj) {
   32.70 +        return obj.m(); // should be inlined
   32.71 +    }
   32.72 +
   32.73 +    @Override
   32.74 +    public void check(Integer result, T orig) {
   32.75 +        Asserts.assertEquals(result, orig.m(), "Results mismatch");
   32.76 +    }
   32.77 +}
    33.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    33.2 +++ b/test/compiler/types/correctness/scenarios/Scenario.java	Wed Apr 16 18:40:25 2014 -0400
    33.3 @@ -0,0 +1,108 @@
    33.4 +/*
    33.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    33.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    33.7 + *
    33.8 + * This code is free software; you can redistribute it and/or modify it
    33.9 + * under the terms of the GNU General Public License version 2 only, as
   33.10 + * published by the Free Software Foundation.
   33.11 + *
   33.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   33.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   33.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   33.15 + * version 2 for more details (a copy is included in the LICENSE file that
   33.16 + * accompanied this code).
   33.17 + *
   33.18 + * You should have received a copy of the GNU General Public License version
   33.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   33.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   33.21 + *
   33.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   33.23 + * or visit www.oracle.com if you need additional information or have any
   33.24 + * questions.
   33.25 + */
   33.26 +
   33.27 +package scenarios;
   33.28 +
   33.29 +import hierarchies.TypeHierarchy;
   33.30 +
   33.31 +/**
   33.32 + * Test scenario
   33.33 + *
   33.34 + * @param <T> parameter type
   33.35 + * @param <R> result type
   33.36 + */
   33.37 +public abstract class Scenario<T extends TypeHierarchy.I, R> {
   33.38 +
   33.39 +    private final String name;
   33.40 +    public final ProfilingType profilingType;
   33.41 +    public final TypeHierarchy <? extends T, ? extends T> hierarchy;
   33.42 +    protected volatile T field;
   33.43 +
   33.44 +    /**
   33.45 +     * Constructor
   33.46 +     *
   33.47 +     * @param name          scenario name
   33.48 +     * @param profilingType tested profiling type
   33.49 +     * @param hierarchy     type hierarchy
   33.50 +     */
   33.51 +    protected Scenario(String name, ProfilingType profilingType,
   33.52 +                       TypeHierarchy<? extends T, ? extends T> hierarchy) {
   33.53 +        this.profilingType = profilingType;
   33.54 +        this.name = name + " # " + profilingType.name();
   33.55 +        this.hierarchy = hierarchy;
   33.56 +    }
   33.57 +
   33.58 +    /**
   33.59 +     * Returns the object which should be used as a parameter
   33.60 +     * for the methods used for profile data
   33.61 +     *
   33.62 +     * @return profiled type object
   33.63 +     */
   33.64 +    public T getProfiled() {
   33.65 +        return hierarchy.getM();
   33.66 +    }
   33.67 +
   33.68 +    /**
   33.69 +     * Returns the object which makes a conflict for a profiled data
   33.70 +     * when passed instead of {@linkplain Scenario#getProfiled}
   33.71 +     *
   33.72 +     * @return incompatible to profiled object
   33.73 +     */
   33.74 +    public T getConflict() {
   33.75 +        return hierarchy.getN();
   33.76 +    }
   33.77 +
   33.78 +    /**
   33.79 +     * @return scenario name
   33.80 +     */
   33.81 +    public String getName() {
   33.82 +        return name;
   33.83 +    }
   33.84 +
   33.85 +    /** Is this scenario applicable for a hierarchy it was constructed with */
   33.86 +    public boolean isApplicable() {
   33.87 +        return true;
   33.88 +    }
   33.89 +
   33.90 +    /**
   33.91 +     * Runs test scenario
   33.92 +     *
   33.93 +     * @param t subject of the test
   33.94 +     * @return  result of the test invocation
   33.95 +     */
   33.96 +    public abstract R run(T t);
   33.97 +
   33.98 +    /** Used for a return type profiling */
   33.99 +    protected final T collectReturnType(T t) {
  33.100 +        return t;
  33.101 +    }
  33.102 +
  33.103 +    /**
  33.104 +     * Checks the result for R and T
  33.105 +     *
  33.106 +     * @param r result
  33.107 +     * @param t original
  33.108 +     * @throws java.lang.RuntimeException on result mismatch
  33.109 +     */
  33.110 +    public abstract void check(R r, T t);
  33.111 +}
    34.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    34.2 +++ b/test/runtime/ClassFile/UnsupportedClassFileVersion.java	Wed Apr 16 18:40:25 2014 -0400
    34.3 @@ -0,0 +1,69 @@
    34.4 +/*
    34.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    34.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    34.7 + *
    34.8 + * This code is free software; you can redistribute it and/or modify it
    34.9 + * under the terms of the GNU General Public License version 2 only, as
   34.10 + * published by the Free Software Foundation.
   34.11 + *
   34.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   34.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   34.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   34.15 + * version 2 for more details (a copy is included in the LICENSE file that
   34.16 + * accompanied this code).
   34.17 + *
   34.18 + * You should have received a copy of the GNU General Public License version
   34.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   34.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   34.21 + *
   34.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   34.23 + * or visit www.oracle.com if you need additional information or have any
   34.24 + * questions.
   34.25 + */
   34.26 +
   34.27 +/*
   34.28 + * @test
   34.29 + * @library /testlibrary
   34.30 + * @compile -XDignore.symbol.file UnsupportedClassFileVersion.java
   34.31 + * @run main UnsupportedClassFileVersion
   34.32 + */
   34.33 +
   34.34 +import java.io.File;
   34.35 +import java.io.FileOutputStream;
   34.36 +import jdk.internal.org.objectweb.asm.ClassWriter;
   34.37 +import jdk.internal.org.objectweb.asm.MethodVisitor;
   34.38 +import jdk.internal.org.objectweb.asm.Opcodes;
   34.39 +import com.oracle.java.testlibrary.*;
   34.40 +
   34.41 +public class UnsupportedClassFileVersion implements Opcodes {
   34.42 +    public static void main(String... args) throws Exception {
   34.43 +        writeClassFile();
   34.44 +        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, "-cp", ".",  "ClassFile");
   34.45 +        OutputAnalyzer output = new OutputAnalyzer(pb.start());
   34.46 +        output.shouldContain("ClassFile has been compiled by a more recent version of the " +
   34.47 +                            "Java Runtime (class file version 99.0), this version of " +
   34.48 +                            "the Java Runtime only recognizes class file versions up to " +
   34.49 +                            System.getProperty("java.class.version"));
   34.50 +
   34.51 +        output.shouldHaveExitValue(1);
   34.52 +    }
   34.53 +
   34.54 +    public static void writeClassFile() throws Exception {
   34.55 +        ClassWriter cw = new ClassWriter(0);
   34.56 +        MethodVisitor mv;
   34.57 +
   34.58 +        cw.visit(99, ACC_PUBLIC + ACC_SUPER, "ClassFile", null, "java/lang/Object", null);
   34.59 +        mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
   34.60 +        mv.visitCode();
   34.61 +        mv.visitVarInsn(ALOAD, 0);
   34.62 +        mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
   34.63 +        mv.visitInsn(RETURN);
   34.64 +        mv.visitMaxs(1, 1);
   34.65 +        mv.visitEnd();
   34.66 +        cw.visitEnd();
   34.67 +
   34.68 +        try (FileOutputStream fos = new FileOutputStream(new File("ClassFile.class"))) {
   34.69 +             fos.write(cw.toByteArray());
   34.70 +        }
   34.71 +    }
   34.72 +}
    35.1 --- a/test/testlibrary/com/oracle/java/testlibrary/ProcessTools.java	Mon Mar 03 13:58:52 2014 -0500
    35.2 +++ b/test/testlibrary/com/oracle/java/testlibrary/ProcessTools.java	Wed Apr 16 18:40:25 2014 -0400
    35.3 @@ -142,11 +142,23 @@
    35.4     * with any platform specific arguments prepended
    35.5     */
    35.6    public static ProcessBuilder createJavaProcessBuilder(String... command) throws Exception {
    35.7 +    return createJavaProcessBuilder(false, command);
    35.8 +  }
    35.9 +
   35.10 +  public static ProcessBuilder createJavaProcessBuilder(boolean addTestVmOptions, String... command) throws Exception {
   35.11      String javapath = JDKToolFinder.getJDKTool("java");
   35.12  
   35.13      ArrayList<String> args = new ArrayList<>();
   35.14      args.add(javapath);
   35.15      Collections.addAll(args, getPlatformSpecificVMArgs());
   35.16 +
   35.17 +    if (addTestVmOptions) {
   35.18 +      String vmopts = System.getProperty("test.vm.opts");
   35.19 +      if (vmopts != null && vmopts.length() > 0) {
   35.20 +        Collections.addAll(args, vmopts.split("\\s"));
   35.21 +      }
   35.22 +    }
   35.23 +
   35.24      Collections.addAll(args, command);
   35.25  
   35.26      // Reporting
   35.27 @@ -234,5 +246,4 @@
   35.28      }
   35.29      return cmd.toString().trim();
   35.30    }
   35.31 -
   35.32  }

mercurial