Merge

Thu, 08 Jun 2017 13:40:41 -0700

author
asaha
date
Thu, 08 Jun 2017 13:40:41 -0700
changeset 8813
0fbba64c6b6e
parent 8812
02d5e7b64b28
parent 8803
c37b56787d13
child 8814
596b584c68b7

Merge

.hgtags file | annotate | diff | comparison | revisions
     1.1 --- a/.hgtags	Tue Dec 13 12:51:17 2016 -0800
     1.2 +++ b/.hgtags	Thu Jun 08 13:40:41 2017 -0700
     1.3 @@ -930,11 +930,44 @@
     1.4  c2c4db2a42a215c98a4f027edb8bbb00dd62d9b9 jdk8u112-b14
     1.5  b28d012a24cab8f4ceeee0c9d3252969757423ed jdk8u112-b15
     1.6  e134dc1879b72124e478be01680b0646a2fbf585 jdk8u112-b16
     1.7 +87440ed4e1de7753a436f957d35555d8b4e26f1d jdk8u112-b31
     1.8  3b0e5f01891f5ebbf67797b1aae786196f1bb4f6 jdk8u121-b00
     1.9  251a2493b1857f2ff4f11eab2dfd8b2fe8ed441b jdk8u121-b01
    1.10  70c4a50f576a01ec975d0a02b3642ee33db39ed8 jdk8u121-b02
    1.11  fa3bb4153a28b45a7a80cbf1058979b8f1c8b104 jdk8u121-b03
    1.12  35cff8508ca15dc18c598501cab160aee7220d44 jdk8u121-b04
    1.13 +f71447f104ce7b018a08bf1cf385438525744d13 jdk8u121-b05
    1.14 +49a2fc91c46f3d73aac7dbd420a4a007fe453ef8 jdk8u121-b06
    1.15 +f31c7533cfcb55acfb8dc5b31779d3a64708f5ce jdk8u121-b07
    1.16 +02a3d0dcbeddd8507d9a4b1f5a9f83aca75e5acb jdk8u121-b08
    1.17 +8cae1bdbd73cb1a84afad07a8e18467f56560bc4 jdk8u121-b09
    1.18 +f26f6895c9dfb32dfb4c228d69b371d8ab118536 jdk8u121-b10
    1.19 +11f91811e4d7e5ddfaf938dcf386ec8fe5bf7b7c jdk8u121-b11
    1.20 +b132b08b28bf23a26329928cf6b4ffda5857f4d3 jdk8u121-b12
    1.21 +90f94521c3515e5f27af0ab9b31d036e88bb322a jdk8u121-b13
    1.22  c0a1ba0df20fda10ddb8599e888eb56ad98b3874 jdk8u131-b00
    1.23 +0b85ccd6240991e1a501602ff5addec6b88ae0af jdk8u131-b01
    1.24 +ef90c721a4e59b01ca36f25619010a1afe9ed4d5 jdk8u131-b02
    1.25 +0ca47d0811b01ecf8651b6045a1e33a4a9bed0ee jdk8u131-b03
    1.26 +dab1d597165207e14b6886b1823c1e990bc776a3 jdk8u131-b04
    1.27 +c965fc1aa840a0903709ad69aa0e2100330ccd84 jdk8u131-b05
    1.28 +6e4cfbc7534f83902692132efb61683528c04a59 jdk8u131-b06
    1.29 +5b3cb4fbdbc7bdeb7c78a8703c3084ce068f6691 jdk8u131-b07
    1.30 +db221c0a423e776bec5c3198d11d3f26827bd786 jdk8u131-b08
    1.31 +56e71d16083904ceddfdd1d66312582a42781646 jdk8u131-b09
    1.32 +1da23ae49386608550596502d90a381ee6c1dfaa jdk8u131-b10
    1.33 +829ea9b92cda9545652f1b309f56c57383024ebb jdk8u131-b11
    1.34  692bc6b674dcab72453de08ee9da0856a7e41c0f jdk8u141-b00
    1.35 +0cee0db0180b64655751e7058c251103f9660f85 jdk8u141-b01
    1.36 +82435799636c8b50a090aebcb5af49946afa7bb5 jdk8u141-b02
    1.37 +678f11cc769eb79d35d49a94c769304df67a9cef jdk8u141-b03
    1.38 +62b0b4a31b44e8b159bff106c04ecfabc9d78d9b jdk8u141-b04
    1.39 +53a48dc8e4418ed422c69361193add798cb4ed55 jdk8u141-b05
    1.40 +4b7067065b0ad08c41a6334b44877319cbb2de54 jdk8u141-b06
    1.41 +42f196fd7c589e439c4e6d86b7d845ff024cfe45 jdk8u141-b07
    1.42 +37ba410ffd431c76961255b87398f6ace7b6794f jdk8u141-b08
    1.43 +b23c5879a33cf2c2e7c3e2cdfb0285bb7e64198e jdk8u141-b09
    1.44 +1a3f8a55df45dd79cb566d172e925faa464534f0 jdk8u141-b10
    1.45 +de803a292be4add77fd8a1e034481f0692c89f95 jdk8u141-b11
    1.46 +d6e7c7d2c6f69906b4cb643a6813eccba0de988f jdk8u141-b12
    1.47  2d5100bddeb80cf767485b787fc3051311e3d7b9 jdk8u151-b00
     2.1 --- a/THIRD_PARTY_README	Tue Dec 13 12:51:17 2016 -0800
     2.2 +++ b/THIRD_PARTY_README	Thu Jun 08 13:40:41 2017 -0700
     2.3 @@ -3318,12 +3318,12 @@
     2.4  
     2.5  -------------------------------------------------------------------------------
     2.6  
     2.7 -%% This notice is provided with respect to zlib v1.2.8, which may be included 
     2.8 +%% This notice is provided with respect to zlib v1.2.11, which may be included 
     2.9  with JRE 8, JDK 8, and OpenJDK 8.
    2.10  
    2.11  --- begin of LICENSE ---
    2.12  
    2.13 -  version 1.2.8, April 28th, 2013
    2.14 +  version 1.2.11, January 15th, 2017
    2.15  
    2.16    Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler
    2.17  
     3.1 --- a/src/cpu/ppc/vm/ppc.ad	Tue Dec 13 12:51:17 2016 -0800
     3.2 +++ b/src/cpu/ppc/vm/ppc.ad	Thu Jun 08 13:40:41 2017 -0700
     3.3 @@ -10230,6 +10230,29 @@
     3.4    ins_pipe(pipe_class_compare);
     3.5  %}
     3.6  
     3.7 +// Added CmpUL for LoopPredicate.
     3.8 +instruct cmpUL_reg_reg(flagsReg crx, iRegLsrc src1, iRegLsrc src2) %{
     3.9 +  match(Set crx (CmpUL src1 src2));
    3.10 +  format %{ "CMPLD   $crx, $src1, $src2" %}
    3.11 +  size(4);
    3.12 +  ins_encode %{
    3.13 +    // TODO: PPC port $archOpcode(ppc64Opcode_cmpl);
    3.14 +    __ cmpld($crx$$CondRegister, $src1$$Register, $src2$$Register);
    3.15 +  %}
    3.16 +  ins_pipe(pipe_class_compare);
    3.17 +%}
    3.18 +
    3.19 +instruct cmpUL_reg_imm16(flagsReg crx, iRegLsrc src1, uimmL16 src2) %{
    3.20 +  match(Set crx (CmpUL src1 src2));
    3.21 +  format %{ "CMPLDI  $crx, $src1, $src2" %}
    3.22 +  size(4);
    3.23 +  ins_encode %{
    3.24 +    // TODO: PPC port $archOpcode(ppc64Opcode_cmpli);
    3.25 +    __ cmpldi($crx$$CondRegister, $src1$$Register, $src2$$constant);
    3.26 +  %}
    3.27 +  ins_pipe(pipe_class_compare);
    3.28 +%}
    3.29 +
    3.30  instruct testL_reg_reg(flagsRegCR0 cr0, iRegLsrc src1, iRegLsrc src2, immL_0 zero) %{
    3.31    match(Set cr0 (CmpL (AndL src1 src2) zero));
    3.32    // r0 is killed
     4.1 --- a/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp	Tue Dec 13 12:51:17 2016 -0800
     4.2 +++ b/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp	Thu Jun 08 13:40:41 2017 -0700
     4.3 @@ -1023,11 +1023,16 @@
     4.4    obj.load_item();
     4.5    LIR_Opr out_reg = rlock_result(x);
     4.6    CodeStub* stub;
     4.7 -  CodeEmitInfo* info_for_exception = state_for(x);
     4.8 +  CodeEmitInfo* info_for_exception =
     4.9 +      (x->needs_exception_state() ? state_for(x) :
    4.10 +                                    state_for(x, x->state_before(), true /*ignore_xhandler*/));
    4.11  
    4.12    if (x->is_incompatible_class_change_check()) {
    4.13      assert(patching_info == NULL, "can't patch this");
    4.14      stub = new SimpleExceptionStub(Runtime1::throw_incompatible_class_change_error_id, LIR_OprFact::illegalOpr, info_for_exception);
    4.15 +  } else if (x->is_invokespecial_receiver_check()) {
    4.16 +    assert(patching_info == NULL, "can't patch this");
    4.17 +    stub = new DeoptimizeStub(info_for_exception);
    4.18    } else {
    4.19      stub = new SimpleExceptionStub(Runtime1::throw_class_cast_exception_id, obj.result(), info_for_exception);
    4.20    }
     5.1 --- a/src/cpu/sparc/vm/sparc.ad	Tue Dec 13 12:51:17 2016 -0800
     5.2 +++ b/src/cpu/sparc/vm/sparc.ad	Thu Jun 08 13:40:41 2017 -0700
     5.3 @@ -3458,6 +3458,16 @@
     5.4    interface(CONST_INTER);
     5.5  %}
     5.6  
     5.7 +// Unsigned Long Immediate: 12-bit (non-negative that fits in simm13)
     5.8 +operand immUL12() %{
     5.9 +  predicate((0 <= n->get_long()) && (n->get_long() == (int)n->get_long()) && Assembler::is_simm13((int)n->get_long()));
    5.10 +  match(ConL);
    5.11 +  op_cost(0);
    5.12 +
    5.13 +  format %{ %}
    5.14 +  interface(CONST_INTER);
    5.15 +%}
    5.16 +
    5.17  // Int Immediate non-negative
    5.18  operand immU31()
    5.19  %{
    5.20 @@ -4083,6 +4093,15 @@
    5.21    interface(REG_INTER);
    5.22  %}
    5.23  
    5.24 +// Condition Code Register, unsigned long comparisons.
    5.25 +operand flagsRegUL() %{
    5.26 +  constraint(ALLOC_IN_RC(int_flags));
    5.27 +  match(RegFlags);
    5.28 +
    5.29 +  format %{ "xcc_UL" %}
    5.30 +  interface(REG_INTER);
    5.31 +%}
    5.32 +
    5.33  // Condition Code Register, floating comparisons, unordered same as "less".
    5.34  operand flagsRegF() %{
    5.35    constraint(ALLOC_IN_RC(float_flags));
    5.36 @@ -8962,6 +8981,17 @@
    5.37    ins_pipe(ialu_cconly_reg_reg);
    5.38  %}
    5.39  
    5.40 +instruct compUL_iReg(flagsRegUL xcc, iRegL op1, iRegL op2) %{
    5.41 +  match(Set xcc (CmpUL op1 op2));
    5.42 +  effect(DEF xcc, USE op1, USE op2);
    5.43 +
    5.44 +  size(4);
    5.45 +  format %{ "CMP    $op1,$op2\t! unsigned long" %}
    5.46 +  opcode(Assembler::subcc_op3, Assembler::arith_op);
    5.47 +  ins_encode(form3_rs1_rs2_rd(op1, op2, R_G0));
    5.48 +  ins_pipe(ialu_cconly_reg_reg);
    5.49 +%}
    5.50 +
    5.51  instruct compI_iReg_imm13(flagsReg icc, iRegI op1, immI13 op2) %{
    5.52    match(Set icc (CmpI op1 op2));
    5.53    effect( DEF icc, USE op1 );
    5.54 @@ -9048,6 +9078,17 @@
    5.55    ins_pipe(ialu_cconly_reg_imm);
    5.56  %}
    5.57  
    5.58 +instruct compUL_iReg_imm13(flagsRegUL xcc, iRegL op1, immUL12 op2) %{
    5.59 +  match(Set xcc (CmpUL op1 op2));
    5.60 +  effect(DEF xcc, USE op1, USE op2);
    5.61 +
    5.62 +  size(4);
    5.63 +  format %{ "CMP    $op1,$op2\t! unsigned long" %}
    5.64 +  opcode(Assembler::subcc_op3, Assembler::arith_op);
    5.65 +  ins_encode(form3_rs1_simm13_rd(op1, op2, R_G0));
    5.66 +  ins_pipe(ialu_cconly_reg_imm);
    5.67 +%}
    5.68 +
    5.69  // Compare Pointers
    5.70  instruct compP_iRegP(flagsRegP pcc, iRegP op1, iRegP op2 ) %{
    5.71    match(Set pcc (CmpP op1 op2));
    5.72 @@ -9421,6 +9462,44 @@
    5.73    ins_pipe(cmp_br_reg_imm);
    5.74  %}
    5.75  
    5.76 +instruct cmpUL_reg_branch(cmpOpU cmp, iRegL op1, iRegL op2, label labl, flagsRegUL xcc) %{
    5.77 +  match(If cmp (CmpUL op1 op2));
    5.78 +  effect(USE labl, KILL xcc);
    5.79 +
    5.80 +  size(12);
    5.81 +  ins_cost(BRANCH_COST);
    5.82 +  format %{ "CMP    $op1,$op2\t! unsigned long\n\t"
    5.83 +            "BP$cmp   $labl" %}
    5.84 +  ins_encode %{
    5.85 +    Label* L = $labl$$label;
    5.86 +    Assembler::Predict predict_taken =
    5.87 +      cbuf.is_backward_branch(*L) ? Assembler::pt : Assembler::pn;
    5.88 +    __ cmp($op1$$Register, $op2$$Register);
    5.89 +    __ bp((Assembler::Condition)($cmp$$cmpcode), false, Assembler::xcc, predict_taken, *L);
    5.90 +    __ delayed()->nop();
    5.91 +  %}
    5.92 +  ins_pipe(cmp_br_reg_reg);
    5.93 +%}
    5.94 +
    5.95 +instruct cmpUL_imm_branch(cmpOpU cmp, iRegL op1, immL5 op2, label labl, flagsRegUL xcc) %{
    5.96 +  match(If cmp (CmpUL op1 op2));
    5.97 +  effect(USE labl, KILL xcc);
    5.98 +
    5.99 +  size(12);
   5.100 +  ins_cost(BRANCH_COST);
   5.101 +  format %{ "CMP    $op1,$op2\t! unsigned long\n\t"
   5.102 +            "BP$cmp   $labl" %}
   5.103 +  ins_encode %{
   5.104 +    Label* L = $labl$$label;
   5.105 +    Assembler::Predict predict_taken =
   5.106 +      cbuf.is_backward_branch(*L) ? Assembler::pt : Assembler::pn;
   5.107 +    __ cmp($op1$$Register, $op2$$constant);
   5.108 +    __ bp((Assembler::Condition)($cmp$$cmpcode), false, Assembler::xcc, predict_taken, *L);
   5.109 +    __ delayed()->nop();
   5.110 +  %}
   5.111 +  ins_pipe(cmp_br_reg_imm);
   5.112 +%}
   5.113 +
   5.114  instruct cmpL_reg_branch(cmpOp cmp, iRegL op1, iRegL op2, label labl, flagsRegL xcc) %{
   5.115    match(If cmp (CmpL op1 op2));
   5.116    effect(USE labl, KILL xcc);
   5.117 @@ -9649,6 +9728,42 @@
   5.118    ins_pipe(cbcond_reg_imm);
   5.119  %}
   5.120  
   5.121 +instruct cmpUL_reg_branch_short(cmpOpU cmp, iRegL op1, iRegL op2, label labl, flagsRegUL xcc) %{
   5.122 +  match(If cmp (CmpUL op1 op2));
   5.123 +  predicate(UseCBCond);
   5.124 +  effect(USE labl, KILL xcc);
   5.125 +
   5.126 +  size(4);
   5.127 +  ins_cost(BRANCH_COST);
   5.128 +  format %{ "CXB$cmp  $op1,$op2,$labl\t! unsigned long" %}
   5.129 +  ins_encode %{
   5.130 +    Label* L = $labl$$label;
   5.131 +    assert(__ use_cbcond(*L), "back to back cbcond");
   5.132 +    __ cbcond((Assembler::Condition)($cmp$$cmpcode), Assembler::xcc, $op1$$Register, $op2$$Register, *L);
   5.133 +  %}
   5.134 +  ins_short_branch(1);
   5.135 +  ins_avoid_back_to_back(AVOID_BEFORE_AND_AFTER);
   5.136 +  ins_pipe(cbcond_reg_reg);
   5.137 +%}
   5.138 +
   5.139 +instruct cmpUL_imm_branch_short(cmpOpU cmp, iRegL op1, immL5 op2, label labl, flagsRegUL xcc) %{
   5.140 +  match(If cmp (CmpUL op1 op2));
   5.141 +  predicate(UseCBCond);
   5.142 +  effect(USE labl, KILL xcc);
   5.143 +
   5.144 +  size(4);
   5.145 +  ins_cost(BRANCH_COST);
   5.146 +  format %{ "CXB$cmp  $op1,$op2,$labl\t! unsigned long" %}
   5.147 +  ins_encode %{
   5.148 +    Label* L = $labl$$label;
   5.149 +    assert(__ use_cbcond(*L), "back to back cbcond");
   5.150 +    __ cbcond((Assembler::Condition)($cmp$$cmpcode), Assembler::xcc, $op1$$Register, $op2$$constant, *L);
   5.151 +  %}
   5.152 +  ins_short_branch(1);
   5.153 +  ins_avoid_back_to_back(AVOID_BEFORE_AND_AFTER);
   5.154 +  ins_pipe(cbcond_reg_imm);
   5.155 +%}
   5.156 +
   5.157  instruct cmpL_reg_branch_short(cmpOp cmp, iRegL op1, iRegL op2, label labl, flagsRegL xcc) %{
   5.158    match(If cmp (CmpL op1 op2));
   5.159    predicate(UseCBCond);
   5.160 @@ -9887,6 +10002,25 @@
   5.161    ins_pipe(br_cc);
   5.162  %}
   5.163  
   5.164 +instruct branchConU_long(cmpOpU cmp, flagsRegUL xcc, label labl) %{
   5.165 +  match(If cmp xcc);
   5.166 +  effect(USE labl);
   5.167 +
   5.168 +  size(8);
   5.169 +  ins_cost(BRANCH_COST);
   5.170 +  format %{ "BP$cmp   $xcc,$labl" %}
   5.171 +  ins_encode %{
   5.172 +    Label* L = $labl$$label;
   5.173 +    Assembler::Predict predict_taken =
   5.174 +      cbuf.is_backward_branch(*L) ? Assembler::pt : Assembler::pn;
   5.175 +
   5.176 +    __ bp((Assembler::Condition)($cmp$$cmpcode), false, Assembler::xcc, predict_taken, *L);
   5.177 +    __ delayed()->nop();
   5.178 +  %}
   5.179 +  ins_avoid_back_to_back(AVOID_BEFORE);
   5.180 +  ins_pipe(br_cc);
   5.181 +%}
   5.182 +
   5.183  // Manifest a CmpL3 result in an integer register.  Very painful.
   5.184  // This is the test to avoid.
   5.185  instruct cmpL3_reg_reg(iRegI dst, iRegL src1, iRegL src2, flagsReg ccr ) %{
     6.1 --- a/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp	Tue Dec 13 12:51:17 2016 -0800
     6.2 +++ b/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp	Thu Jun 08 13:40:41 2017 -0700
     6.3 @@ -1228,12 +1228,17 @@
     6.4    obj.load_item();
     6.5  
     6.6    // info for exceptions
     6.7 -  CodeEmitInfo* info_for_exception = state_for(x);
     6.8 +  CodeEmitInfo* info_for_exception =
     6.9 +      (x->needs_exception_state() ? state_for(x) :
    6.10 +                                    state_for(x, x->state_before(), true /*ignore_xhandler*/));
    6.11  
    6.12    CodeStub* stub;
    6.13    if (x->is_incompatible_class_change_check()) {
    6.14      assert(patching_info == NULL, "can't patch this");
    6.15      stub = new SimpleExceptionStub(Runtime1::throw_incompatible_class_change_error_id, LIR_OprFact::illegalOpr, info_for_exception);
    6.16 +  } else if (x->is_invokespecial_receiver_check()) {
    6.17 +    assert(patching_info == NULL, "can't patch this");
    6.18 +    stub = new DeoptimizeStub(info_for_exception);
    6.19    } else {
    6.20      stub = new SimpleExceptionStub(Runtime1::throw_class_cast_exception_id, obj.result(), info_for_exception);
    6.21    }
     7.1 --- a/src/cpu/x86/vm/x86_32.ad	Tue Dec 13 12:51:17 2016 -0800
     7.2 +++ b/src/cpu/x86/vm/x86_32.ad	Thu Jun 08 13:40:41 2017 -0700
     7.3 @@ -3948,6 +3948,26 @@
     7.4    interface(REG_INTER);
     7.5  %}
     7.6  
     7.7 +// Condition Code Register used by unsigned long compare
     7.8 +operand flagsReg_ulong_LTGE() %{
     7.9 +  constraint(ALLOC_IN_RC(int_flags));
    7.10 +  match(RegFlags);
    7.11 +  format %{ "FLAGS_U_LTGE" %}
    7.12 +  interface(REG_INTER);
    7.13 +%}
    7.14 +operand flagsReg_ulong_EQNE() %{
    7.15 +  constraint(ALLOC_IN_RC(int_flags));
    7.16 +  match(RegFlags);
    7.17 +  format %{ "FLAGS_U_EQNE" %}
    7.18 +  interface(REG_INTER);
    7.19 +%}
    7.20 +operand flagsReg_ulong_LEGT() %{
    7.21 +  constraint(ALLOC_IN_RC(int_flags));
    7.22 +  match(RegFlags);
    7.23 +  format %{ "FLAGS_U_LEGT" %}
    7.24 +  interface(REG_INTER);
    7.25 +%}
    7.26 +
    7.27  // Float register operands
    7.28  operand regDPR() %{
    7.29    predicate( UseSSE < 2 );
    7.30 @@ -4473,7 +4493,7 @@
    7.31    %}
    7.32  %}
    7.33  
    7.34 -// Comparision Code used in long compares
    7.35 +// Comparison Code used in long compares
    7.36  operand cmpOp_commute() %{
    7.37    match(Bool);
    7.38  
    7.39 @@ -4490,6 +4510,23 @@
    7.40    %}
    7.41  %}
    7.42  
    7.43 +// Comparison Code used in unsigned long compares
    7.44 +operand cmpOpU_commute() %{
    7.45 +  match(Bool);
    7.46 +
    7.47 +  format %{ "" %}
    7.48 +  interface(COND_INTER) %{
    7.49 +    equal(0x4, "e");
    7.50 +    not_equal(0x5, "ne");
    7.51 +    less(0x7, "nbe");
    7.52 +    greater_equal(0x6, "be");
    7.53 +    less_equal(0x3, "nb");
    7.54 +    greater(0x2, "b");
    7.55 +    overflow(0x0, "o");
    7.56 +    no_overflow(0x1, "no");
    7.57 +  %}
    7.58 +%}
    7.59 +
    7.60  //----------OPERAND CLASSES----------------------------------------------------
    7.61  // Operand Classes are groups of operands that are used as to simplify
    7.62  // instruction definitions by not requiring the AD writer to specify separate
    7.63 @@ -12382,6 +12419,44 @@
    7.64    %}
    7.65  %}
    7.66  
    7.67 +//======
    7.68 +// Manifest a CmpUL result in the normal flags.  Only good for LT or GE
    7.69 +// compares.  Can be used for LE or GT compares by reversing arguments.
    7.70 +// NOT GOOD FOR EQ/NE tests.
    7.71 +instruct cmpUL_zero_flags_LTGE(flagsReg_ulong_LTGE flags, eRegL src, immL0 zero) %{
    7.72 +  match(Set flags (CmpUL src zero));
    7.73 +  ins_cost(100);
    7.74 +  format %{ "TEST   $src.hi,$src.hi" %}
    7.75 +  opcode(0x85);
    7.76 +  ins_encode(OpcP, RegReg_Hi2(src, src));
    7.77 +  ins_pipe(ialu_cr_reg_reg);
    7.78 +%}
    7.79 +
    7.80 +// Manifest a CmpUL result in the normal flags.  Only good for LT or GE
    7.81 +// compares.  Can be used for LE or GT compares by reversing arguments.
    7.82 +// NOT GOOD FOR EQ/NE tests.
    7.83 +instruct cmpUL_reg_flags_LTGE(flagsReg_ulong_LTGE flags, eRegL src1, eRegL src2, rRegI tmp) %{
    7.84 +  match(Set flags (CmpUL src1 src2));
    7.85 +  effect(TEMP tmp);
    7.86 +  ins_cost(300);
    7.87 +  format %{ "CMP    $src1.lo,$src2.lo\t! Unsigned long compare; set flags for low bits\n\t"
    7.88 +            "MOV    $tmp,$src1.hi\n\t"
    7.89 +            "SBB    $tmp,$src2.hi\t! Compute flags for unsigned long compare" %}
    7.90 +  ins_encode(long_cmp_flags2(src1, src2, tmp));
    7.91 +  ins_pipe(ialu_cr_reg_reg);
    7.92 +%}
    7.93 +
    7.94 +// Unsigned long compares reg < zero/req OR reg >= zero/req.
    7.95 +// Just a wrapper for a normal branch, plus the predicate test.
    7.96 +instruct cmpUL_LTGE(cmpOpU cmp, flagsReg_ulong_LTGE flags, label labl) %{
    7.97 +  match(If cmp flags);
    7.98 +  effect(USE labl);
    7.99 +  predicate(_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::lt || _kids[0]->_leaf->as_Bool()->_test._test == BoolTest::ge);
   7.100 +  expand %{
   7.101 +    jmpCon(cmp, flags, labl);    // JLT or JGE...
   7.102 +  %}
   7.103 +%}
   7.104 +
   7.105  // Compare 2 longs and CMOVE longs.
   7.106  instruct cmovLL_reg_LTGE(cmpOp cmp, flagsReg_long_LTGE flags, eRegL dst, eRegL src) %{
   7.107    match(Set dst (CMoveL (Binary cmp flags) (Binary dst src)));
   7.108 @@ -12510,6 +12585,41 @@
   7.109    %}
   7.110  %}
   7.111  
   7.112 +//======
   7.113 +// Manifest a CmpUL result in the normal flags.  Only good for EQ/NE compares.
   7.114 +instruct cmpUL_zero_flags_EQNE(flagsReg_ulong_EQNE flags, eRegL src, immL0 zero, rRegI tmp) %{
   7.115 +  match(Set flags (CmpUL src zero));
   7.116 +  effect(TEMP tmp);
   7.117 +  ins_cost(200);
   7.118 +  format %{ "MOV    $tmp,$src.lo\n\t"
   7.119 +            "OR     $tmp,$src.hi\t! Unsigned long is EQ/NE 0?" %}
   7.120 +  ins_encode(long_cmp_flags0(src, tmp));
   7.121 +  ins_pipe(ialu_reg_reg_long);
   7.122 +%}
   7.123 +
   7.124 +// Manifest a CmpUL result in the normal flags.  Only good for EQ/NE compares.
   7.125 +instruct cmpUL_reg_flags_EQNE(flagsReg_ulong_EQNE flags, eRegL src1, eRegL src2) %{
   7.126 +  match(Set flags (CmpUL src1 src2));
   7.127 +  ins_cost(200+300);
   7.128 +  format %{ "CMP    $src1.lo,$src2.lo\t! Unsigned long compare; set flags for low bits\n\t"
   7.129 +            "JNE,s  skip\n\t"
   7.130 +            "CMP    $src1.hi,$src2.hi\n\t"
   7.131 +     "skip:\t" %}
   7.132 +  ins_encode(long_cmp_flags1(src1, src2));
   7.133 +  ins_pipe(ialu_cr_reg_reg);
   7.134 +%}
   7.135 +
   7.136 +// Unsigned long compare reg == zero/reg OR reg != zero/reg
   7.137 +// Just a wrapper for a normal branch, plus the predicate test.
   7.138 +instruct cmpUL_EQNE(cmpOpU cmp, flagsReg_ulong_EQNE flags, label labl) %{
   7.139 +  match(If cmp flags);
   7.140 +  effect(USE labl);
   7.141 +  predicate(_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::eq || _kids[0]->_leaf->as_Bool()->_test._test == BoolTest::ne);
   7.142 +  expand %{
   7.143 +    jmpCon(cmp, flags, labl);    // JEQ or JNE...
   7.144 +  %}
   7.145 +%}
   7.146 +
   7.147  // Compare 2 longs and CMOVE longs.
   7.148  instruct cmovLL_reg_EQNE(cmpOp cmp, flagsReg_long_EQNE flags, eRegL dst, eRegL src) %{
   7.149    match(Set dst (CMoveL (Binary cmp flags) (Binary dst src)));
   7.150 @@ -12643,6 +12753,46 @@
   7.151    %}
   7.152  %}
   7.153  
   7.154 +//======
   7.155 +// Manifest a CmpUL result in the normal flags.  Only good for LE or GT compares.
   7.156 +// Same as cmpUL_reg_flags_LEGT except must negate src
   7.157 +instruct cmpUL_zero_flags_LEGT(flagsReg_ulong_LEGT flags, eRegL src, immL0 zero, rRegI tmp) %{
   7.158 +  match(Set flags (CmpUL src zero));
   7.159 +  effect(TEMP tmp);
   7.160 +  ins_cost(300);
   7.161 +  format %{ "XOR    $tmp,$tmp\t# Unsigned long compare for -$src < 0, use commuted test\n\t"
   7.162 +            "CMP    $tmp,$src.lo\n\t"
   7.163 +            "SBB    $tmp,$src.hi\n\t" %}
   7.164 +  ins_encode(long_cmp_flags3(src, tmp));
   7.165 +  ins_pipe(ialu_reg_reg_long);
   7.166 +%}
   7.167 +
   7.168 +// Manifest a CmpUL result in the normal flags.  Only good for LE or GT compares.
   7.169 +// Same as cmpUL_reg_flags_LTGE except operands swapped.  Swapping operands
   7.170 +// requires a commuted test to get the same result.
   7.171 +instruct cmpUL_reg_flags_LEGT(flagsReg_ulong_LEGT flags, eRegL src1, eRegL src2, rRegI tmp) %{
   7.172 +  match(Set flags (CmpUL src1 src2));
   7.173 +  effect(TEMP tmp);
   7.174 +  ins_cost(300);
   7.175 +  format %{ "CMP    $src2.lo,$src1.lo\t! Unsigned long compare, swapped operands, use with commuted test\n\t"
   7.176 +            "MOV    $tmp,$src2.hi\n\t"
   7.177 +            "SBB    $tmp,$src1.hi\t! Compute flags for unsigned long compare" %}
   7.178 +  ins_encode(long_cmp_flags2( src2, src1, tmp));
   7.179 +  ins_pipe(ialu_cr_reg_reg);
   7.180 +%}
   7.181 +
   7.182 +// Unsigned long compares reg < zero/req OR reg >= zero/req.
   7.183 +// Just a wrapper for a normal branch, plus the predicate test
   7.184 +instruct cmpUL_LEGT(cmpOpU_commute cmp, flagsReg_ulong_LEGT flags, label labl) %{
   7.185 +  match(If cmp flags);
   7.186 +  effect(USE labl);
   7.187 +  predicate(_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::gt || _kids[0]->_leaf->as_Bool()->_test._test == BoolTest::le);
   7.188 +  ins_cost(300);
   7.189 +  expand %{
   7.190 +    jmpCon(cmp, flags, labl);    // JGT or JLE...
   7.191 +  %}
   7.192 +%}
   7.193 +
   7.194  // Compare 2 longs and CMOVE longs.
   7.195  instruct cmovLL_reg_LEGT(cmpOp_commute cmp, flagsReg_long_LEGT flags, eRegL dst, eRegL src) %{
   7.196    match(Set dst (CMoveL (Binary cmp flags) (Binary dst src)));
     8.1 --- a/src/cpu/x86/vm/x86_64.ad	Tue Dec 13 12:51:17 2016 -0800
     8.2 +++ b/src/cpu/x86/vm/x86_64.ad	Thu Jun 08 13:40:41 2017 -0700
     8.3 @@ -11068,6 +11068,48 @@
     8.4    ins_pipe(pipe_slow);
     8.5  %}
     8.6  
     8.7 +// Unsigned long compare Instructions; really, same as signed long except they
     8.8 +// produce an rFlagsRegU instead of rFlagsReg.
     8.9 +instruct compUL_rReg(rFlagsRegU cr, rRegL op1, rRegL op2)
    8.10 +%{
    8.11 +  match(Set cr (CmpUL op1 op2));
    8.12 +
    8.13 +  format %{ "cmpq    $op1, $op2\t# unsigned" %}
    8.14 +  opcode(0x3B);  /* Opcode 3B /r */
    8.15 +  ins_encode(REX_reg_reg_wide(op1, op2), OpcP, reg_reg(op1, op2));
    8.16 +  ins_pipe(ialu_cr_reg_reg);
    8.17 +%}
    8.18 +
    8.19 +instruct compUL_rReg_imm(rFlagsRegU cr, rRegL op1, immL32 op2)
    8.20 +%{
    8.21 +  match(Set cr (CmpUL op1 op2));
    8.22 +
    8.23 +  format %{ "cmpq    $op1, $op2\t# unsigned" %}
    8.24 +  opcode(0x81, 0x07); /* Opcode 81 /7 */
    8.25 +  ins_encode(OpcSErm_wide(op1, op2), Con8or32(op2));
    8.26 +  ins_pipe(ialu_cr_reg_imm);
    8.27 +%}
    8.28 +
    8.29 +instruct compUL_rReg_mem(rFlagsRegU cr, rRegL op1, memory op2)
    8.30 +%{
    8.31 +  match(Set cr (CmpUL op1 (LoadL op2)));
    8.32 +
    8.33 +  format %{ "cmpq    $op1, $op2\t# unsigned" %}
    8.34 +  opcode(0x3B); /* Opcode 3B /r */
    8.35 +  ins_encode(REX_reg_mem_wide(op1, op2), OpcP, reg_mem(op1, op2));
    8.36 +  ins_pipe(ialu_cr_reg_mem);
    8.37 +%}
    8.38 +
    8.39 +instruct testUL_reg(rFlagsRegU cr, rRegL src, immL0 zero)
    8.40 +%{
    8.41 +  match(Set cr (CmpUL src zero));
    8.42 +
    8.43 +  format %{ "testq   $src, $src\t# unsigned" %}
    8.44 +  opcode(0x85);
    8.45 +  ins_encode(REX_reg_reg_wide(src, src), OpcP, reg_reg(src, src));
    8.46 +  ins_pipe(ialu_cr_reg_imm);
    8.47 +%}
    8.48 +
    8.49  //----------Max and Min--------------------------------------------------------
    8.50  // Min Instructions
    8.51  
     9.1 --- a/src/os/linux/vm/globals_linux.hpp	Tue Dec 13 12:51:17 2016 -0800
     9.2 +++ b/src/os/linux/vm/globals_linux.hpp	Thu Jun 08 13:40:41 2017 -0700
     9.3 @@ -1,5 +1,5 @@
     9.4  /*
     9.5 - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
     9.6 + * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
     9.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     9.8   *
     9.9   * This code is free software; you can redistribute it and/or modify it
    9.10 @@ -47,7 +47,10 @@
    9.11            "Load DLLs with executable-stack attribute in the VM Thread") \
    9.12                                                                          \
    9.13    product(bool, UseSHM, false,                                          \
    9.14 -          "Use SYSV shared memory for large pages")
    9.15 +          "Use SYSV shared memory for large pages")                     \
    9.16 +                                                                        \
    9.17 +  diagnostic(bool, PrintActiveCpus, false,                              \
    9.18 +          "Print the number of CPUs detected in os::active_processor_count")
    9.19  
    9.20  //
    9.21  // Defines Linux-specific default values. The flags are available on all
    10.1 --- a/src/os/linux/vm/os_linux.cpp	Tue Dec 13 12:51:17 2016 -0800
    10.2 +++ b/src/os/linux/vm/os_linux.cpp	Thu Jun 08 13:40:41 2017 -0700
    10.3 @@ -1,5 +1,5 @@
    10.4  /*
    10.5 - * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
    10.6 + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
    10.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    10.8   *
    10.9   * This code is free software; you can redistribute it and/or modify it
   10.10 @@ -104,6 +104,14 @@
   10.11  
   10.12  PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
   10.13  
   10.14 +#ifndef _GNU_SOURCE
   10.15 +  #define _GNU_SOURCE
   10.16 +  #include <sched.h>
   10.17 +  #undef _GNU_SOURCE
   10.18 +#else
   10.19 +  #include <sched.h>
   10.20 +#endif
   10.21 +
   10.22  // if RUSAGE_THREAD for getrusage() has not been defined, do it here. The code calling
   10.23  // getrusage() is prepared to handle the associated failure.
   10.24  #ifndef RUSAGE_THREAD
   10.25 @@ -1067,29 +1075,30 @@
   10.26  
   10.27  // Locate initial thread stack. This special handling of initial thread stack
   10.28  // is needed because pthread_getattr_np() on most (all?) Linux distros returns
   10.29 -// bogus value for initial thread.
   10.30 +// bogus value for the primordial process thread. While the launcher has created
   10.31 +// the VM in a new thread since JDK 6, we still have to allow for the use of the
   10.32 +// JNI invocation API from a primordial thread.
   10.33  void os::Linux::capture_initial_stack(size_t max_size) {
   10.34 -  // stack size is the easy part, get it from RLIMIT_STACK
   10.35 -  size_t stack_size;
   10.36 +
   10.37 +  // max_size is either 0 (which means accept OS default for thread stacks) or
   10.38 +  // a user-specified value known to be at least the minimum needed. If we
   10.39 +  // are actually on the primordial thread we can make it appear that we have a
   10.40 +  // smaller max_size stack by inserting the guard pages at that location. But we
   10.41 +  // cannot do anything to emulate a larger stack than what has been provided by
   10.42 +  // the OS or threading library. In fact if we try to use a stack greater than
   10.43 +  // what is set by rlimit then we will crash the hosting process.
   10.44 +
   10.45 +  // Maximum stack size is the easy part, get it from RLIMIT_STACK.
   10.46 +  // If this is "unlimited" then it will be a huge value.
   10.47    struct rlimit rlim;
   10.48    getrlimit(RLIMIT_STACK, &rlim);
   10.49 -  stack_size = rlim.rlim_cur;
   10.50 +  size_t stack_size = rlim.rlim_cur;
   10.51  
   10.52    // 6308388: a bug in ld.so will relocate its own .data section to the
   10.53    //   lower end of primordial stack; reduce ulimit -s value a little bit
   10.54    //   so we won't install guard page on ld.so's data section.
   10.55    stack_size -= 2 * page_size();
   10.56  
   10.57 -  // 4441425: avoid crash with "unlimited" stack size on SuSE 7.1 or Redhat
   10.58 -  //   7.1, in both cases we will get 2G in return value.
   10.59 -  // 4466587: glibc 2.2.x compiled w/o "--enable-kernel=2.4.0" (RH 7.0,
   10.60 -  //   SuSE 7.2, Debian) can not handle alternate signal stack correctly
   10.61 -  //   for initial thread if its stack size exceeds 6M. Cap it at 2M,
   10.62 -  //   in case other parts in glibc still assumes 2M max stack size.
   10.63 -  // FIXME: alt signal stack is gone, maybe we can relax this constraint?
   10.64 -  // Problem still exists RH7.2 (IA64 anyway) but 2MB is a little small
   10.65 -  if (stack_size > 2 * K * K IA64_ONLY(*2))
   10.66 -      stack_size = 2 * K * K IA64_ONLY(*2);
   10.67    // Try to figure out where the stack base (top) is. This is harder.
   10.68    //
   10.69    // When an application is started, glibc saves the initial stack pointer in
   10.70 @@ -1249,14 +1258,18 @@
   10.71    // stack_top could be partially down the page so align it
   10.72    stack_top = align_size_up(stack_top, page_size());
   10.73  
   10.74 -  if (max_size && stack_size > max_size) {
   10.75 -     _initial_thread_stack_size = max_size;
   10.76 +  // Allowed stack value is minimum of max_size and what we derived from rlimit
   10.77 +  if (max_size > 0) {
   10.78 +    _initial_thread_stack_size = MIN2(max_size, stack_size);
   10.79    } else {
   10.80 -     _initial_thread_stack_size = stack_size;
   10.81 +    // Accept the rlimit max, but if stack is unlimited then it will be huge, so
   10.82 +    // clamp it at 8MB as we do on Solaris
   10.83 +    _initial_thread_stack_size = MIN2(stack_size, 8*M);
   10.84    }
   10.85  
   10.86    _initial_thread_stack_size = align_size_down(_initial_thread_stack_size, page_size());
   10.87    _initial_thread_stack_bottom = (address)stack_top - _initial_thread_stack_size;
   10.88 +  assert(_initial_thread_stack_bottom < (address)stack_top, "overflow!");
   10.89  }
   10.90  
   10.91  ////////////////////////////////////////////////////////////////////////////////
   10.92 @@ -5016,12 +5029,42 @@
   10.93    }
   10.94  };
   10.95  
   10.96 +static int os_cpu_count(const cpu_set_t* cpus) {
   10.97 +  int count = 0;
   10.98 +  // only look up to the number of configured processors
   10.99 +  for (int i = 0; i < os::processor_count(); i++) {
  10.100 +    if (CPU_ISSET(i, cpus)) {
  10.101 +      count++;
  10.102 +    }
  10.103 +  }
  10.104 +  return count;
  10.105 +}
  10.106 +
  10.107 +// Get the current number of available processors for this process.
  10.108 +// This value can change at any time during a process's lifetime.
  10.109 +// sched_getaffinity gives an accurate answer as it accounts for cpusets.
  10.110 +// If anything goes wrong we fallback to returning the number of online
  10.111 +// processors - which can be greater than the number available to the process.
  10.112  int os::active_processor_count() {
  10.113 -  // Linux doesn't yet have a (official) notion of processor sets,
  10.114 -  // so just return the number of online processors.
  10.115 -  int online_cpus = ::sysconf(_SC_NPROCESSORS_ONLN);
  10.116 -  assert(online_cpus > 0 && online_cpus <= processor_count(), "sanity check");
  10.117 -  return online_cpus;
  10.118 +  cpu_set_t cpus;  // can represent at most 1024 (CPU_SETSIZE) processors
  10.119 +  int cpus_size = sizeof(cpu_set_t);
  10.120 +  int cpu_count = 0;
  10.121 +
  10.122 +  // pid 0 means the current thread - which we have to assume represents the process
  10.123 +  if (sched_getaffinity(0, cpus_size, &cpus) == 0) {
  10.124 +    cpu_count = os_cpu_count(&cpus);
  10.125 +    if (PrintActiveCpus) {
  10.126 +      tty->print_cr("active_processor_count: sched_getaffinity processor count: %d", cpu_count);
  10.127 +    }
  10.128 +  }
  10.129 +  else {
  10.130 +    cpu_count = ::sysconf(_SC_NPROCESSORS_ONLN);
  10.131 +    warning("sched_getaffinity failed (%s)- using online processor count (%d) "
  10.132 +            "which may exceed available processors", strerror(errno), cpu_count);
  10.133 +  }
  10.134 +
  10.135 +  assert(cpu_count > 0 && cpu_count <= processor_count(), "sanity check");
  10.136 +  return cpu_count;
  10.137  }
  10.138  
  10.139  void os::set_native_thread_name(const char *name) {
    11.1 --- a/src/os/windows/vm/os_windows.cpp	Tue Dec 13 12:51:17 2016 -0800
    11.2 +++ b/src/os/windows/vm/os_windows.cpp	Thu Jun 08 13:40:41 2017 -0700
    11.3 @@ -1,5 +1,5 @@
    11.4  /*
    11.5 - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
    11.6 + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    11.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    11.8   *
    11.9   * This code is free software; you can redistribute it and/or modify it
   11.10 @@ -1747,8 +1747,7 @@
   11.11      if (is_workstation) {
   11.12        st->print("10");
   11.13      } else {
   11.14 -      // The server version name of Windows 10 is not known at this time
   11.15 -      st->print("%d.%d", major_version, minor_version);
   11.16 +      st->print("Server 2016");
   11.17      }
   11.18      break;
   11.19  
    12.1 --- a/src/share/vm/adlc/archDesc.cpp	Tue Dec 13 12:51:17 2016 -0800
    12.2 +++ b/src/share/vm/adlc/archDesc.cpp	Thu Jun 08 13:40:41 2017 -0700
    12.3 @@ -1189,6 +1189,7 @@
    12.4           || strcmp(idealName,"CmpP") == 0
    12.5           || strcmp(idealName,"CmpN") == 0
    12.6           || strcmp(idealName,"CmpL") == 0
    12.7 +         || strcmp(idealName,"CmpUL") == 0
    12.8           || strcmp(idealName,"CmpD") == 0
    12.9           || strcmp(idealName,"CmpF") == 0
   12.10           || strcmp(idealName,"FastLock") == 0
    13.1 --- a/src/share/vm/c1/c1_CodeStubs.hpp	Tue Dec 13 12:51:17 2016 -0800
    13.2 +++ b/src/share/vm/c1/c1_CodeStubs.hpp	Thu Jun 08 13:40:41 2017 -0700
    13.3 @@ -1,5 +1,5 @@
    13.4  /*
    13.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
    13.6 + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
    13.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    13.8   *
    13.9   * This code is free software; you can redistribute it and/or modify it
   13.10 @@ -57,6 +57,7 @@
   13.11    virtual bool is_exception_throw_stub() const   { return false; }
   13.12    virtual bool is_range_check_stub() const       { return false; }
   13.13    virtual bool is_divbyzero_stub() const         { return false; }
   13.14 +  virtual bool is_simple_exception_stub() const  { return false; }
   13.15  #ifndef PRODUCT
   13.16    virtual void print_name(outputStream* out) const = 0;
   13.17  #endif
   13.18 @@ -484,6 +485,7 @@
   13.19    virtual void emit_code(LIR_Assembler* e);
   13.20    virtual CodeEmitInfo* info() const             { return _info; }
   13.21    virtual bool is_exception_throw_stub() const   { return true; }
   13.22 +  virtual bool is_simple_exception_stub() const  { return true; }
   13.23    virtual void visit(LIR_OpVisitState* visitor) {
   13.24      if (_obj->is_valid()) visitor->do_input(_obj);
   13.25      visitor->do_slow_case(_info);
    14.1 --- a/src/share/vm/c1/c1_GraphBuilder.cpp	Tue Dec 13 12:51:17 2016 -0800
    14.2 +++ b/src/share/vm/c1/c1_GraphBuilder.cpp	Thu Jun 08 13:40:41 2017 -0700
    14.3 @@ -1823,6 +1823,20 @@
    14.4                  log->identify(target),
    14.5                  Bytecodes::name(code));
    14.6  
    14.7 +  // invoke-special-super
    14.8 +  if (bc_raw == Bytecodes::_invokespecial && !target->is_object_initializer()) {
    14.9 +    ciInstanceKlass* sender_klass =
   14.10 +          calling_klass->is_anonymous() ? calling_klass->host_klass() :
   14.11 +                                          calling_klass;
   14.12 +    if (sender_klass->is_interface()) {
   14.13 +      int index = state()->stack_size() - (target->arg_size_no_receiver() + 1);
   14.14 +      Value receiver = state()->stack_at(index);
   14.15 +      CheckCast* c = new CheckCast(sender_klass, receiver, copy_state_before());
   14.16 +      c->set_invokespecial_receiver_check();
   14.17 +      state()->stack_at_put(index, append_split(c));
   14.18 +    }
   14.19 +  }
   14.20 +
   14.21    // Some methods are obviously bindable without any type checks so
   14.22    // convert them directly to an invokespecial or invokestatic.
   14.23    if (target->is_loaded() && !target->is_abstract() && target->can_be_statically_bound()) {
    15.1 --- a/src/share/vm/c1/c1_Instruction.hpp	Tue Dec 13 12:51:17 2016 -0800
    15.2 +++ b/src/share/vm/c1/c1_Instruction.hpp	Thu Jun 08 13:40:41 2017 -0700
    15.3 @@ -381,6 +381,7 @@
    15.4      UnorderedIsTrueFlag,
    15.5      NeedsPatchingFlag,
    15.6      ThrowIncompatibleClassChangeErrorFlag,
    15.7 +    InvokeSpecialReceiverCheckFlag,
    15.8      ProfileMDOFlag,
    15.9      IsLinkedInBlockFlag,
   15.10      NeedsRangeCheckFlag,
   15.11 @@ -1456,6 +1457,16 @@
   15.12    bool is_incompatible_class_change_check() const {
   15.13      return check_flag(ThrowIncompatibleClassChangeErrorFlag);
   15.14    }
   15.15 +  void set_invokespecial_receiver_check() {
   15.16 +    set_flag(InvokeSpecialReceiverCheckFlag, true);
   15.17 +  }
   15.18 +  bool is_invokespecial_receiver_check() const {
   15.19 +    return check_flag(InvokeSpecialReceiverCheckFlag);
   15.20 +  }
   15.21 +
   15.22 +  virtual bool needs_exception_state() const {
   15.23 +    return !is_invokespecial_receiver_check();
   15.24 +  }
   15.25  
   15.26    ciType* declared_type() const;
   15.27  };
    16.1 --- a/src/share/vm/ci/ciInstanceKlass.cpp	Tue Dec 13 12:51:17 2016 -0800
    16.2 +++ b/src/share/vm/ci/ciInstanceKlass.cpp	Thu Jun 08 13:40:41 2017 -0700
    16.3 @@ -1,5 +1,5 @@
    16.4  /*
    16.5 - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
    16.6 + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
    16.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    16.8   *
    16.9   * This code is free software; you can redistribute it and/or modify it
   16.10 @@ -58,6 +58,7 @@
   16.11    _nonstatic_field_size = ik->nonstatic_field_size();
   16.12    _has_nonstatic_fields = ik->has_nonstatic_fields();
   16.13    _has_default_methods = ik->has_default_methods();
   16.14 +  _is_anonymous = ik->is_anonymous();
   16.15    _nonstatic_fields = NULL; // initialized lazily by compute_nonstatic_fields:
   16.16  
   16.17    _implementor = NULL; // we will fill these lazily
   16.18 @@ -100,6 +101,7 @@
   16.19    _nonstatic_field_size = -1;
   16.20    _has_nonstatic_fields = false;
   16.21    _nonstatic_fields = NULL;
   16.22 +  _is_anonymous = false;
   16.23    _loader = loader;
   16.24    _protection_domain = protection_domain;
   16.25    _is_shared = false;
   16.26 @@ -591,6 +593,16 @@
   16.27    return impl;
   16.28  }
   16.29  
   16.30 +ciInstanceKlass* ciInstanceKlass::host_klass() {
   16.31 +  assert(is_loaded(), "must be loaded");
   16.32 +  if (is_anonymous()) {
   16.33 +    VM_ENTRY_MARK
   16.34 +    Klass* host_klass = get_instanceKlass()->host_klass();
   16.35 +    return CURRENT_ENV->get_instance_klass(host_klass);
   16.36 +  }
   16.37 +  return NULL;
   16.38 +}
   16.39 +
   16.40  // Utility class for printing of the contents of the static fields for
   16.41  // use by compilation replay.  It only prints out the information that
   16.42  // could be consumed by the compiler, so for primitive types it prints
    17.1 --- a/src/share/vm/ci/ciInstanceKlass.hpp	Tue Dec 13 12:51:17 2016 -0800
    17.2 +++ b/src/share/vm/ci/ciInstanceKlass.hpp	Thu Jun 08 13:40:41 2017 -0700
    17.3 @@ -1,5 +1,5 @@
    17.4  /*
    17.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
    17.6 + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
    17.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    17.8   *
    17.9   * This code is free software; you can redistribute it and/or modify it
   17.10 @@ -53,6 +53,7 @@
   17.11    bool                   _has_subklass;
   17.12    bool                   _has_nonstatic_fields;
   17.13    bool                   _has_default_methods;
   17.14 +  bool                   _is_anonymous;
   17.15  
   17.16    ciFlags                _flags;
   17.17    jint                   _nonstatic_field_size;
   17.18 @@ -177,6 +178,10 @@
   17.19      return _has_default_methods;
   17.20    }
   17.21  
   17.22 +  bool is_anonymous() {
   17.23 +    return _is_anonymous;
   17.24 +  }
   17.25 +
   17.26    ciInstanceKlass* get_canonical_holder(int offset);
   17.27    ciField* get_field_by_offset(int field_offset, bool is_static);
   17.28    ciField* get_field_by_name(ciSymbol* name, ciSymbol* signature, bool is_static);
   17.29 @@ -248,6 +253,8 @@
   17.30      return NULL;
   17.31    }
   17.32  
   17.33 +  ciInstanceKlass* host_klass();
   17.34 +
   17.35    // Dump the current state of this klass for compilation replay.
   17.36    virtual void dump_replay_data(outputStream* out);
   17.37  };
    18.1 --- a/src/share/vm/ci/ciMethod.cpp	Tue Dec 13 12:51:17 2016 -0800
    18.2 +++ b/src/share/vm/ci/ciMethod.cpp	Thu Jun 08 13:40:41 2017 -0700
    18.3 @@ -1,5 +1,5 @@
    18.4  /*
    18.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
    18.6 + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
    18.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    18.8   *
    18.9   * This code is free software; you can redistribute it and/or modify it
   18.10 @@ -948,6 +948,13 @@
   18.11  }
   18.12  
   18.13  // ------------------------------------------------------------------
   18.14 +// ciMethod::is_object_initializer
   18.15 +//
   18.16 +bool ciMethod::is_object_initializer() const {
   18.17 +   return name() == ciSymbol::object_initializer_name();
   18.18 +}
   18.19 +
   18.20 +// ------------------------------------------------------------------
   18.21  // ciMethod::has_member_arg
   18.22  //
   18.23  // Return true if the method is a linker intrinsic like _linkToVirtual.
    19.1 --- a/src/share/vm/ci/ciMethod.hpp	Tue Dec 13 12:51:17 2016 -0800
    19.2 +++ b/src/share/vm/ci/ciMethod.hpp	Thu Jun 08 13:40:41 2017 -0700
    19.3 @@ -1,5 +1,5 @@
    19.4  /*
    19.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
    19.6 + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
    19.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    19.8   *
    19.9   * This code is free software; you can redistribute it and/or modify it
   19.10 @@ -316,6 +316,7 @@
   19.11    bool can_be_statically_bound() const           { return _can_be_statically_bound; }
   19.12    bool is_boxing_method() const;
   19.13    bool is_unboxing_method() const;
   19.14 +  bool is_object_initializer() const;
   19.15  
   19.16    // Replay data methods
   19.17    void dump_name_as_ascii(outputStream* st);
    20.1 --- a/src/share/vm/classfile/stackMapFrame.cpp	Tue Dec 13 12:51:17 2016 -0800
    20.2 +++ b/src/share/vm/classfile/stackMapFrame.cpp	Thu Jun 08 13:40:41 2017 -0700
    20.3 @@ -1,5 +1,5 @@
    20.4  /*
    20.5 - * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
    20.6 + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
    20.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    20.8   *
    20.9   * This code is free software; you can redistribute it and/or modify it
   20.10 @@ -155,47 +155,8 @@
   20.11    return i;
   20.12  }
   20.13  
   20.14 -bool StackMapFrame::has_flag_match_exception(
   20.15 -    const StackMapFrame* target) const {
   20.16 -  // We allow flags of {UninitThis} to assign to {} if-and-only-if the
   20.17 -  // target frame does not depend upon the current type.
   20.18 -  // This is slightly too strict, as we need only enforce that the
   20.19 -  // slots that were initialized by the <init> (the things that were
   20.20 -  // UninitializedThis before initialize_object() converted them) are unused.
   20.21 -  // However we didn't save that information so we'll enforce this upon
   20.22 -  // anything that might have been initialized.  This is a rare situation
   20.23 -  // and javac never generates code that would end up here, but some profilers
   20.24 -  // (such as NetBeans) might, when adding exception handlers in <init>
   20.25 -  // methods to cover the invokespecial instruction.  See 7020118.
   20.26 -
   20.27 -  assert(max_locals() == target->max_locals() &&
   20.28 -         stack_size() == target->stack_size(), "StackMap sizes must match");
   20.29 -
   20.30 -  VerificationType top = VerificationType::top_type();
   20.31 -  VerificationType this_type = verifier()->current_type();
   20.32 -
   20.33 -  if (!flag_this_uninit() || target->flags() != 0) {
   20.34 -    return false;
   20.35 -  }
   20.36 -
   20.37 -  for (int i = 0; i < target->locals_size(); ++i) {
   20.38 -    if (locals()[i] == this_type && target->locals()[i] != top) {
   20.39 -      return false;
   20.40 -    }
   20.41 -  }
   20.42 -
   20.43 -  for (int i = 0; i < target->stack_size(); ++i) {
   20.44 -    if (stack()[i] == this_type && target->stack()[i] != top) {
   20.45 -      return false;
   20.46 -    }
   20.47 -  }
   20.48 -
   20.49 -  return true;
   20.50 -}
   20.51 -
   20.52  bool StackMapFrame::is_assignable_to(
   20.53 -    const StackMapFrame* target, bool is_exception_handler,
   20.54 -    ErrorContext* ctx, TRAPS) const {
   20.55 +    const StackMapFrame* target, ErrorContext* ctx, TRAPS) const {
   20.56    if (_max_locals != target->max_locals()) {
   20.57      *ctx = ErrorContext::locals_size_mismatch(
   20.58          _offset, (StackMapFrame*)this, (StackMapFrame*)target);
   20.59 @@ -226,8 +187,7 @@
   20.60      return false;
   20.61    }
   20.62  
   20.63 -  bool match_flags = (_flags | target->flags()) == target->flags();
   20.64 -  if (match_flags || is_exception_handler && has_flag_match_exception(target)) {
   20.65 +  if ((_flags | target->flags()) == target->flags()) {
   20.66      return true;
   20.67    } else {
   20.68      *ctx = ErrorContext::bad_flags(target->offset(),
    21.1 --- a/src/share/vm/classfile/stackMapFrame.hpp	Tue Dec 13 12:51:17 2016 -0800
    21.2 +++ b/src/share/vm/classfile/stackMapFrame.hpp	Thu Jun 08 13:40:41 2017 -0700
    21.3 @@ -1,5 +1,5 @@
    21.4  /*
    21.5 - * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
    21.6 + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
    21.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    21.8   *
    21.9   * This code is free software; you can redistribute it and/or modify it
   21.10 @@ -167,8 +167,7 @@
   21.11  
   21.12    // Return true if this stack map frame is assignable to target.
   21.13    bool is_assignable_to(
   21.14 -      const StackMapFrame* target, bool is_exception_handler,
   21.15 -      ErrorContext* ctx, TRAPS) const;
   21.16 +      const StackMapFrame* target, ErrorContext* ctx, TRAPS) const;
   21.17  
   21.18    inline void set_mark() {
   21.19  #ifdef ASSERT
   21.20 @@ -290,8 +289,6 @@
   21.21    int is_assignable_to(
   21.22      VerificationType* src, VerificationType* target, int32_t len, TRAPS) const;
   21.23  
   21.24 -  bool has_flag_match_exception(const StackMapFrame* target) const;
   21.25 -
   21.26    TypeOrigin stack_top_ctx();
   21.27  
   21.28    void print_on(outputStream* str) const;
    22.1 --- a/src/share/vm/classfile/stackMapTable.cpp	Tue Dec 13 12:51:17 2016 -0800
    22.2 +++ b/src/share/vm/classfile/stackMapTable.cpp	Thu Jun 08 13:40:41 2017 -0700
    22.3 @@ -1,5 +1,5 @@
    22.4  /*
    22.5 - * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
    22.6 + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
    22.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    22.8   *
    22.9   * This code is free software; you can redistribute it and/or modify it
   22.10 @@ -70,26 +70,25 @@
   22.11  
   22.12  bool StackMapTable::match_stackmap(
   22.13      StackMapFrame* frame, int32_t target,
   22.14 -    bool match, bool update, bool handler, ErrorContext* ctx, TRAPS) const {
   22.15 +    bool match, bool update, ErrorContext* ctx, TRAPS) const {
   22.16    int index = get_index_from_offset(target);
   22.17 -  return match_stackmap(frame, target, index, match, update, handler, ctx, THREAD);
   22.18 +  return match_stackmap(frame, target, index, match, update, ctx, THREAD);
   22.19  }
   22.20  
   22.21  // Match and/or update current_frame to the frame in stackmap table with
   22.22  // specified offset and frame index. Return true if the two frames match.
   22.23 -// handler is true if the frame in stackmap_table is for an exception handler.
   22.24  //
   22.25 -// The values of match and update are:                  _match__update__handler
   22.26 +// The values of match and update are:                  _match__update
   22.27  //
   22.28 -// checking a branch target:                             true   false   false
   22.29 -// checking an exception handler:                        true   false   true
   22.30 +// checking a branch target:                             true   false
   22.31 +// checking an exception handler:                        true   false
   22.32  // linear bytecode verification following an
   22.33 -// unconditional branch:                                 false  true    false
   22.34 +// unconditional branch:                                 false  true
   22.35  // linear bytecode verification not following an
   22.36 -// unconditional branch:                                 true   true    false
   22.37 +// unconditional branch:                                 true   true
   22.38  bool StackMapTable::match_stackmap(
   22.39      StackMapFrame* frame, int32_t target, int32_t frame_index,
   22.40 -    bool match, bool update, bool handler, ErrorContext* ctx, TRAPS) const {
   22.41 +    bool match, bool update, ErrorContext* ctx, TRAPS) const {
   22.42    if (frame_index < 0 || frame_index >= _frame_count) {
   22.43      *ctx = ErrorContext::missing_stackmap(frame->offset());
   22.44      frame->verifier()->verify_error(
   22.45 @@ -102,7 +101,7 @@
   22.46    if (match) {
   22.47      // Has direct control flow from last instruction, need to match the two
   22.48      // frames.
   22.49 -    result = frame->is_assignable_to(stackmap_frame, handler,
   22.50 +    result = frame->is_assignable_to(stackmap_frame,
   22.51          ctx, CHECK_VERIFY_(frame->verifier(), result));
   22.52    }
   22.53    if (update) {
   22.54 @@ -126,7 +125,7 @@
   22.55      StackMapFrame* frame, int32_t target, TRAPS) const {
   22.56    ErrorContext ctx;
   22.57    bool match = match_stackmap(
   22.58 -    frame, target, true, false, false, &ctx, CHECK_VERIFY(frame->verifier()));
   22.59 +    frame, target, true, false, &ctx, CHECK_VERIFY(frame->verifier()));
   22.60    if (!match || (target < 0 || target >= _code_length)) {
   22.61      frame->verifier()->verify_error(ctx,
   22.62          "Inconsistent stackmap frames at branch target %d", target);
    23.1 --- a/src/share/vm/classfile/stackMapTable.hpp	Tue Dec 13 12:51:17 2016 -0800
    23.2 +++ b/src/share/vm/classfile/stackMapTable.hpp	Thu Jun 08 13:40:41 2017 -0700
    23.3 @@ -1,5 +1,5 @@
    23.4  /*
    23.5 - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
    23.6 + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
    23.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    23.8   *
    23.9   * This code is free software; you can redistribute it and/or modify it
   23.10 @@ -74,12 +74,12 @@
   23.11    // specified offset. Return true if the two frames match.
   23.12    bool match_stackmap(
   23.13      StackMapFrame* current_frame, int32_t offset,
   23.14 -    bool match, bool update, bool handler, ErrorContext* ctx, TRAPS) const;
   23.15 +    bool match, bool update, ErrorContext* ctx, TRAPS) const;
   23.16    // Match and/or update current_frame to the frame in stackmap table with
   23.17    // specified offset and frame index. Return true if the two frames match.
   23.18    bool match_stackmap(
   23.19      StackMapFrame* current_frame, int32_t offset, int32_t frame_index,
   23.20 -    bool match, bool update, bool handler, ErrorContext* ctx, TRAPS) const;
   23.21 +    bool match, bool update, ErrorContext* ctx, TRAPS) const;
   23.22  
   23.23    // Check jump instructions. Make sure there are no uninitialized
   23.24    // instances on backward branch.
    24.1 --- a/src/share/vm/classfile/verifier.cpp	Tue Dec 13 12:51:17 2016 -0800
    24.2 +++ b/src/share/vm/classfile/verifier.cpp	Thu Jun 08 13:40:41 2017 -0700
    24.3 @@ -1814,7 +1814,7 @@
    24.4        // If matched, current_frame will be updated by this method.
    24.5        bool matches = stackmap_table->match_stackmap(
    24.6          current_frame, this_offset, stackmap_index,
    24.7 -        !no_control_flow, true, false, &ctx, CHECK_VERIFY_(this, 0));
    24.8 +        !no_control_flow, true, &ctx, CHECK_VERIFY_(this, 0));
    24.9        if (!matches) {
   24.10          // report type error
   24.11          verify_error(ctx, "Instruction type does not match stack map");
   24.12 @@ -1861,7 +1861,7 @@
   24.13        }
   24.14        ErrorContext ctx;
   24.15        bool matches = stackmap_table->match_stackmap(
   24.16 -        new_frame, handler_pc, true, false, true, &ctx, CHECK_VERIFY(this));
   24.17 +        new_frame, handler_pc, true, false, &ctx, CHECK_VERIFY(this));
   24.18        if (!matches) {
   24.19          verify_error(ctx, "Stack map does not match the one at "
   24.20              "exception handler %d", handler_pc);
    25.1 --- a/src/share/vm/gc_implementation/g1/concurrentMark.cpp	Tue Dec 13 12:51:17 2016 -0800
    25.2 +++ b/src/share/vm/gc_implementation/g1/concurrentMark.cpp	Thu Jun 08 13:40:41 2017 -0700
    25.3 @@ -1,5 +1,5 @@
    25.4  /*
    25.5 - * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
    25.6 + * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
    25.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    25.8   *
    25.9   * This code is free software; you can redistribute it and/or modify it
   25.10 @@ -631,11 +631,10 @@
   25.11        double overall_cm_overhead =
   25.12          (double) MaxGCPauseMillis * marking_overhead /
   25.13          (double) GCPauseIntervalMillis;
   25.14 -      double cpu_ratio = 1.0 / (double) os::processor_count();
   25.15 +      double cpu_ratio = 1.0 / os::initial_active_processor_count();
   25.16        double marking_thread_num = ceil(overall_cm_overhead / cpu_ratio);
   25.17        double marking_task_overhead =
   25.18 -        overall_cm_overhead / marking_thread_num *
   25.19 -                                                (double) os::processor_count();
   25.20 +        overall_cm_overhead / marking_thread_num * os::initial_active_processor_count();
   25.21        double sleep_factor =
   25.22                           (1.0 - marking_task_overhead) / marking_task_overhead;
   25.23  
    26.1 --- a/src/share/vm/gc_implementation/g1/dirtyCardQueue.cpp	Tue Dec 13 12:51:17 2016 -0800
    26.2 +++ b/src/share/vm/gc_implementation/g1/dirtyCardQueue.cpp	Thu Jun 08 13:40:41 2017 -0700
    26.3 @@ -1,5 +1,5 @@
    26.4  /*
    26.5 - * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
    26.6 + * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
    26.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    26.8   *
    26.9   * This code is free software; you can redistribute it and/or modify it
   26.10 @@ -80,7 +80,7 @@
   26.11  
   26.12  // Determines how many mutator threads can process the buffers in parallel.
   26.13  uint DirtyCardQueueSet::num_par_ids() {
   26.14 -  return (uint)os::processor_count();
   26.15 +  return (uint)os::initial_active_processor_count();
   26.16  }
   26.17  
   26.18  void DirtyCardQueueSet::initialize(CardTableEntryClosure* cl, Monitor* cbl_mon, Mutex* fl_lock,
    27.1 --- a/src/share/vm/interpreter/interpreterRuntime.cpp	Tue Dec 13 12:51:17 2016 -0800
    27.2 +++ b/src/share/vm/interpreter/interpreterRuntime.cpp	Thu Jun 08 13:40:41 2017 -0700
    27.3 @@ -690,7 +690,8 @@
    27.4  IRT_ENTRY(void, InterpreterRuntime::resolve_invoke(JavaThread* thread, Bytecodes::Code bytecode)) {
    27.5    // extract receiver from the outgoing argument list if necessary
    27.6    Handle receiver(thread, NULL);
    27.7 -  if (bytecode == Bytecodes::_invokevirtual || bytecode == Bytecodes::_invokeinterface) {
    27.8 +  if (bytecode == Bytecodes::_invokevirtual || bytecode == Bytecodes::_invokeinterface ||
    27.9 +      bytecode == Bytecodes::_invokespecial) {
   27.10      ResourceMark rm(thread);
   27.11      methodHandle m (thread, method(thread));
   27.12      Bytecode_invoke call(m, bci(thread));
   27.13 @@ -756,16 +757,25 @@
   27.14        int index = info.resolved_method()->itable_index();
   27.15        assert(info.itable_index() == index, "");
   27.16      }
   27.17 +  } else if (bytecode == Bytecodes::_invokespecial) {
   27.18 +    assert(info.call_kind() == CallInfo::direct_call, "must be direct call");
   27.19    } else {
   27.20      assert(info.call_kind() == CallInfo::direct_call ||
   27.21             info.call_kind() == CallInfo::vtable_call, "");
   27.22    }
   27.23  #endif
   27.24 +  // Get sender or sender's host_klass, and only set cpCache entry to resolved if
   27.25 +  // it is not an interface.  The receiver for invokespecial calls within interface
   27.26 +  // methods must be checked for every call.
   27.27 +  InstanceKlass* sender = pool->pool_holder();
   27.28 +  sender = sender->is_anonymous() ? InstanceKlass::cast(sender->host_klass()) : sender;
   27.29 +
   27.30    switch (info.call_kind()) {
   27.31    case CallInfo::direct_call:
   27.32      cache_entry(thread)->set_direct_call(
   27.33        bytecode,
   27.34 -      info.resolved_method());
   27.35 +      info.resolved_method(),
   27.36 +      sender->is_interface());
   27.37      break;
   27.38    case CallInfo::vtable_call:
   27.39      cache_entry(thread)->set_vtable_call(
    28.1 --- a/src/share/vm/interpreter/linkResolver.cpp	Tue Dec 13 12:51:17 2016 -0800
    28.2 +++ b/src/share/vm/interpreter/linkResolver.cpp	Thu Jun 08 13:40:41 2017 -0700
    28.3 @@ -1,5 +1,5 @@
    28.4  /*
    28.5 - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
    28.6 + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    28.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    28.8   *
    28.9   * This code is free software; you can redistribute it and/or modify it
   28.10 @@ -913,11 +913,11 @@
   28.11  }
   28.12  
   28.13  
   28.14 -void LinkResolver::resolve_special_call(CallInfo& result, KlassHandle resolved_klass, Symbol* method_name,
   28.15 +void LinkResolver::resolve_special_call(CallInfo& result, Handle recv, KlassHandle resolved_klass, Symbol* method_name,
   28.16                                          Symbol* method_signature, KlassHandle current_klass, bool check_access, TRAPS) {
   28.17    methodHandle resolved_method;
   28.18    linktime_resolve_special_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK);
   28.19 -  runtime_resolve_special_method(result, resolved_method, resolved_klass, current_klass, check_access, CHECK);
   28.20 +  runtime_resolve_special_method(result, resolved_method, resolved_klass, current_klass, recv, check_access, CHECK);
   28.21  }
   28.22  
   28.23  // throws linktime exceptions
   28.24 @@ -1016,7 +1016,7 @@
   28.25  
   28.26  // throws runtime exceptions
   28.27  void LinkResolver::runtime_resolve_special_method(CallInfo& result, methodHandle resolved_method, KlassHandle resolved_klass,
   28.28 -                                                  KlassHandle current_klass, bool check_access, TRAPS) {
   28.29 +                                                  KlassHandle current_klass, Handle recv, bool check_access, TRAPS) {
   28.30  
   28.31    // resolved method is selected method unless we have an old-style lookup
   28.32    // for a superclass method
   28.33 @@ -1024,21 +1024,19 @@
   28.34    // no checks for shadowing
   28.35    methodHandle sel_method(THREAD, resolved_method());
   28.36  
   28.37 +  if (check_access &&
   28.38 +      // check if the method is not <init>
   28.39 +      resolved_method->name() != vmSymbols::object_initializer_name()) {
   28.40 +
   28.41    // check if this is an old-style super call and do a new lookup if so
   28.42 -  { KlassHandle method_klass  = KlassHandle(THREAD,
   28.43 -                                            resolved_method->method_holder());
   28.44 -
   28.45 -    if (check_access &&
   28.46          // a) check if ACC_SUPER flag is set for the current class
   28.47 -        (current_klass->is_super() || !AllowNonVirtualCalls) &&
   28.48 +    if ((current_klass->is_super() || !AllowNonVirtualCalls) &&
   28.49          // b) check if the class of the resolved_klass is a superclass
   28.50          // (not supertype in order to exclude interface classes) of the current class.
   28.51          // This check is not performed for super.invoke for interface methods
   28.52          // in super interfaces.
   28.53          current_klass->is_subclass_of(resolved_klass()) &&
   28.54 -        current_klass() != resolved_klass() &&
   28.55 -        // c) check if the method is not <init>
   28.56 -        resolved_method->name() != vmSymbols::object_initializer_name()) {
   28.57 +        current_klass() != resolved_klass()) {
   28.58        // Lookup super method
   28.59        KlassHandle super_klass(THREAD, current_klass->super());
   28.60        lookup_instance_method_in_klasses(sel_method, super_klass,
   28.61 @@ -1053,6 +1051,27 @@
   28.62                                              resolved_method->signature()));
   28.63        }
   28.64      }
   28.65 +
   28.66 +    // Check that the class of objectref (the receiver) is the current class or interface,
   28.67 +    // or a subtype of the current class or interface (the sender), otherwise invokespecial
   28.68 +    // throws IllegalAccessError.
   28.69 +    // The verifier checks that the sender is a subtype of the class in the I/MR operand.
   28.70 +    // The verifier also checks that the receiver is a subtype of the sender, if the sender is
   28.71 +    // a class.  If the sender is an interface, the check has to be performed at runtime.
   28.72 +    InstanceKlass* sender = InstanceKlass::cast(current_klass());
   28.73 +    sender = sender->is_anonymous() ? InstanceKlass::cast(sender->host_klass()) : sender;
   28.74 +    if (sender->is_interface() && recv.not_null()) {
   28.75 +      Klass* receiver_klass = recv->klass();
   28.76 +      if (!receiver_klass->is_subtype_of(sender)) {
   28.77 +        ResourceMark rm(THREAD);
   28.78 +        char buf[500];
   28.79 +        jio_snprintf(buf, sizeof(buf),
   28.80 +                     "Receiver class %s must be the current class or a subtype of interface %s",
   28.81 +                     receiver_klass->name()->as_C_string(),
   28.82 +                     sender->name()->as_C_string());
   28.83 +        THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), buf);
   28.84 +      }
   28.85 +    }
   28.86    }
   28.87  
   28.88    // check if not static
   28.89 @@ -1479,7 +1498,7 @@
   28.90                                                    bool check_access) {
   28.91    EXCEPTION_MARK;
   28.92    CallInfo info;
   28.93 -  resolve_special_call(info, resolved_klass, name, signature, current_klass, check_access, THREAD);
   28.94 +  resolve_special_call(info, Handle(), resolved_klass, name, signature, current_klass, check_access, THREAD);
   28.95    if (HAS_PENDING_EXCEPTION) {
   28.96      CLEAR_PENDING_EXCEPTION;
   28.97      return methodHandle();
   28.98 @@ -1495,7 +1514,7 @@
   28.99  void LinkResolver::resolve_invoke(CallInfo& result, Handle recv, constantPoolHandle pool, int index, Bytecodes::Code byte, TRAPS) {
  28.100    switch (byte) {
  28.101      case Bytecodes::_invokestatic   : resolve_invokestatic   (result,       pool, index, CHECK); break;
  28.102 -    case Bytecodes::_invokespecial  : resolve_invokespecial  (result,       pool, index, CHECK); break;
  28.103 +    case Bytecodes::_invokespecial  : resolve_invokespecial  (result, recv, pool, index, CHECK); break;
  28.104      case Bytecodes::_invokevirtual  : resolve_invokevirtual  (result, recv, pool, index, CHECK); break;
  28.105      case Bytecodes::_invokehandle   : resolve_invokehandle   (result,       pool, index, CHECK); break;
  28.106      case Bytecodes::_invokedynamic  : resolve_invokedynamic  (result,       pool, index, CHECK); break;
  28.107 @@ -1526,13 +1545,13 @@
  28.108  }
  28.109  
  28.110  
  28.111 -void LinkResolver::resolve_invokespecial(CallInfo& result, constantPoolHandle pool, int index, TRAPS) {
  28.112 +void LinkResolver::resolve_invokespecial(CallInfo& result, Handle recv, constantPoolHandle pool, int index, TRAPS) {
  28.113    KlassHandle  resolved_klass;
  28.114    Symbol* method_name = NULL;
  28.115    Symbol* method_signature = NULL;
  28.116    KlassHandle  current_klass;
  28.117    resolve_pool(resolved_klass, method_name,  method_signature, current_klass, pool, index, CHECK);
  28.118 -  resolve_special_call(result, resolved_klass, method_name, method_signature, current_klass, true, CHECK);
  28.119 +  resolve_special_call(result, recv, resolved_klass, method_name, method_signature, current_klass, true, CHECK);
  28.120  }
  28.121  
  28.122  
    29.1 --- a/src/share/vm/interpreter/linkResolver.hpp	Tue Dec 13 12:51:17 2016 -0800
    29.2 +++ b/src/share/vm/interpreter/linkResolver.hpp	Thu Jun 08 13:40:41 2017 -0700
    29.3 @@ -1,5 +1,5 @@
    29.4  /*
    29.5 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
    29.6 + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    29.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    29.8   *
    29.9   * This code is free software; you can redistribute it and/or modify it
   29.10 @@ -142,7 +142,7 @@
   29.11    static void linktime_resolve_virtual_method   (methodHandle &resolved_method, KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature,KlassHandle current_klass, bool check_access, TRAPS);
   29.12    static void linktime_resolve_interface_method (methodHandle& resolved_method, KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, bool check_access, TRAPS);
   29.13  
   29.14 -  static void runtime_resolve_special_method    (CallInfo& result, methodHandle resolved_method, KlassHandle resolved_klass, KlassHandle current_klass, bool check_access, TRAPS);
   29.15 +  static void runtime_resolve_special_method    (CallInfo& result, methodHandle resolved_method, KlassHandle resolved_klass, KlassHandle current_klass, Handle recv, bool check_access, TRAPS);
   29.16    static void runtime_resolve_virtual_method    (CallInfo& result, methodHandle resolved_method, KlassHandle resolved_klass, Handle recv, KlassHandle recv_klass, bool check_null_and_abstract, TRAPS);
   29.17    static void runtime_resolve_interface_method  (CallInfo& result, methodHandle resolved_method, KlassHandle resolved_klass, Handle recv, KlassHandle recv_klass, bool check_null_and_abstract, TRAPS);
   29.18  
   29.19 @@ -173,7 +173,7 @@
   29.20    //   resolved_klass = specified class (i.e., static receiver class)
   29.21    //   current_klass  = sending method holder (i.e., class containing the method containing the call being resolved)
   29.22    static void resolve_static_call   (CallInfo& result,              KlassHandle& resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, bool check_access, bool initialize_klass, TRAPS);
   29.23 -  static void resolve_special_call  (CallInfo& result,              KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, bool check_access, TRAPS);
   29.24 +  static void resolve_special_call  (CallInfo& result, Handle recv, KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, bool check_access, TRAPS);
   29.25    static void resolve_virtual_call  (CallInfo& result, Handle recv, KlassHandle recv_klass, KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, bool check_access, bool check_null_and_abstract, TRAPS);
   29.26    static void resolve_interface_call(CallInfo& result, Handle recv, KlassHandle recv_klass, KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, bool check_access, bool check_null_and_abstract, TRAPS);
   29.27    static void resolve_handle_call   (CallInfo& result,                                      KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, TRAPS);
   29.28 @@ -196,7 +196,7 @@
   29.29  
   29.30    // runtime resolving from constant pool
   29.31    static void resolve_invokestatic   (CallInfo& result,              constantPoolHandle pool, int index, TRAPS);
   29.32 -  static void resolve_invokespecial  (CallInfo& result,              constantPoolHandle pool, int index, TRAPS);
   29.33 +  static void resolve_invokespecial  (CallInfo& result, Handle recv, constantPoolHandle pool, int index, TRAPS);
   29.34    static void resolve_invokevirtual  (CallInfo& result, Handle recv, constantPoolHandle pool, int index, TRAPS);
   29.35    static void resolve_invokeinterface(CallInfo& result, Handle recv, constantPoolHandle pool, int index, TRAPS);
   29.36    static void resolve_invokedynamic  (CallInfo& result,              constantPoolHandle pool, int index, TRAPS);
    30.1 --- a/src/share/vm/oops/cpCache.cpp	Tue Dec 13 12:51:17 2016 -0800
    30.2 +++ b/src/share/vm/oops/cpCache.cpp	Thu Jun 08 13:40:41 2017 -0700
    30.3 @@ -1,5 +1,5 @@
    30.4  /*
    30.5 - * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
    30.6 + * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
    30.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    30.8   *
    30.9   * This code is free software; you can redistribute it and/or modify it
   30.10 @@ -144,7 +144,8 @@
   30.11  
   30.12  void ConstantPoolCacheEntry::set_direct_or_vtable_call(Bytecodes::Code invoke_code,
   30.13                                                         methodHandle method,
   30.14 -                                                       int vtable_index) {
   30.15 +                                                       int vtable_index,
   30.16 +                                                       bool sender_is_interface) {
   30.17    bool is_vtable_call = (vtable_index >= 0);  // FIXME: split this method on this boolean
   30.18    assert(method->interpreter_entry() != NULL, "should have been set at this point");
   30.19    assert(!method->is_obsolete(),  "attempt to write obsolete method to cpCache");
   30.20 @@ -208,7 +209,13 @@
   30.21    if (byte_no == 1) {
   30.22      assert(invoke_code != Bytecodes::_invokevirtual &&
   30.23             invoke_code != Bytecodes::_invokeinterface, "");
   30.24 +    // Don't mark invokespecial to method as resolved if sender is an interface.  The receiver
   30.25 +    // has to be checked that it is a subclass of the current class every time this bytecode
   30.26 +    // is executed.
   30.27 +    if (invoke_code != Bytecodes::_invokespecial || !sender_is_interface ||
   30.28 +        method->name() == vmSymbols::object_initializer_name()) {
   30.29      set_bytecode_1(invoke_code);
   30.30 +    }
   30.31    } else if (byte_no == 2)  {
   30.32      if (change_to_virtual) {
   30.33        assert(invoke_code == Bytecodes::_invokeinterface, "");
   30.34 @@ -238,17 +245,18 @@
   30.35    NOT_PRODUCT(verify(tty));
   30.36  }
   30.37  
   30.38 -void ConstantPoolCacheEntry::set_direct_call(Bytecodes::Code invoke_code, methodHandle method) {
   30.39 +void ConstantPoolCacheEntry::set_direct_call(Bytecodes::Code invoke_code, methodHandle method,
   30.40 +                                             bool sender_is_interface) {
   30.41    int index = Method::nonvirtual_vtable_index;
   30.42    // index < 0; FIXME: inline and customize set_direct_or_vtable_call
   30.43 -  set_direct_or_vtable_call(invoke_code, method, index);
   30.44 +  set_direct_or_vtable_call(invoke_code, method, index, sender_is_interface);
   30.45  }
   30.46  
   30.47  void ConstantPoolCacheEntry::set_vtable_call(Bytecodes::Code invoke_code, methodHandle method, int index) {
   30.48    // either the method is a miranda or its holder should accept the given index
   30.49    assert(method->method_holder()->is_interface() || method->method_holder()->verify_vtable_index(index), "");
   30.50    // index >= 0; FIXME: inline and customize set_direct_or_vtable_call
   30.51 -  set_direct_or_vtable_call(invoke_code, method, index);
   30.52 +  set_direct_or_vtable_call(invoke_code, method, index, false);
   30.53  }
   30.54  
   30.55  void ConstantPoolCacheEntry::set_itable_call(Bytecodes::Code invoke_code, methodHandle method, int index) {
    31.1 --- a/src/share/vm/oops/cpCache.hpp	Tue Dec 13 12:51:17 2016 -0800
    31.2 +++ b/src/share/vm/oops/cpCache.hpp	Thu Jun 08 13:40:41 2017 -0700
    31.3 @@ -229,13 +229,15 @@
    31.4    void set_direct_or_vtable_call(
    31.5      Bytecodes::Code invoke_code,                 // the bytecode used for invoking the method
    31.6      methodHandle    method,                      // the method/prototype if any (NULL, otherwise)
    31.7 -    int             vtable_index                 // the vtable index if any, else negative
    31.8 +    int             vtable_index,                // the vtable index if any, else negative
    31.9 +    bool            sender_is_interface
   31.10    );
   31.11  
   31.12   public:
   31.13    void set_direct_call(                          // sets entry to exact concrete method entry
   31.14      Bytecodes::Code invoke_code,                 // the bytecode used for invoking the method
   31.15 -    methodHandle    method                       // the method to call
   31.16 +    methodHandle    method,                      // the method to call
   31.17 +    bool            sender_is_interface
   31.18    );
   31.19  
   31.20    void set_vtable_call(                          // sets entry to vtable index
    32.1 --- a/src/share/vm/opto/callnode.hpp	Tue Dec 13 12:51:17 2016 -0800
    32.2 +++ b/src/share/vm/opto/callnode.hpp	Thu Jun 08 13:40:41 2017 -0700
    32.3 @@ -449,8 +449,8 @@
    32.4    void delete_replaced_nodes() {
    32.5      _replaced_nodes.reset();
    32.6    }
    32.7 -  void apply_replaced_nodes() {
    32.8 -    _replaced_nodes.apply(this);
    32.9 +  void apply_replaced_nodes(uint idx) {
   32.10 +    _replaced_nodes.apply(this, idx);
   32.11    }
   32.12    void merge_replaced_nodes_with(SafePointNode* sfpt) {
   32.13      _replaced_nodes.merge_with(sfpt->_replaced_nodes);
    33.1 --- a/src/share/vm/opto/classes.hpp	Tue Dec 13 12:51:17 2016 -0800
    33.2 +++ b/src/share/vm/opto/classes.hpp	Thu Jun 08 13:40:41 2017 -0700
    33.3 @@ -79,6 +79,7 @@
    33.4  macro(CmpLTMask)
    33.5  macro(CmpP)
    33.6  macro(CmpU)
    33.7 +macro(CmpUL)
    33.8  macro(CompareAndSwapI)
    33.9  macro(CompareAndSwapL)
   33.10  macro(CompareAndSwapP)
    34.1 --- a/src/share/vm/opto/doCall.cpp	Tue Dec 13 12:51:17 2016 -0800
    34.2 +++ b/src/share/vm/opto/doCall.cpp	Thu Jun 08 13:40:41 2017 -0700
    34.3 @@ -1,5 +1,5 @@
    34.4  /*
    34.5 - * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
    34.6 + * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
    34.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    34.8   *
    34.9   * This code is free software; you can redistribute it and/or modify it
   34.10 @@ -477,6 +477,30 @@
   34.11      speculative_receiver_type = receiver_type != NULL ? receiver_type->speculative_type() : NULL;
   34.12    }
   34.13  
   34.14 +  // invoke-super-special
   34.15 +  if (iter().cur_bc_raw() == Bytecodes::_invokespecial && !orig_callee->is_object_initializer()) {
   34.16 +    ciInstanceKlass* calling_klass = method()->holder();
   34.17 +    ciInstanceKlass* sender_klass =
   34.18 +        calling_klass->is_anonymous() ? calling_klass->host_klass() :
   34.19 +                                        calling_klass;
   34.20 +    if (sender_klass->is_interface()) {
   34.21 +      Node* receiver_node = stack(sp() - nargs);
   34.22 +      Node* cls_node = makecon(TypeKlassPtr::make(sender_klass));
   34.23 +      Node* bad_type_ctrl = NULL;
   34.24 +      Node* casted_receiver = gen_checkcast(receiver_node, cls_node, &bad_type_ctrl);
   34.25 +      if (bad_type_ctrl != NULL) {
   34.26 +        PreserveJVMState pjvms(this);
   34.27 +        set_control(bad_type_ctrl);
   34.28 +        uncommon_trap(Deoptimization::Reason_class_check,
   34.29 +                      Deoptimization::Action_none);
   34.30 +      }
   34.31 +      if (stopped()) {
   34.32 +        return; // MUST uncommon-trap?
   34.33 +      }
   34.34 +      set_stack(sp() - nargs, casted_receiver);
   34.35 +    }
   34.36 +  }
   34.37 +
   34.38    // Note:  It's OK to try to inline a virtual call.
   34.39    // The call generator will not attempt to inline a polymorphic call
   34.40    // unless it knows how to optimize the receiver dispatch.
    35.1 --- a/src/share/vm/opto/loopPredicate.cpp	Tue Dec 13 12:51:17 2016 -0800
    35.2 +++ b/src/share/vm/opto/loopPredicate.cpp	Thu Jun 08 13:40:41 2017 -0700
    35.3 @@ -28,6 +28,7 @@
    35.4  #include "opto/callnode.hpp"
    35.5  #include "opto/connode.hpp"
    35.6  #include "opto/loopnode.hpp"
    35.7 +#include "opto/matcher.hpp"
    35.8  #include "opto/mulnode.hpp"
    35.9  #include "opto/rootnode.hpp"
   35.10  #include "opto/subnode.hpp"
   35.11 @@ -593,50 +594,140 @@
   35.12  //   max(scale*i + offset) = scale*init + offset
   35.13  BoolNode* PhaseIdealLoop::rc_predicate(IdealLoopTree *loop, Node* ctrl,
   35.14                                         int scale, Node* offset,
   35.15 -                                       Node* init, Node* limit, Node* stride,
   35.16 -                                       Node* range, bool upper) {
   35.17 +                                       Node* init, Node* limit, jint stride,
   35.18 +                                       Node* range, bool upper, bool &overflow) {
   35.19 +  jint con_limit  = limit->is_Con()  ? limit->get_int()  : 0;
   35.20 +  jint con_init   = init->is_Con()   ? init->get_int()   : 0;
   35.21 +  jint con_offset = offset->is_Con() ? offset->get_int() : 0;
   35.22 +
   35.23    stringStream* predString = NULL;
   35.24    if (TraceLoopPredicate) {
   35.25      predString = new stringStream();
   35.26      predString->print("rc_predicate ");
   35.27    }
   35.28  
   35.29 -  Node* max_idx_expr  = init;
   35.30 -  int stride_con = stride->get_int();
   35.31 -  if ((stride_con > 0) == (scale > 0) == upper) {
   35.32 -    if (LoopLimitCheck) {
   35.33 -      // With LoopLimitCheck limit is not exact.
   35.34 -      // Calculate exact limit here.
   35.35 -      // Note, counted loop's test is '<' or '>'.
   35.36 -      limit = exact_limit(loop);
   35.37 -      max_idx_expr = new (C) SubINode(limit, stride);
   35.38 -      register_new_node(max_idx_expr, ctrl);
   35.39 -      if (TraceLoopPredicate) predString->print("(limit - stride) ");
   35.40 +  overflow = false;
   35.41 +  Node* max_idx_expr = NULL;
   35.42 +  const TypeInt* idx_type = TypeInt::INT;
   35.43 +  if ((stride > 0) == (scale > 0) == upper) {
   35.44 +    if (TraceLoopPredicate) {
   35.45 +      predString->print(limit->is_Con() ? "(%d " : "(limit ", con_limit);
   35.46 +      predString->print("- %d) ", stride);
   35.47 +    }
   35.48 +    // Check if (limit - stride) may overflow
   35.49 +    const TypeInt* limit_type = _igvn.type(limit)->isa_int();
   35.50 +    jint limit_lo = limit_type->_lo;
   35.51 +    jint limit_hi = limit_type->_hi;
   35.52 +    jint res_lo = limit_lo - stride;
   35.53 +    jint res_hi = limit_hi - stride;
   35.54 +    if ((stride > 0 && (res_lo < limit_lo)) ||
   35.55 +        (stride < 0 && (res_hi > limit_hi))) {
   35.56 +      // No overflow possible
   35.57 +      ConINode* con_stride = _igvn.intcon(stride);
   35.58 +      set_ctrl(con_stride, C->root());
   35.59 +      max_idx_expr = new (C) SubINode(limit, con_stride);
   35.60 +      idx_type = TypeInt::make(limit_lo - stride, limit_hi - stride, limit_type->_widen);
   35.61      } else {
   35.62 -      max_idx_expr = new (C) SubINode(limit, stride);
   35.63 -      register_new_node(max_idx_expr, ctrl);
   35.64 -      if (TraceLoopPredicate) predString->print("(limit - stride) ");
   35.65 +      // May overflow
   35.66 +      overflow = true;
   35.67 +      limit = new (C) ConvI2LNode(limit);
   35.68 +      register_new_node(limit, ctrl);
   35.69 +      ConLNode* con_stride = _igvn.longcon(stride);
   35.70 +      set_ctrl(con_stride, C->root());
   35.71 +      max_idx_expr = new (C) SubLNode(limit, con_stride);
   35.72      }
   35.73 +    register_new_node(max_idx_expr, ctrl);
   35.74    } else {
   35.75 -    if (TraceLoopPredicate) predString->print("init ");
   35.76 +    if (TraceLoopPredicate) {
   35.77 +      predString->print(init->is_Con() ? "%d " : "init ", con_init);
   35.78 +    }
   35.79 +    idx_type = _igvn.type(init)->isa_int();
   35.80 +    max_idx_expr = init;
   35.81    }
   35.82  
   35.83    if (scale != 1) {
   35.84      ConNode* con_scale = _igvn.intcon(scale);
   35.85 -    max_idx_expr = new (C) MulINode(max_idx_expr, con_scale);
   35.86 +    set_ctrl(con_scale, C->root());
   35.87 +    if (TraceLoopPredicate) {
   35.88 +      predString->print("* %d ", scale);
   35.89 +    }
   35.90 +    // Check if (scale * max_idx_expr) may overflow
   35.91 +    const TypeInt* scale_type = TypeInt::make(scale);
   35.92 +    MulINode* mul = new (C) MulINode(max_idx_expr, con_scale);
   35.93 +    idx_type = (TypeInt*)mul->mul_ring(idx_type, scale_type);
   35.94 +    if (overflow || TypeInt::INT->higher_equal(idx_type)) {
   35.95 +      // May overflow
   35.96 +      mul->destruct();
   35.97 +      if (!overflow) {
   35.98 +        max_idx_expr = new (C) ConvI2LNode(max_idx_expr);
   35.99 +        register_new_node(max_idx_expr, ctrl);
  35.100 +      }
  35.101 +      overflow = true;
  35.102 +      con_scale = _igvn.longcon(scale);
  35.103 +      set_ctrl(con_scale, C->root());
  35.104 +      max_idx_expr = new (C) MulLNode(max_idx_expr, con_scale);
  35.105 +    } else {
  35.106 +      // No overflow possible
  35.107 +      max_idx_expr = mul;
  35.108 +    }
  35.109      register_new_node(max_idx_expr, ctrl);
  35.110 -    if (TraceLoopPredicate) predString->print("* %d ", scale);
  35.111    }
  35.112  
  35.113 -  if (offset && (!offset->is_Con() || offset->get_int() != 0)){
  35.114 -    max_idx_expr = new (C) AddINode(max_idx_expr, offset);
  35.115 +  if (offset && (!offset->is_Con() || con_offset != 0)){
  35.116 +    if (TraceLoopPredicate) {
  35.117 +      predString->print(offset->is_Con() ? "+ %d " : "+ offset", con_offset);
  35.118 +    }
  35.119 +    // Check if (max_idx_expr + offset) may overflow
  35.120 +    const TypeInt* offset_type = _igvn.type(offset)->isa_int();
  35.121 +    jint lo = idx_type->_lo + offset_type->_lo;
  35.122 +    jint hi = idx_type->_hi + offset_type->_hi;
  35.123 +    if (overflow || (lo > hi) ||
  35.124 +        ((idx_type->_lo & offset_type->_lo) < 0 && lo >= 0) ||
  35.125 +        ((~(idx_type->_hi | offset_type->_hi)) < 0 && hi < 0)) {
  35.126 +      // May overflow
  35.127 +      if (!overflow) {
  35.128 +        max_idx_expr = new (C) ConvI2LNode(max_idx_expr);
  35.129 +        register_new_node(max_idx_expr, ctrl);
  35.130 +      }
  35.131 +      overflow = true;
  35.132 +      offset = new (C) ConvI2LNode(offset);
  35.133 +      register_new_node(offset, ctrl);
  35.134 +      max_idx_expr = new (C) AddLNode(max_idx_expr, offset);
  35.135 +    } else {
  35.136 +      // No overflow possible
  35.137 +      max_idx_expr = new (C) AddINode(max_idx_expr, offset);
  35.138 +    }
  35.139      register_new_node(max_idx_expr, ctrl);
  35.140 -    if (TraceLoopPredicate)
  35.141 -      if (offset->is_Con()) predString->print("+ %d ", offset->get_int());
  35.142 -      else predString->print("+ offset ");
  35.143    }
  35.144  
  35.145 -  CmpUNode* cmp = new (C) CmpUNode(max_idx_expr, range);
  35.146 +  CmpNode* cmp = NULL;
  35.147 +  if (overflow) {
  35.148 +    // Integer expressions may overflow, do long comparison
  35.149 +    range = new (C) ConvI2LNode(range);
  35.150 +    register_new_node(range, ctrl);
  35.151 +    if (!Matcher::has_match_rule(Op_CmpUL)) {
  35.152 +      // We don't support unsigned long comparisons. Set 'max_idx_expr'
  35.153 +      // to max_julong if < 0 to make the signed comparison fail.
  35.154 +      ConINode* sign_pos = _igvn.intcon(BitsPerLong - 1);
  35.155 +      set_ctrl(sign_pos, C->root());
  35.156 +      Node* sign_bit_mask = new (C) RShiftLNode(max_idx_expr, sign_pos);
  35.157 +      register_new_node(sign_bit_mask, ctrl);
  35.158 +      // OR with sign bit to set all bits to 1 if negative (otherwise no change)
  35.159 +      max_idx_expr = new (C) OrLNode(max_idx_expr, sign_bit_mask);
  35.160 +      register_new_node(max_idx_expr, ctrl);
  35.161 +      // AND with 0x7ff... to unset the sign bit
  35.162 +      ConLNode* remove_sign_mask = _igvn.longcon(max_jlong);
  35.163 +      set_ctrl(remove_sign_mask, C->root());
  35.164 +      max_idx_expr = new (C) AndLNode(max_idx_expr, remove_sign_mask);
  35.165 +      register_new_node(max_idx_expr, ctrl);
  35.166 +
  35.167 +      cmp = new (C) CmpLNode(max_idx_expr, range);
  35.168 +    } else {
  35.169 +      cmp = new (C) CmpULNode(max_idx_expr, range);
  35.170 +    }
  35.171 +  } else {
  35.172 +    cmp = new (C) CmpUNode(max_idx_expr, range);
  35.173 +  }
  35.174    register_new_node(cmp, ctrl);
  35.175    BoolNode* bol = new (C) BoolNode(cmp, BoolTest::lt);
  35.176    register_new_node(bol, ctrl);
  35.177 @@ -786,8 +877,11 @@
  35.178        assert(ok, "must be index expression");
  35.179  
  35.180        Node* init    = cl->init_trip();
  35.181 -      Node* limit   = cl->limit();
  35.182 -      Node* stride  = cl->stride();
  35.183 +      // Limit is not exact.
  35.184 +      // Calculate exact limit here.
  35.185 +      // Note, counted loop's test is '<' or '>'.
  35.186 +      Node* limit   = exact_limit(loop);
  35.187 +      int  stride   = cl->stride()->get_int();
  35.188  
  35.189        // Build if's for the upper and lower bound tests.  The
  35.190        // lower_bound test will dominate the upper bound test and all
  35.191 @@ -805,16 +899,18 @@
  35.192          assert(invar.is_invariant(offset), "offset must be loop invariant");
  35.193          offset = invar.clone(offset, ctrl);
  35.194        }
  35.195 +      // If predicate expressions may overflow in the integer range, longs are used.
  35.196 +      bool overflow = false;
  35.197  
  35.198        // Test the lower bound
  35.199 -      Node*  lower_bound_bol = rc_predicate(loop, ctrl, scale, offset, init, limit, stride, rng, false);
  35.200 +      Node*  lower_bound_bol = rc_predicate(loop, ctrl, scale, offset, init, limit, stride, rng, false, overflow);
  35.201        IfNode* lower_bound_iff = lower_bound_proj->in(0)->as_If();
  35.202        _igvn.hash_delete(lower_bound_iff);
  35.203        lower_bound_iff->set_req(1, lower_bound_bol);
  35.204        if (TraceLoopPredicate) tty->print_cr("lower bound check if: %d", lower_bound_iff->_idx);
  35.205  
  35.206        // Test the upper bound
  35.207 -      Node* upper_bound_bol = rc_predicate(loop, lower_bound_proj, scale, offset, init, limit, stride, rng, true);
  35.208 +      Node* upper_bound_bol = rc_predicate(loop, lower_bound_proj, scale, offset, init, limit, stride, rng, true, overflow);
  35.209        IfNode* upper_bound_iff = upper_bound_proj->in(0)->as_If();
  35.210        _igvn.hash_delete(upper_bound_iff);
  35.211        upper_bound_iff->set_req(1, upper_bound_bol);
    36.1 --- a/src/share/vm/opto/loopnode.cpp	Tue Dec 13 12:51:17 2016 -0800
    36.2 +++ b/src/share/vm/opto/loopnode.cpp	Thu Jun 08 13:40:41 2017 -0700
    36.3 @@ -278,8 +278,16 @@
    36.4      return false;
    36.5  
    36.6    // Allow funny placement of Safepoint
    36.7 -  if (back_control->Opcode() == Op_SafePoint)
    36.8 +  if (back_control->Opcode() == Op_SafePoint) {
    36.9 +    if (UseCountedLoopSafepoints) {
   36.10 +      // Leaving the safepoint on the backedge and creating a
   36.11 +      // CountedLoop will confuse optimizations. We can't move the
   36.12 +      // safepoint around because its jvm state wouldn't match a new
   36.13 +      // location. Give up on that loop.
   36.14 +      return false;
   36.15 +    }
   36.16      back_control = back_control->in(TypeFunc::Control);
   36.17 +  }
   36.18  
   36.19    // Controlling test for loop
   36.20    Node *iftrue = back_control;
    37.1 --- a/src/share/vm/opto/loopnode.hpp	Tue Dec 13 12:51:17 2016 -0800
    37.2 +++ b/src/share/vm/opto/loopnode.hpp	Thu Jun 08 13:40:41 2017 -0700
    37.3 @@ -905,8 +905,8 @@
    37.4    // Construct a range check for a predicate if
    37.5    BoolNode* rc_predicate(IdealLoopTree *loop, Node* ctrl,
    37.6                           int scale, Node* offset,
    37.7 -                         Node* init, Node* limit, Node* stride,
    37.8 -                         Node* range, bool upper);
    37.9 +                         Node* init, Node* limit, jint stride,
   37.10 +                         Node* range, bool upper, bool &overflow);
   37.11  
   37.12    // Implementation of the loop predication to promote checks outside the loop
   37.13    bool loop_predication_impl(IdealLoopTree *loop);
    38.1 --- a/src/share/vm/opto/output.cpp	Tue Dec 13 12:51:17 2016 -0800
    38.2 +++ b/src/share/vm/opto/output.cpp	Thu Jun 08 13:40:41 2017 -0700
    38.3 @@ -2095,6 +2095,7 @@
    38.4      if( last->is_MachIf() && last->in(1) == n &&
    38.5          ( op == Op_CmpI ||
    38.6            op == Op_CmpU ||
    38.7 +          op == Op_CmpUL ||
    38.8            op == Op_CmpP ||
    38.9            op == Op_CmpF ||
   38.10            op == Op_CmpD ||
    39.1 --- a/src/share/vm/opto/parse1.cpp	Tue Dec 13 12:51:17 2016 -0800
    39.2 +++ b/src/share/vm/opto/parse1.cpp	Thu Jun 08 13:40:41 2017 -0700
    39.3 @@ -1048,7 +1048,7 @@
    39.4          kit.make_dtrace_method_exit(method());
    39.5        }
    39.6        if (_replaced_nodes_for_exceptions) {
    39.7 -        kit.map()->apply_replaced_nodes();
    39.8 +        kit.map()->apply_replaced_nodes(_new_idx);
    39.9        }
   39.10        // Done with exception-path processing.
   39.11        ex_map = kit.make_exception_state(ex_oop);
   39.12 @@ -1069,7 +1069,7 @@
   39.13        _exits.add_exception_state(ex_map);
   39.14      }
   39.15    }
   39.16 -  _exits.map()->apply_replaced_nodes();
   39.17 +  _exits.map()->apply_replaced_nodes(_new_idx);
   39.18  }
   39.19  
   39.20  //-----------------------------create_entry_map-------------------------------
    40.1 --- a/src/share/vm/opto/replacednodes.cpp	Tue Dec 13 12:51:17 2016 -0800
    40.2 +++ b/src/share/vm/opto/replacednodes.cpp	Thu Jun 08 13:40:41 2017 -0700
    40.3 @@ -91,13 +91,17 @@
    40.4  }
    40.5  
    40.6  // Perfom node replacement (used when returning to caller)
    40.7 -void ReplacedNodes::apply(Node* n) {
    40.8 +void ReplacedNodes::apply(Node* n, uint idx) {
    40.9    if (is_empty()) {
   40.10      return;
   40.11    }
   40.12    for (int i = 0; i < _replaced_nodes->length(); i++) {
   40.13      ReplacedNode replaced = _replaced_nodes->at(i);
   40.14 -    n->replace_edge(replaced.initial(), replaced.improved());
   40.15 +    // Only apply if improved node was created in a callee to avoid
   40.16 +    // issues with irreducible loops in the caller
   40.17 +    if (replaced.improved()->_idx >= idx) {
   40.18 +      n->replace_edge(replaced.initial(), replaced.improved());
   40.19 +    }
   40.20    }
   40.21  }
   40.22  
    41.1 --- a/src/share/vm/opto/replacednodes.hpp	Tue Dec 13 12:51:17 2016 -0800
    41.2 +++ b/src/share/vm/opto/replacednodes.hpp	Thu Jun 08 13:40:41 2017 -0700
    41.3 @@ -71,7 +71,7 @@
    41.4    void record(Node* initial, Node* improved);
    41.5    void transfer_from(const ReplacedNodes& other, uint idx);
    41.6    void reset();
    41.7 -  void apply(Node* n);
    41.8 +  void apply(Node* n, uint idx);
    41.9    void merge_with(const ReplacedNodes& other);
   41.10    bool is_empty() const;
   41.11    void dump(outputStream *st) const;
    42.1 --- a/src/share/vm/opto/subnode.cpp	Tue Dec 13 12:51:17 2016 -0800
    42.2 +++ b/src/share/vm/opto/subnode.cpp	Thu Jun 08 13:40:41 2017 -0700
    42.3 @@ -707,6 +707,60 @@
    42.4    return TypeInt::CC;           // else use worst case results
    42.5  }
    42.6  
    42.7 +
    42.8 +// Simplify a CmpUL (compare 2 unsigned longs) node, based on local information.
    42.9 +// If both inputs are constants, compare them.
   42.10 +const Type* CmpULNode::sub(const Type* t1, const Type* t2) const {
   42.11 +  assert(!t1->isa_ptr(), "obsolete usage of CmpUL");
   42.12 +
   42.13 +  // comparing two unsigned longs
   42.14 +  const TypeLong* r0 = t1->is_long();   // Handy access
   42.15 +  const TypeLong* r1 = t2->is_long();
   42.16 +
   42.17 +  // Current installed version
   42.18 +  // Compare ranges for non-overlap
   42.19 +  julong lo0 = r0->_lo;
   42.20 +  julong hi0 = r0->_hi;
   42.21 +  julong lo1 = r1->_lo;
   42.22 +  julong hi1 = r1->_hi;
   42.23 +
   42.24 +  // If either one has both negative and positive values,
   42.25 +  // it therefore contains both 0 and -1, and since [0..-1] is the
   42.26 +  // full unsigned range, the type must act as an unsigned bottom.
   42.27 +  bool bot0 = ((jlong)(lo0 ^ hi0) < 0);
   42.28 +  bool bot1 = ((jlong)(lo1 ^ hi1) < 0);
   42.29 +
   42.30 +  if (bot0 || bot1) {
   42.31 +    // All unsigned values are LE -1 and GE 0.
   42.32 +    if (lo0 == 0 && hi0 == 0) {
   42.33 +      return TypeInt::CC_LE;            //   0 <= bot
   42.34 +    } else if ((jlong)lo0 == -1 && (jlong)hi0 == -1) {
   42.35 +      return TypeInt::CC_GE;            // -1 >= bot
   42.36 +    } else if (lo1 == 0 && hi1 == 0) {
   42.37 +      return TypeInt::CC_GE;            // bot >= 0
   42.38 +    } else if ((jlong)lo1 == -1 && (jlong)hi1 == -1) {
   42.39 +      return TypeInt::CC_LE;            // bot <= -1
   42.40 +    }
   42.41 +  } else {
   42.42 +    // We can use ranges of the form [lo..hi] if signs are the same.
   42.43 +    assert(lo0 <= hi0 && lo1 <= hi1, "unsigned ranges are valid");
   42.44 +    // results are reversed, '-' > '+' for unsigned compare
   42.45 +    if (hi0 < lo1) {
   42.46 +      return TypeInt::CC_LT;            // smaller
   42.47 +    } else if (lo0 > hi1) {
   42.48 +      return TypeInt::CC_GT;            // greater
   42.49 +    } else if (hi0 == lo1 && lo0 == hi1) {
   42.50 +      return TypeInt::CC_EQ;            // Equal results
   42.51 +    } else if (lo0 >= hi1) {
   42.52 +      return TypeInt::CC_GE;
   42.53 +    } else if (hi0 <= lo1) {
   42.54 +      return TypeInt::CC_LE;
   42.55 +    }
   42.56 +  }
   42.57 +
   42.58 +  return TypeInt::CC;                   // else use worst case results
   42.59 +}
   42.60 +
   42.61  //=============================================================================
   42.62  //------------------------------sub--------------------------------------------
   42.63  // Simplify an CmpP (compare 2 pointers) node, based on local information.
    43.1 --- a/src/share/vm/opto/subnode.hpp	Tue Dec 13 12:51:17 2016 -0800
    43.2 +++ b/src/share/vm/opto/subnode.hpp	Thu Jun 08 13:40:41 2017 -0700
    43.3 @@ -192,6 +192,15 @@
    43.4    virtual const Type *sub( const Type *, const Type * ) const;
    43.5  };
    43.6  
    43.7 +//------------------------------CmpULNode---------------------------------------
    43.8 +// Compare 2 unsigned long values, returning condition codes (-1, 0 or 1).
    43.9 +class CmpULNode : public CmpNode {
   43.10 +public:
   43.11 +  CmpULNode(Node* in1, Node* in2) : CmpNode(in1, in2) { }
   43.12 +  virtual int Opcode() const;
   43.13 +  virtual const Type* sub(const Type*, const Type*) const;
   43.14 +};
   43.15 +
   43.16  //------------------------------CmpL3Node--------------------------------------
   43.17  // Compare 2 long values, returning integer value (-1, 0 or 1).
   43.18  class CmpL3Node : public CmpLNode {
    44.1 --- a/src/share/vm/prims/methodHandles.cpp	Tue Dec 13 12:51:17 2016 -0800
    44.2 +++ b/src/share/vm/prims/methodHandles.cpp	Thu Jun 08 13:40:41 2017 -0700
    44.3 @@ -1,5 +1,5 @@
    44.4  /*
    44.5 - * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
    44.6 + * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
    44.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44.8   *
    44.9   * This code is free software; you can redistribute it and/or modify it
   44.10 @@ -679,7 +679,7 @@
   44.11                          defc, name, type, caller, THREAD);
   44.12          } else if (ref_kind == JVM_REF_invokeSpecial) {
   44.13            LinkResolver::resolve_special_call(result,
   44.14 -                        defc, name, type, caller, caller.not_null(), THREAD);
   44.15 +                        Handle(), defc, name, type, caller, caller.not_null(), THREAD);
   44.16          } else if (ref_kind == JVM_REF_invokeVirtual) {
   44.17            LinkResolver::resolve_virtual_call(result, Handle(), defc,
   44.18                          defc, name, type, caller, caller.not_null(), false, THREAD);
   44.19 @@ -706,7 +706,7 @@
   44.20          assert(!HAS_PENDING_EXCEPTION, "");
   44.21          if (name == vmSymbols::object_initializer_name()) {
   44.22            LinkResolver::resolve_special_call(result,
   44.23 -                        defc, name, type, caller, caller.not_null(), THREAD);
   44.24 +                        Handle(), defc, name, type, caller, caller.not_null(), THREAD);
   44.25          } else {
   44.26            break;                // will throw after end of switch
   44.27          }
    45.1 --- a/src/share/vm/runtime/arguments.cpp	Tue Dec 13 12:51:17 2016 -0800
    45.2 +++ b/src/share/vm/runtime/arguments.cpp	Thu Jun 08 13:40:41 2017 -0700
    45.3 @@ -1,5 +1,5 @@
    45.4  /*
    45.5 - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
    45.6 + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
    45.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    45.8   *
    45.9   * This code is free software; you can redistribute it and/or modify it
   45.10 @@ -1768,10 +1768,39 @@
   45.11      FLAG_SET_CMDLINE(uintx, MaxRAMFraction, DefaultMaxRAMFraction);
   45.12    }
   45.13  
   45.14 -  const julong phys_mem =
   45.15 +  julong phys_mem =
   45.16      FLAG_IS_DEFAULT(MaxRAM) ? MIN2(os::physical_memory(), (julong)MaxRAM)
   45.17                              : (julong)MaxRAM;
   45.18  
   45.19 +  // Experimental support for CGroup memory limits
   45.20 +  if (UseCGroupMemoryLimitForHeap) {
   45.21 +    // This is a rough indicator that a CGroup limit may be in force
   45.22 +    // for this process
   45.23 +    const char* lim_file = "/sys/fs/cgroup/memory/memory.limit_in_bytes";
   45.24 +    FILE *fp = fopen(lim_file, "r");
   45.25 +    if (fp != NULL) {
   45.26 +      julong cgroup_max = 0;
   45.27 +      int ret = fscanf(fp, JULONG_FORMAT, &cgroup_max);
   45.28 +      if (ret == 1 && cgroup_max > 0) {
   45.29 +        // If unlimited, cgroup_max will be a very large, but unspecified
   45.30 +        // value, so use initial phys_mem as a limit
   45.31 +        if (PrintGCDetails && Verbose) {
   45.32 +          // Cannot use gclog_or_tty yet.
   45.33 +          tty->print_cr("Setting phys_mem to the min of cgroup limit ("
   45.34 +                        JULONG_FORMAT "MB) and initial phys_mem ("
   45.35 +                        JULONG_FORMAT "MB)", cgroup_max/M, phys_mem/M);
   45.36 +        }
   45.37 +        phys_mem = MIN2(cgroup_max, phys_mem);
   45.38 +      } else {
   45.39 +        warning("Unable to read/parse cgroup memory limit from %s: %s",
   45.40 +                lim_file, errno != 0 ? strerror(errno) : "unknown error");
   45.41 +      }
   45.42 +      fclose(fp);
   45.43 +    } else {
   45.44 +      warning("Unable to open cgroup memory limit file %s (%s)", lim_file, strerror(errno));
   45.45 +    }
   45.46 +  }
   45.47 +
   45.48    // If the maximum heap size has not been set with -Xmx,
   45.49    // then set it as fraction of the size of physical memory,
   45.50    // respecting the maximum and minimum sizes of the heap.
    46.1 --- a/src/share/vm/runtime/globals.hpp	Tue Dec 13 12:51:17 2016 -0800
    46.2 +++ b/src/share/vm/runtime/globals.hpp	Thu Jun 08 13:40:41 2017 -0700
    46.3 @@ -1,5 +1,5 @@
    46.4  /*
    46.5 - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    46.6 + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
    46.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    46.8   *
    46.9   * This code is free software; you can redistribute it and/or modify it
   46.10 @@ -2068,6 +2068,10 @@
   46.11            "Maximum ergonomically set heap size (in bytes); zero means use " \
   46.12            "MaxRAM / MaxRAMFraction")                                        \
   46.13                                                                              \
   46.14 +  experimental(bool, UseCGroupMemoryLimitForHeap, false,                    \
   46.15 +          "Use CGroup memory limit as physical memory limit for heap "      \
   46.16 +          "sizing")                                                         \
   46.17 +                                                                            \
   46.18    product(uintx, MaxRAMFraction, 4,                                         \
   46.19            "Maximum fraction (1/n) of real memory used for maximum heap "    \
   46.20            "size")                                                           \
    47.1 --- a/src/share/vm/runtime/javaCalls.cpp	Tue Dec 13 12:51:17 2016 -0800
    47.2 +++ b/src/share/vm/runtime/javaCalls.cpp	Thu Jun 08 13:40:41 2017 -0700
    47.3 @@ -1,5 +1,5 @@
    47.4  /*
    47.5 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
    47.6 + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    47.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    47.8   *
    47.9   * This code is free software; you can redistribute it and/or modify it
   47.10 @@ -231,7 +231,7 @@
   47.11  
   47.12  void JavaCalls::call_special(JavaValue* result, KlassHandle klass, Symbol* name, Symbol* signature, JavaCallArguments* args, TRAPS) {
   47.13    CallInfo callinfo;
   47.14 -  LinkResolver::resolve_special_call(callinfo, klass, name, signature, KlassHandle(), false, CHECK);
   47.15 +  LinkResolver::resolve_special_call(callinfo, args->receiver(), klass, name, signature, KlassHandle(), false, CHECK);
   47.16    methodHandle method = callinfo.selected_method();
   47.17    assert(method.not_null(), "should have thrown exception");
   47.18  
    48.1 --- a/src/share/vm/runtime/os.cpp	Tue Dec 13 12:51:17 2016 -0800
    48.2 +++ b/src/share/vm/runtime/os.cpp	Thu Jun 08 13:40:41 2017 -0700
    48.3 @@ -1,5 +1,5 @@
    48.4  /*
    48.5 - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
    48.6 + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    48.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    48.8   *
    48.9   * This code is free software; you can redistribute it and/or modify it
   48.10 @@ -78,6 +78,7 @@
   48.11  uintptr_t         os::_serialize_page_mask = 0;
   48.12  long              os::_rand_seed          = 1;
   48.13  int               os::_processor_count    = 0;
   48.14 +int               os::_initial_active_processor_count = 0;
   48.15  size_t            os::_page_sizes[os::page_sizes_max];
   48.16  
   48.17  #ifndef PRODUCT
   48.18 @@ -322,6 +323,7 @@
   48.19  }
   48.20  
   48.21  void os::init_before_ergo() {
   48.22 +  initialize_initial_active_processor_count();
   48.23    // We need to initialize large page support here because ergonomics takes some
   48.24    // decisions depending on large page support and the calculated large page size.
   48.25    large_page_init();
   48.26 @@ -835,7 +837,11 @@
   48.27    st->print("CPU:");
   48.28    st->print("total %d", os::processor_count());
   48.29    // It's not safe to query number of active processors after crash
   48.30 -  // st->print("(active %d)", os::active_processor_count());
   48.31 +  // st->print("(active %d)", os::active_processor_count()); but we can
   48.32 +  // print the initial number of active processors.
   48.33 +  // We access the raw value here because the assert in the accessor will
   48.34 +  // fail if the crash occurs before initialization of this value.
   48.35 +  st->print(" (initial active %d)", _initial_active_processor_count);
   48.36    st->print(" %s", VM_Version::cpu_features());
   48.37    st->cr();
   48.38    pd_print_cpu_info(st);
   48.39 @@ -1418,6 +1424,11 @@
   48.40    return result;
   48.41  }
   48.42  
   48.43 +void os::initialize_initial_active_processor_count() {
   48.44 +  assert(_initial_active_processor_count == 0, "Initial active processor count already set.");
   48.45 +  _initial_active_processor_count = active_processor_count();
   48.46 +}
   48.47 +
   48.48  void os::SuspendedThreadTask::run() {
   48.49    assert(Threads_lock->owned_by_self() || (_thread == VMThread::vm_thread()), "must have threads lock to call this");
   48.50    internal_do_task();
    49.1 --- a/src/share/vm/runtime/os.hpp	Tue Dec 13 12:51:17 2016 -0800
    49.2 +++ b/src/share/vm/runtime/os.hpp	Thu Jun 08 13:40:41 2017 -0700
    49.3 @@ -151,6 +151,7 @@
    49.4  
    49.5    static size_t page_size_for_region(size_t region_size, size_t min_pages, bool must_be_aligned);
    49.6  
    49.7 +  static void initialize_initial_active_processor_count();
    49.8   public:
    49.9    static void init(void);                      // Called before command line parsing
   49.10    static void init_before_ergo(void);          // Called after command line parsing
   49.11 @@ -238,6 +239,13 @@
   49.12    // Note that on some OSes this can change dynamically.
   49.13    static int active_processor_count();
   49.14  
   49.15 +  // At startup the number of active CPUs this process is allowed to run on.
   49.16 +  // This value does not change dynamically. May be different from active_processor_count().
   49.17 +  static int initial_active_processor_count() {
   49.18 +    assert(_initial_active_processor_count > 0, "Initial active processor count not set yet.");
   49.19 +    return _initial_active_processor_count;
   49.20 +  }
   49.21 +
   49.22    // Bind processes to processors.
   49.23    //     This is a two step procedure:
   49.24    //     first you generate a distribution of processes to processors,
   49.25 @@ -975,8 +983,9 @@
   49.26  
   49.27  
   49.28   protected:
   49.29 -  static long _rand_seed;                   // seed for random number generator
   49.30 -  static int _processor_count;              // number of processors
   49.31 +  static long _rand_seed;                     // seed for random number generator
   49.32 +  static int _processor_count;                // number of processors
   49.33 +  static int _initial_active_processor_count; // number of active processors during initialization.
   49.34  
   49.35    static char* format_boot_path(const char* format_string,
   49.36                                  const char* home,
    50.1 --- a/src/share/vm/runtime/vmStructs.cpp	Tue Dec 13 12:51:17 2016 -0800
    50.2 +++ b/src/share/vm/runtime/vmStructs.cpp	Thu Jun 08 13:40:41 2017 -0700
    50.3 @@ -1942,6 +1942,7 @@
    50.4    declare_c2_type(CmpPNode, CmpNode)                                      \
    50.5    declare_c2_type(CmpNNode, CmpNode)                                      \
    50.6    declare_c2_type(CmpLNode, CmpNode)                                      \
    50.7 +  declare_c2_type(CmpULNode, CmpNode)                                     \
    50.8    declare_c2_type(CmpL3Node, CmpLNode)                                    \
    50.9    declare_c2_type(CmpFNode, CmpNode)                                      \
   50.10    declare_c2_type(CmpF3Node, CmpFNode)                                    \
    51.1 --- a/src/share/vm/runtime/vm_version.cpp	Tue Dec 13 12:51:17 2016 -0800
    51.2 +++ b/src/share/vm/runtime/vm_version.cpp	Thu Jun 08 13:40:41 2017 -0700
    51.3 @@ -1,5 +1,5 @@
    51.4  /*
    51.5 - * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
    51.6 + * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
    51.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    51.8   *
    51.9   * This code is free software; you can redistribute it and/or modify it
   51.10 @@ -296,7 +296,7 @@
   51.11      // processor after the first 8.  For example, on a 72 cpu machine
   51.12      // and a chosen fraction of 5/8
   51.13      // use 8 + (72 - 8) * (5/8) == 48 worker threads.
   51.14 -    unsigned int ncpus = (unsigned int) os::active_processor_count();
   51.15 +    unsigned int ncpus = (unsigned int) os::initial_active_processor_count();
   51.16      return (ncpus <= switch_pt) ?
   51.17             ncpus :
   51.18            (switch_pt + ((ncpus - switch_pt) * num) / den);
    52.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    52.2 +++ b/test/compiler/c2/TestReplacedNodesOSR.java	Thu Jun 08 13:40:41 2017 -0700
    52.3 @@ -0,0 +1,86 @@
    52.4 +/*
    52.5 + * Copyright (c) 2017, Red Hat, Inc. All rights reserved.
    52.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    52.7 + *
    52.8 + * This code is free software; you can redistribute it and/or modify it
    52.9 + * under the terms of the GNU General Public License version 2 only, as
   52.10 + * published by the Free Software Foundation.
   52.11 + *
   52.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   52.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   52.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   52.15 + * version 2 for more details (a copy is included in the LICENSE file that
   52.16 + * accompanied this code).
   52.17 + *
   52.18 + * You should have received a copy of the GNU General Public License version
   52.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   52.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   52.21 + *
   52.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   52.23 + * or visit www.oracle.com if you need additional information or have any
   52.24 + * questions.
   52.25 + */
   52.26 +
   52.27 +/**
   52.28 + * @test
   52.29 + * @bug 8174164
   52.30 + * @summary SafePointNode::_replaced_nodes breaks with irreducible loops
   52.31 + * @run main/othervm -XX:-BackgroundCompilation TestReplacedNodesOSR
   52.32 + *
   52.33 + */
   52.34 +
   52.35 +public class TestReplacedNodesOSR {
   52.36 +
   52.37 +    static Object dummy;
   52.38 +
   52.39 +    static interface I {
   52.40 +    }
   52.41 +
   52.42 +    static class A implements I {
   52.43 +    }
   52.44 +
   52.45 +    static final class MyException extends Exception {
   52.46 +    }
   52.47 +
   52.48 +    static final A obj = new A();
   52.49 +    static I static_field() { return obj; }
   52.50 +
   52.51 +    // When OSR compiled, this method has an irreducible loop
   52.52 +    static void test(int v, MyException e) {
   52.53 +        int i = 0;
   52.54 +        for (;;) {
   52.55 +            if (i == 1000) {
   52.56 +                break;
   52.57 +            }
   52.58 +            try {
   52.59 +                if ((i%2) == 0) {
   52.60 +                    int j = 0;
   52.61 +                    for (;;) {
   52.62 +                        j++;
   52.63 +                        if (i+j != v) {
   52.64 +                            if (j == 1000) {
   52.65 +                                break;
   52.66 +                            }
   52.67 +                        } else {
   52.68 +                            A a = (A)static_field();
   52.69 +                            // replaced node recorded here
   52.70 +                            throw e;
   52.71 +                        }
   52.72 +                    }
   52.73 +                }
   52.74 +            } catch(MyException ex) {
   52.75 +            }
   52.76 +            i++;
   52.77 +            // replaced node applied on return of the method
   52.78 +            // replaced node used here
   52.79 +            dummy = static_field();
   52.80 +        }
   52.81 +    }
   52.82 +
   52.83 +
   52.84 +    static public void main(String[] args) {
   52.85 +        for (int i = 0; i < 1000; i++) {
   52.86 +            test(1100, new MyException());
   52.87 +        }
   52.88 +    }
   52.89 +}
    53.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    53.2 +++ b/test/compiler/loopopts/TestCountedLoopSafepointBackedge.java	Thu Jun 08 13:40:41 2017 -0700
    53.3 @@ -0,0 +1,52 @@
    53.4 +/*
    53.5 + * Copyright (c) 2016, Red Hat, Inc. All rights reserved.
    53.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    53.7 + *
    53.8 + * This code is free software; you can redistribute it and/or modify it
    53.9 + * under the terms of the GNU General Public License version 2 only, as
   53.10 + * published by the Free Software Foundation.
   53.11 + *
   53.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   53.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   53.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   53.15 + * version 2 for more details (a copy is included in the LICENSE file that
   53.16 + * accompanied this code).
   53.17 + *
   53.18 + * You should have received a copy of the GNU General Public License version
   53.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   53.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   53.21 + *
   53.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   53.23 + * or visit www.oracle.com if you need additional information or have any
   53.24 + * questions.
   53.25 + */
   53.26 +
   53.27 +/**
   53.28 + * @test
   53.29 + * @bug 8161147
   53.30 + * @summary Safepoint on backedge breaks UseCountedLoopSafepoints
   53.31 + * @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement -XX:+UseCountedLoopSafepoints TestCountedLoopSafepointBackedge
   53.32 + *
   53.33 + */
   53.34 +
   53.35 +public class TestCountedLoopSafepointBackedge {
   53.36 +    static void test(int[] arr, int inc) {
   53.37 +        int i = 0;
   53.38 +        for (;;) {
   53.39 +            for (int j = 0; j < 10; j++);
   53.40 +            arr[i] = i;
   53.41 +            i++;
   53.42 +            if (i >= 100) {
   53.43 +                break;
   53.44 +            }
   53.45 +            for (int j = 0; j < 10; j++);
   53.46 +        }
   53.47 +    }
   53.48 +
   53.49 +    static public void main(String[] args) {
   53.50 +        int[] arr = new int[100];
   53.51 +        for (int i = 0; i < 20000; i++) {
   53.52 +             test(arr, 1);
   53.53 +        }
   53.54 +    }
   53.55 +}
    54.1 --- a/test/runtime/handlerInTry/LoadHandlerInTry.java	Tue Dec 13 12:51:17 2016 -0800
    54.2 +++ b/test/runtime/handlerInTry/LoadHandlerInTry.java	Thu Jun 08 13:40:41 2017 -0700
    54.3 @@ -1,5 +1,5 @@
    54.4  /*
    54.5 - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
    54.6 + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
    54.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    54.8   *
    54.9   * This code is free software; you can redistribute it and/or modify it
   54.10 @@ -24,7 +24,7 @@
   54.11  /*
   54.12   * @test
   54.13   * @bug 8075118
   54.14 - * @summary Allow a ctor to call super() from a switch bytecode.
   54.15 + * @summary JVM stuck in infinite loop during verification
   54.16   * @compile HandlerInTry.jasm
   54.17   * @compile IsolatedHandlerInTry.jasm
   54.18   * @run main/othervm -Xverify:all LoadHandlerInTry
   54.19 @@ -70,9 +70,10 @@
   54.20          System.out.println("Regression test for bug 8075118");
   54.21          try {
   54.22              Class newClass = Class.forName("HandlerInTry");
   54.23 -        } catch (Exception e) {
   54.24 -            System.out.println("Failed: Exception was thrown: " + e.toString());
   54.25 -            throw e;
   54.26 +            throw new RuntimeException(
   54.27 +                 "Failed to throw VerifyError for HandlerInTry");
   54.28 +        } catch (java.lang.VerifyError e) {
   54.29 +            System.out.println("Passed: VerifyError exception was thrown");
   54.30          }
   54.31  
   54.32          try {
    55.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    55.2 +++ b/test/runtime/os/AvailableProcessors.java	Thu Jun 08 13:40:41 2017 -0700
    55.3 @@ -0,0 +1,103 @@
    55.4 +/*
    55.5 + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
    55.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    55.7 + *
    55.8 + * This code is free software; you can redistribute it and/or modify it
    55.9 + * under the terms of the GNU General Public License version 2 only, as
   55.10 + * published by the Free Software Foundation.
   55.11 + *
   55.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   55.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   55.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   55.15 + * version 2 for more details (a copy is included in the LICENSE file that
   55.16 + * accompanied this code).
   55.17 + *
   55.18 + * You should have received a copy of the GNU General Public License version
   55.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   55.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   55.21 + *
   55.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   55.23 + * or visit www.oracle.com if you need additional information or have any
   55.24 + * questions.
   55.25 + */
   55.26 +import java.io.File;
   55.27 +import com.oracle.java.testlibrary.ProcessTools;
   55.28 +import com.oracle.java.testlibrary.OutputAnalyzer;
   55.29 +import java.util.ArrayList;
   55.30 +
   55.31 +/*
   55.32 + * @test
   55.33 + * @bug 6515172
   55.34 + * @summary Check that availableProcessors reports the correct value when running in a cpuset on linux
   55.35 + * @requires os.family == "linux"
   55.36 + * @library /testlibrary
   55.37 + * @build com.oracle.java.testlibrary.*
   55.38 + * @run driver AvailableProcessors
   55.39 + */
   55.40 +public class AvailableProcessors {
   55.41 +
   55.42 +    static final String SUCCESS_STRING = "Found expected processors: ";
   55.43 +
   55.44 +    public static void main(String[] args) throws Throwable {
   55.45 +        if (args.length > 0)
   55.46 +            checkProcessors(Integer.parseInt(args[0]));
   55.47 +        else {
   55.48 +            // run ourselves under different cpu configurations
   55.49 +            // using the taskset command
   55.50 +            String taskset;
   55.51 +            final String taskset1 = "/bin/taskset";
   55.52 +            final String taskset2 = "/usr/bin/taskset";
   55.53 +            if (new File(taskset1).exists())
   55.54 +                taskset = taskset1;
   55.55 +            else if (new File(taskset2).exists())
   55.56 +                taskset = taskset2;
   55.57 +            else {
   55.58 +                System.out.println("Skipping test: could not find taskset command");
   55.59 +                return;
   55.60 +            }
   55.61 +
   55.62 +            int available = Runtime.getRuntime().availableProcessors();
   55.63 +
   55.64 +            if (available == 1) {
   55.65 +                System.out.println("Skipping test: only one processor available");
   55.66 +                return;
   55.67 +            }
   55.68 +
   55.69 +            // Get the java command we want to execute
   55.70 +            // Enable logging for easier failure diagnosis
   55.71 +            ProcessBuilder master =
   55.72 +                    ProcessTools.createJavaProcessBuilder(false,
   55.73 +                                                          "-XX:+UnlockDiagnosticVMOptions",
   55.74 +                                                          "-XX:+PrintActiveCpus",
   55.75 +                                                          "AvailableProcessors");
   55.76 +
   55.77 +            int[] expected = new int[] { 1, available/2, available-1, available };
   55.78 +
   55.79 +            for (int i : expected) {
   55.80 +                System.out.println("Testing for " + i + " processors ...");
   55.81 +                int max = i - 1;
   55.82 +                ArrayList<String> cmdline = new ArrayList<>(master.command());
   55.83 +                // prepend taskset command
   55.84 +                cmdline.add(0, "0-" + max);
   55.85 +                cmdline.add(0, "-c");
   55.86 +                cmdline.add(0, taskset);
   55.87 +                // append expected processor count
   55.88 +                cmdline.add(String.valueOf(i));
   55.89 +                ProcessBuilder pb = new ProcessBuilder(cmdline);
   55.90 +                System.out.println("Final command line: " +
   55.91 +                                   ProcessTools.getCommandLine(pb));
   55.92 +                OutputAnalyzer output = ProcessTools.executeProcess(pb);
   55.93 +                output.shouldContain(SUCCESS_STRING);
   55.94 +            }
   55.95 +        }
   55.96 +    }
   55.97 +
   55.98 +    static void checkProcessors(int expected) {
   55.99 +        int available = Runtime.getRuntime().availableProcessors();
  55.100 +        if (available != expected)
  55.101 +            throw new Error("Expected " + expected + " processors, but found "
  55.102 +                            + available);
  55.103 +        else
  55.104 +            System.out.println(SUCCESS_STRING + available);
  55.105 +    }
  55.106 +}

mercurial