Merge

Mon, 22 Dec 2014 09:27:29 -0800

author
asaha
date
Mon, 22 Dec 2014 09:27:29 -0800
changeset 7721
eff80b90c3ad
parent 7720
02e2c04a3289
parent 7503
6bed0ca7a09a
child 7722
626fd8c2eec6

Merge

.hgtags file | annotate | diff | comparison | revisions
make/hotspot_version file | annotate | diff | comparison | revisions
     1.1 --- a/.hgtags	Thu Dec 18 17:59:15 2014 -0800
     1.2 +++ b/.hgtags	Mon Dec 22 09:27:29 2014 -0800
     1.3 @@ -577,5 +577,7 @@
     1.4  fc1f9b67fd8c5d5cd94ecc03569d93e7ce7fb574 jdk8u40-b17
     1.5  bc5a90a4db47f1c497d7894434c42325f595cd02 hs25.40-b22
     1.6  31d3306aad29e39929418ed43f28212a5f5306a3 jdk8u40-b18
     1.7 +f8fc5cbe082ce0fb0c6c1dcd39493a16ed916353 hs25.40-b23
     1.8 +d9349fa8822336e0244da0a8448f3e6b2d62741d jdk8u40-b19
     1.9  b95f13f05f553309cd74d6ccf8fcedb259c6716c jdk8u45-b00
    1.10  41c3c456e326185053f0654be838f4b0bfb38078 jdk8u45-b01
     2.1 --- a/THIRD_PARTY_README	Thu Dec 18 17:59:15 2014 -0800
     2.2 +++ b/THIRD_PARTY_README	Mon Dec 22 09:27:29 2014 -0800
     2.3 @@ -3385,7 +3385,7 @@
     2.4  included with JRE 8, JDK 8, and OpenJDK 8.
     2.5  
     2.6    Apache Commons Math 3.2
     2.7 -  Apache Derby 10.10.1.3        
     2.8 +  Apache Derby 10.11.1.2
     2.9    Apache Jakarta BCEL 5.1 
    2.10    Apache Jakarta Regexp 1.4 
    2.11    Apache Santuario XML Security for Java 1.5.4
     3.1 --- a/src/cpu/ppc/vm/interp_masm_ppc_64.cpp	Thu Dec 18 17:59:15 2014 -0800
     3.2 +++ b/src/cpu/ppc/vm/interp_masm_ppc_64.cpp	Mon Dec 22 09:27:29 2014 -0800
     3.3 @@ -545,6 +545,9 @@
     3.4    cmplw(CCR0, Rindex, Rlength);
     3.5    sldi(RsxtIndex, RsxtIndex, index_shift);
     3.6    blt(CCR0, LnotOOR);
     3.7 +  // Index should be in R17_tos, array should be in R4_ARG2.
     3.8 +  mr(R17_tos, Rindex);
     3.9 +  mr(R4_ARG2, Rarray);
    3.10    load_dispatch_table(Rtmp, (address*)Interpreter::_throw_ArrayIndexOutOfBoundsException_entry);
    3.11    mtctr(Rtmp);
    3.12    bctr();
    3.13 @@ -1679,6 +1682,228 @@
    3.14    }
    3.15  }
    3.16  
    3.17 +// Argument and return type profilig.
    3.18 +// kills: tmp, tmp2, R0, CR0, CR1
    3.19 +void InterpreterMacroAssembler::profile_obj_type(Register obj, Register mdo_addr_base,
    3.20 +                                                 RegisterOrConstant mdo_addr_offs, Register tmp, Register tmp2) {
    3.21 +  Label do_nothing, do_update;
    3.22 +
    3.23 +  // tmp2 = obj is allowed
    3.24 +  assert_different_registers(obj, mdo_addr_base, tmp, R0);
    3.25 +  assert_different_registers(tmp2, mdo_addr_base, tmp, R0);
    3.26 +  const Register klass = tmp2;
    3.27 +
    3.28 +  verify_oop(obj);
    3.29 +
    3.30 +  ld(tmp, mdo_addr_offs, mdo_addr_base);
    3.31 +
    3.32 +  // Set null_seen if obj is 0.
    3.33 +  cmpdi(CCR0, obj, 0);
    3.34 +  ori(R0, tmp, TypeEntries::null_seen);
    3.35 +  beq(CCR0, do_update);
    3.36 +
    3.37 +  load_klass(klass, obj);
    3.38 +
    3.39 +  clrrdi(R0, tmp, exact_log2(-TypeEntries::type_klass_mask));
    3.40 +  // Basically same as andi(R0, tmp, TypeEntries::type_klass_mask);
    3.41 +  cmpd(CCR1, R0, klass);
    3.42 +  // Klass seen before, nothing to do (regardless of unknown bit).
    3.43 +  //beq(CCR1, do_nothing);
    3.44 +
    3.45 +  andi_(R0, klass, TypeEntries::type_unknown);
    3.46 +  // Already unknown. Nothing to do anymore.
    3.47 +  //bne(CCR0, do_nothing);
    3.48 +  crorc(/*CCR0 eq*/2, /*CCR1 eq*/4+2, /*CCR0 eq*/2); // cr0 eq = cr1 eq or cr0 ne
    3.49 +  beq(CCR0, do_nothing);
    3.50 +
    3.51 +  clrrdi_(R0, tmp, exact_log2(-TypeEntries::type_mask));
    3.52 +  orr(R0, klass, tmp); // Combine klass and null_seen bit (only used if (tmp & type_mask)==0).
    3.53 +  beq(CCR0, do_update); // First time here. Set profile type.
    3.54 +
    3.55 +  // Different than before. Cannot keep accurate profile.
    3.56 +  ori(R0, tmp, TypeEntries::type_unknown);
    3.57 +
    3.58 +  bind(do_update);
    3.59 +  // update profile
    3.60 +  std(R0, mdo_addr_offs, mdo_addr_base);
    3.61 +
    3.62 +  align(32, 12);
    3.63 +  bind(do_nothing);
    3.64 +}
    3.65 +
    3.66 +void InterpreterMacroAssembler::profile_arguments_type(Register callee, Register tmp1, Register tmp2, bool is_virtual) {
    3.67 +  if (!ProfileInterpreter) {
    3.68 +    return;
    3.69 +  }
    3.70 +
    3.71 +  assert_different_registers(callee, tmp1, tmp2, R28_mdx);
    3.72 +
    3.73 +  if (MethodData::profile_arguments() || MethodData::profile_return()) {
    3.74 +    Label profile_continue;
    3.75 +
    3.76 +    test_method_data_pointer(profile_continue);
    3.77 +
    3.78 +    int off_to_start = is_virtual ? in_bytes(VirtualCallData::virtual_call_data_size()) : in_bytes(CounterData::counter_data_size());
    3.79 +
    3.80 +    lbz(tmp1, in_bytes(DataLayout::tag_offset()) - off_to_start, R28_mdx);
    3.81 +    cmpwi(CCR0, tmp1, is_virtual ? DataLayout::virtual_call_type_data_tag : DataLayout::call_type_data_tag);
    3.82 +    bne(CCR0, profile_continue);
    3.83 +
    3.84 +    if (MethodData::profile_arguments()) {
    3.85 +      Label done;
    3.86 +      int off_to_args = in_bytes(TypeEntriesAtCall::args_data_offset());
    3.87 +      add(R28_mdx, off_to_args, R28_mdx);
    3.88 +
    3.89 +      for (int i = 0; i < TypeProfileArgsLimit; i++) {
    3.90 +        if (i > 0 || MethodData::profile_return()) {
    3.91 +          // If return value type is profiled we may have no argument to profile.
    3.92 +          ld(tmp1, in_bytes(TypeEntriesAtCall::cell_count_offset())-off_to_args, R28_mdx);
    3.93 +          cmpdi(CCR0, tmp1, (i+1)*TypeStackSlotEntries::per_arg_count());
    3.94 +          addi(tmp1, tmp1, -i*TypeStackSlotEntries::per_arg_count());
    3.95 +          blt(CCR0, done);
    3.96 +        }
    3.97 +        ld(tmp1, in_bytes(Method::const_offset()), callee);
    3.98 +        lhz(tmp1, in_bytes(ConstMethod::size_of_parameters_offset()), tmp1);
    3.99 +        // Stack offset o (zero based) from the start of the argument
   3.100 +        // list, for n arguments translates into offset n - o - 1 from
   3.101 +        // the end of the argument list. But there's an extra slot at
   3.102 +        // the top of the stack. So the offset is n - o from Lesp.
   3.103 +        ld(tmp2, in_bytes(TypeEntriesAtCall::stack_slot_offset(i))-off_to_args, R28_mdx);
   3.104 +        subf(tmp1, tmp2, tmp1);
   3.105 +
   3.106 +        sldi(tmp1, tmp1, Interpreter::logStackElementSize);
   3.107 +        ldx(tmp1, tmp1, R15_esp);
   3.108 +
   3.109 +        profile_obj_type(tmp1, R28_mdx, in_bytes(TypeEntriesAtCall::argument_type_offset(i))-off_to_args, tmp2, tmp1);
   3.110 +
   3.111 +        int to_add = in_bytes(TypeStackSlotEntries::per_arg_size());
   3.112 +        addi(R28_mdx, R28_mdx, to_add);
   3.113 +        off_to_args += to_add;
   3.114 +      }
   3.115 +
   3.116 +      if (MethodData::profile_return()) {
   3.117 +        ld(tmp1, in_bytes(TypeEntriesAtCall::cell_count_offset())-off_to_args, R28_mdx);
   3.118 +        addi(tmp1, tmp1, -TypeProfileArgsLimit*TypeStackSlotEntries::per_arg_count());
   3.119 +      }
   3.120 +
   3.121 +      bind(done);
   3.122 +
   3.123 +      if (MethodData::profile_return()) {
   3.124 +        // We're right after the type profile for the last
   3.125 +        // argument. tmp1 is the number of cells left in the
   3.126 +        // CallTypeData/VirtualCallTypeData to reach its end. Non null
   3.127 +        // if there's a return to profile.
   3.128 +        assert(ReturnTypeEntry::static_cell_count() < TypeStackSlotEntries::per_arg_count(), "can't move past ret type");
   3.129 +        sldi(tmp1, tmp1, exact_log2(DataLayout::cell_size));
   3.130 +        add(R28_mdx, tmp1, R28_mdx);
   3.131 +      }
   3.132 +    } else {
   3.133 +      assert(MethodData::profile_return(), "either profile call args or call ret");
   3.134 +      update_mdp_by_constant(in_bytes(TypeEntriesAtCall::return_only_size()));
   3.135 +    }
   3.136 +
   3.137 +    // Mdp points right after the end of the
   3.138 +    // CallTypeData/VirtualCallTypeData, right after the cells for the
   3.139 +    // return value type if there's one.
   3.140 +    align(32, 12);
   3.141 +    bind(profile_continue);
   3.142 +  }
   3.143 +}
   3.144 +
   3.145 +void InterpreterMacroAssembler::profile_return_type(Register ret, Register tmp1, Register tmp2) {
   3.146 +  assert_different_registers(ret, tmp1, tmp2);
   3.147 +  if (ProfileInterpreter && MethodData::profile_return()) {
   3.148 +    Label profile_continue;
   3.149 +
   3.150 +    test_method_data_pointer(profile_continue);
   3.151 +
   3.152 +    if (MethodData::profile_return_jsr292_only()) {
   3.153 +      // If we don't profile all invoke bytecodes we must make sure
   3.154 +      // it's a bytecode we indeed profile. We can't go back to the
   3.155 +      // begining of the ProfileData we intend to update to check its
   3.156 +      // type because we're right after it and we don't known its
   3.157 +      // length.
   3.158 +      lbz(tmp1, 0, R14_bcp);
   3.159 +      lbz(tmp2, Method::intrinsic_id_offset_in_bytes(), R19_method);
   3.160 +      cmpwi(CCR0, tmp1, Bytecodes::_invokedynamic);
   3.161 +      cmpwi(CCR1, tmp1, Bytecodes::_invokehandle);
   3.162 +      cror(/*CR0 eq*/2, /*CR1 eq*/4+2, /*CR0 eq*/2);
   3.163 +      cmpwi(CCR1, tmp2, vmIntrinsics::_compiledLambdaForm);
   3.164 +      cror(/*CR0 eq*/2, /*CR1 eq*/4+2, /*CR0 eq*/2);
   3.165 +      bne(CCR0, profile_continue);
   3.166 +    }
   3.167 +
   3.168 +    profile_obj_type(ret, R28_mdx, -in_bytes(ReturnTypeEntry::size()), tmp1, tmp2);
   3.169 +
   3.170 +    align(32, 12);
   3.171 +    bind(profile_continue);
   3.172 +  }
   3.173 +}
   3.174 +
   3.175 +void InterpreterMacroAssembler::profile_parameters_type(Register tmp1, Register tmp2, Register tmp3, Register tmp4) {
   3.176 +  if (ProfileInterpreter && MethodData::profile_parameters()) {
   3.177 +    Label profile_continue, done;
   3.178 +
   3.179 +    test_method_data_pointer(profile_continue);
   3.180 +
   3.181 +    // Load the offset of the area within the MDO used for
   3.182 +    // parameters. If it's negative we're not profiling any parameters.
   3.183 +    lwz(tmp1, in_bytes(MethodData::parameters_type_data_di_offset()) - in_bytes(MethodData::data_offset()), R28_mdx);
   3.184 +    cmpwi(CCR0, tmp1, 0);
   3.185 +    blt(CCR0, profile_continue);
   3.186 +
   3.187 +    // Compute a pointer to the area for parameters from the offset
   3.188 +    // and move the pointer to the slot for the last
   3.189 +    // parameters. Collect profiling from last parameter down.
   3.190 +    // mdo start + parameters offset + array length - 1
   3.191 +
   3.192 +    // Pointer to the parameter area in the MDO.
   3.193 +    const Register mdp = tmp1;
   3.194 +    add(mdp, tmp1, R28_mdx);
   3.195 +
   3.196 +    // Pffset of the current profile entry to update.
   3.197 +    const Register entry_offset = tmp2;
   3.198 +    // entry_offset = array len in number of cells
   3.199 +    ld(entry_offset, in_bytes(ArrayData::array_len_offset()), mdp);
   3.200 +
   3.201 +    int off_base = in_bytes(ParametersTypeData::stack_slot_offset(0));
   3.202 +    assert(off_base % DataLayout::cell_size == 0, "should be a number of cells");
   3.203 +
   3.204 +    // entry_offset (number of cells)  = array len - size of 1 entry + offset of the stack slot field
   3.205 +    addi(entry_offset, entry_offset, -TypeStackSlotEntries::per_arg_count() + (off_base / DataLayout::cell_size));
   3.206 +    // entry_offset in bytes
   3.207 +    sldi(entry_offset, entry_offset, exact_log2(DataLayout::cell_size));
   3.208 +
   3.209 +    Label loop;
   3.210 +    align(32, 12);
   3.211 +    bind(loop);
   3.212 +
   3.213 +    // Load offset on the stack from the slot for this parameter.
   3.214 +    ld(tmp3, entry_offset, mdp);
   3.215 +    sldi(tmp3, tmp3, Interpreter::logStackElementSize);
   3.216 +    neg(tmp3, tmp3);
   3.217 +    // Read the parameter from the local area.
   3.218 +    ldx(tmp3, tmp3, R18_locals);
   3.219 +
   3.220 +    // Make entry_offset now point to the type field for this parameter.
   3.221 +    int type_base = in_bytes(ParametersTypeData::type_offset(0));
   3.222 +    assert(type_base > off_base, "unexpected");
   3.223 +    addi(entry_offset, entry_offset, type_base - off_base);
   3.224 +
   3.225 +    // Profile the parameter.
   3.226 +    profile_obj_type(tmp3, mdp, entry_offset, tmp4, tmp3);
   3.227 +
   3.228 +    // Go to next parameter.
   3.229 +    int delta = TypeStackSlotEntries::per_arg_count() * DataLayout::cell_size + (type_base - off_base);
   3.230 +    cmpdi(CCR0, entry_offset, off_base + delta);
   3.231 +    addi(entry_offset, entry_offset, -delta);
   3.232 +    bge(CCR0, loop);
   3.233 +
   3.234 +    align(32, 12);
   3.235 +    bind(profile_continue);
   3.236 +  }
   3.237 +}
   3.238 +
   3.239  // Add a InterpMonitorElem to stack (see frame_sparc.hpp).
   3.240  void InterpreterMacroAssembler::add_monitor_to_stack(bool stack_is_empty, Register Rtemp1, Register Rtemp2) {
   3.241  
   3.242 @@ -2040,20 +2265,19 @@
   3.243    bne(CCR0, test);
   3.244  
   3.245    address fd = CAST_FROM_FN_PTR(address, verify_return_address);
   3.246 -  unsigned int nbytes_save = 10*8; // 10 volatile gprs
   3.247 -
   3.248 -  save_LR_CR(Rtmp);
   3.249 +  const int nbytes_save = 11*8; // volatile gprs except R0
   3.250 +  save_volatile_gprs(R1_SP, -nbytes_save); // except R0
   3.251 +  save_LR_CR(Rtmp); // Save in old frame.
   3.252    push_frame_reg_args(nbytes_save, Rtmp);
   3.253 -  save_volatile_gprs(R1_SP, 112); // except R0
   3.254  
   3.255    load_const_optimized(Rtmp, fd, R0);
   3.256    mr_if_needed(R4_ARG2, reg);
   3.257    mr(R3_ARG1, R19_method);
   3.258    call_c(Rtmp); // call C
   3.259  
   3.260 -  restore_volatile_gprs(R1_SP, 112); // except R0
   3.261    pop_frame();
   3.262    restore_LR_CR(Rtmp);
   3.263 +  restore_volatile_gprs(R1_SP, -nbytes_save); // except R0
   3.264    b(skip);
   3.265  
   3.266    // Perform a more elaborate out-of-line call.
     4.1 --- a/src/cpu/ppc/vm/interp_masm_ppc_64.hpp	Thu Dec 18 17:59:15 2014 -0800
     4.2 +++ b/src/cpu/ppc/vm/interp_masm_ppc_64.hpp	Mon Dec 22 09:27:29 2014 -0800
     4.3 @@ -255,6 +255,12 @@
     4.4    void record_klass_in_profile(Register receiver, Register scratch1, Register scratch2, bool is_virtual_call);
     4.5    void record_klass_in_profile_helper(Register receiver, Register scratch1, Register scratch2, int start_row, Label& done, bool is_virtual_call);
     4.6  
     4.7 +  // Argument and return type profiling.
     4.8 +  void profile_obj_type(Register obj, Register mdo_addr_base, RegisterOrConstant mdo_addr_offs, Register tmp, Register tmp2);
     4.9 +  void profile_arguments_type(Register callee, Register tmp1, Register tmp2, bool is_virtual);
    4.10 +  void profile_return_type(Register ret, Register tmp1, Register tmp2);
    4.11 +  void profile_parameters_type(Register tmp1, Register tmp2, Register tmp3, Register tmp4);
    4.12 +
    4.13  #endif // !CC_INTERP
    4.14  
    4.15    // Debugging
     5.1 --- a/src/cpu/ppc/vm/macroAssembler_ppc.cpp	Thu Dec 18 17:59:15 2014 -0800
     5.2 +++ b/src/cpu/ppc/vm/macroAssembler_ppc.cpp	Mon Dec 22 09:27:29 2014 -0800
     5.3 @@ -806,6 +806,7 @@
     5.4  
     5.5  // For verify_oops.
     5.6  void MacroAssembler::save_volatile_gprs(Register dst, int offset) {
     5.7 +  std(R2,  offset, dst);   offset += 8;
     5.8    std(R3,  offset, dst);   offset += 8;
     5.9    std(R4,  offset, dst);   offset += 8;
    5.10    std(R5,  offset, dst);   offset += 8;
    5.11 @@ -820,6 +821,7 @@
    5.12  
    5.13  // For verify_oops.
    5.14  void MacroAssembler::restore_volatile_gprs(Register src, int offset) {
    5.15 +  ld(R2,  offset, src);   offset += 8;
    5.16    ld(R3,  offset, src);   offset += 8;
    5.17    ld(R4,  offset, src);   offset += 8;
    5.18    ld(R5,  offset, src);   offset += 8;
    5.19 @@ -1186,6 +1188,16 @@
    5.20    call_VM(oop_result, entry_point, check_exceptions);
    5.21  }
    5.22  
    5.23 +void MacroAssembler::call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2, Register arg_3,
    5.24 +                             bool check_exceptions) {
    5.25 +  // R3_ARG1 is reserved for the thread
    5.26 +  mr_if_needed(R4_ARG2, arg_1);
    5.27 +  assert(arg_2 != R4_ARG2, "smashed argument");
    5.28 +  mr_if_needed(R5_ARG3, arg_2);
    5.29 +  mr_if_needed(R6_ARG4, arg_3);
    5.30 +  call_VM(oop_result, entry_point, check_exceptions);
    5.31 +}
    5.32 +
    5.33  void MacroAssembler::call_VM_leaf(address entry_point) {
    5.34    call_VM_leaf_base(entry_point);
    5.35  }
    5.36 @@ -3058,35 +3070,27 @@
    5.37    if (!VerifyOops) {
    5.38      return;
    5.39    }
    5.40 -  // Will be preserved.
    5.41 -  Register tmp = R11;
    5.42 -  assert(oop != tmp, "precondition");
    5.43 -  unsigned int nbytes_save = 10*8; // 10 volatile gprs
    5.44 +
    5.45    address/* FunctionDescriptor** */fd = StubRoutines::verify_oop_subroutine_entry_address();
    5.46 -  // save tmp
    5.47 -  mr(R0, tmp);
    5.48 -  // kill tmp
    5.49 -  save_LR_CR(tmp);
    5.50 +  const Register tmp = R11; // Will be preserved.
    5.51 +  const int nbytes_save = 11*8; // Volatile gprs except R0.
    5.52 +  save_volatile_gprs(R1_SP, -nbytes_save); // except R0
    5.53 +
    5.54 +  if (oop == tmp) mr(R4_ARG2, oop);
    5.55 +  save_LR_CR(tmp); // save in old frame
    5.56    push_frame_reg_args(nbytes_save, tmp);
    5.57 -  // restore tmp
    5.58 -  mr(tmp, R0);
    5.59 -  save_volatile_gprs(R1_SP, 112); // except R0
    5.60    // load FunctionDescriptor** / entry_address *
    5.61 -  load_const(tmp, fd);
    5.62 +  load_const_optimized(tmp, fd, R0);
    5.63    // load FunctionDescriptor* / entry_address
    5.64    ld(tmp, 0, tmp);
    5.65 -  mr(R4_ARG2, oop);
    5.66 -  load_const(R3_ARG1, (address)msg);
    5.67 -  // call destination for its side effect
    5.68 +  if (oop != tmp) mr_if_needed(R4_ARG2, oop);
    5.69 +  load_const_optimized(R3_ARG1, (address)msg, R0);
    5.70 +  // Call destination for its side effect.
    5.71    call_c(tmp);
    5.72 -  restore_volatile_gprs(R1_SP, 112); // except R0
    5.73 +
    5.74    pop_frame();
    5.75 -  // save tmp
    5.76 -  mr(R0, tmp);
    5.77 -  // kill tmp
    5.78    restore_LR_CR(tmp);
    5.79 -  // restore tmp
    5.80 -  mr(tmp, R0);
    5.81 +  restore_volatile_gprs(R1_SP, -nbytes_save); // except R0
    5.82  }
    5.83  
    5.84  const char* stop_types[] = {
     6.1 --- a/src/cpu/ppc/vm/macroAssembler_ppc.hpp	Thu Dec 18 17:59:15 2014 -0800
     6.2 +++ b/src/cpu/ppc/vm/macroAssembler_ppc.hpp	Mon Dec 22 09:27:29 2014 -0800
     6.3 @@ -368,6 +368,7 @@
     6.4    void call_VM(Register oop_result, address entry_point, bool check_exceptions = true);
     6.5    void call_VM(Register oop_result, address entry_point, Register arg_1, bool check_exceptions = true);
     6.6    void call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2, bool check_exceptions = true);
     6.7 +  void call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2, Register arg3, bool check_exceptions = true);
     6.8    void call_VM_leaf(address entry_point);
     6.9    void call_VM_leaf(address entry_point, Register arg_1);
    6.10    void call_VM_leaf(address entry_point, Register arg_1, Register arg_2);
     7.1 --- a/src/cpu/ppc/vm/nativeInst_ppc.cpp	Thu Dec 18 17:59:15 2014 -0800
     7.2 +++ b/src/cpu/ppc/vm/nativeInst_ppc.cpp	Mon Dec 22 09:27:29 2014 -0800
     7.3 @@ -100,10 +100,7 @@
     7.4    MacroAssembler* a = new MacroAssembler(&cb);
     7.5  
     7.6    // Patch the call.
     7.7 -  if (ReoptimizeCallSequences &&
     7.8 -      a->is_within_range_of_b(dest, addr_call)) {
     7.9 -    a->bl(dest);
    7.10 -  } else {
    7.11 +  if (!ReoptimizeCallSequences || !a->is_within_range_of_b(dest, addr_call)) {
    7.12      address trampoline_stub_addr = get_trampoline();
    7.13  
    7.14      // We did not find a trampoline stub because the current codeblob
    7.15 @@ -115,9 +112,12 @@
    7.16  
    7.17      // Patch the constant in the call's trampoline stub.
    7.18      NativeCallTrampolineStub_at(trampoline_stub_addr)->set_destination(dest);
    7.19 +    dest = trampoline_stub_addr;
    7.20 +  }
    7.21  
    7.22 -    a->bl(trampoline_stub_addr);
    7.23 -  }
    7.24 +  OrderAccess::release();
    7.25 +  a->bl(dest);
    7.26 +
    7.27    ICache::ppc64_flush_icache_bytes(addr_call, code_size);
    7.28  }
    7.29  
     8.1 --- a/src/cpu/ppc/vm/ppc.ad	Thu Dec 18 17:59:15 2014 -0800
     8.2 +++ b/src/cpu/ppc/vm/ppc.ad	Mon Dec 22 09:27:29 2014 -0800
     8.3 @@ -1938,8 +1938,9 @@
     8.4    // --------------------------------------------------------------------
     8.5    // Check for hi bits still needing moving. Only happens for misaligned
     8.6    // arguments to native calls.
     8.7 -  if (src_hi == dst_hi)
     8.8 +  if (src_hi == dst_hi) {
     8.9      return ppc64Opcode_none;               // Self copy; no move.
    8.10 +  }
    8.11  
    8.12    ShouldNotReachHere();
    8.13    return ppc64Opcode_undefined;
    8.14 @@ -1961,14 +1962,15 @@
    8.15  }
    8.16  
    8.17  uint MachNopNode::size(PhaseRegAlloc *ra_) const {
    8.18 -   return _count * 4;
    8.19 +  return _count * 4;
    8.20  }
    8.21  
    8.22  #ifndef PRODUCT
    8.23  void BoxLockNode::format(PhaseRegAlloc *ra_, outputStream *st) const {
    8.24    int offset = ra_->reg2offset(in_RegMask(0).find_first_elem());
    8.25 -  int reg = ra_->get_reg_first(this);
    8.26 -  st->print("ADDI %s, SP, %d \t// box node", Matcher::regName[reg], offset);
    8.27 +  char reg_str[128];
    8.28 +  ra_->dump_register(this, reg_str);
    8.29 +  st->print("ADDI    %s, SP, %d \t// box node", reg_str, offset);
    8.30  }
    8.31  #endif
    8.32  
     9.1 --- a/src/cpu/ppc/vm/templateInterpreter_ppc.cpp	Thu Dec 18 17:59:15 2014 -0800
     9.2 +++ b/src/cpu/ppc/vm/templateInterpreter_ppc.cpp	Mon Dec 22 09:27:29 2014 -0800
     9.3 @@ -90,7 +90,7 @@
     9.4  
     9.5    // Thread will be loaded to R3_ARG1.
     9.6    // Target class oop is in register R5_ARG3 by convention!
     9.7 -  __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_ClassCastException_verbose, R17_tos, R5_ARG3));
     9.8 +  __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_ClassCastException_verbose), R17_tos, R5_ARG3);
     9.9    // Above call must not return here since exception pending.
    9.10    DEBUG_ONLY(__ should_not_reach_here();)
    9.11    return entry;
    9.12 @@ -171,6 +171,10 @@
    9.13    // Compiled code destroys templateTableBase, reload.
    9.14    __ load_const_optimized(R25_templateTableBase, (address)Interpreter::dispatch_table((TosState)0), R12_scratch2);
    9.15  
    9.16 +  if (state == atos) {
    9.17 +    __ profile_return_type(R3_RET, R11_scratch1, R12_scratch2);
    9.18 +  }
    9.19 +
    9.20    const Register cache = R11_scratch1;
    9.21    const Register size  = R12_scratch2;
    9.22    __ get_cache_and_index_at_bcp(cache, 1, index_size);
    9.23 @@ -1230,6 +1234,10 @@
    9.24        __ li(R0, 1);
    9.25        __ stb(R0, in_bytes(JavaThread::do_not_unlock_if_synchronized_offset()), R16_thread);
    9.26      }
    9.27 +
    9.28 +    // Argument and return type profiling.
    9.29 +    __ profile_parameters_type(R3_ARG1, R4_ARG2, R5_ARG3, R6_ARG4);
    9.30 +
    9.31      // Increment invocation counter and check for overflow.
    9.32      if (inc_counter) {
    9.33        generate_counter_incr(&invocation_counter_overflow, &profile_method, &profile_method_continue);
    9.34 @@ -1549,6 +1557,8 @@
    9.35      __ resize_frame_absolute(R12_scratch2, R11_scratch1, R0);
    9.36      if (ProfileInterpreter) {
    9.37        __ set_method_data_pointer_for_bcp();
    9.38 +      __ ld(R11_scratch1, 0, R1_SP);
    9.39 +      __ std(R28_mdx, _ijava_state_neg(mdx), R11_scratch1);
    9.40      }
    9.41  #if INCLUDE_JVMTI
    9.42      Label L_done;
    9.43 @@ -1560,13 +1570,11 @@
    9.44      // The member name argument must be restored if _invokestatic is re-executed after a PopFrame call.
    9.45      // Detect such a case in the InterpreterRuntime function and return the member name argument, or NULL.
    9.46      __ ld(R4_ARG2, 0, R18_locals);
    9.47 -    __ call_VM(R11_scratch1, CAST_FROM_FN_PTR(address, InterpreterRuntime::member_name_arg_or_null),
    9.48 -               R4_ARG2, R19_method, R14_bcp);
    9.49 -
    9.50 -    __ cmpdi(CCR0, R11_scratch1, 0);
    9.51 +    __ MacroAssembler::call_VM(R4_ARG2, CAST_FROM_FN_PTR(address, InterpreterRuntime::member_name_arg_or_null), R4_ARG2, R19_method, R14_bcp, false);
    9.52 +    __ restore_interpreter_state(R11_scratch1, /*bcp_and_mdx_only*/ true);
    9.53 +    __ cmpdi(CCR0, R4_ARG2, 0);
    9.54      __ beq(CCR0, L_done);
    9.55 -
    9.56 -    __ std(R11_scratch1, wordSize, R15_esp);
    9.57 +    __ std(R4_ARG2, wordSize, R15_esp);
    9.58      __ bind(L_done);
    9.59  #endif // INCLUDE_JVMTI
    9.60      __ dispatch_next(vtos);
    10.1 --- a/src/cpu/ppc/vm/templateTable_ppc_64.cpp	Thu Dec 18 17:59:15 2014 -0800
    10.2 +++ b/src/cpu/ppc/vm/templateTable_ppc_64.cpp	Mon Dec 22 09:27:29 2014 -0800
    10.3 @@ -3234,6 +3234,8 @@
    10.4    // Load target.
    10.5    __ addi(Rrecv_klass, Rrecv_klass, base + vtableEntry::method_offset_in_bytes());
    10.6    __ ldx(Rtarget_method, Rindex, Rrecv_klass);
    10.7 +  // Argument and return type profiling.
    10.8 +  __ profile_arguments_type(Rtarget_method, Rrecv_klass /* scratch1 */, Rtemp /* scratch2 */, true);
    10.9    __ call_from_interpreter(Rtarget_method, Rret, Rrecv_klass /* scratch1 */, Rtemp /* scratch2 */);
   10.10  }
   10.11  
   10.12 @@ -3317,6 +3319,8 @@
   10.13    __ null_check_throw(Rrecv, -1, Rscratch1);
   10.14  
   10.15    __ profile_final_call(Rrecv, Rscratch1);
   10.16 +  // Argument and return type profiling.
   10.17 +  __ profile_arguments_type(Rmethod, Rscratch1, Rscratch2, true);
   10.18  
   10.19    // Do the call.
   10.20    __ call_from_interpreter(Rmethod, Rret_addr, Rscratch1, Rscratch2);
   10.21 @@ -3338,6 +3342,8 @@
   10.22    __ null_check_throw(Rreceiver, -1, R11_scratch1);
   10.23  
   10.24    __ profile_call(R11_scratch1, R12_scratch2);
   10.25 +  // Argument and return type profiling.
   10.26 +  __ profile_arguments_type(Rmethod, R11_scratch1, R12_scratch2, false);
   10.27    __ call_from_interpreter(Rmethod, Rret_addr, R11_scratch1, R12_scratch2);
   10.28  }
   10.29  
   10.30 @@ -3352,6 +3358,8 @@
   10.31    prepare_invoke(byte_no, R19_method, Rret_addr, noreg, noreg, Rflags, R11_scratch1);
   10.32  
   10.33    __ profile_call(R11_scratch1, R12_scratch2);
   10.34 +  // Argument and return type profiling.
   10.35 +  __ profile_arguments_type(R19_method, R11_scratch1, R12_scratch2, false);
   10.36    __ call_from_interpreter(R19_method, Rret_addr, R11_scratch1, R12_scratch2);
   10.37  }
   10.38  
   10.39 @@ -3373,6 +3381,8 @@
   10.40  
   10.41    // Final call case.
   10.42    __ profile_final_call(Rtemp1, Rscratch);
   10.43 +  // Argument and return type profiling.
   10.44 +  __ profile_arguments_type(Rindex, Rscratch, Rrecv_klass /* scratch */, true);
   10.45    // Do the final call - the index (f2) contains the method.
   10.46    __ call_from_interpreter(Rindex, Rret, Rscratch, Rrecv_klass /* scratch */);
   10.47  
   10.48 @@ -3424,6 +3434,8 @@
   10.49    __ cmpdi(CCR0, Rindex, 0);
   10.50    __ beq(CCR0, Lthrow_ame);
   10.51    // Found entry. Jump off!
   10.52 +  // Argument and return type profiling.
   10.53 +  __ profile_arguments_type(Rindex, Rscratch1, Rscratch2, true);
   10.54    __ call_from_interpreter(Rindex, Rret_addr, Rscratch1, Rscratch2);
   10.55  
   10.56    // Vtable entry was NULL => Throw abstract method error.
   10.57 @@ -3477,6 +3489,8 @@
   10.58    // to be the callsite object the bootstrap method returned. This is passed to a
   10.59    // "link" method which does the dispatch (Most likely just grabs the MH stored
   10.60    // inside the callsite and does an invokehandle).
   10.61 +  // Argument and return type profiling.
   10.62 +  __ profile_arguments_type(Rmethod, Rscratch1, Rscratch2, false);
   10.63    __ call_from_interpreter(Rmethod, Rret_addr, Rscratch1 /* scratch1 */, Rscratch2 /* scratch2 */);
   10.64  }
   10.65  
   10.66 @@ -3503,6 +3517,8 @@
   10.67    __ profile_final_call(Rrecv, Rscratch1);
   10.68  
   10.69    // Still no call from handle => We call the method handle interpreter here.
   10.70 +  // Argument and return type profiling.
   10.71 +  __ profile_arguments_type(Rmethod, Rscratch1, Rscratch2, true);
   10.72    __ call_from_interpreter(Rmethod, Rret_addr, Rscratch1 /* scratch1 */, Rscratch2 /* scratch2 */);
   10.73  }
   10.74  
    11.1 --- a/src/cpu/ppc/vm/vm_version_ppc.cpp	Thu Dec 18 17:59:15 2014 -0800
    11.2 +++ b/src/cpu/ppc/vm/vm_version_ppc.cpp	Mon Dec 22 09:27:29 2014 -0800
    11.3 @@ -139,13 +139,44 @@
    11.4    }
    11.5  
    11.6    assert(AllocatePrefetchLines > 0, "invalid value");
    11.7 -  if (AllocatePrefetchLines < 1) // Set valid value in product VM.
    11.8 +  if (AllocatePrefetchLines < 1) { // Set valid value in product VM.
    11.9      AllocatePrefetchLines = 1; // Conservative value.
   11.10 +  }
   11.11  
   11.12 -  if (AllocatePrefetchStyle == 3 && AllocatePrefetchDistance < cache_line_size)
   11.13 +  if (AllocatePrefetchStyle == 3 && AllocatePrefetchDistance < cache_line_size) {
   11.14      AllocatePrefetchStyle = 1; // Fall back if inappropriate.
   11.15 +  }
   11.16  
   11.17    assert(AllocatePrefetchStyle >= 0, "AllocatePrefetchStyle should be positive");
   11.18 +
   11.19 +  if (UseCRC32Intrinsics) {
   11.20 +    if (!FLAG_IS_DEFAULT(UseCRC32Intrinsics))
   11.21 +      warning("CRC32 intrinsics  are not available on this CPU");
   11.22 +    FLAG_SET_DEFAULT(UseCRC32Intrinsics, false);
   11.23 +  }
   11.24 +
   11.25 +  // The AES intrinsic stubs require AES instruction support.
   11.26 +  if (UseAES) {
   11.27 +    warning("AES instructions are not available on this CPU");
   11.28 +    FLAG_SET_DEFAULT(UseAES, false);
   11.29 +  }
   11.30 +  if (UseAESIntrinsics) {
   11.31 +    if (!FLAG_IS_DEFAULT(UseAESIntrinsics))
   11.32 +      warning("AES intrinsics are not available on this CPU");
   11.33 +    FLAG_SET_DEFAULT(UseAESIntrinsics, false);
   11.34 +  }
   11.35 +
   11.36 +  if (UseSHA) {
   11.37 +    warning("SHA instructions are not available on this CPU");
   11.38 +    FLAG_SET_DEFAULT(UseSHA, false);
   11.39 +  }
   11.40 +  if (UseSHA1Intrinsics || UseSHA256Intrinsics || UseSHA512Intrinsics) {
   11.41 +    warning("SHA intrinsics are not available on this CPU");
   11.42 +    FLAG_SET_DEFAULT(UseSHA1Intrinsics, false);
   11.43 +    FLAG_SET_DEFAULT(UseSHA256Intrinsics, false);
   11.44 +    FLAG_SET_DEFAULT(UseSHA512Intrinsics, false);
   11.45 +  }
   11.46 +
   11.47  }
   11.48  
   11.49  void VM_Version::print_features() {
    12.1 --- a/src/cpu/x86/vm/c1_Runtime1_x86.cpp	Thu Dec 18 17:59:15 2014 -0800
    12.2 +++ b/src/cpu/x86/vm/c1_Runtime1_x86.cpp	Mon Dec 22 09:27:29 2014 -0800
    12.3 @@ -675,7 +675,7 @@
    12.4    case handle_exception_nofpu_id:
    12.5    case handle_exception_id:
    12.6      // At this point all registers MAY be live.
    12.7 -    oop_map = save_live_registers(sasm, 1 /*thread*/, id == handle_exception_nofpu_id);
    12.8 +    oop_map = save_live_registers(sasm, 1 /*thread*/, id != handle_exception_nofpu_id);
    12.9      break;
   12.10    case handle_exception_from_callee_id: {
   12.11      // At this point all registers except exception oop (RAX) and
   12.12 @@ -748,7 +748,7 @@
   12.13    case handle_exception_nofpu_id:
   12.14    case handle_exception_id:
   12.15      // Restore the registers that were saved at the beginning.
   12.16 -    restore_live_registers(sasm, id == handle_exception_nofpu_id);
   12.17 +    restore_live_registers(sasm, id != handle_exception_nofpu_id);
   12.18      break;
   12.19    case handle_exception_from_callee_id:
   12.20      // WIN64_ONLY: No need to add frame::arg_reg_save_area_bytes to SP
    13.1 --- a/src/os/aix/vm/os_aix.cpp	Thu Dec 18 17:59:15 2014 -0800
    13.2 +++ b/src/os/aix/vm/os_aix.cpp	Mon Dec 22 09:27:29 2014 -0800
    13.3 @@ -114,12 +114,6 @@
    13.4  }
    13.5  #endif
    13.6  
    13.7 -// Excerpts from systemcfg.h definitions newer than AIX 5.3
    13.8 -#ifndef PV_7
    13.9 -# define PV_7 0x200000          // Power PC 7
   13.10 -# define PV_7_Compat 0x208000   // Power PC 7
   13.11 -#endif
   13.12 -
   13.13  #define MAX_PATH (2 * K)
   13.14  
   13.15  // for timer info max values which include all bits
   13.16 @@ -130,17 +124,40 @@
   13.17  #define ERROR_MP_VMGETINFO_FAILED                    102
   13.18  #define ERROR_MP_VMGETINFO_CLAIMS_NO_SUPPORT_FOR_64K 103
   13.19  
   13.20 -// the semantics in this file are thus that codeptr_t is a *real code ptr*
   13.21 +// The semantics in this file are thus that codeptr_t is a *real code ptr*.
   13.22  // This means that any function taking codeptr_t as arguments will assume
   13.23  // a real codeptr and won't handle function descriptors (eg getFuncName),
   13.24  // whereas functions taking address as args will deal with function
   13.25 -// descriptors (eg os::dll_address_to_library_name)
   13.26 +// descriptors (eg os::dll_address_to_library_name).
   13.27  typedef unsigned int* codeptr_t;
   13.28  
   13.29 -// typedefs for stackslots, stack pointers, pointers to op codes
   13.30 +// Typedefs for stackslots, stack pointers, pointers to op codes.
   13.31  typedef unsigned long stackslot_t;
   13.32  typedef stackslot_t* stackptr_t;
   13.33  
   13.34 +// Excerpts from systemcfg.h definitions newer than AIX 5.3.
   13.35 +#ifndef PV_7
   13.36 +#define PV_7 0x200000          /* Power PC 7 */
   13.37 +#define PV_7_Compat 0x208000   /* Power PC 7 */
   13.38 +#endif
   13.39 +#ifndef PV_8
   13.40 +#define PV_8 0x300000          /* Power PC 8 */
   13.41 +#define PV_8_Compat 0x308000   /* Power PC 8 */
   13.42 +#endif
   13.43 +
   13.44 +#define trcVerbose(fmt, ...) { /* PPC port */  \
   13.45 +  if (Verbose) { \
   13.46 +    fprintf(stderr, fmt, ##__VA_ARGS__); \
   13.47 +    fputc('\n', stderr); fflush(stderr); \
   13.48 +  } \
   13.49 +}
   13.50 +#define trc(fmt, ...)        /* PPC port */
   13.51 +
   13.52 +#define ERRBYE(s) { \
   13.53 +    trcVerbose(s); \
   13.54 +    return -1; \
   13.55 +}
   13.56 +
   13.57  // query dimensions of the stack of the calling thread
   13.58  static void query_stack_dimensions(address* p_stack_base, size_t* p_stack_size);
   13.59  
   13.60 @@ -172,12 +189,12 @@
   13.61    return true;
   13.62  }
   13.63  
   13.64 -// macro to check a given stack pointer against given stack limits and to die if test fails
   13.65 +// Macro to check a given stack pointer against given stack limits and to die if test fails.
   13.66  #define CHECK_STACK_PTR(sp, stack_base, stack_size) { \
   13.67      guarantee(is_valid_stackpointer((stackptr_t)(sp), (stackptr_t)(stack_base), stack_size), "Stack Pointer Invalid"); \
   13.68  }
   13.69  
   13.70 -// macro to check the current stack pointer against given stacklimits
   13.71 +// Macro to check the current stack pointer against given stacklimits.
   13.72  #define CHECK_CURRENT_STACK_PTR(stack_base, stack_size) { \
   13.73    address sp; \
   13.74    sp = os::current_stack_pointer(); \
   13.75 @@ -211,7 +228,7 @@
   13.76  static pid_t    _initial_pid       = 0;
   13.77  static int      SR_signum          = SIGUSR2; // Signal used to suspend/resume a thread (must be > SIGSEGV, see 4355769)
   13.78  static sigset_t SR_sigset;
   13.79 -static pthread_mutex_t dl_mutex;           // Used to protect dlsym() calls */
   13.80 +static pthread_mutex_t dl_mutex;              // Used to protect dlsym() calls.
   13.81  
   13.82  julong os::available_memory() {
   13.83    return Aix::available_memory();
   13.84 @@ -243,7 +260,6 @@
   13.85    return false;
   13.86  }
   13.87  
   13.88 -
   13.89  // Return true if user is running as root.
   13.90  
   13.91  bool os::have_special_privileges() {
   13.92 @@ -274,8 +290,7 @@
   13.93  
   13.94    for (int i = 0; i < numFullDisclaimsNeeded; i ++) {
   13.95      if (::disclaim(p, maxDisclaimSize, DISCLAIM_ZEROMEM) != 0) {
   13.96 -      //if (Verbose)
   13.97 -      fprintf(stderr, "Cannot disclaim %p - %p (errno %d)\n", p, p + maxDisclaimSize, errno);
   13.98 +      trc("Cannot disclaim %p - %p (errno %d)\n", p, p + maxDisclaimSize, errno);
   13.99        return false;
  13.100      }
  13.101      p += maxDisclaimSize;
  13.102 @@ -283,8 +298,7 @@
  13.103  
  13.104    if (lastDisclaimSize > 0) {
  13.105      if (::disclaim(p, lastDisclaimSize, DISCLAIM_ZEROMEM) != 0) {
  13.106 -      //if (Verbose)
  13.107 -        fprintf(stderr, "Cannot disclaim %p - %p (errno %d)\n", p, p + lastDisclaimSize, errno);
  13.108 +      trc("Cannot disclaim %p - %p (errno %d)\n", p, p + lastDisclaimSize, errno);
  13.109        return false;
  13.110      }
  13.111    }
  13.112 @@ -324,11 +338,11 @@
  13.113  
  13.114  void os::Aix::initialize_system_info() {
  13.115  
  13.116 -  // get the number of online(logical) cpus instead of configured
  13.117 +  // Get the number of online(logical) cpus instead of configured.
  13.118    os::_processor_count = sysconf(_SC_NPROCESSORS_ONLN);
  13.119    assert(_processor_count > 0, "_processor_count must be > 0");
  13.120  
  13.121 -  // retrieve total physical storage
  13.122 +  // Retrieve total physical storage.
  13.123    os::Aix::meminfo_t mi;
  13.124    if (!os::Aix::get_meminfo(&mi)) {
  13.125      fprintf(stderr, "os::Aix::get_meminfo failed.\n"); fflush(stderr);
  13.126 @@ -503,7 +517,6 @@
  13.127  
  13.128  } // end os::Aix::query_multipage_support()
  13.129  
  13.130 -// The code for this method was initially derived from the version in os_linux.cpp.
  13.131  void os::init_system_properties_values() {
  13.132  
  13.133  #define DEFAULT_LIBPATH "/usr/lib:/lib"
  13.134 @@ -600,10 +613,11 @@
  13.135    sigaction(sig, (struct sigaction*)NULL, &oact);
  13.136    void* ohlr = oact.sa_sigaction ? CAST_FROM_FN_PTR(void*, oact.sa_sigaction)
  13.137      : CAST_FROM_FN_PTR(void*, oact.sa_handler);
  13.138 -  if (ohlr == CAST_FROM_FN_PTR(void*, SIG_IGN))
  13.139 +  if (ohlr == CAST_FROM_FN_PTR(void*, SIG_IGN)) {
  13.140      return true;
  13.141 -  else
  13.142 +  } else {
  13.143      return false;
  13.144 +  }
  13.145  }
  13.146  
  13.147  void os::Aix::signal_sets_init() {
  13.148 @@ -777,6 +791,9 @@
  13.149  
  13.150    // get the processor version from _system_configuration
  13.151    switch (_system_configuration.version) {
  13.152 +  case PV_8:
  13.153 +    strcpy(pci->version, "Power PC 8");
  13.154 +    break;
  13.155    case PV_7:
  13.156      strcpy(pci->version, "Power PC 7");
  13.157      break;
  13.158 @@ -804,6 +821,9 @@
  13.159    case PV_7_Compat:
  13.160      strcpy(pci->version, "PV_7_Compat");
  13.161      break;
  13.162 +  case PV_8_Compat:
  13.163 +    strcpy(pci->version, "PV_8_Compat");
  13.164 +    break;
  13.165    default:
  13.166      strcpy(pci->version, "unknown");
  13.167    }
  13.168 @@ -939,7 +959,9 @@
  13.169  
  13.170    pthread_attr_destroy(&attr);
  13.171  
  13.172 -  if (ret != 0) {
  13.173 +  if (ret == 0) {
  13.174 +    // PPC port traceOsMisc(("Created New Thread : pthread-id %u", tid));
  13.175 +  } else {
  13.176      if (PrintMiscellaneous && (Verbose || WizardMode)) {
  13.177        perror("pthread_create()");
  13.178      }
  13.179 @@ -1096,8 +1118,7 @@
  13.180    if (os::Aix::on_pase()) {
  13.181      Unimplemented();
  13.182      return 0;
  13.183 -  }
  13.184 -  else {
  13.185 +  } else {
  13.186      // On AIX use the precision of processors real time clock
  13.187      // or time base registers.
  13.188      timebasestruct_t time;
  13.189 @@ -1150,7 +1171,6 @@
  13.190    }
  13.191  }
  13.192  
  13.193 -
  13.194  char * os::local_time_string(char *buf, size_t buflen) {
  13.195    struct tm t;
  13.196    time_t long_time;
  13.197 @@ -1188,7 +1208,6 @@
  13.198    if (abort_hook != NULL) {
  13.199      abort_hook();
  13.200    }
  13.201 -
  13.202  }
  13.203  
  13.204  // Note: os::abort() might be called very early during initialization, or
  13.205 @@ -1220,8 +1239,7 @@
  13.206  // from src/solaris/hpi/src/system_md.c
  13.207  
  13.208  size_t os::lasterror(char *buf, size_t len) {
  13.209 -
  13.210 -  if (errno == 0)  return 0;
  13.211 +  if (errno == 0) return 0;
  13.212  
  13.213    const char *s = ::strerror(errno);
  13.214    size_t n = ::strlen(s);
  13.215 @@ -1234,6 +1252,7 @@
  13.216  }
  13.217  
  13.218  intx os::current_thread_id() { return (intx)pthread_self(); }
  13.219 +
  13.220  int os::current_process_id() {
  13.221  
  13.222    // This implementation returns a unique pid, the pid of the
  13.223 @@ -1370,9 +1389,9 @@
  13.224    if (offset) {
  13.225      *offset = -1;
  13.226    }
  13.227 -  if (buf) {
  13.228 -    buf[0] = '\0';
  13.229 -  }
  13.230 +  // Buf is not optional, but offset is optional.
  13.231 +  assert(buf != NULL, "sanity check");
  13.232 +  buf[0] = '\0';
  13.233  
  13.234    // Resolve function ptr literals first.
  13.235    addr = resolve_function_descriptor_to_code_pointer(addr);
  13.236 @@ -1405,12 +1424,9 @@
  13.237      return 0;
  13.238    }
  13.239  
  13.240 -  if (Verbose) {
  13.241 -    fprintf(stderr, "pc outside any module");
  13.242 -  }
  13.243 +  trcVerbose("pc outside any module");
  13.244  
  13.245    return -1;
  13.246 -
  13.247  }
  13.248  
  13.249  bool os::dll_address_to_library_name(address addr, char* buf,
  13.250 @@ -1418,9 +1434,9 @@
  13.251    if (offset) {
  13.252      *offset = -1;
  13.253    }
  13.254 -  if (buf) {
  13.255 -      buf[0] = '\0';
  13.256 -  }
  13.257 +  // Buf is not optional, but offset is optional.
  13.258 +  assert(buf != NULL, "sanity check");
  13.259 +  buf[0] = '\0';
  13.260  
  13.261    // Resolve function ptr literals first.
  13.262    addr = resolve_function_descriptor_to_code_pointer(addr);
  13.263 @@ -1435,7 +1451,7 @@
  13.264  }
  13.265  
  13.266  // Loads .dll/.so and in case of error it checks if .dll/.so was built
  13.267 -// for the same architecture as Hotspot is running on
  13.268 +// for the same architecture as Hotspot is running on.
  13.269  void *os::dll_load(const char *filename, char *ebuf, int ebuflen) {
  13.270  
  13.271    if (ebuf && ebuflen > 0) {
  13.272 @@ -1598,7 +1614,6 @@
  13.273    st->cr();
  13.274  }
  13.275  
  13.276 -
  13.277  static void print_signal_handler(outputStream* st, int sig,
  13.278                                   char* buf, size_t buflen);
  13.279  
  13.280 @@ -1622,7 +1637,7 @@
  13.281  
  13.282  static char saved_jvm_path[MAXPATHLEN] = {0};
  13.283  
  13.284 -// Find the full path to the current module, libjvm.so or libjvm_g.so
  13.285 +// Find the full path to the current module, libjvm.so.
  13.286  void os::jvm_path(char *buf, jint buflen) {
  13.287    // Error checking.
  13.288    if (buflen < MAXPATHLEN) {
  13.289 @@ -1692,7 +1707,7 @@
  13.290    // Do not block out synchronous signals in the signal handler.
  13.291    // Blocking synchronous signals only makes sense if you can really
  13.292    // be sure that those signals won't happen during signal handling,
  13.293 -  // when the blocking applies.  Normal signal handlers are lean and
  13.294 +  // when the blocking applies. Normal signal handlers are lean and
  13.295    // do not cause signals. But our signal handlers tend to be "risky"
  13.296    // - secondary SIGSEGV, SIGILL, SIGBUS' may and do happen.
  13.297    // On AIX, PASE there was a case where a SIGSEGV happened, followed
  13.298 @@ -2967,13 +2982,9 @@
  13.299    param.sched_priority = newpri;
  13.300    int ret = pthread_setschedparam(thr, policy, &param);
  13.301  
  13.302 -  if (Verbose) {
  13.303 -    if (ret == 0) {
  13.304 -      fprintf(stderr, "changed priority of thread %d to %d\n", (int)thr, newpri);
  13.305 -    } else {
  13.306 -      fprintf(stderr, "Could not changed priority for thread %d to %d (error %d, %s)\n",
  13.307 -              (int)thr, newpri, ret, strerror(ret));
  13.308 -    }
  13.309 +  if (ret != 0) {
  13.310 +    trcVerbose("Could not change priority for thread %d to %d (error %d, %s)",
  13.311 +        (int)thr, newpri, ret, strerror(ret));
  13.312    }
  13.313    return (ret == 0) ? OS_OK : OS_ERR;
  13.314  }
  13.315 @@ -3094,7 +3105,6 @@
  13.316    errno = old_errno;
  13.317  }
  13.318  
  13.319 -
  13.320  static int SR_initialize() {
  13.321    struct sigaction act;
  13.322    char *s;
  13.323 @@ -3337,7 +3347,6 @@
  13.324    JVM_handle_aix_signal(sig, info, uc, true);
  13.325  }
  13.326  
  13.327 -
  13.328  // This boolean allows users to forward their own non-matching signals
  13.329  // to JVM_handle_aix_signal, harmlessly.
  13.330  bool os::Aix::signal_handlers_are_installed = false;
  13.331 @@ -3531,7 +3540,7 @@
  13.332      set_signal_handler(SIGDANGER, true);
  13.333  
  13.334      if (libjsig_is_loaded) {
  13.335 -      // Tell libjsig jvm finishes setting signal handlers
  13.336 +      // Tell libjsig jvm finishes setting signal handlers.
  13.337        (*end_signal_setting)();
  13.338      }
  13.339  
  13.340 @@ -3547,7 +3556,7 @@
  13.341          tty->print_cr("Info: AllowUserSignalHandlers is activated, all active signal checking is disabled");
  13.342          check_signals = false;
  13.343        }
  13.344 -      // need to initialize check_signal_done
  13.345 +      // Need to initialize check_signal_done.
  13.346        ::sigemptyset(&check_signal_done);
  13.347      }
  13.348    }
  13.349 @@ -3621,7 +3630,6 @@
  13.350    st->cr();
  13.351  }
  13.352  
  13.353 -
  13.354  #define DO_SIGNAL_CHECK(sig) \
  13.355    if (!sigismember(&check_signal_done, sig)) \
  13.356      os::Aix::check_signal_handler(sig)
  13.357 @@ -3682,7 +3690,6 @@
  13.358      ? CAST_FROM_FN_PTR(address, act.sa_sigaction)
  13.359      : CAST_FROM_FN_PTR(address, act.sa_handler);
  13.360  
  13.361 -
  13.362    switch(sig) {
  13.363    case SIGSEGV:
  13.364    case SIGBUS:
  13.365 @@ -3830,15 +3837,13 @@
  13.366    pthread_mutex_init(&dl_mutex, NULL);
  13.367  }
  13.368  
  13.369 -// this is called _after_ the global arguments have been parsed
  13.370 +// This is called _after_ the global arguments have been parsed.
  13.371  jint os::init_2(void) {
  13.372  
  13.373 -  if (Verbose) {
  13.374 -    fprintf(stderr, "processor count: %d\n", os::_processor_count);
  13.375 -    fprintf(stderr, "physical memory: %lu\n", Aix::_physical_memory);
  13.376 -  }
  13.377 -
  13.378 -  // initially build up the loaded dll map
  13.379 +  trcVerbose("processor count: %d", os::_processor_count);
  13.380 +  trcVerbose("physical memory: %lu", Aix::_physical_memory);
  13.381 +
  13.382 +  // Initially build up the loaded dll map.
  13.383    LoadedLibraries::reload();
  13.384  
  13.385    const int page_size = Aix::page_size();
  13.386 @@ -3888,7 +3893,7 @@
  13.387        }
  13.388  
  13.389        if (map_address != (address) MAP_FAILED) {
  13.390 -        // map succeeded, but polling_page is not at wished address, unmap and continue.
  13.391 +        // Map succeeded, but polling_page is not at wished address, unmap and continue.
  13.392          ::munmap(map_address, map_size);
  13.393          map_address = (address) MAP_FAILED;
  13.394        }
  13.395 @@ -3942,7 +3947,7 @@
  13.396  
  13.397    // Make the stack size a multiple of the page size so that
  13.398    // the yellow/red zones can be guarded.
  13.399 -  // note that this can be 0, if no default stacksize was set
  13.400 +  // Note that this can be 0, if no default stacksize was set.
  13.401    JavaThread::set_stack_size_at_create(round_to(threadStackSizeInBytes, vm_page_size()));
  13.402  
  13.403    Aix::libpthread_init();
  13.404 @@ -4255,7 +4260,6 @@
  13.405    return fd;
  13.406  }
  13.407  
  13.408 -
  13.409  // create binary file, rewriting existing file if required
  13.410  int os::create_binary_file(const char* path, bool rewrite_existing) {
  13.411    int oflags = O_WRONLY | O_CREAT;
  13.412 @@ -4324,7 +4328,6 @@
  13.413    return NULL;
  13.414  }
  13.415  
  13.416 -
  13.417  // Remap a block of memory.
  13.418  char* os::pd_remap_memory(int fd, const char* file_name, size_t file_offset,
  13.419                            char *addr, size_t bytes, bool read_only,
  13.420 @@ -4372,14 +4375,14 @@
  13.421    jlong sys_time = 0;
  13.422    jlong user_time = 0;
  13.423  
  13.424 -  // reimplemented using getthrds64().
  13.425 +  // Reimplemented using getthrds64().
  13.426    //
  13.427 -  // goes like this:
  13.428 +  // Works like this:
  13.429    // For the thread in question, get the kernel thread id. Then get the
  13.430    // kernel thread statistics using that id.
  13.431    //
  13.432    // This only works of course when no pthread scheduling is used,
  13.433 -  // ie there is a 1:1 relationship to kernel threads.
  13.434 +  // i.e. there is a 1:1 relationship to kernel threads.
  13.435    // On AIX, see AIXTHREAD_SCOPE variable.
  13.436  
  13.437    pthread_t pthtid = thread->osthread()->pthread_id();
  13.438 @@ -4526,14 +4529,12 @@
  13.439    memset(&uts, 0, sizeof(uts));
  13.440    strcpy(uts.sysname, "?");
  13.441    if (::uname(&uts) == -1) {
  13.442 -    fprintf(stderr, "uname failed (%d)\n", errno);
  13.443 +    trc("uname failed (%d)", errno);
  13.444      guarantee(0, "Could not determine whether we run on AIX or PASE");
  13.445    } else {
  13.446 -    if (Verbose) {
  13.447 -      fprintf(stderr,"uname says: sysname \"%s\" version \"%s\" release \"%s\" "
  13.448 -              "node \"%s\" machine \"%s\"\n",
  13.449 -              uts.sysname, uts.version, uts.release, uts.nodename, uts.machine);
  13.450 -    }
  13.451 +    trcVerbose("uname says: sysname \"%s\" version \"%s\" release \"%s\" "
  13.452 +               "node \"%s\" machine \"%s\"\n",
  13.453 +               uts.sysname, uts.version, uts.release, uts.nodename, uts.machine);
  13.454      const int major = atoi(uts.version);
  13.455      assert(major > 0, "invalid OS version");
  13.456      const int minor = atoi(uts.release);
  13.457 @@ -4545,12 +4546,10 @@
  13.458        // We run on AIX. We do not support versions older than AIX 5.3.
  13.459        _on_pase = 0;
  13.460        if (_os_version < 0x0503) {
  13.461 -        fprintf(stderr, "AIX release older than AIX 5.3 not supported.\n");
  13.462 +        trc("AIX release older than AIX 5.3 not supported.");
  13.463          assert(false, "AIX release too old.");
  13.464        } else {
  13.465 -        if (Verbose) {
  13.466 -          fprintf(stderr, "We run on AIX %d.%d\n", major, minor);
  13.467 -        }
  13.468 +        trcVerbose("We run on AIX %d.%d\n", major, minor);
  13.469        }
  13.470      } else {
  13.471        assert(false, "unknown OS");
  13.472 @@ -4558,7 +4557,6 @@
  13.473    }
  13.474  
  13.475    guarantee(_on_pase != -1 && _os_version, "Could not determine AIX/OS400 release");
  13.476 -
  13.477  } // end: os::Aix::initialize_os_info()
  13.478  
  13.479  // Scan environment for important settings which might effect the VM.
  13.480 @@ -4596,12 +4594,10 @@
  13.481    // Note: Setting XPG_SUS_ENV in the process is too late. Must be set earlier (before
  13.482    // exec() ? before loading the libjvm ? ....)
  13.483    p = ::getenv("XPG_SUS_ENV");
  13.484 -  if (Verbose) {
  13.485 -    fprintf(stderr, "XPG_SUS_ENV=%s.\n", p ? p : "<unset>");
  13.486 -  }
  13.487 +  trcVerbose("XPG_SUS_ENV=%s.", p ? p : "<unset>");
  13.488    if (p && strcmp(p, "ON") == 0) {
  13.489      _xpg_sus_mode = 1;
  13.490 -    fprintf(stderr, "Unsupported setting: XPG_SUS_ENV=ON\n");
  13.491 +    trc("Unsupported setting: XPG_SUS_ENV=ON");
  13.492      // This is not supported. Worst of all, it changes behaviour of mmap MAP_FIXED to
  13.493      // clobber address ranges. If we ever want to support that, we have to do some
  13.494      // testing first.
  13.495 @@ -4613,10 +4609,7 @@
  13.496    // Switch off AIX internal (pthread) guard pages. This has
  13.497    // immediate effect for any pthread_create calls which follow.
  13.498    p = ::getenv("AIXTHREAD_GUARDPAGES");
  13.499 -  if (Verbose) {
  13.500 -    fprintf(stderr, "AIXTHREAD_GUARDPAGES=%s.\n", p ? p : "<unset>");
  13.501 -    fprintf(stderr, "setting AIXTHREAD_GUARDPAGES=0.\n");
  13.502 -  }
  13.503 +  trcVerbose("AIXTHREAD_GUARDPAGES=%s.", p ? p : "<unset>");
  13.504    rc = ::putenv("AIXTHREAD_GUARDPAGES=0");
  13.505    guarantee(rc == 0, "");
  13.506  
  13.507 @@ -4634,7 +4627,7 @@
  13.508    assert(os::Aix::on_aix(), "AIX only");
  13.509  
  13.510    if (!libperfstat::init()) {
  13.511 -    fprintf(stderr, "libperfstat initialization failed.\n");
  13.512 +    trc("libperfstat initialization failed.");
  13.513      assert(false, "libperfstat initialization failed");
  13.514    } else {
  13.515      if (Verbose) {
  13.516 @@ -4806,7 +4799,6 @@
  13.517    return abstime;
  13.518  }
  13.519  
  13.520 -
  13.521  // Test-and-clear _Event, always leaves _Event set to 0, returns immediately.
  13.522  // Conceptually TryPark() should be equivalent to park(0).
  13.523  
  13.524 @@ -4889,7 +4881,7 @@
  13.525    while (_Event < 0) {
  13.526      status = pthread_cond_timedwait(_cond, _mutex, &abst);
  13.527      assert_status(status == 0 || status == ETIMEDOUT,
  13.528 -          status, "cond_timedwait");
  13.529 +                  status, "cond_timedwait");
  13.530      if (!FilterSpuriousWakeups) break;         // previous semantics
  13.531      if (status == ETIMEDOUT) break;
  13.532      // We consume and ignore EINTR and spurious wakeups.
  13.533 @@ -5023,9 +5015,9 @@
  13.534    // Optional fast-path check:
  13.535    // Return immediately if a permit is available.
  13.536    if (_counter > 0) {
  13.537 -      _counter = 0;
  13.538 -      OrderAccess::fence();
  13.539 -      return;
  13.540 +    _counter = 0;
  13.541 +    OrderAccess::fence();
  13.542 +    return;
  13.543    }
  13.544  
  13.545    Thread* thread = Thread::current();
  13.546 @@ -5047,7 +5039,6 @@
  13.547      unpackTime(&absTime, isAbsolute, time);
  13.548    }
  13.549  
  13.550 -
  13.551    // Enter safepoint region
  13.552    // Beware of deadlocks such as 6317397.
  13.553    // The per-thread Parker:: mutex is a classic leaf-lock.
  13.554 @@ -5135,7 +5126,6 @@
  13.555    }
  13.556  }
  13.557  
  13.558 -
  13.559  extern char** environ;
  13.560  
  13.561  // Run the specified command in a separate process. Return its exit value,
  13.562 @@ -5154,44 +5144,43 @@
  13.563    } else if (pid == 0) {
  13.564      // child process
  13.565  
  13.566 -    // try to be consistent with system(), which uses "/usr/bin/sh" on AIX
  13.567 +    // Try to be consistent with system(), which uses "/usr/bin/sh" on AIX.
  13.568      execve("/usr/bin/sh", argv, environ);
  13.569  
  13.570      // execve failed
  13.571      _exit(-1);
  13.572  
  13.573 -  } else  {
  13.574 +  } else {
  13.575      // copied from J2SE ..._waitForProcessExit() in UNIXProcess_md.c; we don't
  13.576      // care about the actual exit code, for now.
  13.577  
  13.578      int status;
  13.579  
  13.580 -    // Wait for the child process to exit.  This returns immediately if
  13.581 +    // Wait for the child process to exit. This returns immediately if
  13.582      // the child has already exited. */
  13.583      while (waitpid(pid, &status, 0) < 0) {
  13.584 -        switch (errno) {
  13.585 +      switch (errno) {
  13.586          case ECHILD: return 0;
  13.587          case EINTR: break;
  13.588          default: return -1;
  13.589 -        }
  13.590 +      }
  13.591      }
  13.592  
  13.593      if (WIFEXITED(status)) {
  13.594 -       // The child exited normally; get its exit code.
  13.595 -       return WEXITSTATUS(status);
  13.596 +      // The child exited normally; get its exit code.
  13.597 +      return WEXITSTATUS(status);
  13.598      } else if (WIFSIGNALED(status)) {
  13.599 -       // The child exited because of a signal
  13.600 -       // The best value to return is 0x80 + signal number,
  13.601 -       // because that is what all Unix shells do, and because
  13.602 -       // it allows callers to distinguish between process exit and
  13.603 -       // process death by signal.
  13.604 -       return 0x80 + WTERMSIG(status);
  13.605 +      // The child exited because of a signal.
  13.606 +      // The best value to return is 0x80 + signal number,
  13.607 +      // because that is what all Unix shells do, and because
  13.608 +      // it allows callers to distinguish between process exit and
  13.609 +      // process death by signal.
  13.610 +      return 0x80 + WTERMSIG(status);
  13.611      } else {
  13.612 -       // Unknown exit code; pass it through
  13.613 -       return status;
  13.614 +      // Unknown exit code; pass it through.
  13.615 +      return status;
  13.616      }
  13.617    }
  13.618 -  // Remove warning.
  13.619    return -1;
  13.620  }
  13.621  
  13.622 @@ -5206,7 +5195,7 @@
  13.623    struct stat statbuf;
  13.624    char buf[MAXPATHLEN];
  13.625    char libmawtpath[MAXPATHLEN];
  13.626 -  const char *xawtstr  = "/xawt/libmawt.so";
  13.627 +  const char *xawtstr = "/xawt/libmawt.so";
  13.628    const char *new_xawtstr = "/libawt_xawt.so";
  13.629  
  13.630    char *p;
    14.1 --- a/src/os/aix/vm/os_aix.hpp	Thu Dec 18 17:59:15 2014 -0800
    14.2 +++ b/src/os/aix/vm/os_aix.hpp	Mon Dec 22 09:27:29 2014 -0800
    14.3 @@ -209,7 +209,7 @@
    14.4      return _can_use_16M_pages == 1 ? true : false;
    14.5    }
    14.6  
    14.7 -  static address   ucontext_get_pc(ucontext_t* uc);
    14.8 +  static address   ucontext_get_pc(const ucontext_t* uc);
    14.9    static intptr_t* ucontext_get_sp(ucontext_t* uc);
   14.10    static intptr_t* ucontext_get_fp(ucontext_t* uc);
   14.11    // Set PC into context. Needed for continuation after signal.
    15.1 --- a/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp	Thu Dec 18 17:59:15 2014 -0800
    15.2 +++ b/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp	Mon Dec 22 09:27:29 2014 -0800
    15.3 @@ -91,8 +91,9 @@
    15.4  
    15.5  // Frame information (pc, sp, fp) retrieved via ucontext
    15.6  // always looks like a C-frame according to the frame
    15.7 -// conventions in frame_ppc64.hpp.
    15.8 -address os::Aix::ucontext_get_pc(ucontext_t * uc) {
    15.9 +// conventions in frame_ppc.hpp.
   15.10 +
   15.11 +address os::Aix::ucontext_get_pc(const ucontext_t * uc) {
   15.12    return (address)uc->uc_mcontext.jmp_context.iar;
   15.13  }
   15.14  
   15.15 @@ -486,7 +487,7 @@
   15.16  ////////////////////////////////////////////////////////////////////////////////
   15.17  // thread stack
   15.18  
   15.19 -size_t os::Aix::min_stack_allowed = 768*K;
   15.20 +size_t os::Aix::min_stack_allowed = 128*K;
   15.21  
   15.22  // Aix is always in floating stack mode. The stack size for a new
   15.23  // thread can be set via pthread_attr_setstacksize().
   15.24 @@ -499,7 +500,7 @@
   15.25    // because of the strange 'fallback logic' in os::create_thread().
   15.26    // Better set CompilerThreadStackSize in globals_<os_cpu>.hpp if you want to
   15.27    // specify a different stack size for compiler threads!
   15.28 -  size_t s = (thr_type == os::compiler_thread ? 4 * M : 1024 * K);
   15.29 +  size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M);
   15.30    return s;
   15.31  }
   15.32  
    16.1 --- a/src/os_cpu/aix_ppc/vm/os_aix_ppc.hpp	Thu Dec 18 17:59:15 2014 -0800
    16.2 +++ b/src/os_cpu/aix_ppc/vm/os_aix_ppc.hpp	Mon Dec 22 09:27:29 2014 -0800
    16.3 @@ -23,8 +23,8 @@
    16.4   *
    16.5   */
    16.6  
    16.7 -#ifndef OS_CPU_AIX_OJDKPPC_VM_OS_AIX_PPC_HPP
    16.8 -#define OS_CPU_AIX_OJDKPPC_VM_OS_AIX_PPC_HPP
    16.9 +#ifndef OS_CPU_AIX_PPC_VM_OS_AIX_PPC_HPP
   16.10 +#define OS_CPU_AIX_PPC_VM_OS_AIX_PPC_HPP
   16.11  
   16.12    static void setup_fpu() {}
   16.13  
   16.14 @@ -32,4 +32,4 @@
   16.15    // Note: Currently only used in 64 bit Windows implementations
   16.16    static bool register_code_area(char *low, char *high) { return true; }
   16.17  
   16.18 -#endif // OS_CPU_AIX_OJDKPPC_VM_OS_AIX_PPC_HPP
   16.19 +#endif // OS_CPU_AIX_PPC_VM_OS_AIX_PPC_HPP
    17.1 --- a/src/os_cpu/aix_ppc/vm/prefetch_aix_ppc.inline.hpp	Thu Dec 18 17:59:15 2014 -0800
    17.2 +++ b/src/os_cpu/aix_ppc/vm/prefetch_aix_ppc.inline.hpp	Mon Dec 22 09:27:29 2014 -0800
    17.3 @@ -23,8 +23,8 @@
    17.4   *
    17.5   */
    17.6  
    17.7 -#ifndef OS_CPU_AIX_PPC_64_VM_PREFETCH_AIX_PPC_64_INLINE_HPP
    17.8 -#define OS_CPU_AIX_PPC_64_VM_PREFETCH_AIX_PPC_64_INLINE_HPP
    17.9 +#ifndef OS_CPU_AIX_PPC_VM_PREFETCH_AIX_PPC_INLINE_HPP
   17.10 +#define OS_CPU_AIX_PPC_VM_PREFETCH_AIX_PPC_INLINE_HPP
   17.11  
   17.12  #include "runtime/prefetch.hpp"
   17.13  
   17.14 @@ -55,4 +55,4 @@
   17.15  #endif
   17.16  }
   17.17  
   17.18 -#endif // OS_CPU_AIX_PPC_64_VM_PREFETCH_AIX_PPC_64_INLINE_HPP
   17.19 +#endif // OS_CPU_AIX_PPC_VM_PREFETCH_AIX_PPC_INLINE_HPP
    18.1 --- a/src/os_cpu/aix_ppc/vm/threadLS_aix_ppc.hpp	Thu Dec 18 17:59:15 2014 -0800
    18.2 +++ b/src/os_cpu/aix_ppc/vm/threadLS_aix_ppc.hpp	Mon Dec 22 09:27:29 2014 -0800
    18.3 @@ -23,8 +23,8 @@
    18.4   *
    18.5   */
    18.6  
    18.7 -#ifndef OS_CPU_AIX_OJDKPPC_VM_THREADLS_AIX_PPC_HPP
    18.8 -#define OS_CPU_AIX_OJDKPPC_VM_THREADLS_AIX_PPC_HPP
    18.9 +#ifndef OS_CPU_AIX_PPC_VM_THREADLS_AIX_PPC_HPP
   18.10 +#define OS_CPU_AIX_PPC_VM_THREADLS_AIX_PPC_HPP
   18.11  
   18.12    // Processor dependent parts of ThreadLocalStorage
   18.13  
   18.14 @@ -33,4 +33,4 @@
   18.15      return (Thread *) os::thread_local_storage_at(thread_index());
   18.16    }
   18.17  
   18.18 -#endif // OS_CPU_AIX_OJDKPPC_VM_THREADLS_AIX_PPC_HPP
   18.19 +#endif // OS_CPU_AIX_PPC_VM_THREADLS_AIX_PPC_HPP
    19.1 --- a/src/os_cpu/aix_ppc/vm/thread_aix_ppc.hpp	Thu Dec 18 17:59:15 2014 -0800
    19.2 +++ b/src/os_cpu/aix_ppc/vm/thread_aix_ppc.hpp	Mon Dec 22 09:27:29 2014 -0800
    19.3 @@ -23,8 +23,8 @@
    19.4   *
    19.5   */
    19.6  
    19.7 -#ifndef OS_CPU_AIX_OJDKPPC_VM_THREAD_AIX_PPC_HPP
    19.8 -#define OS_CPU_AIX_OJDKPPC_VM_THREAD_AIX_PPC_HPP
    19.9 +#ifndef OS_CPU_AIX_PPC_VM_THREAD_AIX_PPC_HPP
   19.10 +#define OS_CPU_AIX_PPC_VM_THREAD_AIX_PPC_HPP
   19.11  
   19.12   private:
   19.13    void pd_initialize() {
   19.14 @@ -76,4 +76,4 @@
   19.15  
   19.16    intptr_t* last_interpreter_fp() { return _last_interpreter_fp; }
   19.17  
   19.18 -#endif // OS_CPU_AIX_OJDKPPC_VM_THREAD_AIX_PPC_HPP
   19.19 +#endif // OS_CPU_AIX_PPC_VM_THREAD_AIX_PPC_HPP
    20.1 --- a/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp	Thu Dec 18 17:59:15 2014 -0800
    20.2 +++ b/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp	Mon Dec 22 09:27:29 2014 -0800
    20.3 @@ -453,7 +453,7 @@
    20.4  ////////////////////////////////////////////////////////////////////////////////
    20.5  // thread stack
    20.6  
    20.7 -size_t os::Linux::min_stack_allowed = 768*K;
    20.8 +size_t os::Linux::min_stack_allowed = 128*K;
    20.9  
   20.10  bool os::Linux::supports_variable_stack_size() { return true; }
   20.11  
    21.1 --- a/src/share/vm/classfile/classFileParser.cpp	Thu Dec 18 17:59:15 2014 -0800
    21.2 +++ b/src/share/vm/classfile/classFileParser.cpp	Mon Dec 22 09:27:29 2014 -0800
    21.3 @@ -3058,21 +3058,39 @@
    21.4    }
    21.5  }
    21.6  
    21.7 -// Transfer ownership of metadata allocated to the InstanceKlass.
    21.8 -void ClassFileParser::apply_parsed_class_metadata(
    21.9 -                                            instanceKlassHandle this_klass,
   21.10 -                                            int java_fields_count, TRAPS) {
   21.11 -  // Assign annotations if needed
   21.12 -  if (_annotations != NULL || _type_annotations != NULL ||
   21.13 -      _fields_annotations != NULL || _fields_type_annotations != NULL) {
   21.14 +// Create the Annotations object that will
   21.15 +// hold the annotations array for the Klass.
   21.16 +void ClassFileParser::create_combined_annotations(TRAPS) {
   21.17 +    if (_annotations == NULL &&
   21.18 +        _type_annotations == NULL &&
   21.19 +        _fields_annotations == NULL &&
   21.20 +        _fields_type_annotations == NULL) {
   21.21 +      // Don't create the Annotations object unnecessarily.
   21.22 +      return;
   21.23 +    }
   21.24 +
   21.25      Annotations* annotations = Annotations::allocate(_loader_data, CHECK);
   21.26      annotations->set_class_annotations(_annotations);
   21.27      annotations->set_class_type_annotations(_type_annotations);
   21.28      annotations->set_fields_annotations(_fields_annotations);
   21.29      annotations->set_fields_type_annotations(_fields_type_annotations);
   21.30 -    this_klass->set_annotations(annotations);
   21.31 -  }
   21.32 -
   21.33 +
   21.34 +    // This is the Annotations object that will be
   21.35 +    // assigned to InstanceKlass being constructed.
   21.36 +    _combined_annotations = annotations;
   21.37 +
   21.38 +    // The annotations arrays below has been transfered the
   21.39 +    // _combined_annotations so these fields can now be cleared.
   21.40 +    _annotations             = NULL;
   21.41 +    _type_annotations        = NULL;
   21.42 +    _fields_annotations      = NULL;
   21.43 +    _fields_type_annotations = NULL;
   21.44 +}
   21.45 +
   21.46 +// Transfer ownership of metadata allocated to the InstanceKlass.
   21.47 +void ClassFileParser::apply_parsed_class_metadata(
   21.48 +                                            instanceKlassHandle this_klass,
   21.49 +                                            int java_fields_count, TRAPS) {
   21.50    _cp->set_pool_holder(this_klass());
   21.51    this_klass->set_constants(_cp);
   21.52    this_klass->set_fields(_fields, java_fields_count);
   21.53 @@ -3080,6 +3098,7 @@
   21.54    this_klass->set_inner_classes(_inner_classes);
   21.55    this_klass->set_local_interfaces(_local_interfaces);
   21.56    this_klass->set_transitive_interfaces(_transitive_interfaces);
   21.57 +  this_klass->set_annotations(_combined_annotations);
   21.58  
   21.59    // Clear out these fields so they don't get deallocated by the destructor
   21.60    clear_class_metadata();
   21.61 @@ -3939,6 +3958,10 @@
   21.62      ClassAnnotationCollector parsed_annotations;
   21.63      parse_classfile_attributes(&parsed_annotations, CHECK_(nullHandle));
   21.64  
   21.65 +    // Finalize the Annotations metadata object,
   21.66 +    // now that all annotation arrays have been created.
   21.67 +    create_combined_annotations(CHECK_(nullHandle));
   21.68 +
   21.69      // Make sure this is the end of class file stream
   21.70      guarantee_property(cfs->at_eos(), "Extra bytes at the end of class file %s", CHECK_(nullHandle));
   21.71  
   21.72 @@ -4239,10 +4262,27 @@
   21.73    InstanceKlass::deallocate_interfaces(_loader_data, _super_klass(),
   21.74                                         _local_interfaces, _transitive_interfaces);
   21.75  
   21.76 -  MetadataFactory::free_array<u1>(_loader_data, _annotations);
   21.77 -  MetadataFactory::free_array<u1>(_loader_data, _type_annotations);
   21.78 -  Annotations::free_contents(_loader_data, _fields_annotations);
   21.79 -  Annotations::free_contents(_loader_data, _fields_type_annotations);
   21.80 +  if (_combined_annotations != NULL) {
   21.81 +    // After all annotations arrays have been created, they are installed into the
   21.82 +    // Annotations object that will be assigned to the InstanceKlass being created.
   21.83 +
   21.84 +    // Deallocate the Annotations object and the installed annotations arrays.
   21.85 +    _combined_annotations->deallocate_contents(_loader_data);
   21.86 +
   21.87 +    // If the _combined_annotations pointer is non-NULL,
   21.88 +    // then the other annotations fields should have been cleared.
   21.89 +    assert(_annotations             == NULL, "Should have been cleared");
   21.90 +    assert(_type_annotations        == NULL, "Should have been cleared");
   21.91 +    assert(_fields_annotations      == NULL, "Should have been cleared");
   21.92 +    assert(_fields_type_annotations == NULL, "Should have been cleared");
   21.93 +  } else {
   21.94 +    // If the annotations arrays were not installed into the Annotations object,
   21.95 +    // then they have to be deallocated explicitly.
   21.96 +    MetadataFactory::free_array<u1>(_loader_data, _annotations);
   21.97 +    MetadataFactory::free_array<u1>(_loader_data, _type_annotations);
   21.98 +    Annotations::free_contents(_loader_data, _fields_annotations);
   21.99 +    Annotations::free_contents(_loader_data, _fields_type_annotations);
  21.100 +  }
  21.101  
  21.102    clear_class_metadata();
  21.103  
    22.1 --- a/src/share/vm/classfile/classFileParser.hpp	Thu Dec 18 17:59:15 2014 -0800
    22.2 +++ b/src/share/vm/classfile/classFileParser.hpp	Mon Dec 22 09:27:29 2014 -0800
    22.3 @@ -75,6 +75,7 @@
    22.4    Array<u2>*       _inner_classes;
    22.5    Array<Klass*>*   _local_interfaces;
    22.6    Array<Klass*>*   _transitive_interfaces;
    22.7 +  Annotations*     _combined_annotations;
    22.8    AnnotationArray* _annotations;
    22.9    AnnotationArray* _type_annotations;
   22.10    Array<AnnotationArray*>* _fields_annotations;
   22.11 @@ -86,6 +87,8 @@
   22.12    void set_class_generic_signature_index(u2 x) { _generic_signature_index = x; }
   22.13    void set_class_sde_buffer(char* x, int len)  { _sde_buffer = x; _sde_length = len; }
   22.14  
   22.15 +  void create_combined_annotations(TRAPS);
   22.16 +
   22.17    void init_parsed_class_attributes(ClassLoaderData* loader_data) {
   22.18      _loader_data = loader_data;
   22.19      _synthetic_flag = false;
   22.20 @@ -110,6 +113,7 @@
   22.21      _inner_classes = NULL;
   22.22      _local_interfaces = NULL;
   22.23      _transitive_interfaces = NULL;
   22.24 +    _combined_annotations = NULL;
   22.25      _annotations = _type_annotations = NULL;
   22.26      _fields_annotations = _fields_type_annotations = NULL;
   22.27    }
    23.1 --- a/src/share/vm/interpreter/interpreterRuntime.cpp	Thu Dec 18 17:59:15 2014 -0800
    23.2 +++ b/src/share/vm/interpreter/interpreterRuntime.cpp	Mon Dec 22 09:27:29 2014 -0800
    23.3 @@ -398,6 +398,18 @@
    23.4    int                handler_bci;
    23.5    int                current_bci = bci(thread);
    23.6  
    23.7 +  if (thread->frames_to_pop_failed_realloc() > 0) {
    23.8 +    // Allocation of scalar replaced object used in this frame
    23.9 +    // failed. Unconditionally pop the frame.
   23.10 +    thread->dec_frames_to_pop_failed_realloc();
   23.11 +    thread->set_vm_result(h_exception());
   23.12 +    // If the method is synchronized we already unlocked the monitor
   23.13 +    // during deoptimization so the interpreter needs to skip it when
   23.14 +    // the frame is popped.
   23.15 +    thread->set_do_not_unlock_if_synchronized(true);
   23.16 +    return Interpreter::remove_activation_entry();
   23.17 +  }
   23.18 +
   23.19    // Need to do this check first since when _do_not_unlock_if_synchronized
   23.20    // is set, we don't want to trigger any classloading which may make calls
   23.21    // into java, or surprisingly find a matching exception handler for bci 0
    24.1 --- a/src/share/vm/memory/filemap.cpp	Thu Dec 18 17:59:15 2014 -0800
    24.2 +++ b/src/share/vm/memory/filemap.cpp	Mon Dec 22 09:27:29 2014 -0800
    24.3 @@ -97,11 +97,11 @@
    24.4          tty->print_cr("UseSharedSpaces: %s", msg);
    24.5        }
    24.6      }
    24.7 +    UseSharedSpaces = false;
    24.8 +    assert(current_info() != NULL, "singleton must be registered");
    24.9 +    current_info()->close();
   24.10    }
   24.11    va_end(ap);
   24.12 -  UseSharedSpaces = false;
   24.13 -  assert(current_info() != NULL, "singleton must be registered");
   24.14 -  current_info()->close();
   24.15  }
   24.16  
   24.17  // Fill in the fileMapInfo structure with data about this VM instance.
    25.1 --- a/src/share/vm/memory/metaspaceShared.cpp	Thu Dec 18 17:59:15 2014 -0800
    25.2 +++ b/src/share/vm/memory/metaspaceShared.cpp	Mon Dec 22 09:27:29 2014 -0800
    25.3 @@ -967,7 +967,7 @@
    25.4  #endif
    25.5      // If -Xshare:on is specified, print out the error message and exit VM,
    25.6      // otherwise, set UseSharedSpaces to false and continue.
    25.7 -    if (RequireSharedSpaces) {
    25.8 +    if (RequireSharedSpaces || PrintSharedArchiveAndExit) {
    25.9        vm_exit_during_initialization("Unable to use shared archive.", "Failed map_region for using -Xshare:on.");
   25.10      } else {
   25.11        FLAG_SET_DEFAULT(UseSharedSpaces, false);
    26.1 --- a/src/share/vm/memory/universe.cpp	Thu Dec 18 17:59:15 2014 -0800
    26.2 +++ b/src/share/vm/memory/universe.cpp	Mon Dec 22 09:27:29 2014 -0800
    26.3 @@ -119,6 +119,7 @@
    26.4  oop Universe::_out_of_memory_error_class_metaspace    = NULL;
    26.5  oop Universe::_out_of_memory_error_array_size         = NULL;
    26.6  oop Universe::_out_of_memory_error_gc_overhead_limit  = NULL;
    26.7 +oop Universe::_out_of_memory_error_realloc_objects    = NULL;
    26.8  objArrayOop Universe::_preallocated_out_of_memory_error_array = NULL;
    26.9  volatile jint Universe::_preallocated_out_of_memory_error_avail_count = 0;
   26.10  bool Universe::_verify_in_progress                    = false;
   26.11 @@ -190,6 +191,7 @@
   26.12    f->do_oop((oop*)&_out_of_memory_error_class_metaspace);
   26.13    f->do_oop((oop*)&_out_of_memory_error_array_size);
   26.14    f->do_oop((oop*)&_out_of_memory_error_gc_overhead_limit);
   26.15 +  f->do_oop((oop*)&_out_of_memory_error_realloc_objects);
   26.16      f->do_oop((oop*)&_preallocated_out_of_memory_error_array);
   26.17    f->do_oop((oop*)&_null_ptr_exception_instance);
   26.18    f->do_oop((oop*)&_arithmetic_exception_instance);
   26.19 @@ -574,7 +576,8 @@
   26.20            (throwable() != Universe::_out_of_memory_error_metaspace)  &&
   26.21            (throwable() != Universe::_out_of_memory_error_class_metaspace)  &&
   26.22            (throwable() != Universe::_out_of_memory_error_array_size) &&
   26.23 -          (throwable() != Universe::_out_of_memory_error_gc_overhead_limit));
   26.24 +          (throwable() != Universe::_out_of_memory_error_gc_overhead_limit) &&
   26.25 +          (throwable() != Universe::_out_of_memory_error_realloc_objects));
   26.26  }
   26.27  
   26.28  
   26.29 @@ -1044,6 +1047,7 @@
   26.30      Universe::_out_of_memory_error_array_size = k_h->allocate_instance(CHECK_false);
   26.31      Universe::_out_of_memory_error_gc_overhead_limit =
   26.32        k_h->allocate_instance(CHECK_false);
   26.33 +    Universe::_out_of_memory_error_realloc_objects = k_h->allocate_instance(CHECK_false);
   26.34  
   26.35      // Setup preallocated NullPointerException
   26.36      // (this is currently used for a cheap & dirty solution in compiler exception handling)
   26.37 @@ -1083,6 +1087,9 @@
   26.38      msg = java_lang_String::create_from_str("GC overhead limit exceeded", CHECK_false);
   26.39      java_lang_Throwable::set_message(Universe::_out_of_memory_error_gc_overhead_limit, msg());
   26.40  
   26.41 +    msg = java_lang_String::create_from_str("Java heap space: failed reallocation of scalar replaced objects", CHECK_false);
   26.42 +    java_lang_Throwable::set_message(Universe::_out_of_memory_error_realloc_objects, msg());
   26.43 +
   26.44      msg = java_lang_String::create_from_str("/ by zero", CHECK_false);
   26.45      java_lang_Throwable::set_message(Universe::_arithmetic_exception_instance, msg());
   26.46  
    27.1 --- a/src/share/vm/memory/universe.hpp	Thu Dec 18 17:59:15 2014 -0800
    27.2 +++ b/src/share/vm/memory/universe.hpp	Mon Dec 22 09:27:29 2014 -0800
    27.3 @@ -157,6 +157,7 @@
    27.4    static oop          _out_of_memory_error_class_metaspace;
    27.5    static oop          _out_of_memory_error_array_size;
    27.6    static oop          _out_of_memory_error_gc_overhead_limit;
    27.7 +  static oop          _out_of_memory_error_realloc_objects;
    27.8  
    27.9    static Array<int>*       _the_empty_int_array;    // Canonicalized int array
   27.10    static Array<u2>*        _the_empty_short_array;  // Canonicalized short array
   27.11 @@ -328,6 +329,7 @@
   27.12    static oop out_of_memory_error_class_metaspace()    { return gen_out_of_memory_error(_out_of_memory_error_class_metaspace);   }
   27.13    static oop out_of_memory_error_array_size()         { return gen_out_of_memory_error(_out_of_memory_error_array_size); }
   27.14    static oop out_of_memory_error_gc_overhead_limit()  { return gen_out_of_memory_error(_out_of_memory_error_gc_overhead_limit);  }
   27.15 +  static oop out_of_memory_error_realloc_objects()    { return gen_out_of_memory_error(_out_of_memory_error_realloc_objects);  }
   27.16  
   27.17    // Accessors needed for fast allocation
   27.18    static Klass** boolArrayKlassObj_addr()           { return &_boolArrayKlassObj;   }
    28.1 --- a/src/share/vm/opto/connode.cpp	Thu Dec 18 17:59:15 2014 -0800
    28.2 +++ b/src/share/vm/opto/connode.cpp	Mon Dec 22 09:27:29 2014 -0800
    28.3 @@ -462,7 +462,8 @@
    28.4    // Try to improve the type of the CastII if we recognize a CmpI/If
    28.5    // pattern.
    28.6    if (_carry_dependency) {
    28.7 -    if (in(0) != NULL && (in(0)->is_IfFalse() || in(0)->is_IfTrue())) {
    28.8 +    if (in(0) != NULL && in(0)->in(0) != NULL && in(0)->in(0)->is_If()) {
    28.9 +      assert(in(0)->is_IfFalse() || in(0)->is_IfTrue(), "should be If proj");
   28.10        Node* proj = in(0);
   28.11        if (proj->in(0)->in(1)->is_Bool()) {
   28.12          Node* b = proj->in(0)->in(1);
    29.1 --- a/src/share/vm/opto/ifnode.cpp	Thu Dec 18 17:59:15 2014 -0800
    29.2 +++ b/src/share/vm/opto/ifnode.cpp	Mon Dec 22 09:27:29 2014 -0800
    29.3 @@ -820,6 +820,11 @@
    29.4  
    29.5  static IfNode* idealize_test(PhaseGVN* phase, IfNode* iff);
    29.6  
    29.7 +struct RangeCheck {
    29.8 +  Node* ctl;
    29.9 +  jint off;
   29.10 +};
   29.11 +
   29.12  //------------------------------Ideal------------------------------------------
   29.13  // Return a node which is more "ideal" than the current node.  Strip out
   29.14  // control copies
   29.15 @@ -861,83 +866,141 @@
   29.16    jint offset1;
   29.17    int flip1 = is_range_check(range1, index1, offset1);
   29.18    if( flip1 ) {
   29.19 -    Node *first_prev_dom = NULL;
   29.20 -
   29.21      // Try to remove extra range checks.  All 'up_one_dom' gives up at merges
   29.22      // so all checks we inspect post-dominate the top-most check we find.
   29.23      // If we are going to fail the current check and we reach the top check
   29.24      // then we are guaranteed to fail, so just start interpreting there.
   29.25 -    // We 'expand' the top 2 range checks to include all post-dominating
   29.26 +    // We 'expand' the top 3 range checks to include all post-dominating
   29.27      // checks.
   29.28  
   29.29 -    // The top 2 range checks seen
   29.30 -    Node *prev_chk1 = NULL;
   29.31 -    Node *prev_chk2 = NULL;
   29.32 +    // The top 3 range checks seen
   29.33 +    const int NRC =3;
   29.34 +    RangeCheck prev_checks[NRC];
   29.35 +    int nb_checks = 0;
   29.36 +
   29.37      // Low and high offsets seen so far
   29.38      jint off_lo = offset1;
   29.39      jint off_hi = offset1;
   29.40  
   29.41 -    // Scan for the top 2 checks and collect range of offsets
   29.42 -    for( int dist = 0; dist < 999; dist++ ) { // Range-Check scan limit
   29.43 -      if( dom->Opcode() == Op_If &&  // Not same opcode?
   29.44 -          prev_dom->in(0) == dom ) { // One path of test does dominate?
   29.45 -        if( dom == this ) return NULL; // dead loop
   29.46 +    bool found_immediate_dominator = false;
   29.47 +
   29.48 +    // Scan for the top checks and collect range of offsets
   29.49 +    for (int dist = 0; dist < 999; dist++) { // Range-Check scan limit
   29.50 +      if (dom->Opcode() == Op_If &&  // Not same opcode?
   29.51 +          prev_dom->in(0) == dom) { // One path of test does dominate?
   29.52 +        if (dom == this) return NULL; // dead loop
   29.53          // See if this is a range check
   29.54          Node *index2, *range2;
   29.55          jint offset2;
   29.56          int flip2 = dom->as_If()->is_range_check(range2, index2, offset2);
   29.57          // See if this is a _matching_ range check, checking against
   29.58          // the same array bounds.
   29.59 -        if( flip2 == flip1 && range2 == range1 && index2 == index1 &&
   29.60 -            dom->outcnt() == 2 ) {
   29.61 +        if (flip2 == flip1 && range2 == range1 && index2 == index1 &&
   29.62 +            dom->outcnt() == 2) {
   29.63 +          if (nb_checks == 0 && dom->in(1) == in(1)) {
   29.64 +            // Found an immediately dominating test at the same offset.
   29.65 +            // This kind of back-to-back test can be eliminated locally,
   29.66 +            // and there is no need to search further for dominating tests.
   29.67 +            assert(offset2 == offset1, "Same test but different offsets");
   29.68 +            found_immediate_dominator = true;
   29.69 +            break;
   29.70 +          }
   29.71            // Gather expanded bounds
   29.72            off_lo = MIN2(off_lo,offset2);
   29.73            off_hi = MAX2(off_hi,offset2);
   29.74 -          // Record top 2 range checks
   29.75 -          prev_chk2 = prev_chk1;
   29.76 -          prev_chk1 = prev_dom;
   29.77 -          // If we match the test exactly, then the top test covers
   29.78 -          // both our lower and upper bounds.
   29.79 -          if( dom->in(1) == in(1) )
   29.80 -            prev_chk2 = prev_chk1;
   29.81 +          // Record top NRC range checks
   29.82 +          prev_checks[nb_checks%NRC].ctl = prev_dom;
   29.83 +          prev_checks[nb_checks%NRC].off = offset2;
   29.84 +          nb_checks++;
   29.85          }
   29.86        }
   29.87        prev_dom = dom;
   29.88 -      dom = up_one_dom( dom );
   29.89 -      if( !dom ) break;
   29.90 +      dom = up_one_dom(dom);
   29.91 +      if (!dom) break;
   29.92      }
   29.93  
   29.94 +    if (!found_immediate_dominator) {
   29.95 +      // Attempt to widen the dominating range check to cover some later
   29.96 +      // ones.  Since range checks "fail" by uncommon-trapping to the
   29.97 +      // interpreter, widening a check can make us speculatively enter
   29.98 +      // the interpreter.  If we see range-check deopt's, do not widen!
   29.99 +      if (!phase->C->allow_range_check_smearing())  return NULL;
  29.100  
  29.101 -    // Attempt to widen the dominating range check to cover some later
  29.102 -    // ones.  Since range checks "fail" by uncommon-trapping to the
  29.103 -    // interpreter, widening a check can make us speculative enter the
  29.104 -    // interpreter.  If we see range-check deopt's, do not widen!
  29.105 -    if (!phase->C->allow_range_check_smearing())  return NULL;
  29.106 -
  29.107 -    // Constant indices only need to check the upper bound.
  29.108 -    // Non-constance indices must check both low and high.
  29.109 -    if( index1 ) {
  29.110 -      // Didn't find 2 prior covering checks, so cannot remove anything.
  29.111 -      if( !prev_chk2 ) return NULL;
  29.112 -      // 'Widen' the offsets of the 1st and 2nd covering check
  29.113 -      adjust_check( prev_chk1, range1, index1, flip1, off_lo, igvn );
  29.114 -      // Do not call adjust_check twice on the same projection
  29.115 -      // as the first call may have transformed the BoolNode to a ConI
  29.116 -      if( prev_chk1 != prev_chk2 ) {
  29.117 -        adjust_check( prev_chk2, range1, index1, flip1, off_hi, igvn );
  29.118 +      // Didn't find prior covering check, so cannot remove anything.
  29.119 +      if (nb_checks == 0) {
  29.120 +        return NULL;
  29.121        }
  29.122 -      // Test is now covered by prior checks, dominate it out
  29.123 -      prev_dom = prev_chk2;
  29.124 -    } else {
  29.125 -      // Didn't find prior covering check, so cannot remove anything.
  29.126 -      if( !prev_chk1 ) return NULL;
  29.127 -      // 'Widen' the offset of the 1st and only covering check
  29.128 -      adjust_check( prev_chk1, range1, index1, flip1, off_hi, igvn );
  29.129 -      // Test is now covered by prior checks, dominate it out
  29.130 -      prev_dom = prev_chk1;
  29.131 +      // Constant indices only need to check the upper bound.
  29.132 +      // Non-constant indices must check both low and high.
  29.133 +      int chk0 = (nb_checks - 1) % NRC;
  29.134 +      if (index1) {
  29.135 +        if (nb_checks == 1) {
  29.136 +          return NULL;
  29.137 +        } else {
  29.138 +          // If the top range check's constant is the min or max of
  29.139 +          // all constants we widen the next one to cover the whole
  29.140 +          // range of constants.
  29.141 +          RangeCheck rc0 = prev_checks[chk0];
  29.142 +          int chk1 = (nb_checks - 2) % NRC;
  29.143 +          RangeCheck rc1 = prev_checks[chk1];
  29.144 +          if (rc0.off == off_lo) {
  29.145 +            adjust_check(rc1.ctl, range1, index1, flip1, off_hi, igvn);
  29.146 +            prev_dom = rc1.ctl;
  29.147 +          } else if (rc0.off == off_hi) {
  29.148 +            adjust_check(rc1.ctl, range1, index1, flip1, off_lo, igvn);
  29.149 +            prev_dom = rc1.ctl;
  29.150 +          } else {
  29.151 +            // If the top test's constant is not the min or max of all
  29.152 +            // constants, we need 3 range checks. We must leave the
  29.153 +            // top test unchanged because widening it would allow the
  29.154 +            // accesses it protects to successfully read/write out of
  29.155 +            // bounds.
  29.156 +            if (nb_checks == 2) {
  29.157 +              return NULL;
  29.158 +            }
  29.159 +            int chk2 = (nb_checks - 3) % NRC;
  29.160 +            RangeCheck rc2 = prev_checks[chk2];
  29.161 +            // The top range check a+i covers interval: -a <= i < length-a
  29.162 +            // The second range check b+i covers interval: -b <= i < length-b
  29.163 +            if (rc1.off <= rc0.off) {
  29.164 +              // if b <= a, we change the second range check to:
  29.165 +              // -min_of_all_constants <= i < length-min_of_all_constants
  29.166 +              // Together top and second range checks now cover:
  29.167 +              // -min_of_all_constants <= i < length-a
  29.168 +              // which is more restrictive than -b <= i < length-b:
  29.169 +              // -b <= -min_of_all_constants <= i < length-a <= length-b
  29.170 +              // The third check is then changed to:
  29.171 +              // -max_of_all_constants <= i < length-max_of_all_constants
  29.172 +              // so 2nd and 3rd checks restrict allowed values of i to:
  29.173 +              // -min_of_all_constants <= i < length-max_of_all_constants
  29.174 +              adjust_check(rc1.ctl, range1, index1, flip1, off_lo, igvn);
  29.175 +              adjust_check(rc2.ctl, range1, index1, flip1, off_hi, igvn);
  29.176 +            } else {
  29.177 +              // if b > a, we change the second range check to:
  29.178 +              // -max_of_all_constants <= i < length-max_of_all_constants
  29.179 +              // Together top and second range checks now cover:
  29.180 +              // -a <= i < length-max_of_all_constants
  29.181 +              // which is more restrictive than -b <= i < length-b:
  29.182 +              // -b < -a <= i < length-max_of_all_constants <= length-b
  29.183 +              // The third check is then changed to:
  29.184 +              // -max_of_all_constants <= i < length-max_of_all_constants
  29.185 +              // so 2nd and 3rd checks restrict allowed values of i to:
  29.186 +              // -min_of_all_constants <= i < length-max_of_all_constants
  29.187 +              adjust_check(rc1.ctl, range1, index1, flip1, off_hi, igvn);
  29.188 +              adjust_check(rc2.ctl, range1, index1, flip1, off_lo, igvn);
  29.189 +            }
  29.190 +            prev_dom = rc2.ctl;
  29.191 +          }
  29.192 +        }
  29.193 +      } else {
  29.194 +        RangeCheck rc0 = prev_checks[chk0];
  29.195 +        // 'Widen' the offset of the 1st and only covering check
  29.196 +        adjust_check(rc0.ctl, range1, index1, flip1, off_hi, igvn);
  29.197 +        // Test is now covered by prior checks, dominate it out
  29.198 +        prev_dom = rc0.ctl;
  29.199 +      }
  29.200      }
  29.201  
  29.202 -
  29.203    } else {                      // Scan for an equivalent test
  29.204  
  29.205      Node *cmp;
  29.206 @@ -1019,7 +1082,7 @@
  29.207    // for lower and upper bounds.
  29.208    ProjNode* unc_proj = proj_out(1 - prev_dom->as_Proj()->_con)->as_Proj();
  29.209    if (unc_proj->is_uncommon_trap_proj(Deoptimization::Reason_predicate))
  29.210 -    prev_dom = idom;
  29.211 +   prev_dom = idom;
  29.212  
  29.213    // Now walk the current IfNode's projections.
  29.214    // Loop ends when 'this' has no more uses.
    30.1 --- a/src/share/vm/opto/loopopts.cpp	Thu Dec 18 17:59:15 2014 -0800
    30.2 +++ b/src/share/vm/opto/loopopts.cpp	Mon Dec 22 09:27:29 2014 -0800
    30.3 @@ -239,8 +239,13 @@
    30.4    ProjNode* dp_proj  = dp->as_Proj();
    30.5    ProjNode* unc_proj = iff->as_If()->proj_out(1 - dp_proj->_con)->as_Proj();
    30.6    if (exclude_loop_predicate &&
    30.7 -      unc_proj->is_uncommon_trap_proj(Deoptimization::Reason_predicate))
    30.8 +      (unc_proj->is_uncommon_trap_proj(Deoptimization::Reason_predicate) ||
    30.9 +       unc_proj->is_uncommon_trap_proj(Deoptimization::Reason_range_check))) {
   30.10 +    // If this is a range check (IfNode::is_range_check), do not
   30.11 +    // reorder because Compile::allow_range_check_smearing might have
   30.12 +    // changed the check.
   30.13      return; // Let IGVN transformation change control dependence.
   30.14 +  }
   30.15  
   30.16    IdealLoopTree *old_loop = get_loop(dp);
   30.17  
   30.18 @@ -896,23 +901,23 @@
   30.19    int n_op = n->Opcode();
   30.20  
   30.21    // Check for an IF being dominated by another IF same test
   30.22 -  if( n_op == Op_If ) {
   30.23 +  if (n_op == Op_If) {
   30.24      Node *bol = n->in(1);
   30.25      uint max = bol->outcnt();
   30.26      // Check for same test used more than once?
   30.27 -    if( n_op == Op_If && max > 1 && bol->is_Bool() ) {
   30.28 +    if (max > 1 && bol->is_Bool()) {
   30.29        // Search up IDOMs to see if this IF is dominated.
   30.30        Node *cutoff = get_ctrl(bol);
   30.31  
   30.32        // Now search up IDOMs till cutoff, looking for a dominating test
   30.33        Node *prevdom = n;
   30.34        Node *dom = idom(prevdom);
   30.35 -      while( dom != cutoff ) {
   30.36 -        if( dom->req() > 1 && dom->in(1) == bol && prevdom->in(0) == dom ) {
   30.37 +      while (dom != cutoff) {
   30.38 +        if (dom->req() > 1 && dom->in(1) == bol && prevdom->in(0) == dom) {
   30.39            // Replace the dominated test with an obvious true or false.
   30.40            // Place it on the IGVN worklist for later cleanup.
   30.41            C->set_major_progress();
   30.42 -          dominated_by( prevdom, n, false, true );
   30.43 +          dominated_by(prevdom, n, false, true);
   30.44  #ifndef PRODUCT
   30.45            if( VerifyLoopOptimizations ) verify();
   30.46  #endif
    31.1 --- a/src/share/vm/opto/macro.cpp	Thu Dec 18 17:59:15 2014 -0800
    31.2 +++ b/src/share/vm/opto/macro.cpp	Mon Dec 22 09:27:29 2014 -0800
    31.3 @@ -964,7 +964,11 @@
    31.4  }
    31.5  
    31.6  bool PhaseMacroExpand::eliminate_allocate_node(AllocateNode *alloc) {
    31.7 -  if (!EliminateAllocations || !alloc->_is_non_escaping) {
    31.8 +  // Don't do scalar replacement if the frame can be popped by JVMTI:
    31.9 +  // if reallocation fails during deoptimization we'll pop all
   31.10 +  // interpreter frames for this compiled frame and that won't play
   31.11 +  // nice with JVMTI popframe.
   31.12 +  if (!EliminateAllocations || JvmtiExport::can_pop_frame() || !alloc->_is_non_escaping) {
   31.13      return false;
   31.14    }
   31.15    Node* klass = alloc->in(AllocateNode::KlassNode);
    32.1 --- a/src/share/vm/runtime/deoptimization.cpp	Thu Dec 18 17:59:15 2014 -0800
    32.2 +++ b/src/share/vm/runtime/deoptimization.cpp	Mon Dec 22 09:27:29 2014 -0800
    32.3 @@ -213,6 +213,8 @@
    32.4    assert(vf->is_compiled_frame(), "Wrong frame type");
    32.5    chunk->push(compiledVFrame::cast(vf));
    32.6  
    32.7 +  bool realloc_failures = false;
    32.8 +
    32.9  #ifdef COMPILER2
   32.10    // Reallocate the non-escaping objects and restore their fields. Then
   32.11    // relock objects if synchronization on them was eliminated.
   32.12 @@ -243,19 +245,16 @@
   32.13            tty->print_cr("SAVED OOP RESULT " INTPTR_FORMAT " in thread " INTPTR_FORMAT, (void *)result, thread);
   32.14          }
   32.15        }
   32.16 -      bool reallocated = false;
   32.17        if (objects != NULL) {
   32.18          JRT_BLOCK
   32.19 -          reallocated = realloc_objects(thread, &deoptee, objects, THREAD);
   32.20 +          realloc_failures = realloc_objects(thread, &deoptee, objects, THREAD);
   32.21          JRT_END
   32.22 -      }
   32.23 -      if (reallocated) {
   32.24 -        reassign_fields(&deoptee, &map, objects);
   32.25 +        reassign_fields(&deoptee, &map, objects, realloc_failures);
   32.26  #ifndef PRODUCT
   32.27          if (TraceDeoptimization) {
   32.28            ttyLocker ttyl;
   32.29            tty->print_cr("REALLOC OBJECTS in thread " INTPTR_FORMAT, thread);
   32.30 -          print_objects(objects);
   32.31 +          print_objects(objects, realloc_failures);
   32.32          }
   32.33  #endif
   32.34        }
   32.35 @@ -273,7 +272,7 @@
   32.36          assert (cvf->scope() != NULL,"expect only compiled java frames");
   32.37          GrowableArray<MonitorInfo*>* monitors = cvf->monitors();
   32.38          if (monitors->is_nonempty()) {
   32.39 -          relock_objects(monitors, thread);
   32.40 +          relock_objects(monitors, thread, realloc_failures);
   32.41  #ifndef PRODUCT
   32.42            if (TraceDeoptimization) {
   32.43              ttyLocker ttyl;
   32.44 @@ -284,7 +283,12 @@
   32.45                    first = false;
   32.46                    tty->print_cr("RELOCK OBJECTS in thread " INTPTR_FORMAT, thread);
   32.47                  }
   32.48 -                tty->print_cr("     object <" INTPTR_FORMAT "> locked", (void *)mi->owner());
   32.49 +                if (mi->owner_is_scalar_replaced()) {
   32.50 +                  Klass* k = java_lang_Class::as_Klass(mi->owner_klass());
   32.51 +                  tty->print_cr("     failed reallocation for klass %s", k->external_name());
   32.52 +                } else {
   32.53 +                  tty->print_cr("     object <" INTPTR_FORMAT "> locked", (void *)mi->owner());
   32.54 +                }
   32.55                }
   32.56              }
   32.57            }
   32.58 @@ -299,9 +303,14 @@
   32.59    // out the java state residing in the vframeArray will be missed.
   32.60    No_Safepoint_Verifier no_safepoint;
   32.61  
   32.62 -  vframeArray* array = create_vframeArray(thread, deoptee, &map, chunk);
   32.63 +  vframeArray* array = create_vframeArray(thread, deoptee, &map, chunk, realloc_failures);
   32.64 +#ifdef COMPILER2
   32.65 +  if (realloc_failures) {
   32.66 +    pop_frames_failed_reallocs(thread, array);
   32.67 +  }
   32.68 +#endif
   32.69  
   32.70 -  assert(thread->vframe_array_head() == NULL, "Pending deopt!");;
   32.71 +  assert(thread->vframe_array_head() == NULL, "Pending deopt!");
   32.72    thread->set_vframe_array_head(array);
   32.73  
   32.74    // Now that the vframeArray has been created if we have any deferred local writes
   32.75 @@ -753,6 +762,8 @@
   32.76    int exception_line = thread->exception_line();
   32.77    thread->clear_pending_exception();
   32.78  
   32.79 +  bool failures = false;
   32.80 +
   32.81    for (int i = 0; i < objects->length(); i++) {
   32.82      assert(objects->at(i)->is_object(), "invalid debug information");
   32.83      ObjectValue* sv = (ObjectValue*) objects->at(i);
   32.84 @@ -762,27 +773,34 @@
   32.85  
   32.86      if (k->oop_is_instance()) {
   32.87        InstanceKlass* ik = InstanceKlass::cast(k());
   32.88 -      obj = ik->allocate_instance(CHECK_(false));
   32.89 +      obj = ik->allocate_instance(THREAD);
   32.90      } else if (k->oop_is_typeArray()) {
   32.91        TypeArrayKlass* ak = TypeArrayKlass::cast(k());
   32.92        assert(sv->field_size() % type2size[ak->element_type()] == 0, "non-integral array length");
   32.93        int len = sv->field_size() / type2size[ak->element_type()];
   32.94 -      obj = ak->allocate(len, CHECK_(false));
   32.95 +      obj = ak->allocate(len, THREAD);
   32.96      } else if (k->oop_is_objArray()) {
   32.97        ObjArrayKlass* ak = ObjArrayKlass::cast(k());
   32.98 -      obj = ak->allocate(sv->field_size(), CHECK_(false));
   32.99 +      obj = ak->allocate(sv->field_size(), THREAD);
  32.100      }
  32.101  
  32.102 -    assert(obj != NULL, "allocation failed");
  32.103 +    if (obj == NULL) {
  32.104 +      failures = true;
  32.105 +    }
  32.106 +
  32.107      assert(sv->value().is_null(), "redundant reallocation");
  32.108 +    assert(obj != NULL || HAS_PENDING_EXCEPTION, "allocation should succeed or we should get an exception");
  32.109 +    CLEAR_PENDING_EXCEPTION;
  32.110      sv->set_value(obj);
  32.111    }
  32.112  
  32.113 -  if (pending_exception.not_null()) {
  32.114 +  if (failures) {
  32.115 +    THROW_OOP_(Universe::out_of_memory_error_realloc_objects(), failures);
  32.116 +  } else if (pending_exception.not_null()) {
  32.117      thread->set_pending_exception(pending_exception(), exception_file, exception_line);
  32.118    }
  32.119  
  32.120 -  return true;
  32.121 +  return failures;
  32.122  }
  32.123  
  32.124  // This assumes that the fields are stored in ObjectValue in the same order
  32.125 @@ -920,12 +938,15 @@
  32.126  
  32.127  
  32.128  // restore fields of all eliminated objects and arrays
  32.129 -void Deoptimization::reassign_fields(frame* fr, RegisterMap* reg_map, GrowableArray<ScopeValue*>* objects) {
  32.130 +void Deoptimization::reassign_fields(frame* fr, RegisterMap* reg_map, GrowableArray<ScopeValue*>* objects, bool realloc_failures) {
  32.131    for (int i = 0; i < objects->length(); i++) {
  32.132      ObjectValue* sv = (ObjectValue*) objects->at(i);
  32.133      KlassHandle k(java_lang_Class::as_Klass(sv->klass()->as_ConstantOopReadValue()->value()()));
  32.134      Handle obj = sv->value();
  32.135 -    assert(obj.not_null(), "reallocation was missed");
  32.136 +    assert(obj.not_null() || realloc_failures, "reallocation was missed");
  32.137 +    if (obj.is_null()) {
  32.138 +      continue;
  32.139 +    }
  32.140  
  32.141      if (k->oop_is_instance()) {
  32.142        InstanceKlass* ik = InstanceKlass::cast(k());
  32.143 @@ -942,34 +963,36 @@
  32.144  
  32.145  
  32.146  // relock objects for which synchronization was eliminated
  32.147 -void Deoptimization::relock_objects(GrowableArray<MonitorInfo*>* monitors, JavaThread* thread) {
  32.148 +void Deoptimization::relock_objects(GrowableArray<MonitorInfo*>* monitors, JavaThread* thread, bool realloc_failures) {
  32.149    for (int i = 0; i < monitors->length(); i++) {
  32.150      MonitorInfo* mon_info = monitors->at(i);
  32.151      if (mon_info->eliminated()) {
  32.152 -      assert(mon_info->owner() != NULL, "reallocation was missed");
  32.153 -      Handle obj = Handle(mon_info->owner());
  32.154 -      markOop mark = obj->mark();
  32.155 -      if (UseBiasedLocking && mark->has_bias_pattern()) {
  32.156 -        // New allocated objects may have the mark set to anonymously biased.
  32.157 -        // Also the deoptimized method may called methods with synchronization
  32.158 -        // where the thread-local object is bias locked to the current thread.
  32.159 -        assert(mark->is_biased_anonymously() ||
  32.160 -               mark->biased_locker() == thread, "should be locked to current thread");
  32.161 -        // Reset mark word to unbiased prototype.
  32.162 -        markOop unbiased_prototype = markOopDesc::prototype()->set_age(mark->age());
  32.163 -        obj->set_mark(unbiased_prototype);
  32.164 +      assert(!mon_info->owner_is_scalar_replaced() || realloc_failures, "reallocation was missed");
  32.165 +      if (!mon_info->owner_is_scalar_replaced()) {
  32.166 +        Handle obj = Handle(mon_info->owner());
  32.167 +        markOop mark = obj->mark();
  32.168 +        if (UseBiasedLocking && mark->has_bias_pattern()) {
  32.169 +          // New allocated objects may have the mark set to anonymously biased.
  32.170 +          // Also the deoptimized method may called methods with synchronization
  32.171 +          // where the thread-local object is bias locked to the current thread.
  32.172 +          assert(mark->is_biased_anonymously() ||
  32.173 +                 mark->biased_locker() == thread, "should be locked to current thread");
  32.174 +          // Reset mark word to unbiased prototype.
  32.175 +          markOop unbiased_prototype = markOopDesc::prototype()->set_age(mark->age());
  32.176 +          obj->set_mark(unbiased_prototype);
  32.177 +        }
  32.178 +        BasicLock* lock = mon_info->lock();
  32.179 +        ObjectSynchronizer::slow_enter(obj, lock, thread);
  32.180 +        assert(mon_info->owner()->is_locked(), "object must be locked now");
  32.181        }
  32.182 -      BasicLock* lock = mon_info->lock();
  32.183 -      ObjectSynchronizer::slow_enter(obj, lock, thread);
  32.184      }
  32.185 -    assert(mon_info->owner()->is_locked(), "object must be locked now");
  32.186    }
  32.187  }
  32.188  
  32.189  
  32.190  #ifndef PRODUCT
  32.191  // print information about reallocated objects
  32.192 -void Deoptimization::print_objects(GrowableArray<ScopeValue*>* objects) {
  32.193 +void Deoptimization::print_objects(GrowableArray<ScopeValue*>* objects, bool realloc_failures) {
  32.194    fieldDescriptor fd;
  32.195  
  32.196    for (int i = 0; i < objects->length(); i++) {
  32.197 @@ -979,10 +1002,15 @@
  32.198  
  32.199      tty->print("     object <" INTPTR_FORMAT "> of type ", (void *)sv->value()());
  32.200      k->print_value();
  32.201 -    tty->print(" allocated (%d bytes)", obj->size() * HeapWordSize);
  32.202 +    assert(obj.not_null() || realloc_failures, "reallocation was missed");
  32.203 +    if (obj.is_null()) {
  32.204 +      tty->print(" allocation failed");
  32.205 +    } else {
  32.206 +      tty->print(" allocated (%d bytes)", obj->size() * HeapWordSize);
  32.207 +    }
  32.208      tty->cr();
  32.209  
  32.210 -    if (Verbose) {
  32.211 +    if (Verbose && !obj.is_null()) {
  32.212        k->oop_print_on(obj(), tty);
  32.213      }
  32.214    }
  32.215 @@ -990,7 +1018,7 @@
  32.216  #endif
  32.217  #endif // COMPILER2
  32.218  
  32.219 -vframeArray* Deoptimization::create_vframeArray(JavaThread* thread, frame fr, RegisterMap *reg_map, GrowableArray<compiledVFrame*>* chunk) {
  32.220 +vframeArray* Deoptimization::create_vframeArray(JavaThread* thread, frame fr, RegisterMap *reg_map, GrowableArray<compiledVFrame*>* chunk, bool realloc_failures) {
  32.221    Events::log(thread, "DEOPT PACKING pc=" INTPTR_FORMAT " sp=" INTPTR_FORMAT, fr.pc(), fr.sp());
  32.222  
  32.223  #ifndef PRODUCT
  32.224 @@ -1033,7 +1061,7 @@
  32.225    // Since the Java thread being deoptimized will eventually adjust it's own stack,
  32.226    // the vframeArray containing the unpacking information is allocated in the C heap.
  32.227    // For Compiler1, the caller of the deoptimized frame is saved for use by unpack_frames().
  32.228 -  vframeArray* array = vframeArray::allocate(thread, frame_size, chunk, reg_map, sender, caller, fr);
  32.229 +  vframeArray* array = vframeArray::allocate(thread, frame_size, chunk, reg_map, sender, caller, fr, realloc_failures);
  32.230  
  32.231    // Compare the vframeArray to the collected vframes
  32.232    assert(array->structural_compare(thread, chunk), "just checking");
  32.233 @@ -1048,6 +1076,33 @@
  32.234    return array;
  32.235  }
  32.236  
  32.237 +#ifdef COMPILER2
  32.238 +void Deoptimization::pop_frames_failed_reallocs(JavaThread* thread, vframeArray* array) {
  32.239 +  // Reallocation of some scalar replaced objects failed. Record
  32.240 +  // that we need to pop all the interpreter frames for the
  32.241 +  // deoptimized compiled frame.
  32.242 +  assert(thread->frames_to_pop_failed_realloc() == 0, "missed frames to pop?");
  32.243 +  thread->set_frames_to_pop_failed_realloc(array->frames());
  32.244 +  // Unlock all monitors here otherwise the interpreter will see a
  32.245 +  // mix of locked and unlocked monitors (because of failed
  32.246 +  // reallocations of synchronized objects) and be confused.
  32.247 +  for (int i = 0; i < array->frames(); i++) {
  32.248 +    MonitorChunk* monitors = array->element(i)->monitors();
  32.249 +    if (monitors != NULL) {
  32.250 +      for (int j = 0; j < monitors->number_of_monitors(); j++) {
  32.251 +        BasicObjectLock* src = monitors->at(j);
  32.252 +        if (src->obj() != NULL) {
  32.253 +          ObjectSynchronizer::fast_exit(src->obj(), src->lock(), thread);
  32.254 +        }
  32.255 +      }
  32.256 +      array->element(i)->free_monitors(thread);
  32.257 +#ifdef ASSERT
  32.258 +      array->element(i)->set_removed_monitors();
  32.259 +#endif
  32.260 +    }
  32.261 +  }
  32.262 +}
  32.263 +#endif
  32.264  
  32.265  static void collect_monitors(compiledVFrame* cvf, GrowableArray<Handle>* objects_to_revoke) {
  32.266    GrowableArray<MonitorInfo*>* monitors = cvf->monitors();
    33.1 --- a/src/share/vm/runtime/deoptimization.hpp	Thu Dec 18 17:59:15 2014 -0800
    33.2 +++ b/src/share/vm/runtime/deoptimization.hpp	Mon Dec 22 09:27:29 2014 -0800
    33.3 @@ -120,13 +120,14 @@
    33.4    static bool realloc_objects(JavaThread* thread, frame* fr, GrowableArray<ScopeValue*>* objects, TRAPS);
    33.5    static void reassign_type_array_elements(frame* fr, RegisterMap* reg_map, ObjectValue* sv, typeArrayOop obj, BasicType type);
    33.6    static void reassign_object_array_elements(frame* fr, RegisterMap* reg_map, ObjectValue* sv, objArrayOop obj);
    33.7 -  static void reassign_fields(frame* fr, RegisterMap* reg_map, GrowableArray<ScopeValue*>* objects);
    33.8 -  static void relock_objects(GrowableArray<MonitorInfo*>* monitors, JavaThread* thread);
    33.9 -  NOT_PRODUCT(static void print_objects(GrowableArray<ScopeValue*>* objects);)
   33.10 +  static void reassign_fields(frame* fr, RegisterMap* reg_map, GrowableArray<ScopeValue*>* objects, bool realloc_failures);
   33.11 +  static void relock_objects(GrowableArray<MonitorInfo*>* monitors, JavaThread* thread, bool realloc_failures);
   33.12 +  static void pop_frames_failed_reallocs(JavaThread* thread, vframeArray* array);
   33.13 +  NOT_PRODUCT(static void print_objects(GrowableArray<ScopeValue*>* objects, bool realloc_failures);)
   33.14  #endif // COMPILER2
   33.15  
   33.16    public:
   33.17 -  static vframeArray* create_vframeArray(JavaThread* thread, frame fr, RegisterMap *reg_map, GrowableArray<compiledVFrame*>* chunk);
   33.18 +  static vframeArray* create_vframeArray(JavaThread* thread, frame fr, RegisterMap *reg_map, GrowableArray<compiledVFrame*>* chunk, bool realloc_failures);
   33.19  
   33.20    // Interface used for unpacking deoptimized frames
   33.21  
    34.1 --- a/src/share/vm/runtime/sharedRuntime.cpp	Thu Dec 18 17:59:15 2014 -0800
    34.2 +++ b/src/share/vm/runtime/sharedRuntime.cpp	Mon Dec 22 09:27:29 2014 -0800
    34.3 @@ -482,6 +482,7 @@
    34.4  
    34.5  address SharedRuntime::raw_exception_handler_for_return_address(JavaThread* thread, address return_address) {
    34.6    assert(frame::verify_return_pc(return_address), err_msg("must be a return address: " INTPTR_FORMAT, return_address));
    34.7 +  assert(thread->frames_to_pop_failed_realloc() == 0 || Interpreter::contains(return_address), "missed frames to pop?");
    34.8  
    34.9    // Reset method handle flag.
   34.10    thread->set_is_method_handle_return(false);
    35.1 --- a/src/share/vm/runtime/thread.cpp	Thu Dec 18 17:59:15 2014 -0800
    35.2 +++ b/src/share/vm/runtime/thread.cpp	Mon Dec 22 09:27:29 2014 -0800
    35.3 @@ -1495,6 +1495,7 @@
    35.4    _popframe_condition = popframe_inactive;
    35.5    _popframe_preserved_args = NULL;
    35.6    _popframe_preserved_args_size = 0;
    35.7 +  _frames_to_pop_failed_realloc = 0;
    35.8  
    35.9    pd_initialize();
   35.10  }
    36.1 --- a/src/share/vm/runtime/thread.hpp	Thu Dec 18 17:59:15 2014 -0800
    36.2 +++ b/src/share/vm/runtime/thread.hpp	Mon Dec 22 09:27:29 2014 -0800
    36.3 @@ -933,6 +933,12 @@
    36.4    // This is set to popframe_pending to signal that top Java frame should be popped immediately
    36.5    int _popframe_condition;
    36.6  
    36.7 +  // If reallocation of scalar replaced objects fails, we throw OOM
    36.8 +  // and during exception propagation, pop the top
    36.9 +  // _frames_to_pop_failed_realloc frames, the ones that reference
   36.10 +  // failed reallocations.
   36.11 +  int _frames_to_pop_failed_realloc;
   36.12 +
   36.13  #ifndef PRODUCT
   36.14    int _jmp_ring_index;
   36.15    struct {
   36.16 @@ -1585,6 +1591,10 @@
   36.17    void clr_pop_frame_in_process(void)                 { _popframe_condition &= ~popframe_processing_bit; }
   36.18  #endif
   36.19  
   36.20 +  int frames_to_pop_failed_realloc() const            { return _frames_to_pop_failed_realloc; }
   36.21 +  void set_frames_to_pop_failed_realloc(int nb)       { _frames_to_pop_failed_realloc = nb; }
   36.22 +  void dec_frames_to_pop_failed_realloc()             { _frames_to_pop_failed_realloc--; }
   36.23 +
   36.24   private:
   36.25    // Saved incoming arguments to popped frame.
   36.26    // Used only when popped interpreted frame returns to deoptimized frame.
    37.1 --- a/src/share/vm/runtime/vframeArray.cpp	Thu Dec 18 17:59:15 2014 -0800
    37.2 +++ b/src/share/vm/runtime/vframeArray.cpp	Mon Dec 22 09:27:29 2014 -0800
    37.3 @@ -56,7 +56,7 @@
    37.4    }
    37.5  }
    37.6  
    37.7 -void vframeArrayElement::fill_in(compiledVFrame* vf) {
    37.8 +void vframeArrayElement::fill_in(compiledVFrame* vf, bool realloc_failures) {
    37.9  
   37.10  // Copy the information from the compiled vframe to the
   37.11  // interpreter frame we will be creating to replace vf
   37.12 @@ -64,6 +64,9 @@
   37.13    _method = vf->method();
   37.14    _bci    = vf->raw_bci();
   37.15    _reexecute = vf->should_reexecute();
   37.16 +#ifdef ASSERT
   37.17 +  _removed_monitors = false;
   37.18 +#endif
   37.19  
   37.20    int index;
   37.21  
   37.22 @@ -81,11 +84,15 @@
   37.23      // Migrate the BasicLocks from the stack to the monitor chunk
   37.24      for (index = 0; index < list->length(); index++) {
   37.25        MonitorInfo* monitor = list->at(index);
   37.26 -      assert(!monitor->owner_is_scalar_replaced(), "object should be reallocated already");
   37.27 -      assert(monitor->owner() == NULL || (!monitor->owner()->is_unlocked() && !monitor->owner()->has_bias_pattern()), "object must be null or locked, and unbiased");
   37.28 +      assert(!monitor->owner_is_scalar_replaced() || realloc_failures, "object should be reallocated already");
   37.29        BasicObjectLock* dest = _monitors->at(index);
   37.30 -      dest->set_obj(monitor->owner());
   37.31 -      monitor->lock()->move_to(monitor->owner(), dest->lock());
   37.32 +      if (monitor->owner_is_scalar_replaced()) {
   37.33 +        dest->set_obj(NULL);
   37.34 +      } else {
   37.35 +        assert(monitor->owner() == NULL || (!monitor->owner()->is_unlocked() && !monitor->owner()->has_bias_pattern()), "object must be null or locked, and unbiased");
   37.36 +        dest->set_obj(monitor->owner());
   37.37 +        monitor->lock()->move_to(monitor->owner(), dest->lock());
   37.38 +      }
   37.39      }
   37.40    }
   37.41  
   37.42 @@ -110,7 +117,7 @@
   37.43      StackValue* value = locs->at(index);
   37.44      switch(value->type()) {
   37.45        case T_OBJECT:
   37.46 -        assert(!value->obj_is_scalar_replaced(), "object should be reallocated already");
   37.47 +        assert(!value->obj_is_scalar_replaced() || realloc_failures, "object should be reallocated already");
   37.48          // preserve object type
   37.49          _locals->add( new StackValue(cast_from_oop<intptr_t>((value->get_obj()())), T_OBJECT ));
   37.50          break;
   37.51 @@ -135,7 +142,7 @@
   37.52      StackValue* value = exprs->at(index);
   37.53      switch(value->type()) {
   37.54        case T_OBJECT:
   37.55 -        assert(!value->obj_is_scalar_replaced(), "object should be reallocated already");
   37.56 +        assert(!value->obj_is_scalar_replaced() || realloc_failures, "object should be reallocated already");
   37.57          // preserve object type
   37.58          _expressions->add( new StackValue(cast_from_oop<intptr_t>((value->get_obj()())), T_OBJECT ));
   37.59          break;
   37.60 @@ -286,7 +293,7 @@
   37.61  
   37.62    _frame.patch_pc(thread, pc);
   37.63  
   37.64 -  assert (!method()->is_synchronized() || locks > 0, "synchronized methods must have monitors");
   37.65 +  assert (!method()->is_synchronized() || locks > 0 || _removed_monitors, "synchronized methods must have monitors");
   37.66  
   37.67    BasicObjectLock* top = iframe()->interpreter_frame_monitor_begin();
   37.68    for (int index = 0; index < locks; index++) {
   37.69 @@ -438,7 +445,8 @@
   37.70  
   37.71  
   37.72  vframeArray* vframeArray::allocate(JavaThread* thread, int frame_size, GrowableArray<compiledVFrame*>* chunk,
   37.73 -                                   RegisterMap *reg_map, frame sender, frame caller, frame self) {
   37.74 +                                   RegisterMap *reg_map, frame sender, frame caller, frame self,
   37.75 +                                   bool realloc_failures) {
   37.76  
   37.77    // Allocate the vframeArray
   37.78    vframeArray * result = (vframeArray*) AllocateHeap(sizeof(vframeArray) + // fixed part
   37.79 @@ -450,19 +458,20 @@
   37.80    result->_caller = caller;
   37.81    result->_original = self;
   37.82    result->set_unroll_block(NULL); // initialize it
   37.83 -  result->fill_in(thread, frame_size, chunk, reg_map);
   37.84 +  result->fill_in(thread, frame_size, chunk, reg_map, realloc_failures);
   37.85    return result;
   37.86  }
   37.87  
   37.88  void vframeArray::fill_in(JavaThread* thread,
   37.89                            int frame_size,
   37.90                            GrowableArray<compiledVFrame*>* chunk,
   37.91 -                          const RegisterMap *reg_map) {
   37.92 +                          const RegisterMap *reg_map,
   37.93 +                          bool realloc_failures) {
   37.94    // Set owner first, it is used when adding monitor chunks
   37.95  
   37.96    _frame_size = frame_size;
   37.97    for(int i = 0; i < chunk->length(); i++) {
   37.98 -    element(i)->fill_in(chunk->at(i));
   37.99 +    element(i)->fill_in(chunk->at(i), realloc_failures);
  37.100    }
  37.101  
  37.102    // Copy registers for callee-saved registers
    38.1 --- a/src/share/vm/runtime/vframeArray.hpp	Thu Dec 18 17:59:15 2014 -0800
    38.2 +++ b/src/share/vm/runtime/vframeArray.hpp	Mon Dec 22 09:27:29 2014 -0800
    38.3 @@ -58,6 +58,9 @@
    38.4      MonitorChunk* _monitors;                                     // active monitors for this vframe
    38.5      StackValueCollection* _locals;
    38.6      StackValueCollection* _expressions;
    38.7 +#ifdef ASSERT
    38.8 +    bool _removed_monitors;
    38.9 +#endif
   38.10  
   38.11    public:
   38.12  
   38.13 @@ -78,7 +81,7 @@
   38.14  
   38.15    StackValueCollection* expressions(void) const        { return _expressions; }
   38.16  
   38.17 -  void fill_in(compiledVFrame* vf);
   38.18 +  void fill_in(compiledVFrame* vf, bool realloc_failures);
   38.19  
   38.20    // Formerly part of deoptimizedVFrame
   38.21  
   38.22 @@ -99,6 +102,12 @@
   38.23                         bool is_bottom_frame,
   38.24                         int exec_mode);
   38.25  
   38.26 +#ifdef ASSERT
   38.27 +  void set_removed_monitors() {
   38.28 +    _removed_monitors = true;
   38.29 +  }
   38.30 +#endif
   38.31 +
   38.32  #ifndef PRODUCT
   38.33    void print(outputStream* st);
   38.34  #endif /* PRODUCT */
   38.35 @@ -160,13 +169,14 @@
   38.36    int frames() const                            { return _frames;   }
   38.37  
   38.38    static vframeArray* allocate(JavaThread* thread, int frame_size, GrowableArray<compiledVFrame*>* chunk,
   38.39 -                               RegisterMap* reg_map, frame sender, frame caller, frame self);
   38.40 +                               RegisterMap* reg_map, frame sender, frame caller, frame self,
   38.41 +                               bool realloc_failures);
   38.42  
   38.43  
   38.44    vframeArrayElement* element(int index)        { assert(is_within_bounds(index), "Bad index"); return &_elements[index]; }
   38.45  
   38.46    // Allocates a new vframe in the array and fills the array with vframe information in chunk
   38.47 -  void fill_in(JavaThread* thread, int frame_size, GrowableArray<compiledVFrame*>* chunk, const RegisterMap *reg_map);
   38.48 +  void fill_in(JavaThread* thread, int frame_size, GrowableArray<compiledVFrame*>* chunk, const RegisterMap *reg_map, bool realloc_failures);
   38.49  
   38.50    // Returns the owner of this vframeArray
   38.51    JavaThread* owner_thread() const           { return _owner_thread; }
    39.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    39.2 +++ b/test/compiler/exceptions/SumTest.java	Mon Dec 22 09:27:29 2014 -0800
    39.3 @@ -0,0 +1,86 @@
    39.4 +/*
    39.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    39.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    39.7 + *
    39.8 + * This code is free software; you can redistribute it and/or modify it
    39.9 + * under the terms of the GNU General Public License version 2 only, as
   39.10 + * published by the Free Software Foundation.
   39.11 + *
   39.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   39.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   39.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   39.15 + * version 2 for more details (a copy is included in the LICENSE file that
   39.16 + * accompanied this code).
   39.17 + *
   39.18 + * You should have received a copy of the GNU General Public License version
   39.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   39.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   39.21 + *
   39.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   39.23 + * or visit www.oracle.com if you need additional information or have any
   39.24 + * questions.
   39.25 + */
   39.26 +
   39.27 +/*
   39.28 + * @test
   39.29 + * @bug 8066900
   39.30 + * @summary FP registers are not properly restored by C1 when handling exceptions
   39.31 + * @run main/othervm -Xbatch SumTest
   39.32 + *
   39.33 + */
   39.34 +public class SumTest {
   39.35 +    private static class Sum {
   39.36 +
   39.37 +        double[] sums;
   39.38 +
   39.39 +        /**
   39.40 +         * Construct empty Sum
   39.41 +         */
   39.42 +        public Sum() {
   39.43 +            sums = new double[0];
   39.44 +        }
   39.45 +
   39.46 +        /**
   39.47 +         * Return the sum of all numbers added to this Sum
   39.48 +         *
   39.49 +         * @return the sum
   39.50 +         */
   39.51 +        final public double getSum() {
   39.52 +            double sum = 0;
   39.53 +            for (final double s : sums) {
   39.54 +                sum += s;
   39.55 +            }
   39.56 +
   39.57 +            return sum;
   39.58 +        }
   39.59 +
   39.60 +        /**
   39.61 +         * Add a new number to this Sum
   39.62 +         *
   39.63 +         * @param a number to be added.
   39.64 +         */
   39.65 +        final public void add(double a) {
   39.66 +            try {
   39.67 +                sums[sums.length] = -1; // Cause IndexOutOfBoundsException
   39.68 +            } catch (final IndexOutOfBoundsException e) {
   39.69 +                final double[] oldSums = sums;
   39.70 +                sums = new double[oldSums.length + 1]; // Extend sums
   39.71 +                System.arraycopy(oldSums, 0, sums, 0, oldSums.length);
   39.72 +                sums[oldSums.length] = a; // Append a
   39.73 +            }
   39.74 +        }
   39.75 +    }
   39.76 +
   39.77 +    public static void main(String[] args) throws Exception {
   39.78 +        final Sum sum = new Sum();
   39.79 +        for (int i = 1; i <= 10000; ++i) {
   39.80 +            sum.add(1);
   39.81 +            double ii = sum.getSum();
   39.82 +            if (i != ii) {
   39.83 +                throw new Exception("Failure: computed = " + ii + ", expected = " + i);
   39.84 +            }
   39.85 +        }
   39.86 +    }
   39.87 +
   39.88 +}
   39.89 +
    40.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    40.2 +++ b/test/compiler/rangechecks/TestRangeCheckSmearing.java	Mon Dec 22 09:27:29 2014 -0800
    40.3 @@ -0,0 +1,436 @@
    40.4 +/*
    40.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    40.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    40.7 + *
    40.8 + * This code is free software; you can redistribute it and/or modify it
    40.9 + * under the terms of the GNU General Public License version 2 only, as
   40.10 + * published by the Free Software Foundation.
   40.11 + *
   40.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   40.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   40.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   40.15 + * version 2 for more details (a copy is included in the LICENSE file that
   40.16 + * accompanied this code).
   40.17 + *
   40.18 + * You should have received a copy of the GNU General Public License version
   40.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   40.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   40.21 + *
   40.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   40.23 + * or visit www.oracle.com if you need additional information or have any
   40.24 + * questions.
   40.25 + */
   40.26 +
   40.27 +/*
   40.28 + * @test
   40.29 + * @bug 8066103
   40.30 + * @summary C2's range check smearing allows out of bound array accesses
   40.31 + * @library /testlibrary /testlibrary/whitebox /compiler/whitebox /testlibrary/com/oracle/java/testlibrary
   40.32 + * @build TestRangeCheckSmearing
   40.33 + * @run main ClassFileInstaller sun.hotspot.WhiteBox
   40.34 + * @run main ClassFileInstaller com.oracle.java.testlibrary.Platform
   40.35 + * @run main/othervm -ea -Xmixed -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
   40.36 + *                   -XX:-BackgroundCompilation -XX:-UseOnStackReplacement TestRangeCheckSmearing
   40.37 + *
   40.38 + */
   40.39 +
   40.40 +import java.lang.annotation.*;
   40.41 +import java.lang.reflect.*;
   40.42 +import java.util.*;
   40.43 +import sun.hotspot.WhiteBox;
   40.44 +import sun.hotspot.code.NMethod;
   40.45 +import com.oracle.java.testlibrary.Platform;
   40.46 +
   40.47 +public class TestRangeCheckSmearing {
   40.48 +    private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
   40.49 +
   40.50 +    @Retention(RetentionPolicy.RUNTIME)
   40.51 +    @interface Args { int[] value(); }
   40.52 +
   40.53 +    // first range check is i + max of all constants
   40.54 +    @Args({0, 8})
   40.55 +    static int m1(int[] array, int i, boolean allaccesses) {
   40.56 +        int res = 0;
   40.57 +        res += array[i+9];
   40.58 +        if (allaccesses) {
   40.59 +            res += array[i+8];
   40.60 +            res += array[i+7];
   40.61 +            res += array[i+6];
   40.62 +            res += array[i+5];
   40.63 +            res += array[i+4];
   40.64 +            res += array[i+3];
   40.65 +            res += array[i+2];
   40.66 +            res += array[i+1];
   40.67 +        }
   40.68 +        return res;
   40.69 +    }
   40.70 +
   40.71 +    // first range check is i + min of all constants
   40.72 +    @Args({0, -9})
   40.73 +    static int m2(int[] array, int i, boolean allaccesses) {
   40.74 +        int res = 0;
   40.75 +        res += array[i+1];
   40.76 +        if (allaccesses) {
   40.77 +            res += array[i+2];
   40.78 +            res += array[i+3];
   40.79 +            res += array[i+4];
   40.80 +            res += array[i+5];
   40.81 +            res += array[i+6];
   40.82 +            res += array[i+7];
   40.83 +            res += array[i+8];
   40.84 +            res += array[i+9];
   40.85 +        }
   40.86 +        return res;
   40.87 +    }
   40.88 +
   40.89 +    // first range check is not i + min/max of all constants
   40.90 +    @Args({0, 8})
   40.91 +    static int m3(int[] array, int i, boolean allaccesses) {
   40.92 +        int res = 0;
   40.93 +        res += array[i+3];
   40.94 +        if (allaccesses) {
   40.95 +            res += array[i+2];
   40.96 +            res += array[i+1];
   40.97 +            res += array[i+4];
   40.98 +            res += array[i+5];
   40.99 +            res += array[i+6];
  40.100 +            res += array[i+7];
  40.101 +            res += array[i+8];
  40.102 +            res += array[i+9];
  40.103 +        }
  40.104 +        return res;
  40.105 +    }
  40.106 +
  40.107 +    @Args({0, -9})
  40.108 +    static int m4(int[] array, int i, boolean allaccesses) {
  40.109 +        int res = 0;
  40.110 +        res += array[i+3];
  40.111 +        if (allaccesses) {
  40.112 +            res += array[i+4];
  40.113 +            res += array[i+1];
  40.114 +            res += array[i+2];
  40.115 +            res += array[i+5];
  40.116 +            res += array[i+6];
  40.117 +            res += array[i+7];
  40.118 +            res += array[i+8];
  40.119 +            res += array[i+9];
  40.120 +        }
  40.121 +        return res;
  40.122 +    }
  40.123 +
  40.124 +    @Args({0, -3})
  40.125 +    static int m5(int[] array, int i, boolean allaccesses) {
  40.126 +        int res = 0;
  40.127 +        res += array[i+3];
  40.128 +        res += array[i+2];
  40.129 +        if (allaccesses) {
  40.130 +            res += array[i+1];
  40.131 +            res += array[i+4];
  40.132 +            res += array[i+5];
  40.133 +            res += array[i+6];
  40.134 +            res += array[i+7];
  40.135 +            res += array[i+8];
  40.136 +            res += array[i+9];
  40.137 +        }
  40.138 +        return res;
  40.139 +    }
  40.140 +
  40.141 +    @Args({0, 6})
  40.142 +    static int m6(int[] array, int i, boolean allaccesses) {
  40.143 +        int res = 0;
  40.144 +        res += array[i+3];
  40.145 +        res += array[i+4];
  40.146 +        if (allaccesses) {
  40.147 +            res += array[i+2];
  40.148 +            res += array[i+1];
  40.149 +            res += array[i+5];
  40.150 +            res += array[i+6];
  40.151 +            res += array[i+7];
  40.152 +            res += array[i+8];
  40.153 +            res += array[i+9];
  40.154 +        }
  40.155 +        return res;
  40.156 +    }
  40.157 +
  40.158 +    @Args({0, 6})
  40.159 +    static int m7(int[] array, int i, boolean allaccesses) {
  40.160 +        int res = 0;
  40.161 +        res += array[i+3];
  40.162 +        res += array[i+2];
  40.163 +        res += array[i+4];
  40.164 +        if (allaccesses) {
  40.165 +            res += array[i+1];
  40.166 +            res += array[i+5];
  40.167 +            res += array[i+6];
  40.168 +            res += array[i+7];
  40.169 +            res += array[i+8];
  40.170 +            res += array[i+9];
  40.171 +        }
  40.172 +        return res;
  40.173 +    }
  40.174 +
  40.175 +    @Args({0, -3})
  40.176 +    static int m8(int[] array, int i, boolean allaccesses) {
  40.177 +        int res = 0;
  40.178 +        res += array[i+3];
  40.179 +        res += array[i+4];
  40.180 +        res += array[i+2];
  40.181 +        if (allaccesses) {
  40.182 +            res += array[i+1];
  40.183 +            res += array[i+5];
  40.184 +            res += array[i+6];
  40.185 +            res += array[i+7];
  40.186 +            res += array[i+8];
  40.187 +            res += array[i+9];
  40.188 +        }
  40.189 +        return res;
  40.190 +    }
  40.191 +
  40.192 +    @Args({6, 15})
  40.193 +    static int m9(int[] array, int i, boolean allaccesses) {
  40.194 +        int res = 0;
  40.195 +        res += array[i+3];
  40.196 +        if (allaccesses) {
  40.197 +            res += array[i-2];
  40.198 +            res += array[i-1];
  40.199 +            res += array[i-4];
  40.200 +            res += array[i-5];
  40.201 +            res += array[i-6];
  40.202 +        }
  40.203 +        return res;
  40.204 +    }
  40.205 +
  40.206 +    @Args({3, 12})
  40.207 +    static int m10(int[] array, int i, boolean allaccesses) {
  40.208 +        int res = 0;
  40.209 +        res += array[i+3];
  40.210 +        if (allaccesses) {
  40.211 +            res += array[i-2];
  40.212 +            res += array[i-1];
  40.213 +            res += array[i-3];
  40.214 +            res += array[i+4];
  40.215 +            res += array[i+5];
  40.216 +            res += array[i+6];
  40.217 +        }
  40.218 +        return res;
  40.219 +    }
  40.220 +
  40.221 +    @Args({3, -3})
  40.222 +    static int m11(int[] array, int i, boolean allaccesses) {
  40.223 +        int res = 0;
  40.224 +        res += array[i+3];
  40.225 +        res += array[i-2];
  40.226 +        if (allaccesses) {
  40.227 +            res += array[i+5];
  40.228 +            res += array[i+6];
  40.229 +        }
  40.230 +        return res;
  40.231 +    }
  40.232 +
  40.233 +    @Args({3, 6})
  40.234 +    static int m12(int[] array, int i, boolean allaccesses) {
  40.235 +        int res = 0;
  40.236 +        res += array[i+3];
  40.237 +        res += array[i+6];
  40.238 +        if (allaccesses) {
  40.239 +            res += array[i-2];
  40.240 +            res += array[i-3];
  40.241 +        }
  40.242 +        return res;
  40.243 +    }
  40.244 +
  40.245 +    // check that identical range check is replaced by dominating one
  40.246 +    // only when correct
  40.247 +    @Args({0})
  40.248 +    static int m13(int[] array, int i, boolean ignore) {
  40.249 +        int res = 0;
  40.250 +        res += array[i+3];
  40.251 +        res += array[i+3];
  40.252 +        return res;
  40.253 +    }
  40.254 +
  40.255 +    @Args({2, 0})
  40.256 +    static int m14(int[] array, int i, boolean ignore) {
  40.257 +        int res = 0;
  40.258 +
  40.259 +        res += array[i];
  40.260 +        res += array[i-2];
  40.261 +        res += array[i]; // If range check below were to be removed first this cannot be considered identical to first range check
  40.262 +        res += array[i-1]; // range check removed so i-1 array access depends on previous check
  40.263 +
  40.264 +        return res;
  40.265 +    }
  40.266 +
  40.267 +    static int[] m15_dummy = new int[10];
  40.268 +    @Args({2, 0})
  40.269 +    static int m15(int[] array, int i, boolean ignore) {
  40.270 +        int res = 0;
  40.271 +        res += array[i];
  40.272 +
  40.273 +        // When the loop is optimized out we don't want the
  40.274 +        // array[i-1] access which is dependent on array[i]'s
  40.275 +        // range check to become dependent on the identical range
  40.276 +        // check above.
  40.277 +
  40.278 +        int[] array2 = m15_dummy;
  40.279 +        int j = 0;
  40.280 +        for (; j < 10; j++);
  40.281 +        if (j == 10) {
  40.282 +            array2 = array;
  40.283 +        }
  40.284 +
  40.285 +        res += array2[i-2];
  40.286 +        res += array2[i];
  40.287 +        res += array2[i-1]; // range check removed so i-1 array access depends on previous check
  40.288 +
  40.289 +        return res;
  40.290 +    }
  40.291 +
  40.292 +    @Args({2, 0})
  40.293 +    static int m16(int[] array, int i, boolean ignore) {
  40.294 +        int res = 0;
  40.295 +
  40.296 +        res += array[i];
  40.297 +        res += array[i-1];
  40.298 +        res += array[i-1];
  40.299 +        res += array[i-2];
  40.300 +
  40.301 +        return res;
  40.302 +    }
  40.303 +
  40.304 +    @Args({2, 0})
  40.305 +    static int m17(int[] array, int i, boolean ignore) {
  40.306 +        int res = 0;
  40.307 +
  40.308 +        res += array[i];
  40.309 +        res += array[i-2];
  40.310 +        res += array[i-2];
  40.311 +        res += array[i+2];
  40.312 +        res += array[i+2];
  40.313 +        res += array[i-1];
  40.314 +        res += array[i-1];
  40.315 +
  40.316 +        return res;
  40.317 +    }
  40.318 +
  40.319 +    static public void main(String[] args) {
  40.320 +        if (WHITE_BOX.getBooleanVMFlag("BackgroundCompilation")) {
  40.321 +            throw new AssertionError("Background compilation enabled");
  40.322 +        }
  40.323 +        new TestRangeCheckSmearing().doTests();
  40.324 +    }
  40.325 +    boolean success = true;
  40.326 +    boolean exception = false;
  40.327 +    final int[] array = new int[10];
  40.328 +    final HashMap<String,Method> tests = new HashMap<>();
  40.329 +    {
  40.330 +        final Class<?> TEST_PARAM_TYPES[] = { int[].class, int.class, boolean.class };
  40.331 +        for (Method m : this.getClass().getDeclaredMethods()) {
  40.332 +            if (m.getName().matches("m[0-9]+")) {
  40.333 +                assert(Modifier.isStatic(m.getModifiers())) : m;
  40.334 +                assert(m.getReturnType() == int.class) : m;
  40.335 +                assert(Arrays.equals(m.getParameterTypes(), TEST_PARAM_TYPES)) : m;
  40.336 +                tests.put(m.getName(), m);
  40.337 +            }
  40.338 +        }
  40.339 +    }
  40.340 +
  40.341 +    void invokeTest(Method m, int[] array, int index, boolean z) {
  40.342 +        try {
  40.343 +            m.invoke(null, array, index, z);
  40.344 +        } catch (ReflectiveOperationException roe) {
  40.345 +            Throwable ex = roe.getCause();
  40.346 +            if (ex instanceof ArrayIndexOutOfBoundsException)
  40.347 +                throw (ArrayIndexOutOfBoundsException) ex;
  40.348 +            throw new AssertionError(roe);
  40.349 +        }
  40.350 +    }
  40.351 +
  40.352 +    void doTest(String name) {
  40.353 +        Method m = tests.get(name);
  40.354 +        tests.remove(name);
  40.355 +        int[] args = m.getAnnotation(Args.class).value();
  40.356 +        int index0 = args[0], index1;
  40.357 +        boolean exceptionRequired = true;
  40.358 +        if (args.length == 2) {
  40.359 +            index1 = args[1];
  40.360 +        } else {
  40.361 +            // no negative test for this one
  40.362 +            assert(args.length == 1);
  40.363 +            assert(name.equals("m13"));
  40.364 +            exceptionRequired = false;
  40.365 +            index1 = index0;
  40.366 +        }
  40.367 +        // Get the method compiled.
  40.368 +        if (!WHITE_BOX.isMethodCompiled(m)) {
  40.369 +            // If not, try to compile it with C2
  40.370 +            if(!WHITE_BOX.enqueueMethodForCompilation(m, CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION)) {
  40.371 +                // C2 compiler not available, try to compile with C1
  40.372 +                WHITE_BOX.enqueueMethodForCompilation(m, CompilerWhiteBoxTest.COMP_LEVEL_SIMPLE);
  40.373 +            }
  40.374 +        }
  40.375 +        if (!WHITE_BOX.isMethodCompiled(m)) {
  40.376 +            throw new RuntimeException(m + " not compiled");
  40.377 +        }
  40.378 +
  40.379 +        // valid access
  40.380 +        invokeTest(m, array, index0, true);
  40.381 +
  40.382 +        if (!WHITE_BOX.isMethodCompiled(m)) {
  40.383 +            throw new RuntimeException(m + " deoptimized on valid array access");
  40.384 +        }
  40.385 +
  40.386 +        exception = false;
  40.387 +        boolean test_success = true;
  40.388 +        try {
  40.389 +            invokeTest(m, array, index1, false);
  40.390 +        } catch(ArrayIndexOutOfBoundsException aioob) {
  40.391 +            exception = true;
  40.392 +            System.out.println("ArrayIndexOutOfBoundsException thrown in "+name);
  40.393 +        }
  40.394 +        if (!exception) {
  40.395 +            System.out.println("ArrayIndexOutOfBoundsException was not thrown in "+name);
  40.396 +        }
  40.397 +
  40.398 +        if (Platform.isServer()) {
  40.399 +            if (exceptionRequired == WHITE_BOX.isMethodCompiled(m)) {
  40.400 +                System.out.println((exceptionRequired?"Didn't deoptimized":"deoptimized") + " in "+name);
  40.401 +                test_success = false;
  40.402 +            }
  40.403 +        }
  40.404 +
  40.405 +        if (exception != exceptionRequired) {
  40.406 +            System.out.println((exceptionRequired?"exception required but not thrown":"not exception required but thrown") + " in "+name);
  40.407 +            test_success = false;
  40.408 +        }
  40.409 +
  40.410 +        if (!test_success) {
  40.411 +            success = false;
  40.412 +            System.out.println("TEST FAILED: "+name);
  40.413 +        }
  40.414 +
  40.415 +    }
  40.416 +    void doTests() {
  40.417 +        doTest("m1");
  40.418 +        doTest("m2");
  40.419 +        doTest("m3");
  40.420 +        doTest("m4");
  40.421 +        doTest("m5");
  40.422 +        doTest("m6");
  40.423 +        doTest("m7");
  40.424 +        doTest("m8");
  40.425 +        doTest("m9");
  40.426 +        doTest("m10");
  40.427 +        doTest("m11");
  40.428 +        doTest("m12");
  40.429 +        doTest("m13");
  40.430 +        doTest("m14");
  40.431 +        doTest("m15");
  40.432 +        doTest("m16");
  40.433 +        doTest("m17");
  40.434 +        if (!success) {
  40.435 +            throw new RuntimeException("Some tests failed");
  40.436 +        }
  40.437 +        assert(tests.isEmpty()) : tests;
  40.438 +    }
  40.439 +}
    41.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    41.2 +++ b/test/compiler/rangechecks/TestRangeCheckSmearingLoopOpts.java	Mon Dec 22 09:27:29 2014 -0800
    41.3 @@ -0,0 +1,76 @@
    41.4 +/*
    41.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    41.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    41.7 + *
    41.8 + * This code is free software; you can redistribute it and/or modify it
    41.9 + * under the terms of the GNU General Public License version 2 only, as
   41.10 + * published by the Free Software Foundation.
   41.11 + *
   41.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   41.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   41.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   41.15 + * version 2 for more details (a copy is included in the LICENSE file that
   41.16 + * accompanied this code).
   41.17 + *
   41.18 + * You should have received a copy of the GNU General Public License version
   41.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   41.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   41.21 + *
   41.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   41.23 + * or visit www.oracle.com if you need additional information or have any
   41.24 + * questions.
   41.25 + */
   41.26 +
   41.27 +/*
   41.28 + * @test
   41.29 + * @bug 8048170
   41.30 + * @summary Following range check smearing, range check cannot be replaced by dominating identical test.
   41.31 + * @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement TestRangeCheckSmearingLoopOpts
   41.32 + *
   41.33 + */
   41.34 +public class TestRangeCheckSmearingLoopOpts {
   41.35 +
   41.36 +    static int dummy;
   41.37 +
   41.38 +    static int m1(int[] array, int i) {
   41.39 +        for (;;) {
   41.40 +            for (;;) {
   41.41 +                if (array[i] < 0) { // range check (i+0) dominates equivalent check below
   41.42 +                    break;
   41.43 +                }
   41.44 +                i++;
   41.45 +            }
   41.46 +
   41.47 +            // A control flow that stops IfNode::up_one_dom()
   41.48 +            if ((i % 2)== 0) {
   41.49 +                if ((array[i] % 2) == 0) {
   41.50 +                    dummy = i;
   41.51 +                }
   41.52 +            }
   41.53 +
   41.54 +            // IfNode::Ideal will rewrite some range checks if Compile::allow_range_check_smearing
   41.55 +            if (array[i-1] == 9) {    // range check (i-1) unchanged
   41.56 +                int res = array[i-3]; // range check (i-3) unchanged
   41.57 +                res += array[i];      // range check (i+0) unchanged
   41.58 +                res += array[i-2];    // removed redundant range check
   41.59 +                // the previous access might be hoisted by
   41.60 +                // PhaseIdealLoop::split_if_with_blocks_post because
   41.61 +                // it appears to have the same guard, but it also
   41.62 +                // depends on the previous guards
   41.63 +                return res;
   41.64 +            }
   41.65 +            i++;
   41.66 +        }
   41.67 +    }
   41.68 +
   41.69 +    static public void main(String[] args) {
   41.70 +        int[] array = { 0, 1, 2, -3, 4, 5, -2, 7, 8, 9, -1 };
   41.71 +        for (int i = 0; i < 20000; i++) {
   41.72 +            m1(array, 0);
   41.73 +        }
   41.74 +        array[0] = -1;
   41.75 +        try {
   41.76 +            m1(array, 0);
   41.77 +        } catch(ArrayIndexOutOfBoundsException aioobe) {}
   41.78 +    }
   41.79 +}
    42.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    42.2 +++ b/test/compiler/uncommontrap/TestDeoptOOM.java	Mon Dec 22 09:27:29 2014 -0800
    42.3 @@ -0,0 +1,426 @@
    42.4 +/*
    42.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    42.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    42.7 + *
    42.8 + * This code is free software; you can redistribute it and/or modify it
    42.9 + * under the terms of the GNU General Public License version 2 only, as
   42.10 + * published by the Free Software Foundation.
   42.11 + *
   42.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   42.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   42.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   42.15 + * version 2 for more details (a copy is included in the LICENSE file that
   42.16 + * accompanied this code).
   42.17 + *
   42.18 + * You should have received a copy of the GNU General Public License version
   42.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   42.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   42.21 + *
   42.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   42.23 + * or visit www.oracle.com if you need additional information or have any
   42.24 + * questions.
   42.25 + */
   42.26 +
   42.27 +/*
   42.28 + * @test
   42.29 + * @bug 6898462
   42.30 + * @summary failed reallocations of scalar replaced objects during deoptimization causes crash
   42.31 + * @run main/othervm -XX:-BackgroundCompilation -XX:CompileCommand=exclude,TestDeoptOOM::main -XX:CompileCommand=exclude,TestDeoptOOM::m9_1 -Xmx128M TestDeoptOOM
   42.32 + *
   42.33 + */
   42.34 +
   42.35 +public class TestDeoptOOM {
   42.36 +
   42.37 +    long f1;
   42.38 +    long f2;
   42.39 +    long f3;
   42.40 +    long f4;
   42.41 +    long f5;
   42.42 +
   42.43 +    static class LinkedList {
   42.44 +        LinkedList l;
   42.45 +        long[] array;
   42.46 +        LinkedList(LinkedList l, int size) {
   42.47 +            array = new long[size];
   42.48 +            this.l = l;
   42.49 +        }
   42.50 +    }
   42.51 +
   42.52 +    static LinkedList ll;
   42.53 +
   42.54 +    static void consume_all_memory() {
   42.55 +        int size = 128 * 1024 * 1024;
   42.56 +        while(size > 0) {
   42.57 +            try {
   42.58 +                while(true) {
   42.59 +                    ll = new LinkedList(ll, size);
   42.60 +                }
   42.61 +            } catch(OutOfMemoryError oom) {
   42.62 +            }
   42.63 +            size = size / 2;
   42.64 +        }
   42.65 +    }
   42.66 +
   42.67 +    static void free_memory() {
   42.68 +        ll = null;
   42.69 +    }
   42.70 +
   42.71 +    static TestDeoptOOM m1(boolean deopt) {
   42.72 +        try {
   42.73 +            TestDeoptOOM tdoom = new TestDeoptOOM();
   42.74 +            if (deopt) {
   42.75 +                return tdoom;
   42.76 +            }
   42.77 +        } catch(OutOfMemoryError oom) {
   42.78 +            free_memory();
   42.79 +            System.out.println("OOM caught in m1");
   42.80 +        }
   42.81 +        return null;
   42.82 +    }
   42.83 +
   42.84 +    static TestDeoptOOM m2_1(boolean deopt) {
   42.85 +        try {
   42.86 +            TestDeoptOOM tdoom = new TestDeoptOOM();
   42.87 +            if (deopt) {
   42.88 +                return tdoom;
   42.89 +            }
   42.90 +        } catch(OutOfMemoryError oom) {
   42.91 +            free_memory();
   42.92 +            System.out.println("OOM caught in m2_1");
   42.93 +        }
   42.94 +        return null;
   42.95 +    }
   42.96 +
   42.97 +    static TestDeoptOOM m2(boolean deopt) {
   42.98 +        try {
   42.99 +            return m2_1(deopt);
  42.100 +        } catch(OutOfMemoryError oom) {
  42.101 +            free_memory();
  42.102 +            System.out.println("OOM caught in m2");
  42.103 +        }
  42.104 +        return null;
  42.105 +    }
  42.106 +
  42.107 +    static TestDeoptOOM m3_3(boolean deopt) {
  42.108 +        try {
  42.109 +            TestDeoptOOM tdoom = new TestDeoptOOM();
  42.110 +            if (deopt) {
  42.111 +                return tdoom;
  42.112 +            }
  42.113 +        } catch(OutOfMemoryError oom) {
  42.114 +            free_memory();
  42.115 +            System.out.println("OOM caught in m3_3");
  42.116 +        }
  42.117 +        return null;
  42.118 +    }
  42.119 +
  42.120 +    static boolean m3_2(boolean deopt) {
  42.121 +        try {
  42.122 +            return m3_3(deopt) != null;
  42.123 +        } catch(OutOfMemoryError oom) {
  42.124 +            free_memory();
  42.125 +            System.out.println("OOM caught in m3_2");
  42.126 +        }
  42.127 +        return false;
  42.128 +    }
  42.129 +
  42.130 +    static TestDeoptOOM m3_1(boolean deopt) {
  42.131 +        try {
  42.132 +            TestDeoptOOM tdoom = new TestDeoptOOM();
  42.133 +            if (m3_2(deopt)) {
  42.134 +                return tdoom;
  42.135 +            }
  42.136 +        } catch(OutOfMemoryError oom) {
  42.137 +            free_memory();
  42.138 +            System.out.println("OOM caught in m3_1");
  42.139 +        }
  42.140 +        return null;
  42.141 +    }
  42.142 +
  42.143 +    static TestDeoptOOM m3(boolean deopt) {
  42.144 +        try {
  42.145 +            return m3_1(deopt);
  42.146 +        } catch(OutOfMemoryError oom) {
  42.147 +            free_memory();
  42.148 +            System.out.println("OOM caught in m3");
  42.149 +        }
  42.150 +        return null;
  42.151 +    }
  42.152 +
  42.153 +    static TestDeoptOOM m4(boolean deopt) {
  42.154 +        try {
  42.155 +            TestDeoptOOM tdoom = new TestDeoptOOM();
  42.156 +            if (deopt) {
  42.157 +                tdoom.f1 = 1l;
  42.158 +                tdoom.f2 = 2l;
  42.159 +                tdoom.f3 = 3l;
  42.160 +                return tdoom;
  42.161 +            }
  42.162 +        } catch(OutOfMemoryError oom) {
  42.163 +            free_memory();
  42.164 +            System.out.println("OOM caught in m4");
  42.165 +        }
  42.166 +        return null;
  42.167 +    }
  42.168 +
  42.169 +    static TestDeoptOOM m5(boolean deopt) {
  42.170 +        try {
  42.171 +            TestDeoptOOM tdoom = new TestDeoptOOM();
  42.172 +            synchronized(tdoom) {
  42.173 +                if (deopt) {
  42.174 +                    return tdoom;
  42.175 +                }
  42.176 +            }
  42.177 +        } catch(OutOfMemoryError oom) {
  42.178 +            free_memory();
  42.179 +            System.out.println("OOM caught in m5");
  42.180 +        }
  42.181 +        return null;
  42.182 +    }
  42.183 +
  42.184 +    synchronized TestDeoptOOM m6_1(boolean deopt) {
  42.185 +        if (deopt) {
  42.186 +            return this;
  42.187 +        }
  42.188 +        return null;
  42.189 +    }
  42.190 +
  42.191 +    static TestDeoptOOM m6(boolean deopt) {
  42.192 +        try {
  42.193 +            TestDeoptOOM tdoom = new TestDeoptOOM();
  42.194 +            return tdoom.m6_1(deopt);
  42.195 +        } catch(OutOfMemoryError oom) {
  42.196 +            free_memory();
  42.197 +            System.out.println("OOM caught in m6");
  42.198 +        }
  42.199 +        return null;
  42.200 +    }
  42.201 +
  42.202 +    static TestDeoptOOM m7_1(boolean deopt, Object lock) {
  42.203 +        try {
  42.204 +            synchronized(lock) {
  42.205 +                TestDeoptOOM tdoom = new TestDeoptOOM();
  42.206 +                if (deopt) {
  42.207 +                    return tdoom;
  42.208 +                }
  42.209 +            }
  42.210 +        } catch(OutOfMemoryError oom) {
  42.211 +            free_memory();
  42.212 +            System.out.println("OOM caught in m7_1");
  42.213 +        }
  42.214 +        return null;
  42.215 +    }
  42.216 +
  42.217 +    static TestDeoptOOM m7(boolean deopt, Object lock) {
  42.218 +        try {
  42.219 +            return m7_1(deopt, lock);
  42.220 +        } catch(OutOfMemoryError oom) {
  42.221 +            free_memory();
  42.222 +            System.out.println("OOM caught in m7");
  42.223 +        }
  42.224 +        return null;
  42.225 +    }
  42.226 +
  42.227 +    static class A {
  42.228 +        long f1;
  42.229 +        long f2;
  42.230 +        long f3;
  42.231 +        long f4;
  42.232 +        long f5;
  42.233 +    }
  42.234 +
  42.235 +    static class B {
  42.236 +        long f1;
  42.237 +        long f2;
  42.238 +        long f3;
  42.239 +        long f4;
  42.240 +        long f5;
  42.241 +
  42.242 +        A a;
  42.243 +    }
  42.244 +
  42.245 +    static B m8(boolean deopt) {
  42.246 +        try {
  42.247 +            A a = new A();
  42.248 +            B b = new B();
  42.249 +            b.a = a;
  42.250 +            if (deopt) {
  42.251 +                return b;
  42.252 +            }
  42.253 +        } catch(OutOfMemoryError oom) {
  42.254 +            free_memory();
  42.255 +            System.out.println("OOM caught in m8");
  42.256 +        }
  42.257 +        return null;
  42.258 +    }
  42.259 +
  42.260 +    static void m9_1(int i) {
  42.261 +        if (i > 90000) {
  42.262 +            consume_all_memory();
  42.263 +        }
  42.264 +    }
  42.265 +
  42.266 +    static TestDeoptOOM m9() {
  42.267 +        try {
  42.268 +            for (int i = 0; i < 100000; i++) {
  42.269 +                TestDeoptOOM tdoom = new TestDeoptOOM();
  42.270 +                m9_1(i);
  42.271 +                if (i > 90000) {
  42.272 +                    return tdoom;
  42.273 +                }
  42.274 +            }
  42.275 +        } catch(OutOfMemoryError oom) {
  42.276 +            free_memory();
  42.277 +            System.out.println("OOM caught in m1");
  42.278 +        }
  42.279 +        return null;
  42.280 +    }
  42.281 +
  42.282 +    public static void main(String[] args) {
  42.283 +        for (int i = 0; i < 20000; i++) {
  42.284 +            m1(false);
  42.285 +        }
  42.286 +
  42.287 +        consume_all_memory();
  42.288 +
  42.289 +        try {
  42.290 +            m1(true);
  42.291 +        } catch(OutOfMemoryError oom) {
  42.292 +            free_memory();
  42.293 +            System.out.println("OOM caught in main " + oom.getMessage());
  42.294 +        }
  42.295 +
  42.296 +        free_memory();
  42.297 +
  42.298 +        for (int i = 0; i < 20000; i++) {
  42.299 +            m2(false);
  42.300 +        }
  42.301 +
  42.302 +        consume_all_memory();
  42.303 +
  42.304 +        try {
  42.305 +            m2(true);
  42.306 +        } catch(OutOfMemoryError oom) {
  42.307 +            free_memory();
  42.308 +            System.out.println("OOM caught in main");
  42.309 +        }
  42.310 +
  42.311 +        free_memory();
  42.312 +
  42.313 +        for (int i = 0; i < 20000; i++) {
  42.314 +            m3(false);
  42.315 +        }
  42.316 +
  42.317 +        consume_all_memory();
  42.318 +
  42.319 +        try {
  42.320 +            m3(true);
  42.321 +        } catch(OutOfMemoryError oom) {
  42.322 +            free_memory();
  42.323 +            System.out.println("OOM caught in main");
  42.324 +        }
  42.325 +
  42.326 +        free_memory();
  42.327 +
  42.328 +        for (int i = 0; i < 20000; i++) {
  42.329 +            m4(false);
  42.330 +        }
  42.331 +
  42.332 +        consume_all_memory();
  42.333 +
  42.334 +        try {
  42.335 +            m4(true);
  42.336 +        } catch(OutOfMemoryError oom) {
  42.337 +            free_memory();
  42.338 +            System.out.println("OOM caught in main");
  42.339 +        }
  42.340 +
  42.341 +        free_memory();
  42.342 +
  42.343 +        for (int i = 0; i < 20000; i++) {
  42.344 +            m5(false);
  42.345 +        }
  42.346 +
  42.347 +        consume_all_memory();
  42.348 +
  42.349 +        try {
  42.350 +            m5(true);
  42.351 +        } catch(OutOfMemoryError oom) {
  42.352 +            free_memory();
  42.353 +            System.out.println("OOM caught in main");
  42.354 +        }
  42.355 +
  42.356 +        free_memory();
  42.357 +
  42.358 +        for (int i = 0; i < 20000; i++) {
  42.359 +            m6(false);
  42.360 +        }
  42.361 +
  42.362 +        consume_all_memory();
  42.363 +
  42.364 +        try {
  42.365 +            m6(true);
  42.366 +        } catch(OutOfMemoryError oom) {
  42.367 +            free_memory();
  42.368 +            System.out.println("OOM caught in main");
  42.369 +        }
  42.370 +
  42.371 +        free_memory();
  42.372 +
  42.373 +        final Object lock = new Object();
  42.374 +
  42.375 +        for (int i = 0; i < 20000; i++) {
  42.376 +            m7(false, lock);
  42.377 +        }
  42.378 +
  42.379 +        consume_all_memory();
  42.380 +
  42.381 +        try {
  42.382 +            m7(true, lock);
  42.383 +        } catch(OutOfMemoryError oom) {
  42.384 +            free_memory();
  42.385 +            System.out.println("OOM caught in main");
  42.386 +        }
  42.387 +
  42.388 +        free_memory();
  42.389 +
  42.390 +        Thread thread = new Thread() {
  42.391 +                public void run() {
  42.392 +                    System.out.println("Acquiring lock");
  42.393 +                    synchronized(lock) {
  42.394 +                        System.out.println("Lock acquired");
  42.395 +                    }
  42.396 +                    System.out.println("Lock released");
  42.397 +                }
  42.398 +            };
  42.399 +        thread.start();
  42.400 +        try {
  42.401 +            thread.join();
  42.402 +        } catch(InterruptedException ie) {
  42.403 +        }
  42.404 +
  42.405 +        for (int i = 0; i < 20000; i++) {
  42.406 +            m8(false);
  42.407 +        }
  42.408 +
  42.409 +        consume_all_memory();
  42.410 +
  42.411 +        try {
  42.412 +            m8(true);
  42.413 +        } catch(OutOfMemoryError oom) {
  42.414 +            free_memory();
  42.415 +            System.out.println("OOM caught in main");
  42.416 +        }
  42.417 +
  42.418 +        free_memory();
  42.419 +
  42.420 +        try {
  42.421 +            m9();
  42.422 +        } catch(OutOfMemoryError oom) {
  42.423 +            free_memory();
  42.424 +            System.out.println("OOM caught in main");
  42.425 +        }
  42.426 +
  42.427 +        free_memory();
  42.428 +    }
  42.429 +}
    43.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    43.2 +++ b/test/compiler/uncommontrap/TraceDeoptimizationNoRealloc.java	Mon Dec 22 09:27:29 2014 -0800
    43.3 @@ -0,0 +1,47 @@
    43.4 +/*
    43.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    43.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    43.7 + *
    43.8 + * This code is free software; you can redistribute it and/or modify it
    43.9 + * under the terms of the GNU General Public License version 2 only, as
   43.10 + * published by the Free Software Foundation.
   43.11 + *
   43.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   43.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   43.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   43.15 + * version 2 for more details (a copy is included in the LICENSE file that
   43.16 + * accompanied this code).
   43.17 + *
   43.18 + * You should have received a copy of the GNU General Public License version
   43.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   43.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   43.21 + *
   43.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   43.23 + * or visit www.oracle.com if you need additional information or have any
   43.24 + * questions.
   43.25 + */
   43.26 +
   43.27 +/*
   43.28 + * @test
   43.29 + * @bug 8067144
   43.30 + * @summary -XX:+TraceDeoptimization tries to print realloc'ed objects even when there are none
   43.31 + * @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement -XX:+IgnoreUnrecognizedVMOptions -XX:+TraceDeoptimization TraceDeoptimizationNoRealloc
   43.32 + *
   43.33 + */
   43.34 +
   43.35 +public class TraceDeoptimizationNoRealloc {
   43.36 +
   43.37 +    static void m(boolean some_condition) {
   43.38 +        if (some_condition) {
   43.39 +            return;
   43.40 +        }
   43.41 +    }
   43.42 +
   43.43 +
   43.44 +    static public void main(String[] args) {
   43.45 +        for (int i = 0; i < 20000; i++) {
   43.46 +            m(false);
   43.47 +        }
   43.48 +        m(true);
   43.49 +    }
   43.50 +}
    44.1 --- a/test/runtime/CheckEndorsedAndExtDirs/EndorsedExtDirs.java	Thu Dec 18 17:59:15 2014 -0800
    44.2 +++ b/test/runtime/CheckEndorsedAndExtDirs/EndorsedExtDirs.java	Mon Dec 22 09:27:29 2014 -0800
    44.3 @@ -26,6 +26,7 @@
    44.4   * @bug 8064667
    44.5   * @summary Sanity test for -XX:+CheckEndorsedAndExtDirs
    44.6   * @library /testlibrary
    44.7 + * @build com.oracle.java.testlibrary.*
    44.8   * @run main/othervm EndorsedExtDirs
    44.9   */
   44.10  
    45.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    45.2 +++ b/test/runtime/SharedArchiveFile/PrintSharedArchiveAndExit.java	Mon Dec 22 09:27:29 2014 -0800
    45.3 @@ -0,0 +1,83 @@
    45.4 +/*
    45.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    45.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    45.7 + *
    45.8 + * This code is free software; you can redistribute it and/or modify it
    45.9 + * under the terms of the GNU General Public License version 2 only, as
   45.10 + * published by the Free Software Foundation.
   45.11 + *
   45.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   45.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   45.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   45.15 + * version 2 for more details (a copy is included in the LICENSE file that
   45.16 + * accompanied this code).
   45.17 + *
   45.18 + * You should have received a copy of the GNU General Public License version
   45.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   45.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   45.21 + *
   45.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   45.23 + * or visit www.oracle.com if you need additional information or have any
   45.24 + * questions.
   45.25 + */
   45.26 +
   45.27 +/*
   45.28 + * @test
   45.29 + * @bug 8066670
   45.30 + * @summary Testing -XX:+PrintSharedArchiveAndExit option
   45.31 + * @library /testlibrary
   45.32 + */
   45.33 +
   45.34 +import com.oracle.java.testlibrary.*;
   45.35 +
   45.36 +public class PrintSharedArchiveAndExit {
   45.37 +  public static void main(String[] args) throws Exception {
   45.38 +    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
   45.39 +        "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa", "-Xshare:dump");
   45.40 +    OutputAnalyzer output = new OutputAnalyzer(pb.start());
   45.41 +    try {
   45.42 +      output.shouldContain("Loading classes to share");
   45.43 +      output.shouldHaveExitValue(0);
   45.44 +
   45.45 +      // (1) With a valid archive
   45.46 +      pb = ProcessTools.createJavaProcessBuilder(
   45.47 +          "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa",
   45.48 +          "-XX:+PrintSharedArchiveAndExit", "-version");
   45.49 +      output = new OutputAnalyzer(pb.start());
   45.50 +      output.shouldContain("archive is valid");
   45.51 +      output.shouldNotContain("java version");     // Should not print JVM version
   45.52 +      output.shouldHaveExitValue(0);               // Should report success in error code.
   45.53 +
   45.54 +      pb = ProcessTools.createJavaProcessBuilder(
   45.55 +          "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa",
   45.56 +          "-XX:+PrintSharedArchiveAndExit");
   45.57 +      output = new OutputAnalyzer(pb.start());
   45.58 +      output.shouldContain("archive is valid");
   45.59 +      output.shouldNotContain("Usage:");           // Should not print JVM help message
   45.60 +      output.shouldHaveExitValue(0);               // Should report success in error code.
   45.61 +
   45.62 +      // (2) With an invalid archive (boot class path has been prepended)
   45.63 +      pb = ProcessTools.createJavaProcessBuilder(
   45.64 +          "-Xbootclasspath/p:foo.jar",
   45.65 +          "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa",
   45.66 +          "-XX:+PrintSharedArchiveAndExit", "-version");
   45.67 +      output = new OutputAnalyzer(pb.start());
   45.68 +      output.shouldContain("archive is invalid");
   45.69 +      output.shouldNotContain("java version");     // Should not print JVM version
   45.70 +      output.shouldHaveExitValue(1);               // Should report failure in error code.
   45.71 +
   45.72 +      pb = ProcessTools.createJavaProcessBuilder(
   45.73 +          "-Xbootclasspath/p:foo.jar",
   45.74 +          "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa",
   45.75 +          "-XX:+PrintSharedArchiveAndExit");
   45.76 +      output = new OutputAnalyzer(pb.start());
   45.77 +      output.shouldContain("archive is invalid");
   45.78 +      output.shouldNotContain("Usage:");           // Should not print JVM help message
   45.79 +      output.shouldHaveExitValue(1);               // Should report failure in error code.
   45.80 +    } catch (RuntimeException e) {
   45.81 +      e.printStackTrace();
   45.82 +      output.shouldContain("Unable to use shared archive");
   45.83 +      output.shouldHaveExitValue(1);
   45.84 +    }
   45.85 +  }
   45.86 +}

mercurial