Merge

Tue, 09 Aug 2016 13:24:03 -0700

author
asaha
date
Tue, 09 Aug 2016 13:24:03 -0700
changeset 8678
57f957f4731d
parent 8677
f797a341d89e
parent 8582
56ff16dd9b8c
child 8679
fff265b31090

Merge

.hgtags file | annotate | diff | comparison | revisions
     1.1 --- a/.hgtags	Tue Aug 09 13:21:40 2016 -0700
     1.2 +++ b/.hgtags	Tue Aug 09 13:24:03 2016 -0700
     1.3 @@ -904,4 +904,12 @@
     1.4  019b22dd8128840ecdcd1bfebcf4447e28e45068 jdk8u111-b06
     1.5  3f337aaf090769653ee0a746fbe661d09055a883 jdk8u111-b07
     1.6  e180e364a40364a059a20c74b97ab4e928e2b676 jdk8u111-b08
     1.7 +b09a69142dd3bf78ca66bb0c99046ca7cccbdda9 jdk8u112-b00
     1.8 +cf1faa9100dd8c8df6e1a604aaf613d037f51ebf jdk8u112-b01
     1.9 +f22b5be95347c669a1463d9e05ec3bf11420208e jdk8u112-b02
    1.10 +f2f59d888427b1db336766bc8cd272f2b2d84e1a jdk8u112-b03
    1.11 +c171546c49b5ff57bcb74bb54e8860647f83f268 jdk8u112-b04
    1.12 +4b7af794466ba22461ed043a1394df43e4993c4f jdk8u112-b06
    1.13 +55ed9b0a35e4ad4bb5ca3f393f6749e81ad9fef0 jdk8u112-b07
    1.14 +670f8169b83c6af14339fe37b2a2b8384dc2149b jdk8u112-b08
    1.15  3b0e5f01891f5ebbf67797b1aae786196f1bb4f6 jdk8u121-b00
     2.1 --- a/LICENSE	Tue Aug 09 13:21:40 2016 -0700
     2.2 +++ b/LICENSE	Tue Aug 09 13:24:03 2016 -0700
     2.3 @@ -3,7 +3,7 @@
     2.4  Version 2, June 1991
     2.5  
     2.6  Copyright (C) 1989, 1991 Free Software Foundation, Inc.
     2.7 -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
     2.8 +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
     2.9  
    2.10  Everyone is permitted to copy and distribute verbatim copies of this license
    2.11  document, but changing it is not allowed.
    2.12 @@ -287,8 +287,8 @@
    2.13      more details.
    2.14  
    2.15      You should have received a copy of the GNU General Public License along
    2.16 -    with this program; if not, write to the Free Software Foundation, Inc., 59
    2.17 -    Temple Place, Suite 330, Boston, MA 02111-1307 USA
    2.18 +    with this program; if not, write to the Free Software Foundation, Inc.,
    2.19 +    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
    2.20  
    2.21  Also add information on how to contact you by electronic and paper mail.
    2.22  
     3.1 --- a/src/cpu/ppc/vm/compiledIC_ppc.cpp	Tue Aug 09 13:21:40 2016 -0700
     3.2 +++ b/src/cpu/ppc/vm/compiledIC_ppc.cpp	Tue Aug 09 13:24:03 2016 -0700
     3.3 @@ -94,7 +94,7 @@
     3.4  
     3.5  const int IC_pos_in_java_to_interp_stub = 8;
     3.6  #define __ _masm.
     3.7 -void CompiledStaticCall::emit_to_interp_stub(CodeBuffer &cbuf) {
     3.8 +address CompiledStaticCall::emit_to_interp_stub(CodeBuffer &cbuf) {
     3.9  #ifdef COMPILER2
    3.10    // Get the mark within main instrs section which is set to the address of the call.
    3.11    address call_addr = cbuf.insts_mark();
    3.12 @@ -106,8 +106,7 @@
    3.13    // Start the stub.
    3.14    address stub = __ start_a_stub(CompiledStaticCall::to_interp_stub_size());
    3.15    if (stub == NULL) {
    3.16 -    Compile::current()->env()->record_out_of_memory_failure();
    3.17 -    return;
    3.18 +    return NULL; // CodeCache is full
    3.19    }
    3.20  
    3.21    // For java_to_interp stubs we use R11_scratch1 as scratch register
    3.22 @@ -149,6 +148,7 @@
    3.23  
    3.24   // End the stub.
    3.25    __ end_a_stub();
    3.26 +  return stub;
    3.27  #else
    3.28    ShouldNotReachHere();
    3.29  #endif
     4.1 --- a/src/cpu/ppc/vm/ppc.ad	Tue Aug 09 13:21:40 2016 -0700
     4.2 +++ b/src/cpu/ppc/vm/ppc.ad	Tue Aug 09 13:24:03 2016 -0700
     4.3 @@ -1171,7 +1171,7 @@
     4.4    // Start the stub.
     4.5    address stub = __ start_a_stub(Compile::MAX_stubs_size/2);
     4.6    if (stub == NULL) {
     4.7 -    Compile::current()->env()->record_out_of_memory_failure();
     4.8 +    ciEnv::current()->record_failure("CodeCache is full");
     4.9      return;
    4.10    }
    4.11  
    4.12 @@ -1249,7 +1249,7 @@
    4.13  
    4.14      // Emit the trampoline stub which will be related to the branch-and-link below.
    4.15      CallStubImpl::emit_trampoline_stub(_masm, entry_point_toc_offset, offsets.insts_call_instruction_offset);
    4.16 -    if (Compile::current()->env()->failing()) { return offsets; } // Code cache may be full.
    4.17 +    if (ciEnv::current()->failing()) { return offsets; } // Code cache may be full.
    4.18      __ relocate(rtype);
    4.19    }
    4.20  
    4.21 @@ -3488,7 +3488,7 @@
    4.22  
    4.23          // Emit the trampoline stub which will be related to the branch-and-link below.
    4.24          CallStubImpl::emit_trampoline_stub(_masm, entry_point_toc_offset, start_offset);
    4.25 -        if (Compile::current()->env()->failing()) { return; } // Code cache may be full.
    4.26 +        if (ciEnv::current()->failing()) { return; } // Code cache may be full.
    4.27          __ relocate(_optimized_virtual ?
    4.28                      relocInfo::opt_virtual_call_type : relocInfo::static_call_type);
    4.29        }
    4.30 @@ -3501,7 +3501,11 @@
    4.31        __ bl(__ pc());  // Emits a relocation.
    4.32  
    4.33        // The stub for call to interpreter.
    4.34 -      CompiledStaticCall::emit_to_interp_stub(cbuf);
    4.35 +      address stub = CompiledStaticCall::emit_to_interp_stub(cbuf);
    4.36 +      if (stub == NULL) {
    4.37 +        ciEnv::current()->record_failure("CodeCache is full"); 
    4.38 +        return;
    4.39 +      }
    4.40      }
    4.41    %}
    4.42  
    4.43 @@ -3546,7 +3550,11 @@
    4.44  
    4.45      assert(_method, "execute next statement conditionally");
    4.46      // The stub for call to interpreter.
    4.47 -    CompiledStaticCall::emit_to_interp_stub(cbuf);
    4.48 +    address stub = CompiledStaticCall::emit_to_interp_stub(cbuf);
    4.49 +    if (stub == NULL) {
    4.50 +      ciEnv::current()->record_failure("CodeCache is full"); 
    4.51 +      return;
    4.52 +    }
    4.53  
    4.54      // Restore original sp.
    4.55      __ ld(R11_scratch1, 0, R1_SP); // Load caller sp.
    4.56 @@ -5461,7 +5469,7 @@
    4.57  %}
    4.58  
    4.59  // Match loading integer and casting it to long.
    4.60 -instruct loadI2L(iRegLdst dst, memory mem) %{
    4.61 +instruct loadI2L(iRegLdst dst, memoryAlg4 mem) %{
    4.62    match(Set dst (ConvI2L (LoadI mem)));
    4.63    predicate(_kids[0]->_leaf->as_Load()->is_unordered());
    4.64    ins_cost(MEMORY_REF_COST);
    4.65 @@ -5477,7 +5485,7 @@
    4.66  %}
    4.67  
    4.68  // Match loading integer and casting it to long - acquire.
    4.69 -instruct loadI2L_ac(iRegLdst dst, memory mem) %{
    4.70 +instruct loadI2L_ac(iRegLdst dst, memoryAlg4 mem) %{
    4.71    match(Set dst (ConvI2L (LoadI mem)));
    4.72    ins_cost(3*MEMORY_REF_COST);
    4.73  
     5.1 --- a/src/cpu/sparc/vm/c1_CodeStubs_sparc.cpp	Tue Aug 09 13:21:40 2016 -0700
     5.2 +++ b/src/cpu/sparc/vm/c1_CodeStubs_sparc.cpp	Tue Aug 09 13:24:03 2016 -0700
     5.3 @@ -431,6 +431,9 @@
     5.4    __ mov(length()->as_register(),  O4);
     5.5  
     5.6    ce->emit_static_call_stub();
     5.7 +  if (ce->compilation()->bailed_out()) {
     5.8 +    return; // CodeCache is full
     5.9 +  }
    5.10  
    5.11    __ call(SharedRuntime::get_resolve_static_call_stub(), relocInfo::static_call_type);
    5.12    __ delayed()->nop();
     6.1 --- a/src/cpu/sparc/vm/compiledIC_sparc.cpp	Tue Aug 09 13:21:40 2016 -0700
     6.2 +++ b/src/cpu/sparc/vm/compiledIC_sparc.cpp	Tue Aug 09 13:24:03 2016 -0700
     6.3 @@ -53,7 +53,7 @@
     6.4  // ----------------------------------------------------------------------------
     6.5  
     6.6  #define __ _masm.
     6.7 -void CompiledStaticCall::emit_to_interp_stub(CodeBuffer &cbuf) {
     6.8 +address CompiledStaticCall::emit_to_interp_stub(CodeBuffer &cbuf) {
     6.9  #ifdef COMPILER2
    6.10    // Stub is fixed up when the corresponding call is converted from calling
    6.11    // compiled code to calling interpreted code.
    6.12 @@ -64,9 +64,10 @@
    6.13  
    6.14    MacroAssembler _masm(&cbuf);
    6.15  
    6.16 -  address base =
    6.17 -  __ start_a_stub(to_interp_stub_size()*2);
    6.18 -  if (base == NULL) return;  // CodeBuffer::expand failed.
    6.19 +  address base = __ start_a_stub(to_interp_stub_size());
    6.20 +  if (base == NULL) {
    6.21 +    return NULL;  // CodeBuffer::expand failed.
    6.22 +  }
    6.23  
    6.24    // Static stub relocation stores the instruction address of the call.
    6.25    __ relocate(static_stub_Relocation::spec(mark));
    6.26 @@ -81,6 +82,7 @@
    6.27  
    6.28    // Update current stubs pointer and restore code_end.
    6.29    __ end_a_stub();
    6.30 +  return base;
    6.31  #else
    6.32    ShouldNotReachHere();
    6.33  #endif
     7.1 --- a/src/cpu/sparc/vm/sparc.ad	Tue Aug 09 13:21:40 2016 -0700
     7.2 +++ b/src/cpu/sparc/vm/sparc.ad	Tue Aug 09 13:24:03 2016 -0700
     7.3 @@ -1775,9 +1775,11 @@
     7.4    AddressLiteral exception_blob(OptoRuntime::exception_blob()->entry_point());
     7.5    MacroAssembler _masm(&cbuf);
     7.6  
     7.7 -  address base =
     7.8 -  __ start_a_stub(size_exception_handler());
     7.9 -  if (base == NULL)  return 0;  // CodeBuffer::expand failed
    7.10 +  address base = __ start_a_stub(size_exception_handler());
    7.11 +  if (base == NULL) {
    7.12 +    ciEnv::current()->record_failure("CodeCache is full");
    7.13 +    return 0;  // CodeBuffer::expand failed
    7.14 +  }
    7.15  
    7.16    int offset = __ offset();
    7.17  
    7.18 @@ -1798,9 +1800,11 @@
    7.19    AddressLiteral deopt_blob(SharedRuntime::deopt_blob()->unpack());
    7.20    MacroAssembler _masm(&cbuf);
    7.21  
    7.22 -  address base =
    7.23 -  __ start_a_stub(size_deopt_handler());
    7.24 -  if (base == NULL)  return 0;  // CodeBuffer::expand failed
    7.25 +  address base = __ start_a_stub(size_deopt_handler());
    7.26 +  if (base == NULL) {
    7.27 +    ciEnv::current()->record_failure("CodeCache is full");
    7.28 +    return 0;  // CodeBuffer::expand failed
    7.29 +  }
    7.30  
    7.31    int offset = __ offset();
    7.32    __ save_frame(0);
    7.33 @@ -2601,7 +2605,12 @@
    7.34        emit_call_reloc(cbuf, $meth$$method, relocInfo::static_call_type);
    7.35      }
    7.36      if (_method) {  // Emit stub for static call.
    7.37 -      CompiledStaticCall::emit_to_interp_stub(cbuf);
    7.38 +      address stub = CompiledStaticCall::emit_to_interp_stub(cbuf);
    7.39 +      // Stub does not fit into scratch buffer if TraceJumps is enabled
    7.40 +      if (stub == NULL && !(TraceJumps && Compile::current()->in_scratch_emit_size())) {
    7.41 +        ciEnv::current()->record_failure("CodeCache is full");
    7.42 +        return;
    7.43 +      } 
    7.44      }
    7.45    %}
    7.46  
     8.1 --- a/src/cpu/x86/vm/c1_CodeStubs_x86.cpp	Tue Aug 09 13:21:40 2016 -0700
     8.2 +++ b/src/cpu/x86/vm/c1_CodeStubs_x86.cpp	Tue Aug 09 13:24:03 2016 -0700
     8.3 @@ -502,6 +502,9 @@
     8.4    ce->align_call(lir_static_call);
     8.5  
     8.6    ce->emit_static_call_stub();
     8.7 +  if (ce->compilation()->bailed_out()) {
     8.8 +    return; // CodeCache is full
     8.9 +  }
    8.10    AddressLiteral resolve(SharedRuntime::get_resolve_static_call_stub(),
    8.11                           relocInfo::static_call_type);
    8.12    __ call(resolve);
     9.1 --- a/src/cpu/x86/vm/compiledIC_x86.cpp	Tue Aug 09 13:21:40 2016 -0700
     9.2 +++ b/src/cpu/x86/vm/compiledIC_x86.cpp	Tue Aug 09 13:24:03 2016 -0700
     9.3 @@ -50,7 +50,7 @@
     9.4  // ----------------------------------------------------------------------------
     9.5  
     9.6  #define __ _masm.
     9.7 -void CompiledStaticCall::emit_to_interp_stub(CodeBuffer &cbuf) {
     9.8 +address CompiledStaticCall::emit_to_interp_stub(CodeBuffer &cbuf) {
     9.9    // Stub is fixed up when the corresponding call is converted from
    9.10    // calling compiled code to calling interpreted code.
    9.11    // movq rbx, 0
    9.12 @@ -62,9 +62,10 @@
    9.13    // That's why we must use the macroassembler to generate a stub.
    9.14    MacroAssembler _masm(&cbuf);
    9.15  
    9.16 -  address base =
    9.17 -  __ start_a_stub(to_interp_stub_size()*2);
    9.18 -  if (base == NULL) return;  // CodeBuffer::expand failed.
    9.19 +  address base = __ start_a_stub(to_interp_stub_size());
    9.20 +  if (base == NULL) {
    9.21 +    return NULL;  // CodeBuffer::expand failed.
    9.22 +  }
    9.23    // Static stub relocation stores the instruction address of the call.
    9.24    __ relocate(static_stub_Relocation::spec(mark), Assembler::imm_operand);
    9.25    // Static stub relocation also tags the Method* in the code-stream.
    9.26 @@ -74,6 +75,7 @@
    9.27  
    9.28    // Update current stubs pointer and restore insts_end.
    9.29    __ end_a_stub();
    9.30 +  return base;
    9.31  }
    9.32  #undef __
    9.33  
    10.1 --- a/src/cpu/x86/vm/x86.ad	Tue Aug 09 13:21:40 2016 -0700
    10.2 +++ b/src/cpu/x86/vm/x86.ad	Tue Aug 09 13:24:03 2016 -0700
    10.3 @@ -550,7 +550,10 @@
    10.4    // That's why we must use the macroassembler to generate a handler.
    10.5    MacroAssembler _masm(&cbuf);
    10.6    address base = __ start_a_stub(size_exception_handler());
    10.7 -  if (base == NULL)  return 0;  // CodeBuffer::expand failed
    10.8 +  if (base == NULL) {
    10.9 +    ciEnv::current()->record_failure("CodeCache is full");
   10.10 +    return 0;  // CodeBuffer::expand failed
   10.11 +  }
   10.12    int offset = __ offset();
   10.13    __ jump(RuntimeAddress(OptoRuntime::exception_blob()->entry_point()));
   10.14    assert(__ offset() - offset <= (int) size_exception_handler(), "overflow");
   10.15 @@ -565,7 +568,10 @@
   10.16    // That's why we must use the macroassembler to generate a handler.
   10.17    MacroAssembler _masm(&cbuf);
   10.18    address base = __ start_a_stub(size_deopt_handler());
   10.19 -  if (base == NULL)  return 0;  // CodeBuffer::expand failed
   10.20 +  if (base == NULL) {
   10.21 +    ciEnv::current()->record_failure("CodeCache is full");
   10.22 +    return 0;  // CodeBuffer::expand failed
   10.23 +  }
   10.24    int offset = __ offset();
   10.25  
   10.26  #ifdef _LP64
    11.1 --- a/src/cpu/x86/vm/x86_32.ad	Tue Aug 09 13:21:40 2016 -0700
    11.2 +++ b/src/cpu/x86/vm/x86_32.ad	Tue Aug 09 13:24:03 2016 -0700
    11.3 @@ -1870,7 +1870,11 @@
    11.4                       static_call_Relocation::spec(), RELOC_IMM32 );
    11.5      }
    11.6      if (_method) {  // Emit stub for static call.
    11.7 -      CompiledStaticCall::emit_to_interp_stub(cbuf);
    11.8 +      address stub = CompiledStaticCall::emit_to_interp_stub(cbuf);
    11.9 +      if (stub == NULL) {
   11.10 +        ciEnv::current()->record_failure("CodeCache is full");
   11.11 +        return;
   11.12 +      } 
   11.13      }
   11.14    %}
   11.15  
    12.1 --- a/src/cpu/x86/vm/x86_64.ad	Tue Aug 09 13:21:40 2016 -0700
    12.2 +++ b/src/cpu/x86/vm/x86_64.ad	Tue Aug 09 13:24:03 2016 -0700
    12.3 @@ -2125,7 +2125,11 @@
    12.4      }
    12.5      if (_method) {
    12.6        // Emit stub for static call.
    12.7 -      CompiledStaticCall::emit_to_interp_stub(cbuf);
    12.8 +      address stub = CompiledStaticCall::emit_to_interp_stub(cbuf);
    12.9 +      if (stub == NULL) {
   12.10 +        ciEnv::current()->record_failure("CodeCache is full");
   12.11 +        return;
   12.12 +      } 
   12.13      }
   12.14    %}
   12.15  
    13.1 --- a/src/cpu/zero/vm/compiledIC_zero.cpp	Tue Aug 09 13:21:40 2016 -0700
    13.2 +++ b/src/cpu/zero/vm/compiledIC_zero.cpp	Tue Aug 09 13:24:03 2016 -0700
    13.3 @@ -60,8 +60,9 @@
    13.4  
    13.5  // ----------------------------------------------------------------------------
    13.6  
    13.7 -void CompiledStaticCall::emit_to_interp_stub(CodeBuffer &cbuf) {
    13.8 +address CompiledStaticCall::emit_to_interp_stub(CodeBuffer &cbuf) {
    13.9    ShouldNotReachHere(); // Only needed for COMPILER2.
   13.10 +  return NULL;
   13.11  }
   13.12  
   13.13  int CompiledStaticCall::to_interp_stub_size() {
    14.1 --- a/src/cpu/zero/vm/cppInterpreter_zero.cpp	Tue Aug 09 13:21:40 2016 -0700
    14.2 +++ b/src/cpu/zero/vm/cppInterpreter_zero.cpp	Tue Aug 09 13:24:03 2016 -0700
    14.3 @@ -220,9 +220,16 @@
    14.4    // Push our result
    14.5    for (int i = 0; i < result_slots; i++) {
    14.6      // Adjust result to smaller
    14.7 -    intptr_t res = result[-i];
    14.8 +    union {
    14.9 +      intptr_t res;
   14.10 +      jint res_jint;
   14.11 +    };
   14.12 +    res = result[-i];
   14.13      if (result_slots == 1) {
   14.14 -      res = narrow(method->result_type(), res);
   14.15 +      BasicType t = method->result_type();
   14.16 +      if (is_subword_type(t)) {
   14.17 +        res_jint = (jint)narrow(t, res_jint);
   14.18 +      }
   14.19      }
   14.20      stack->push(res);
   14.21    }
    15.1 --- a/src/os/linux/vm/os_linux.cpp	Tue Aug 09 13:21:40 2016 -0700
    15.2 +++ b/src/os/linux/vm/os_linux.cpp	Tue Aug 09 13:24:03 2016 -0700
    15.3 @@ -3047,6 +3047,48 @@
    15.4    return addr == MAP_FAILED ? NULL : addr;
    15.5  }
    15.6  
    15.7 +// Allocate (using mmap, NO_RESERVE, with small pages) at either a given request address
    15.8 +//   (req_addr != NULL) or with a given alignment.
    15.9 +//  - bytes shall be a multiple of alignment.
   15.10 +//  - req_addr can be NULL. If not NULL, it must be a multiple of alignment.
   15.11 +//  - alignment sets the alignment at which memory shall be allocated.
   15.12 +//     It must be a multiple of allocation granularity.
   15.13 +// Returns address of memory or NULL. If req_addr was not NULL, will only return
   15.14 +//  req_addr or NULL.
   15.15 +static char* anon_mmap_aligned(size_t bytes, size_t alignment, char* req_addr) {
   15.16 +
   15.17 +  size_t extra_size = bytes;
   15.18 +  if (req_addr == NULL && alignment > 0) {
   15.19 +    extra_size += alignment;
   15.20 +  }
   15.21 +
   15.22 +  char* start = (char*) ::mmap(req_addr, extra_size, PROT_NONE,
   15.23 +    MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE,
   15.24 +    -1, 0);
   15.25 +  if (start == MAP_FAILED) {
   15.26 +    start = NULL;
   15.27 +  } else {
   15.28 +    if (req_addr != NULL) {
   15.29 +      if (start != req_addr) {
   15.30 +        ::munmap(start, extra_size);
   15.31 +        start = NULL;
   15.32 +      }
   15.33 +    } else {
   15.34 +      char* const start_aligned = (char*) align_ptr_up(start, alignment);
   15.35 +      char* const end_aligned = start_aligned + bytes;
   15.36 +      char* const end = start + extra_size;
   15.37 +      if (start_aligned > start) {
   15.38 +        ::munmap(start, start_aligned - start);
   15.39 +      }
   15.40 +      if (end_aligned < end) {
   15.41 +        ::munmap(end_aligned, end - end_aligned);
   15.42 +      }
   15.43 +      start = start_aligned;
   15.44 +    }
   15.45 +  }
   15.46 +  return start;
   15.47 +}
   15.48 +
   15.49  // Don't update _highest_vm_reserved_address, because there might be memory
   15.50  // regions above addr + size. If so, releasing a memory region only creates
   15.51  // a hole in the address space, it doesn't help prevent heap-stack collision.
   15.52 @@ -3331,54 +3373,133 @@
   15.53  #define SHM_HUGETLB 04000
   15.54  #endif
   15.55  
   15.56 +#define shm_warning_format(format, ...)              \
   15.57 +  do {                                               \
   15.58 +    if (UseLargePages &&                             \
   15.59 +        (!FLAG_IS_DEFAULT(UseLargePages) ||          \
   15.60 +         !FLAG_IS_DEFAULT(UseSHM) ||                 \
   15.61 +         !FLAG_IS_DEFAULT(LargePageSizeInBytes))) {  \
   15.62 +      warning(format, __VA_ARGS__);                  \
   15.63 +    }                                                \
   15.64 +  } while (0)
   15.65 +
   15.66 +#define shm_warning(str) shm_warning_format("%s", str)
   15.67 +
   15.68 +#define shm_warning_with_errno(str)                \
   15.69 +  do {                                             \
   15.70 +    int err = errno;                               \
   15.71 +    shm_warning_format(str " (error = %d)", err);  \
   15.72 +  } while (0)
   15.73 +
   15.74 +static char* shmat_with_alignment(int shmid, size_t bytes, size_t alignment) {
   15.75 +  assert(is_size_aligned(bytes, alignment), "Must be divisible by the alignment");
   15.76 +
   15.77 +  if (!is_size_aligned(alignment, SHMLBA)) {
   15.78 +    assert(false, "Code below assumes that alignment is at least SHMLBA aligned");
   15.79 +    return NULL;
   15.80 +  }
   15.81 +
   15.82 +  // To ensure that we get 'alignment' aligned memory from shmat,
   15.83 +  // we pre-reserve aligned virtual memory and then attach to that.
   15.84 +
   15.85 +  char* pre_reserved_addr = anon_mmap_aligned(bytes, alignment, NULL);
   15.86 +  if (pre_reserved_addr == NULL) {
   15.87 +    // Couldn't pre-reserve aligned memory.
   15.88 +    shm_warning("Failed to pre-reserve aligned memory for shmat.");
   15.89 +    return NULL;
   15.90 +  }
   15.91 +
   15.92 +  // SHM_REMAP is needed to allow shmat to map over an existing mapping.
   15.93 +  char* addr = (char*)shmat(shmid, pre_reserved_addr, SHM_REMAP);
   15.94 +
   15.95 +  if ((intptr_t)addr == -1) {
   15.96 +    int err = errno;
   15.97 +    shm_warning_with_errno("Failed to attach shared memory.");
   15.98 +
   15.99 +    assert(err != EACCES, "Unexpected error");
  15.100 +    assert(err != EIDRM,  "Unexpected error");
  15.101 +    assert(err != EINVAL, "Unexpected error");
  15.102 +
  15.103 +    // Since we don't know if the kernel unmapped the pre-reserved memory area
  15.104 +    // we can't unmap it, since that would potentially unmap memory that was
  15.105 +    // mapped from other threads.
  15.106 +    return NULL;
  15.107 +  }
  15.108 +
  15.109 +  return addr;
  15.110 +}
  15.111 +
  15.112 +static char* shmat_at_address(int shmid, char* req_addr) {
  15.113 +  if (!is_ptr_aligned(req_addr, SHMLBA)) {
  15.114 +    assert(false, "Requested address needs to be SHMLBA aligned");
  15.115 +    return NULL;
  15.116 +  }
  15.117 +
  15.118 +  char* addr = (char*)shmat(shmid, req_addr, 0);
  15.119 +
  15.120 +  if ((intptr_t)addr == -1) {
  15.121 +    shm_warning_with_errno("Failed to attach shared memory.");
  15.122 +    return NULL;
  15.123 +  }
  15.124 +
  15.125 +  return addr;
  15.126 +}
  15.127 +
  15.128 +static char* shmat_large_pages(int shmid, size_t bytes, size_t alignment, char* req_addr) {
  15.129 +  // If a req_addr has been provided, we assume that the caller has already aligned the address.
  15.130 +  if (req_addr != NULL) {
  15.131 +    assert(is_ptr_aligned(req_addr, os::large_page_size()), "Must be divisible by the large page size");
  15.132 +    assert(is_ptr_aligned(req_addr, alignment), "Must be divisible by given alignment");
  15.133 +    return shmat_at_address(shmid, req_addr);
  15.134 +  }
  15.135 +
  15.136 +  // Since shmid has been setup with SHM_HUGETLB, shmat will automatically
  15.137 +  // return large page size aligned memory addresses when req_addr == NULL.
  15.138 +  // However, if the alignment is larger than the large page size, we have
  15.139 +  // to manually ensure that the memory returned is 'alignment' aligned.
  15.140 +  if (alignment > os::large_page_size()) {
  15.141 +    assert(is_size_aligned(alignment, os::large_page_size()), "Must be divisible by the large page size");
  15.142 +    return shmat_with_alignment(shmid, bytes, alignment);
  15.143 +  } else {
  15.144 +    return shmat_at_address(shmid, NULL);
  15.145 +  }
  15.146 +}
  15.147 +
  15.148  char* os::Linux::reserve_memory_special_shm(size_t bytes, size_t alignment, char* req_addr, bool exec) {
  15.149    // "exec" is passed in but not used.  Creating the shared image for
  15.150    // the code cache doesn't have an SHM_X executable permission to check.
  15.151    assert(UseLargePages && UseSHM, "only for SHM large pages");
  15.152    assert(is_ptr_aligned(req_addr, os::large_page_size()), "Unaligned address");
  15.153 -
  15.154 -  if (!is_size_aligned(bytes, os::large_page_size()) || alignment > os::large_page_size()) {
  15.155 +  assert(is_ptr_aligned(req_addr, alignment), "Unaligned address");
  15.156 +
  15.157 +  if (!is_size_aligned(bytes, os::large_page_size())) {
  15.158      return NULL; // Fallback to small pages.
  15.159    }
  15.160  
  15.161 -  key_t key = IPC_PRIVATE;
  15.162 -  char *addr;
  15.163 -
  15.164 -  bool warn_on_failure = UseLargePages &&
  15.165 -                        (!FLAG_IS_DEFAULT(UseLargePages) ||
  15.166 -                         !FLAG_IS_DEFAULT(UseSHM) ||
  15.167 -                         !FLAG_IS_DEFAULT(LargePageSizeInBytes)
  15.168 -                        );
  15.169 -  char msg[128];
  15.170 -
  15.171    // Create a large shared memory region to attach to based on size.
  15.172 -  // Currently, size is the total size of the heap
  15.173 -  int shmid = shmget(key, bytes, SHM_HUGETLB|IPC_CREAT|SHM_R|SHM_W);
  15.174 +  // Currently, size is the total size of the heap.
  15.175 +  int shmid = shmget(IPC_PRIVATE, bytes, SHM_HUGETLB|IPC_CREAT|SHM_R|SHM_W);
  15.176    if (shmid == -1) {
  15.177 -     // Possible reasons for shmget failure:
  15.178 -     // 1. shmmax is too small for Java heap.
  15.179 -     //    > check shmmax value: cat /proc/sys/kernel/shmmax
  15.180 -     //    > increase shmmax value: echo "0xffffffff" > /proc/sys/kernel/shmmax
  15.181 -     // 2. not enough large page memory.
  15.182 -     //    > check available large pages: cat /proc/meminfo
  15.183 -     //    > increase amount of large pages:
  15.184 -     //          echo new_value > /proc/sys/vm/nr_hugepages
  15.185 -     //      Note 1: different Linux may use different name for this property,
  15.186 -     //            e.g. on Redhat AS-3 it is "hugetlb_pool".
  15.187 -     //      Note 2: it's possible there's enough physical memory available but
  15.188 -     //            they are so fragmented after a long run that they can't
  15.189 -     //            coalesce into large pages. Try to reserve large pages when
  15.190 -     //            the system is still "fresh".
  15.191 -     if (warn_on_failure) {
  15.192 -       jio_snprintf(msg, sizeof(msg), "Failed to reserve shared memory (errno = %d).", errno);
  15.193 -       warning("%s", msg);
  15.194 -     }
  15.195 -     return NULL;
  15.196 -  }
  15.197 -
  15.198 -  // attach to the region
  15.199 -  addr = (char*)shmat(shmid, req_addr, 0);
  15.200 -  int err = errno;
  15.201 +    // Possible reasons for shmget failure:
  15.202 +    // 1. shmmax is too small for Java heap.
  15.203 +    //    > check shmmax value: cat /proc/sys/kernel/shmmax
  15.204 +    //    > increase shmmax value: echo "0xffffffff" > /proc/sys/kernel/shmmax
  15.205 +    // 2. not enough large page memory.
  15.206 +    //    > check available large pages: cat /proc/meminfo
  15.207 +    //    > increase amount of large pages:
  15.208 +    //          echo new_value > /proc/sys/vm/nr_hugepages
  15.209 +    //      Note 1: different Linux may use different name for this property,
  15.210 +    //            e.g. on Redhat AS-3 it is "hugetlb_pool".
  15.211 +    //      Note 2: it's possible there's enough physical memory available but
  15.212 +    //            they are so fragmented after a long run that they can't
  15.213 +    //            coalesce into large pages. Try to reserve large pages when
  15.214 +    //            the system is still "fresh".
  15.215 +    shm_warning_with_errno("Failed to reserve shared memory.");
  15.216 +    return NULL;
  15.217 +  }
  15.218 +
  15.219 +  // Attach to the region.
  15.220 +  char* addr = shmat_large_pages(shmid, bytes, alignment, req_addr);
  15.221  
  15.222    // Remove shmid. If shmat() is successful, the actual shared memory segment
  15.223    // will be deleted when it's detached by shmdt() or when the process
  15.224 @@ -3386,14 +3507,6 @@
  15.225    // segment immediately.
  15.226    shmctl(shmid, IPC_RMID, NULL);
  15.227  
  15.228 -  if ((intptr_t)addr == -1) {
  15.229 -     if (warn_on_failure) {
  15.230 -       jio_snprintf(msg, sizeof(msg), "Failed to attach shared memory (errno = %d).", err);
  15.231 -       warning("%s", msg);
  15.232 -     }
  15.233 -     return NULL;
  15.234 -  }
  15.235 -
  15.236    return addr;
  15.237  }
  15.238  
  15.239 @@ -3433,22 +3546,22 @@
  15.240    return addr;
  15.241  }
  15.242  
  15.243 +// Reserve memory using mmap(MAP_HUGETLB).
  15.244 +//  - bytes shall be a multiple of alignment.
  15.245 +//  - req_addr can be NULL. If not NULL, it must be a multiple of alignment.
  15.246 +//  - alignment sets the alignment at which memory shall be allocated.
  15.247 +//     It must be a multiple of allocation granularity.
  15.248 +// Returns address of memory or NULL. If req_addr was not NULL, will only return
  15.249 +//  req_addr or NULL.
  15.250  char* os::Linux::reserve_memory_special_huge_tlbfs_mixed(size_t bytes, size_t alignment, char* req_addr, bool exec) {
  15.251    size_t large_page_size = os::large_page_size();
  15.252 -
  15.253    assert(bytes >= large_page_size, "Shouldn't allocate large pages for small sizes");
  15.254  
  15.255 -  // Allocate small pages.
  15.256 -
  15.257 -  char* start;
  15.258 -  if (req_addr != NULL) {
  15.259 -    assert(is_ptr_aligned(req_addr, alignment), "Must be");
  15.260 -    assert(is_size_aligned(bytes, alignment), "Must be");
  15.261 -    start = os::reserve_memory(bytes, req_addr);
  15.262 -    assert(start == NULL || start == req_addr, "Must be");
  15.263 -  } else {
  15.264 -    start = os::reserve_memory_aligned(bytes, alignment);
  15.265 -  }
  15.266 +  assert(is_ptr_aligned(req_addr, alignment), "Must be");
  15.267 +  assert(is_size_aligned(bytes, alignment), "Must be");
  15.268 +
  15.269 +  // First reserve - but not commit - the address range in small pages.
  15.270 +  char* const start = anon_mmap_aligned(bytes, alignment, req_addr);
  15.271  
  15.272    if (start == NULL) {
  15.273      return NULL;
  15.274 @@ -3456,13 +3569,6 @@
  15.275  
  15.276    assert(is_ptr_aligned(start, alignment), "Must be");
  15.277  
  15.278 -  if (MemTracker::tracking_level() > NMT_minimal) {
  15.279 -    // os::reserve_memory_special will record this memory area.
  15.280 -    // Need to release it here to prevent overlapping reservations.
  15.281 -    Tracker tkr = MemTracker::get_virtual_memory_release_tracker();
  15.282 -    tkr.record((address)start, bytes);
  15.283 -  }
  15.284 -
  15.285    char* end = start + bytes;
  15.286  
  15.287    // Find the regions of the allocated chunk that can be promoted to large pages.
  15.288 @@ -3482,9 +3588,9 @@
  15.289  
  15.290    int prot = exec ? PROT_READ|PROT_WRITE|PROT_EXEC : PROT_READ|PROT_WRITE;
  15.291  
  15.292 -
  15.293    void* result;
  15.294  
  15.295 +  // Commit small-paged leading area.
  15.296    if (start != lp_start) {
  15.297      result = ::mmap(start, lp_start - start, prot,
  15.298                      MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED,
  15.299 @@ -3495,11 +3601,12 @@
  15.300      }
  15.301    }
  15.302  
  15.303 +  // Commit large-paged area.
  15.304    result = ::mmap(lp_start, lp_bytes, prot,
  15.305                    MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED|MAP_HUGETLB,
  15.306                    -1, 0);
  15.307    if (result == MAP_FAILED) {
  15.308 -    warn_on_large_pages_failure(req_addr, bytes, errno);
  15.309 +    warn_on_large_pages_failure(lp_start, lp_bytes, errno);
  15.310      // If the mmap above fails, the large pages region will be unmapped and we
  15.311      // have regions before and after with small pages. Release these regions.
  15.312      //
  15.313 @@ -3512,6 +3619,7 @@
  15.314      return NULL;
  15.315    }
  15.316  
  15.317 +  // Commit small-paged trailing area.
  15.318    if (lp_end != end) {
  15.319        result = ::mmap(lp_end, end - lp_end, prot,
  15.320                        MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED,
  15.321 @@ -3528,7 +3636,7 @@
  15.322  char* os::Linux::reserve_memory_special_huge_tlbfs(size_t bytes, size_t alignment, char* req_addr, bool exec) {
  15.323    assert(UseLargePages && UseHugeTLBFS, "only for Huge TLBFS large pages");
  15.324    assert(is_ptr_aligned(req_addr, alignment), "Must be");
  15.325 -  assert(is_power_of_2(alignment), "Must be");
  15.326 +  assert(is_size_aligned(alignment, os::vm_allocation_granularity()), "Must be");
  15.327    assert(is_power_of_2(os::large_page_size()), "Must be");
  15.328    assert(bytes >= os::large_page_size(), "Shouldn't allocate large pages for small sizes");
  15.329  
  15.330 @@ -6102,47 +6210,100 @@
  15.331      }
  15.332    }
  15.333  
  15.334 -  static void test_reserve_memory_special_huge_tlbfs_mixed(size_t size, size_t alignment) {
  15.335 -    if (!UseHugeTLBFS) {
  15.336 -        return;
  15.337 -    }
  15.338 -
  15.339 -    test_log("test_reserve_memory_special_huge_tlbfs_mixed(" SIZE_FORMAT ", " SIZE_FORMAT ")",
  15.340 -        size, alignment);
  15.341 -
  15.342 -    assert(size >= os::large_page_size(), "Incorrect input to test");
  15.343 -
  15.344 -    char* addr = os::Linux::reserve_memory_special_huge_tlbfs_mixed(size, alignment, NULL, false);
  15.345 -
  15.346 -    if (addr != NULL) {
  15.347 -      small_page_write(addr, size);
  15.348 -
  15.349 -      os::Linux::release_memory_special_huge_tlbfs(addr, size);
  15.350 -    }
  15.351 -  }
  15.352 -
  15.353 -  static void test_reserve_memory_special_huge_tlbfs_mixed_all_alignments(size_t size) {
  15.354 -    size_t lp = os::large_page_size();
  15.355 -    size_t ag = os::vm_allocation_granularity();
  15.356 -
  15.357 -    for (size_t alignment = ag; is_size_aligned(size, alignment); alignment *= 2) {
  15.358 -      test_reserve_memory_special_huge_tlbfs_mixed(size, alignment);
  15.359 -    }
  15.360 -  }
  15.361 -
  15.362    static void test_reserve_memory_special_huge_tlbfs_mixed() {
  15.363      size_t lp = os::large_page_size();
  15.364      size_t ag = os::vm_allocation_granularity();
  15.365  
  15.366 -    test_reserve_memory_special_huge_tlbfs_mixed_all_alignments(lp);
  15.367 -    test_reserve_memory_special_huge_tlbfs_mixed_all_alignments(lp + ag);
  15.368 -    test_reserve_memory_special_huge_tlbfs_mixed_all_alignments(lp + lp / 2);
  15.369 -    test_reserve_memory_special_huge_tlbfs_mixed_all_alignments(lp * 2);
  15.370 -    test_reserve_memory_special_huge_tlbfs_mixed_all_alignments(lp * 2 + ag);
  15.371 -    test_reserve_memory_special_huge_tlbfs_mixed_all_alignments(lp * 2 - ag);
  15.372 -    test_reserve_memory_special_huge_tlbfs_mixed_all_alignments(lp * 2 + lp / 2);
  15.373 -    test_reserve_memory_special_huge_tlbfs_mixed_all_alignments(lp * 10);
  15.374 -    test_reserve_memory_special_huge_tlbfs_mixed_all_alignments(lp * 10 + lp / 2);
  15.375 +    // sizes to test
  15.376 +    const size_t sizes[] = {
  15.377 +      lp, lp + ag, lp + lp / 2, lp * 2,
  15.378 +      lp * 2 + ag, lp * 2 - ag, lp * 2 + lp / 2,
  15.379 +      lp * 10, lp * 10 + lp / 2
  15.380 +    };
  15.381 +    const int num_sizes = sizeof(sizes) / sizeof(size_t);
  15.382 +
  15.383 +    // For each size/alignment combination, we test three scenarios:
  15.384 +    // 1) with req_addr == NULL
  15.385 +    // 2) with a non-null req_addr at which we expect to successfully allocate
  15.386 +    // 3) with a non-null req_addr which contains a pre-existing mapping, at which we
  15.387 +    //    expect the allocation to either fail or to ignore req_addr
  15.388 +
  15.389 +    // Pre-allocate two areas; they shall be as large as the largest allocation
  15.390 +    //  and aligned to the largest alignment we will be testing.
  15.391 +    const size_t mapping_size = sizes[num_sizes - 1] * 2;
  15.392 +    char* const mapping1 = (char*) ::mmap(NULL, mapping_size,
  15.393 +      PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE,
  15.394 +      -1, 0);
  15.395 +    assert(mapping1 != MAP_FAILED, "should work");
  15.396 +
  15.397 +    char* const mapping2 = (char*) ::mmap(NULL, mapping_size,
  15.398 +      PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE,
  15.399 +      -1, 0);
  15.400 +    assert(mapping2 != MAP_FAILED, "should work");
  15.401 +
  15.402 +    // Unmap the first mapping, but leave the second mapping intact: the first
  15.403 +    // mapping will serve as a value for a "good" req_addr (case 2). The second
  15.404 +    // mapping, still intact, as "bad" req_addr (case 3).
  15.405 +    ::munmap(mapping1, mapping_size);
  15.406 +
  15.407 +    // Case 1
  15.408 +    test_log("%s, req_addr NULL:", __FUNCTION__);
  15.409 +    test_log("size            align           result");
  15.410 +
  15.411 +    for (int i = 0; i < num_sizes; i++) {
  15.412 +      const size_t size = sizes[i];
  15.413 +      for (size_t alignment = ag; is_size_aligned(size, alignment); alignment *= 2) {
  15.414 +        char* p = os::Linux::reserve_memory_special_huge_tlbfs_mixed(size, alignment, NULL, false);
  15.415 +        test_log(SIZE_FORMAT_HEX " " SIZE_FORMAT_HEX " ->  " PTR_FORMAT " %s",
  15.416 +            size, alignment, p, (p != NULL ? "" : "(failed)"));
  15.417 +        if (p != NULL) {
  15.418 +          assert(is_ptr_aligned(p, alignment), "must be");
  15.419 +          small_page_write(p, size);
  15.420 +          os::Linux::release_memory_special_huge_tlbfs(p, size);
  15.421 +        }
  15.422 +      }
  15.423 +    }
  15.424 +
  15.425 +    // Case 2
  15.426 +    test_log("%s, req_addr non-NULL:", __FUNCTION__);
  15.427 +    test_log("size            align           req_addr         result");
  15.428 +
  15.429 +    for (int i = 0; i < num_sizes; i++) {
  15.430 +      const size_t size = sizes[i];
  15.431 +      for (size_t alignment = ag; is_size_aligned(size, alignment); alignment *= 2) {
  15.432 +        char* const req_addr = (char*) align_ptr_up(mapping1, alignment);
  15.433 +        char* p = os::Linux::reserve_memory_special_huge_tlbfs_mixed(size, alignment, req_addr, false);
  15.434 +        test_log(SIZE_FORMAT_HEX " " SIZE_FORMAT_HEX " " PTR_FORMAT " ->  " PTR_FORMAT " %s",
  15.435 +            size, alignment, req_addr, p,
  15.436 +            ((p != NULL ? (p == req_addr ? "(exact match)" : "") : "(failed)")));
  15.437 +        if (p != NULL) {
  15.438 +          assert(p == req_addr, "must be");
  15.439 +          small_page_write(p, size);
  15.440 +          os::Linux::release_memory_special_huge_tlbfs(p, size);
  15.441 +        }
  15.442 +      }
  15.443 +    }
  15.444 +
  15.445 +    // Case 3
  15.446 +    test_log("%s, req_addr non-NULL with preexisting mapping:", __FUNCTION__);
  15.447 +    test_log("size            align           req_addr         result");
  15.448 +
  15.449 +    for (int i = 0; i < num_sizes; i++) {
  15.450 +      const size_t size = sizes[i];
  15.451 +      for (size_t alignment = ag; is_size_aligned(size, alignment); alignment *= 2) {
  15.452 +        char* const req_addr = (char*) align_ptr_up(mapping2, alignment);
  15.453 +        char* p = os::Linux::reserve_memory_special_huge_tlbfs_mixed(size, alignment, req_addr, false);
  15.454 +        test_log(SIZE_FORMAT_HEX " " SIZE_FORMAT_HEX " " PTR_FORMAT " ->  " PTR_FORMAT " %s",
  15.455 +            size, alignment, req_addr, p,
  15.456 +            ((p != NULL ? "" : "(failed)")));
  15.457 +        // as the area around req_addr contains already existing mappings, the API should always
  15.458 +        // return NULL (as per contract, it cannot return another address)
  15.459 +        assert(p == NULL, "must be");
  15.460 +      }
  15.461 +    }
  15.462 +
  15.463 +    ::munmap(mapping2, mapping_size);
  15.464 +
  15.465    }
  15.466  
  15.467    static void test_reserve_memory_special_huge_tlbfs() {
    16.1 --- a/src/share/vm/c1/c1_LIRAssembler.cpp	Tue Aug 09 13:21:40 2016 -0700
    16.2 +++ b/src/share/vm/c1/c1_LIRAssembler.cpp	Tue Aug 09 13:24:03 2016 -0700
    16.3 @@ -464,6 +464,7 @@
    16.4  
    16.5    // emit the static call stub stuff out of line
    16.6    emit_static_call_stub();
    16.7 +  CHECK_BAILOUT();
    16.8  
    16.9    switch (op->code()) {
   16.10    case lir_static_call:
    17.1 --- a/src/share/vm/classfile/classFileParser.cpp	Tue Aug 09 13:21:40 2016 -0700
    17.2 +++ b/src/share/vm/classfile/classFileParser.cpp	Tue Aug 09 13:24:03 2016 -0700
    17.3 @@ -537,6 +537,9 @@
    17.4            int name_index = cp->name_ref_index_at(index);
    17.5            Symbol*  name = cp->symbol_at(name_index);
    17.6            Symbol*  sig = cp->symbol_at(sig_index);
    17.7 +          guarantee_property(sig->utf8_length() != 0,
    17.8 +            "Illegal zero length constant pool entry at %d in class %s",
    17.9 +            sig_index, CHECK_(nullHandle));
   17.10            if (sig->byte_at(0) == JVM_SIGNATURE_FUNC) {
   17.11              verify_legal_method_signature(name, sig, CHECK_(nullHandle));
   17.12            } else {
   17.13 @@ -560,8 +563,9 @@
   17.14            verify_legal_field_name(name, CHECK_(nullHandle));
   17.15            if (_need_verify && _major_version >= JAVA_7_VERSION) {
   17.16              // Signature is verified above, when iterating NameAndType_info.
   17.17 -            // Need only to be sure it's the right type.
   17.18 -            if (signature->byte_at(0) == JVM_SIGNATURE_FUNC) {
   17.19 +            // Need only to be sure it's non-zero length and the right type.
   17.20 +            if (signature->utf8_length() == 0 ||
   17.21 +                signature->byte_at(0) == JVM_SIGNATURE_FUNC) {
   17.22                throwIllegalSignature(
   17.23                    "Field", name, signature, CHECK_(nullHandle));
   17.24              }
   17.25 @@ -572,8 +576,9 @@
   17.26            verify_legal_method_name(name, CHECK_(nullHandle));
   17.27            if (_need_verify && _major_version >= JAVA_7_VERSION) {
   17.28              // Signature is verified above, when iterating NameAndType_info.
   17.29 -            // Need only to be sure it's the right type.
   17.30 -            if (signature->byte_at(0) != JVM_SIGNATURE_FUNC) {
   17.31 +            // Need only to be sure it's non-zero length and the right type.
   17.32 +            if (signature->utf8_length() == 0 ||
   17.33 +                signature->byte_at(0) != JVM_SIGNATURE_FUNC) {
   17.34                throwIllegalSignature(
   17.35                    "Method", name, signature, CHECK_(nullHandle));
   17.36              }
   17.37 @@ -584,8 +589,7 @@
   17.38              // 4509014: If a class method name begins with '<', it must be "<init>".
   17.39              assert(name != NULL, "method name in constant pool is null");
   17.40              unsigned int name_len = name->utf8_length();
   17.41 -            assert(name_len > 0, "bad method name");  // already verified as legal name
   17.42 -            if (name->byte_at(0) == '<') {
   17.43 +            if (name_len != 0 && name->byte_at(0) == '<') {
   17.44                if (name != vmSymbols::object_initializer_name()) {
   17.45                  classfile_parse_error(
   17.46                    "Bad method name at constant pool index %u in class file %s",
    18.1 --- a/src/share/vm/classfile/classLoaderData.cpp	Tue Aug 09 13:21:40 2016 -0700
    18.2 +++ b/src/share/vm/classfile/classLoaderData.cpp	Tue Aug 09 13:24:03 2016 -0700
    18.3 @@ -813,6 +813,12 @@
    18.4      // called on all alive classes. See the comment in ClassLoaderDataGraph::clean_metaspaces.
    18.5      cld->free_deallocate_list();
    18.6    }
    18.7 +
    18.8 +  // In some rare cases items added to the unloading list will not be freed elsewhere.
    18.9 +  // To keep it simple, walk the _unloading list also.
   18.10 +  for (ClassLoaderData* cld = _unloading; cld != _saved_unloading; cld = cld->next()) {
   18.11 +    cld->free_deallocate_list();
   18.12 +  }
   18.13  }
   18.14  
   18.15  // CDS support
    19.1 --- a/src/share/vm/classfile/classLoaderData.inline.hpp	Tue Aug 09 13:21:40 2016 -0700
    19.2 +++ b/src/share/vm/classfile/classLoaderData.inline.hpp	Tue Aug 09 13:24:03 2016 -0700
    19.3 @@ -40,7 +40,7 @@
    19.4  
    19.5  
    19.6  inline ClassLoaderData *ClassLoaderDataGraph::find_or_create(Handle loader, TRAPS) {
    19.7 -  assert(loader() != NULL,"Must be a class loader");
    19.8 +  guarantee(loader() != NULL && loader()->is_oop(), "Loader must be oop");
    19.9    // Gets the class loader data out of the java/lang/ClassLoader object, if non-null
   19.10    // it's already in the loader_data, so no need to add
   19.11    ClassLoaderData* loader_data= java_lang_ClassLoader::loader_data(loader());
    20.1 --- a/src/share/vm/classfile/vmSymbols.hpp	Tue Aug 09 13:21:40 2016 -0700
    20.2 +++ b/src/share/vm/classfile/vmSymbols.hpp	Tue Aug 09 13:24:03 2016 -0700
    20.3 @@ -1,5 +1,5 @@
    20.4  /*
    20.5 - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
    20.6 + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    20.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    20.8   *
    20.9   * This code is free software; you can redistribute it and/or modify it
   20.10 @@ -517,6 +517,7 @@
   20.11    template(int_StringBuffer_signature,                "(I)Ljava/lang/StringBuffer;")                              \
   20.12    template(char_StringBuffer_signature,               "(C)Ljava/lang/StringBuffer;")                              \
   20.13    template(int_String_signature,                      "(I)Ljava/lang/String;")                                    \
   20.14 +  template(codesource_permissioncollection_signature, "(Ljava/security/CodeSource;Ljava/security/PermissionCollection;)V") \
   20.15    /* signature symbols needed by intrinsics */                                                                    \
   20.16    VM_INTRINSICS_DO(VM_INTRINSIC_IGNORE, VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, template, VM_ALIAS_IGNORE)            \
   20.17                                                                                                                    \
    21.1 --- a/src/share/vm/code/compiledIC.hpp	Tue Aug 09 13:21:40 2016 -0700
    21.2 +++ b/src/share/vm/code/compiledIC.hpp	Tue Aug 09 13:24:03 2016 -0700
    21.3 @@ -320,7 +320,7 @@
    21.4    friend CompiledStaticCall* compiledStaticCall_at(Relocation* call_site);
    21.5  
    21.6    // Code
    21.7 -  static void emit_to_interp_stub(CodeBuffer &cbuf);
    21.8 +  static address emit_to_interp_stub(CodeBuffer &cbuf);
    21.9    static int to_interp_stub_size();
   21.10    static int reloc_to_interp_stub();
   21.11  
    22.1 --- a/src/share/vm/gc_implementation/g1/g1RemSetSummary.cpp	Tue Aug 09 13:21:40 2016 -0700
    22.2 +++ b/src/share/vm/gc_implementation/g1/g1RemSetSummary.cpp	Tue Aug 09 13:24:03 2016 -0700
    22.3 @@ -1,5 +1,5 @@
    22.4  /*
    22.5 - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    22.6 + * Copyright (c) 2013, 2016 Oracle and/or its affiliates. All rights reserved.
    22.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    22.8   *
    22.9   * This code is free software; you can redistribute it and/or modify it
   22.10 @@ -133,10 +133,6 @@
   22.11    }
   22.12  }
   22.13  
   22.14 -static size_t round_to_K(size_t value) {
   22.15 -  return value / K;
   22.16 -}
   22.17 -
   22.18  class RegionTypeCounter VALUE_OBJ_CLASS_SPEC {
   22.19  private:
   22.20    const char* _name;
   22.21 @@ -187,8 +183,10 @@
   22.22    size_t code_root_elems() const { return _code_root_elems; }
   22.23  
   22.24    void print_rs_mem_info_on(outputStream * out, size_t total) {
   22.25 -    out->print_cr("    "SIZE_FORMAT_W(8)"K (%5.1f%%) by "SIZE_FORMAT" %s regions",
   22.26 -        round_to_K(rs_mem_size()), rs_mem_size_percent_of(total), amount(), _name);
   22.27 +    out->print_cr("    "SIZE_FORMAT_W(8) "%s (%5.1f%%) by "SIZE_FORMAT" %s regions",
   22.28 +        byte_size_in_proper_unit(rs_mem_size()),
   22.29 +        proper_unit_for_byte_size(rs_mem_size()),
   22.30 +        rs_mem_size_percent_of(total), amount(), _name);
   22.31    }
   22.32  
   22.33    void print_cards_occupied_info_on(outputStream * out, size_t total) {
   22.34 @@ -197,8 +195,10 @@
   22.35    }
   22.36  
   22.37    void print_code_root_mem_info_on(outputStream * out, size_t total) {
   22.38 -    out->print_cr("    "SIZE_FORMAT_W(8)"K (%5.1f%%) by "SIZE_FORMAT" %s regions",
   22.39 -        round_to_K(code_root_mem_size()), code_root_mem_size_percent_of(total), amount(), _name);
   22.40 +    out->print_cr("    "SIZE_FORMAT_W(8) "%s (%5.1f%%) by "SIZE_FORMAT" %s regions",
   22.41 +        byte_size_in_proper_unit(code_root_mem_size()),
   22.42 +        proper_unit_for_byte_size(code_root_mem_size()),
   22.43 +        code_root_mem_size_percent_of(total), amount(), _name);
   22.44    }
   22.45  
   22.46    void print_code_root_elems_info_on(outputStream * out, size_t total) {
   22.47 @@ -280,17 +280,23 @@
   22.48      RegionTypeCounter* counters[] = { &_young, &_humonguous, &_free, &_old, NULL };
   22.49  
   22.50      out->print_cr("\n Current rem set statistics");
   22.51 -    out->print_cr("  Total per region rem sets sizes = "SIZE_FORMAT"K."
   22.52 -                  " Max = "SIZE_FORMAT"K.",
   22.53 -                  round_to_K(total_rs_mem_sz()), round_to_K(max_rs_mem_sz()));
   22.54 +    out->print_cr("  Total per region rem sets sizes = " SIZE_FORMAT "%s."
   22.55 +                  " Max = " SIZE_FORMAT "%s.",
   22.56 +                  byte_size_in_proper_unit(total_rs_mem_sz()),
   22.57 +                  proper_unit_for_byte_size(total_rs_mem_sz()),
   22.58 +                  byte_size_in_proper_unit(max_rs_mem_sz()),
   22.59 +                  proper_unit_for_byte_size(max_rs_mem_sz()));
   22.60 +
   22.61      for (RegionTypeCounter** current = &counters[0]; *current != NULL; current++) {
   22.62        (*current)->print_rs_mem_info_on(out, total_rs_mem_sz());
   22.63      }
   22.64  
   22.65 -    out->print_cr("   Static structures = "SIZE_FORMAT"K,"
   22.66 -                  " free_lists = "SIZE_FORMAT"K.",
   22.67 -                  round_to_K(HeapRegionRemSet::static_mem_size()),
   22.68 -                  round_to_K(HeapRegionRemSet::fl_mem_size()));
   22.69 +    out->print_cr("   Static structures = " SIZE_FORMAT "%s,"
   22.70 +                  " free_lists = " SIZE_FORMAT "%s.",
   22.71 +                  byte_size_in_proper_unit(HeapRegionRemSet::static_mem_size()),
   22.72 +                  proper_unit_for_byte_size(HeapRegionRemSet::static_mem_size()),
   22.73 +                  byte_size_in_proper_unit(HeapRegionRemSet::fl_mem_size()),
   22.74 +                  proper_unit_for_byte_size(HeapRegionRemSet::fl_mem_size()));
   22.75  
   22.76      out->print_cr("    "SIZE_FORMAT" occupied cards represented.",
   22.77                    total_cards_occupied());
   22.78 @@ -301,17 +307,21 @@
   22.79      // Largest sized rem set region statistics
   22.80      HeapRegionRemSet* rem_set = max_rs_mem_sz_region()->rem_set();
   22.81      out->print_cr("    Region with largest rem set = "HR_FORMAT", "
   22.82 -                  "size = "SIZE_FORMAT "K, occupied = "SIZE_FORMAT"K.",
   22.83 +                  "size = "SIZE_FORMAT "%s, occupied = "SIZE_FORMAT "%s.",
   22.84                    HR_FORMAT_PARAMS(max_rs_mem_sz_region()),
   22.85 -                  round_to_K(rem_set->mem_size()),
   22.86 -                  round_to_K(rem_set->occupied()));
   22.87 -
   22.88 +                  byte_size_in_proper_unit(rem_set->mem_size()),
   22.89 +                  proper_unit_for_byte_size(rem_set->mem_size()),
   22.90 +                  byte_size_in_proper_unit(rem_set->occupied()),
   22.91 +                  proper_unit_for_byte_size(rem_set->occupied()));
   22.92      // Strong code root statistics
   22.93      HeapRegionRemSet* max_code_root_rem_set = max_code_root_mem_sz_region()->rem_set();
   22.94 -    out->print_cr("  Total heap region code root sets sizes = "SIZE_FORMAT"K."
   22.95 -                  "  Max = "SIZE_FORMAT"K.",
   22.96 -                  round_to_K(total_code_root_mem_sz()),
   22.97 -                  round_to_K(max_code_root_rem_set->strong_code_roots_mem_size()));
   22.98 +    out->print_cr("  Total heap region code root sets sizes = " SIZE_FORMAT "%s."
   22.99 +                  "  Max = " SIZE_FORMAT "%s.",
  22.100 +                  byte_size_in_proper_unit(total_code_root_mem_sz()),
  22.101 +                  proper_unit_for_byte_size(total_code_root_mem_sz()),
  22.102 +                  byte_size_in_proper_unit(max_code_root_rem_set->strong_code_roots_mem_size()),
  22.103 +                  proper_unit_for_byte_size(max_code_root_rem_set->strong_code_roots_mem_size()));
  22.104 +
  22.105      for (RegionTypeCounter** current = &counters[0]; *current != NULL; current++) {
  22.106        (*current)->print_code_root_mem_info_on(out, total_code_root_mem_sz());
  22.107      }
  22.108 @@ -323,10 +333,12 @@
  22.109      }
  22.110  
  22.111      out->print_cr("    Region with largest amount of code roots = "HR_FORMAT", "
  22.112 -                  "size = "SIZE_FORMAT "K, num_elems = "SIZE_FORMAT".",
  22.113 +                  "size = "SIZE_FORMAT "%s, num_elems = "SIZE_FORMAT".",
  22.114                    HR_FORMAT_PARAMS(max_code_root_mem_sz_region()),
  22.115 -                  round_to_K(max_code_root_rem_set->strong_code_roots_mem_size()),
  22.116 -                  round_to_K(max_code_root_rem_set->strong_code_roots_list_length()));
  22.117 +                  byte_size_in_proper_unit(max_code_root_rem_set->strong_code_roots_mem_size()),
  22.118 +                  proper_unit_for_byte_size(max_code_root_rem_set->strong_code_roots_mem_size()),
  22.119 +                  max_code_root_rem_set->strong_code_roots_list_length());
  22.120 +
  22.121    }
  22.122  };
  22.123  
    23.1 --- a/src/share/vm/gc_implementation/g1/g1StringDedupTable.cpp	Tue Aug 09 13:21:40 2016 -0700
    23.2 +++ b/src/share/vm/gc_implementation/g1/g1StringDedupTable.cpp	Tue Aug 09 13:24:03 2016 -0700
    23.3 @@ -1,5 +1,5 @@
    23.4  /*
    23.5 - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    23.6 + * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
    23.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    23.8   *
    23.9   * This code is free software; you can redistribute it and/or modify it
   23.10 @@ -28,22 +28,23 @@
   23.11  #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
   23.12  #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"
   23.13  #include "gc_implementation/g1/g1StringDedupTable.hpp"
   23.14 +#include "gc_implementation/shared/concurrentGCThread.hpp"
   23.15  #include "memory/gcLocker.hpp"
   23.16  #include "memory/padded.inline.hpp"
   23.17  #include "oops/typeArrayOop.hpp"
   23.18  #include "runtime/mutexLocker.hpp"
   23.19  
   23.20  //
   23.21 -// Freelist in the deduplication table entry cache. Links table
   23.22 +// List of deduplication table entries. Links table
   23.23  // entries together using their _next fields.
   23.24  //
   23.25 -class G1StringDedupEntryFreeList : public CHeapObj<mtGC> {
   23.26 +class G1StringDedupEntryList : public CHeapObj<mtGC> {
   23.27  private:
   23.28    G1StringDedupEntry* _list;
   23.29    size_t              _length;
   23.30  
   23.31  public:
   23.32 -  G1StringDedupEntryFreeList() :
   23.33 +  G1StringDedupEntryList() :
   23.34      _list(NULL),
   23.35      _length(0) {
   23.36    }
   23.37 @@ -63,6 +64,12 @@
   23.38      return entry;
   23.39    }
   23.40  
   23.41 +  G1StringDedupEntry* remove_all() {
   23.42 +    G1StringDedupEntry* list = _list;
   23.43 +    _list = NULL;
   23.44 +    return list;
   23.45 +  }
   23.46 +
   23.47    size_t length() {
   23.48      return _length;
   23.49    }
   23.50 @@ -84,43 +91,53 @@
   23.51  //
   23.52  class G1StringDedupEntryCache : public CHeapObj<mtGC> {
   23.53  private:
   23.54 -  // One freelist per GC worker to allow lock less freeing of
   23.55 -  // entries while doing a parallel scan of the table. Using
   23.56 -  // PaddedEnd to avoid false sharing.
   23.57 -  PaddedEnd<G1StringDedupEntryFreeList>* _lists;
   23.58 -  size_t                                 _nlists;
   23.59 +  // One cache/overflow list per GC worker to allow lock less freeing of
   23.60 +  // entries while doing a parallel scan of the table. Using PaddedEnd to
   23.61 +  // avoid false sharing.
   23.62 +  size_t                             _nlists;
   23.63 +  size_t                             _max_list_length;
   23.64 +  PaddedEnd<G1StringDedupEntryList>* _cached;
   23.65 +  PaddedEnd<G1StringDedupEntryList>* _overflowed;
   23.66  
   23.67  public:
   23.68 -  G1StringDedupEntryCache();
   23.69 +  G1StringDedupEntryCache(size_t max_size);
   23.70    ~G1StringDedupEntryCache();
   23.71  
   23.72 -  // Get a table entry from the cache freelist, or allocate a new
   23.73 -  // entry if the cache is empty.
   23.74 +  // Set max number of table entries to cache.
   23.75 +  void set_max_size(size_t max_size);
   23.76 +
   23.77 +  // Get a table entry from the cache, or allocate a new entry if the cache is empty.
   23.78    G1StringDedupEntry* alloc();
   23.79  
   23.80 -  // Insert a table entry into the cache freelist.
   23.81 +  // Insert a table entry into the cache.
   23.82    void free(G1StringDedupEntry* entry, uint worker_id);
   23.83  
   23.84    // Returns current number of entries in the cache.
   23.85    size_t size();
   23.86  
   23.87 -  // If the cache has grown above the given max size, trim it down
   23.88 -  // and deallocate the memory occupied by trimmed of entries.
   23.89 -  void trim(size_t max_size);
   23.90 +  // Deletes overflowed entries.
   23.91 +  void delete_overflowed();
   23.92  };
   23.93  
   23.94 -G1StringDedupEntryCache::G1StringDedupEntryCache() {
   23.95 -  _nlists = MAX2(ParallelGCThreads, (size_t)1);
   23.96 -  _lists = PaddedArray<G1StringDedupEntryFreeList, mtGC>::create_unfreeable((uint)_nlists);
   23.97 +G1StringDedupEntryCache::G1StringDedupEntryCache(size_t max_size) :
   23.98 +  _nlists(MAX2(ParallelGCThreads, (size_t)1)),
   23.99 +  _max_list_length(0),
  23.100 +  _cached(PaddedArray<G1StringDedupEntryList, mtGC>::create_unfreeable((uint)_nlists)),
  23.101 +  _overflowed(PaddedArray<G1StringDedupEntryList, mtGC>::create_unfreeable((uint)_nlists)) {
  23.102 +  set_max_size(max_size);
  23.103  }
  23.104  
  23.105  G1StringDedupEntryCache::~G1StringDedupEntryCache() {
  23.106    ShouldNotReachHere();
  23.107  }
  23.108  
  23.109 +void G1StringDedupEntryCache::set_max_size(size_t size) {
  23.110 +  _max_list_length = size / _nlists;
  23.111 +}
  23.112 +
  23.113  G1StringDedupEntry* G1StringDedupEntryCache::alloc() {
  23.114    for (size_t i = 0; i < _nlists; i++) {
  23.115 -    G1StringDedupEntry* entry = _lists[i].remove();
  23.116 +    G1StringDedupEntry* entry = _cached[i].remove();
  23.117      if (entry != NULL) {
  23.118        return entry;
  23.119      }
  23.120 @@ -131,31 +148,55 @@
  23.121  void G1StringDedupEntryCache::free(G1StringDedupEntry* entry, uint worker_id) {
  23.122    assert(entry->obj() != NULL, "Double free");
  23.123    assert(worker_id < _nlists, "Invalid worker id");
  23.124 +
  23.125    entry->set_obj(NULL);
  23.126    entry->set_hash(0);
  23.127 -  _lists[worker_id].add(entry);
  23.128 +
  23.129 +  if (_cached[worker_id].length() < _max_list_length) {
  23.130 +    // Cache is not full
  23.131 +    _cached[worker_id].add(entry);
  23.132 +  } else {
  23.133 +    // Cache is full, add to overflow list for later deletion
  23.134 +    _overflowed[worker_id].add(entry);
  23.135 +  }
  23.136  }
  23.137  
  23.138  size_t G1StringDedupEntryCache::size() {
  23.139    size_t size = 0;
  23.140    for (size_t i = 0; i < _nlists; i++) {
  23.141 -    size += _lists[i].length();
  23.142 +    size += _cached[i].length();
  23.143    }
  23.144    return size;
  23.145  }
  23.146  
  23.147 -void G1StringDedupEntryCache::trim(size_t max_size) {
  23.148 -  size_t cache_size = 0;
  23.149 +void G1StringDedupEntryCache::delete_overflowed() {
  23.150 +  double start = os::elapsedTime();
  23.151 +  uintx count = 0;
  23.152 +
  23.153    for (size_t i = 0; i < _nlists; i++) {
  23.154 -    G1StringDedupEntryFreeList* list = &_lists[i];
  23.155 -    cache_size += list->length();
  23.156 -    while (cache_size > max_size) {
  23.157 -      G1StringDedupEntry* entry = list->remove();
  23.158 -      assert(entry != NULL, "Should not be null");
  23.159 -      cache_size--;
  23.160 +    G1StringDedupEntry* entry;
  23.161 +
  23.162 +    {
  23.163 +      // The overflow list can be modified during safepoints, therefore
  23.164 +      // we temporarily join the suspendible thread set while removing
  23.165 +      // all entries from the list.
  23.166 +      SuspendibleThreadSetJoiner sts_join;
  23.167 +      entry = _overflowed[i].remove_all();
  23.168 +    }
  23.169 +
  23.170 +    // Delete all entries
  23.171 +    while (entry != NULL) {
  23.172 +      G1StringDedupEntry* next = entry->next();
  23.173        delete entry;
  23.174 +      entry = next;
  23.175 +      count++;
  23.176      }
  23.177    }
  23.178 +
  23.179 +  double end = os::elapsedTime();
  23.180 +  if (PrintStringDeduplicationStatistics) {
  23.181 +    gclog_or_tty->print_cr("[GC concurrent-string-deduplication, deleted " UINTX_FORMAT " entries, " G1_STRDEDUP_TIME_FORMAT "]", count, end - start);
  23.182 +  }
  23.183  }
  23.184  
  23.185  G1StringDedupTable*      G1StringDedupTable::_table = NULL;
  23.186 @@ -192,7 +233,7 @@
  23.187  
  23.188  void G1StringDedupTable::create() {
  23.189    assert(_table == NULL, "One string deduplication table allowed");
  23.190 -  _entry_cache = new G1StringDedupEntryCache();
  23.191 +  _entry_cache = new G1StringDedupEntryCache((size_t)(_min_size * _max_cache_factor));
  23.192    _table = new G1StringDedupTable(_min_size);
  23.193  }
  23.194  
  23.195 @@ -375,6 +416,9 @@
  23.196    // Update statistics
  23.197    _resize_count++;
  23.198  
  23.199 +  // Update max cache size
  23.200 +  _entry_cache->set_max_size((size_t)(size * _max_cache_factor));
  23.201 +
  23.202    // Allocate the new table. The new table will be populated by workers
  23.203    // calling unlink_or_oops_do() and finally installed by finish_resize().
  23.204    return new G1StringDedupTable(size, _table->_hash_seed);
  23.205 @@ -427,7 +471,7 @@
  23.206      removed += unlink_or_oops_do(cl, table_half + partition_begin, table_half + partition_end, worker_id);
  23.207    }
  23.208  
  23.209 -  // Delayed update avoid contention on the table lock
  23.210 +  // Delayed update to avoid contention on the table lock
  23.211    if (removed > 0) {
  23.212      MutexLockerEx ml(StringDedupTable_lock, Mutex::_no_safepoint_check_flag);
  23.213      _table->_entries -= removed;
  23.214 @@ -545,10 +589,8 @@
  23.215    }
  23.216  }
  23.217  
  23.218 -void G1StringDedupTable::trim_entry_cache() {
  23.219 -  MutexLockerEx ml(StringDedupTable_lock, Mutex::_no_safepoint_check_flag);
  23.220 -  size_t max_cache_size = (size_t)(_table->_size * _max_cache_factor);
  23.221 -  _entry_cache->trim(max_cache_size);
  23.222 +void G1StringDedupTable::clean_entry_cache() {
  23.223 +  _entry_cache->delete_overflowed();
  23.224  }
  23.225  
  23.226  void G1StringDedupTable::print_statistics(outputStream* st) {
    24.1 --- a/src/share/vm/gc_implementation/g1/g1StringDedupTable.hpp	Tue Aug 09 13:21:40 2016 -0700
    24.2 +++ b/src/share/vm/gc_implementation/g1/g1StringDedupTable.hpp	Tue Aug 09 13:24:03 2016 -0700
    24.3 @@ -1,5 +1,5 @@
    24.4  /*
    24.5 - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    24.6 + * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
    24.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    24.8   *
    24.9   * This code is free software; you can redistribute it and/or modify it
   24.10 @@ -218,8 +218,8 @@
   24.11    // and deletes the previously active table.
   24.12    static void finish_rehash(G1StringDedupTable* rehashed_table);
   24.13  
   24.14 -  // If the table entry cache has grown too large, trim it down according to policy
   24.15 -  static void trim_entry_cache();
   24.16 +  // If the table entry cache has grown too large, delete overflowed entries.
   24.17 +  static void clean_entry_cache();
   24.18  
   24.19    static void unlink_or_oops_do(G1StringDedupUnlinkOrOopsDoClosure* cl, uint worker_id);
   24.20  
    25.1 --- a/src/share/vm/gc_implementation/g1/g1StringDedupThread.cpp	Tue Aug 09 13:21:40 2016 -0700
    25.2 +++ b/src/share/vm/gc_implementation/g1/g1StringDedupThread.cpp	Tue Aug 09 13:24:03 2016 -0700
    25.3 @@ -100,14 +100,14 @@
    25.4          }
    25.5        }
    25.6  
    25.7 -      G1StringDedupTable::trim_entry_cache();
    25.8 -
    25.9        stat.mark_done();
   25.10  
   25.11        // Print statistics
   25.12        total_stat.add(stat);
   25.13        print(gclog_or_tty, stat, total_stat);
   25.14      }
   25.15 +
   25.16 +    G1StringDedupTable::clean_entry_cache();
   25.17    }
   25.18  
   25.19    terminate();
    26.1 --- a/src/share/vm/interpreter/bytecodeInterpreter.cpp	Tue Aug 09 13:21:40 2016 -0700
    26.2 +++ b/src/share/vm/interpreter/bytecodeInterpreter.cpp	Tue Aug 09 13:24:03 2016 -0700
    26.3 @@ -593,8 +593,9 @@
    26.4  /* 0xDC */ &&opc_default,     &&opc_default,        &&opc_default,      &&opc_default,
    26.5  
    26.6  /* 0xE0 */ &&opc_default,     &&opc_default,        &&opc_default,      &&opc_default,
    26.7 -/* 0xE4 */ &&opc_default,     &&opc_fast_aldc,      &&opc_fast_aldc_w,  &&opc_return_register_finalizer,
    26.8 -/* 0xE8 */ &&opc_invokehandle,&&opc_default,        &&opc_default,      &&opc_default,
    26.9 +/* 0xE4 */ &&opc_default,     &&opc_default,        &&opc_fast_aldc,    &&opc_fast_aldc_w,
   26.10 +/* 0xE8 */ &&opc_return_register_finalizer,
   26.11 +                              &&opc_invokehandle,   &&opc_default,      &&opc_default,
   26.12  /* 0xEC */ &&opc_default,     &&opc_default,        &&opc_default,      &&opc_default,
   26.13  
   26.14  /* 0xF0 */ &&opc_default,     &&opc_default,        &&opc_default,      &&opc_default,
    27.1 --- a/src/share/vm/oops/method.cpp	Tue Aug 09 13:21:40 2016 -0700
    27.2 +++ b/src/share/vm/oops/method.cpp	Tue Aug 09 13:24:03 2016 -0700
    27.3 @@ -1806,7 +1806,7 @@
    27.4    void clear_all_methods() {
    27.5      for (JNIMethodBlock* b = this; b != NULL; b = b->_next) {
    27.6        for (int i = 0; i< number_of_methods; i++) {
    27.7 -        _methods[i] = NULL;
    27.8 +        b->_methods[i] = NULL;
    27.9        }
   27.10      }
   27.11    }
   27.12 @@ -1816,7 +1816,7 @@
   27.13      int count = 0;
   27.14      for (JNIMethodBlock* b = this; b != NULL; b = b->_next) {
   27.15        for (int i = 0; i< number_of_methods; i++) {
   27.16 -        if (_methods[i] != _free_method) count++;
   27.17 +        if (b->_methods[i] != _free_method) count++;
   27.18        }
   27.19      }
   27.20      return count;
   27.21 @@ -1874,6 +1874,9 @@
   27.22    Method* m = resolve_jmethod_id(mid);
   27.23    assert(m != NULL, "should be called with non-null method");
   27.24    InstanceKlass* ik = m->method_holder();
   27.25 +  if (ik == NULL) {
   27.26 +    return false;
   27.27 +  }
   27.28    ClassLoaderData* cld = ik->class_loader_data();
   27.29    if (cld->jmethod_ids() == NULL) return false;
   27.30    return (cld->jmethod_ids()->contains((Method**)mid));
   27.31 @@ -1881,6 +1884,9 @@
   27.32  
   27.33  Method* Method::checked_resolve_jmethod_id(jmethodID mid) {
   27.34    if (mid == NULL) return NULL;
   27.35 +  if (!Method::is_method_id(mid)) {
   27.36 +    return NULL;
   27.37 +  }
   27.38    Method* o = resolve_jmethod_id(mid);
   27.39    if (o == NULL || o == JNIMethodBlock::_free_method || !((Metadata*)o)->is_method()) {
   27.40      return NULL;
    28.1 --- a/src/share/vm/opto/compile.cpp	Tue Aug 09 13:21:40 2016 -0700
    28.2 +++ b/src/share/vm/opto/compile.cpp	Tue Aug 09 13:24:03 2016 -0700
    28.3 @@ -608,6 +608,10 @@
    28.4      n->as_MachBranch()->label_set(&fakeL, 0);
    28.5    }
    28.6    n->emit(buf, this->regalloc());
    28.7 +
    28.8 +  // Emitting into the scratch buffer should not fail
    28.9 +  assert (!failing(), err_msg_res("Must not have pending failure. Reason is: %s", failure_reason()));
   28.10 +
   28.11    if (is_branch) // Restore label.
   28.12      n->as_MachBranch()->label_set(saveL, save_bnum);
   28.13  
    29.1 --- a/src/share/vm/opto/connode.cpp	Tue Aug 09 13:21:40 2016 -0700
    29.2 +++ b/src/share/vm/opto/connode.cpp	Tue Aug 09 13:24:03 2016 -0700
    29.3 @@ -446,7 +446,9 @@
    29.4  }
    29.5  
    29.6  uint CastIINode::cmp(const Node &n) const {
    29.7 -  return TypeNode::cmp(n) && ((CastIINode&)n)._carry_dependency == _carry_dependency;
    29.8 +  return TypeNode::cmp(n) &&
    29.9 +         ((CastIINode&)n)._carry_dependency == _carry_dependency &&
   29.10 +         ((CastIINode&)n)._range_check_dependency == _range_check_dependency;
   29.11  }
   29.12  
   29.13  Node *CastIINode::Identity(PhaseTransform *phase) {
   29.14 @@ -523,7 +525,7 @@
   29.15  }
   29.16  
   29.17  Node *CastIINode::Ideal_DU_postCCP(PhaseCCP *ccp) {
   29.18 -  if (_carry_dependency) {
   29.19 +  if (_carry_dependency || _range_check_dependency) {
   29.20      return NULL;
   29.21    }
   29.22    return ConstraintCastNode::Ideal_DU_postCCP(ccp);
    30.1 --- a/src/share/vm/opto/output.cpp	Tue Aug 09 13:21:40 2016 -0700
    30.2 +++ b/src/share/vm/opto/output.cpp	Tue Aug 09 13:24:03 2016 -0700
    30.3 @@ -1502,6 +1502,13 @@
    30.4        n->emit(*cb, _regalloc);
    30.5        current_offset  = cb->insts_size();
    30.6  
    30.7 +      // Above we only verified that there is enough space in the instruction section.
    30.8 +      // However, the instruction may emit stubs that cause code buffer expansion.
    30.9 +      // Bail out here if expansion failed due to a lack of code cache space.
   30.10 +      if (failing()) {
   30.11 +        return;
   30.12 +      }
   30.13 +
   30.14  #ifdef ASSERT
   30.15        if (n->size(_regalloc) < (current_offset-instr_offset)) {
   30.16          n->dump();
   30.17 @@ -1630,11 +1637,14 @@
   30.18    if (_method) {
   30.19      // Emit the exception handler code.
   30.20      _code_offsets.set_value(CodeOffsets::Exceptions, HandlerImpl::emit_exception_handler(*cb));
   30.21 +    if (failing()) {
   30.22 +      return; // CodeBuffer::expand failed
   30.23 +    }
   30.24      // Emit the deopt handler code.
   30.25      _code_offsets.set_value(CodeOffsets::Deopt, HandlerImpl::emit_deopt_handler(*cb));
   30.26  
   30.27      // Emit the MethodHandle deopt handler code (if required).
   30.28 -    if (has_method_handle_invokes()) {
   30.29 +    if (has_method_handle_invokes() && !failing()) {
   30.30        // We can use the same code as for the normal deopt handler, we
   30.31        // just need a different entry point address.
   30.32        _code_offsets.set_value(CodeOffsets::DeoptMH, HandlerImpl::emit_deopt_handler(*cb));
    31.1 --- a/src/share/vm/opto/stringopts.cpp	Tue Aug 09 13:21:40 2016 -0700
    31.2 +++ b/src/share/vm/opto/stringopts.cpp	Tue Aug 09 13:24:03 2016 -0700
    31.3 @@ -1641,16 +1641,11 @@
    31.4      }
    31.5      kit.store_String_value(kit.control(), result, char_array);
    31.6  
    31.7 -    // Do not let stores that initialize this object be reordered with
    31.8 -    // a subsequent store that would make this object accessible by
    31.9 -    // other threads.
   31.10 -    // Record what AllocateNode this StoreStore protects so that
   31.11 -    // escape analysis can go from the MemBarStoreStoreNode to the
   31.12 -    // AllocateNode and eliminate the MemBarStoreStoreNode if possible
   31.13 -    // based on the escape status of the AllocateNode.
   31.14 -    AllocateNode* alloc = AllocateNode::Ideal_allocation(result, _gvn);
   31.15 -    assert(alloc != NULL, "should be newly allocated");
   31.16 -    kit.insert_mem_bar(Op_MemBarStoreStore, alloc->proj_out(AllocateNode::RawAddress));
   31.17 +    // The value field is final. Emit a barrier here to ensure that the effect
   31.18 +    // of the initialization is committed to memory before any code publishes
   31.19 +    // a reference to the newly constructed object (see Parse::do_exits()).
   31.20 +    assert(AllocateNode::Ideal_allocation(result, _gvn) != NULL, "should be newly allocated");
   31.21 +    kit.insert_mem_bar(Op_MemBarRelease, result);
   31.22    } else {
   31.23      result = C->top();
   31.24    }
    32.1 --- a/src/share/vm/opto/subnode.cpp	Tue Aug 09 13:21:40 2016 -0700
    32.2 +++ b/src/share/vm/opto/subnode.cpp	Tue Aug 09 13:24:03 2016 -0700
    32.3 @@ -547,8 +547,12 @@
    32.4      // All unsigned values are LE -1 and GE 0.
    32.5      if (lo0 == 0 && hi0 == 0) {
    32.6        return TypeInt::CC_LE;            //   0 <= bot
    32.7 +    } else if ((jint)lo0 == -1 && (jint)hi0 == -1) {
    32.8 +      return TypeInt::CC_GE;            // -1 >= bot
    32.9      } else if (lo1 == 0 && hi1 == 0) {
   32.10        return TypeInt::CC_GE;            // bot >= 0
   32.11 +    } else if ((jint)lo1 == -1 && (jint)hi1 == -1) {
   32.12 +      return TypeInt::CC_LE;            // bot <= -1
   32.13      }
   32.14    } else {
   32.15      // We can use ranges of the form [lo..hi] if signs are the same.
    33.1 --- a/src/share/vm/prims/jniCheck.cpp	Tue Aug 09 13:21:40 2016 -0700
    33.2 +++ b/src/share/vm/prims/jniCheck.cpp	Tue Aug 09 13:24:03 2016 -0700
    33.3 @@ -461,16 +461,11 @@
    33.4  
    33.5  Method* jniCheck::validate_jmethod_id(JavaThread* thr, jmethodID method_id) {
    33.6    ASSERT_OOPS_ALLOWED;
    33.7 -  // do the fast jmethodID check first
    33.8 +  // Do the jmethodID check
    33.9    Method* moop = Method::checked_resolve_jmethod_id(method_id);
   33.10    if (moop == NULL) {
   33.11      ReportJNIFatalError(thr, fatal_wrong_class_or_method);
   33.12    }
   33.13 -  // jmethodIDs are supposed to be weak handles in the class loader data,
   33.14 -  // but that can be expensive so check it last
   33.15 -  else if (!Method::is_method_id(method_id)) {
   33.16 -    ReportJNIFatalError(thr, fatal_non_weak_method);
   33.17 -  }
   33.18    return moop;
   33.19  }
   33.20  
    34.1 --- a/src/share/vm/prims/jvm.cpp	Tue Aug 09 13:21:40 2016 -0700
    34.2 +++ b/src/share/vm/prims/jvm.cpp	Tue Aug 09 13:24:03 2016 -0700
    34.3 @@ -1290,18 +1290,22 @@
    34.4  // and null permissions - which gives no permissions.
    34.5  oop create_dummy_access_control_context(TRAPS) {
    34.6    InstanceKlass* pd_klass = InstanceKlass::cast(SystemDictionary::ProtectionDomain_klass());
    34.7 -  // new ProtectionDomain(null,null);
    34.8 -  oop null_protection_domain = pd_klass->allocate_instance(CHECK_NULL);
    34.9 -  Handle null_pd(THREAD, null_protection_domain);
   34.10 +  Handle obj = pd_klass->allocate_instance_handle(CHECK_NULL);
   34.11 +  // Call constructor ProtectionDomain(null, null);
   34.12 +  JavaValue result(T_VOID);
   34.13 +  JavaCalls::call_special(&result, obj, KlassHandle(THREAD, pd_klass),
   34.14 +                          vmSymbols::object_initializer_name(),
   34.15 +                          vmSymbols::codesource_permissioncollection_signature(),
   34.16 +                          Handle(), Handle(), CHECK_NULL);
   34.17  
   34.18    // new ProtectionDomain[] {pd};
   34.19    objArrayOop context = oopFactory::new_objArray(pd_klass, 1, CHECK_NULL);
   34.20 -  context->obj_at_put(0, null_pd());
   34.21 +  context->obj_at_put(0, obj());
   34.22  
   34.23    // new AccessControlContext(new ProtectionDomain[] {pd})
   34.24    objArrayHandle h_context(THREAD, context);
   34.25 -  oop result = java_security_AccessControlContext::create(h_context, false, Handle(), CHECK_NULL);
   34.26 -  return result;
   34.27 +  oop acc = java_security_AccessControlContext::create(h_context, false, Handle(), CHECK_NULL);
   34.28 +  return acc;
   34.29  }
   34.30  
   34.31  JVM_ENTRY(jobject, JVM_DoPrivileged(JNIEnv *env, jclass cls, jobject action, jobject context, jboolean wrapException))
    35.1 --- a/test/compiler/jsr292/VMAnonymousClasses.java	Tue Aug 09 13:21:40 2016 -0700
    35.2 +++ b/test/compiler/jsr292/VMAnonymousClasses.java	Tue Aug 09 13:24:03 2016 -0700
    35.3 @@ -24,7 +24,7 @@
    35.4  /**
    35.5   * @test
    35.6   * @bug 8058828
    35.7 - * @run main/bootclasspath -Xbatch VMAnonymousClasses
    35.8 + * @run main/bootclasspath/othervm -Xbatch VMAnonymousClasses
    35.9   */
   35.10  
   35.11  import jdk.internal.org.objectweb.asm.ClassWriter;
    36.1 --- a/test/compiler/native/TestDirtyInt.sh	Tue Aug 09 13:21:40 2016 -0700
    36.2 +++ b/test/compiler/native/TestDirtyInt.sh	Tue Aug 09 13:24:03 2016 -0700
    36.3 @@ -30,20 +30,19 @@
    36.4  ## @run shell/timeout=30 TestDirtyInt.sh
    36.5  ##
    36.6  
    36.7 -if [ "${TESTSRC}" = "" ]
    36.8 -then
    36.9 -  TESTSRC=${PWD}
   36.10 -  echo "TESTSRC not set.  Using "${TESTSRC}" as default"
   36.11 +if [ -z "${TESTSRC}" ]; then
   36.12 +    TESTSRC="${PWD}"
   36.13 +    echo "TESTSRC not set.  Using "${TESTSRC}" as default"
   36.14  fi
   36.15  echo "TESTSRC=${TESTSRC}"
   36.16  ## Adding common setup Variables for running shell tests.
   36.17  . ${TESTSRC}/../../test_env.sh
   36.18  
   36.19  # set platform-dependent variables
   36.20 -if [ $VM_OS == "linux" -a $VM_CPU == "sparcv9" ]; then
   36.21 +if [ "$VM_OS" = "linux" -a "$VM_CPU" = "sparcv9" ]; then
   36.22      echo "Testing on linux-sparc"
   36.23      gcc_cmd=`which gcc`
   36.24 -    if [ "x$gcc_cmd" == "x" ]; then
   36.25 +    if [ -z "$gcc_cmd" ]; then
   36.26          echo "WARNING: gcc not found. Cannot execute test." 2>&1
   36.27          exit 0;
   36.28      fi
   36.29 @@ -68,10 +67,9 @@
   36.30      -Djava.library.path=${TESTSRC}${FS} TestDirtyInt"
   36.31  
   36.32  echo "$cmd"
   36.33 -eval $cmd 
   36.34 +eval $cmd
   36.35  
   36.36 -if [ $? = 0 ]
   36.37 -then
   36.38 +if [ $? = 0 ]; then
   36.39      echo "Test Passed"
   36.40      exit 0
   36.41  fi
    37.1 --- a/test/compiler/stringopts/TestStringObjectInitialization.java	Tue Aug 09 13:21:40 2016 -0700
    37.2 +++ b/test/compiler/stringopts/TestStringObjectInitialization.java	Tue Aug 09 13:24:03 2016 -0700
    37.3 @@ -27,6 +27,7 @@
    37.4  /*
    37.5   * @test
    37.6   * @bug 8159244
    37.7 + * @requires vm.gc == "Parallel" | vm.gc == "null"
    37.8   * @summary Verifies that no partially initialized String object escapes from
    37.9   *          C2's String concat optimization in a highly concurrent setting.
   37.10   *          This test triggers the bug in about 1 out of 10 runs.
    38.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    38.2 +++ b/test/runtime/classFileParserBug/BadNameAndType.java	Tue Aug 09 13:24:03 2016 -0700
    38.3 @@ -0,0 +1,57 @@
    38.4 +/*
    38.5 + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
    38.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    38.7 + *
    38.8 + * This code is free software; you can redistribute it and/or modify it
    38.9 + * under the terms of the GNU General Public License version 2 only, as
   38.10 + * published by the Free Software Foundation.
   38.11 + *
   38.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   38.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   38.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   38.15 + * version 2 for more details (a copy is included in the LICENSE file that
   38.16 + * accompanied this code).
   38.17 + *
   38.18 + * You should have received a copy of the GNU General Public License version
   38.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   38.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   38.21 + *
   38.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   38.23 + * or visit www.oracle.com if you need additional information or have any
   38.24 + * questions.
   38.25 + *
   38.26 + */
   38.27 +
   38.28 +/*
   38.29 + * @test
   38.30 + * @bug 8042660
   38.31 + * @summary Constant pool NameAndType entries must point to non-zero length Utf8 strings
   38.32 + * @compile emptySigUtf8.jcod
   38.33 + * @compile emptyNameUtf8.jcod
   38.34 + * @run main/othervm -Xverify:all BadNameAndType
   38.35 + */
   38.36 +
   38.37 +// Test that a constant pool NameAndType descriptor_index and/or name_index
   38.38 +// that points to a zero length Utf8 string causes a ClassFormatError.
   38.39 +public class BadNameAndType {
   38.40 +    public static void main(String args[]) throws Throwable {
   38.41 +
   38.42 +        System.out.println("Regression test for bug 8042660");
   38.43 +
   38.44 +        // Test descriptor_index pointing to zero-length string.
   38.45 +        try {
   38.46 +            Class newClass = Class.forName("emptySigUtf8");
   38.47 +            throw new RuntimeException("Expected ClassFormatError exception not thrown");
   38.48 +        } catch (java.lang.ClassFormatError e) {
   38.49 +            System.out.println("Test BadNameAndType passed test case emptySigUtf8");
   38.50 +        }
   38.51 +
   38.52 +        // Test name_index pointing to zero-length string.
   38.53 +        try {
   38.54 +            Class newClass = Class.forName("emptyNameUtf8");
   38.55 +            throw new RuntimeException("Expected ClassFormatError exception not thrown");
   38.56 +        } catch (java.lang.ClassFormatError e) {
   38.57 +            System.out.println("Test BadNameAndType passed test case emptyNameUtf8");
   38.58 +        }
   38.59 +    }
   38.60 +}
    39.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    39.2 +++ b/test/runtime/classFileParserBug/emptyNameUtf8.jcod	Tue Aug 09 13:24:03 2016 -0700
    39.3 @@ -0,0 +1,131 @@
    39.4 +/*
    39.5 + * Copyright (c) 2016, 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 +// This class has an illegal NameAndType at constant pool #4.  It's illegal because
   39.29 +// the Utf8 that it points to at #27 is a zero length string which is not a valid
   39.30 +// name.  Loading this class should cause a ClassFormatError exception.
   39.31 +class emptyNameUtf8 {
   39.32 +  0xCAFEBABE;
   39.33 +  0; // minor version
   39.34 +  52; // version
   39.35 +  [29] { // Constant Pool
   39.36 +    ; // first element is empty
   39.37 +    Method #6 #15; // #1     at 0x0A
   39.38 +    Field #16 #17; // #2     at 0x0F
   39.39 +    String #18; // #3     at 0x14
   39.40 +    NameAndType #27 #28; // #4     at 0x9F
   39.41 +    class #21; // #5     at 0x1C
   39.42 +    class #22; // #6     at 0x1F
   39.43 +    Utf8 "<init>"; // #7     at 0x22
   39.44 +    Utf8 "()V"; // #8     at 0x2B
   39.45 +    Utf8 "Code"; // #9     at 0x2E
   39.46 +    Utf8 "LineNumberTable"; // #10     at 0x35
   39.47 +    Utf8 "main"; // #11     at 0x47
   39.48 +    Utf8 "([Ljava/lang/String;)V"; // #12     at 0x4E
   39.49 +    Utf8 "SourceFile"; // #13     at 0x67
   39.50 +    Utf8 "emptyNameUtf8.java"; // #14     at 0x74
   39.51 +    NameAndType #7 #8; // #15     at 0x81
   39.52 +    class #23; // #16     at 0x86
   39.53 +    NameAndType #24 #25; // #17     at 0x89
   39.54 +    Utf8 "Hello World"; // #18     at 0x8E
   39.55 +    class #26; // #19     at 0x9C
   39.56 +    Method #19 #4; // #20     at 0x17
   39.57 +    Utf8 "emptyNameUtf8"; // #21     at 0xA4
   39.58 +    Utf8 "java/lang/Object"; // #22     at 0xAC
   39.59 +    Utf8 "java/lang/System"; // #23     at 0xBF
   39.60 +    Utf8 "out"; // #24     at 0xD2
   39.61 +    Utf8 "Ljava/io/PrintStream;"; // #25     at 0xD8
   39.62 +    Utf8 "java/io/PrintStream"; // #26     at 0xF0
   39.63 +    Utf8 ""; // #27     at 0x0106
   39.64 +    Utf8 "()V"; // #28     at 0x0110
   39.65 +  } // Constant Pool
   39.66 +
   39.67 +  0x0021; // access
   39.68 +  #5;// this_cpx
   39.69 +  #6;// super_cpx
   39.70 +
   39.71 +  [0] { // Interfaces
   39.72 +  } // Interfaces
   39.73 +
   39.74 +  [0] { // fields
   39.75 +  } // fields
   39.76 +
   39.77 +  [2] { // methods
   39.78 +    { // Member at 0x0134
   39.79 +      0x0001; // access
   39.80 +      #7; // name_cpx
   39.81 +      #8; // sig_cpx
   39.82 +      [1] { // Attributes
   39.83 +        Attr(#9, 29) { // Code at 0x013C
   39.84 +          1; // max_stack
   39.85 +          1; // max_locals
   39.86 +          Bytes[5]{
   39.87 +            0x2AB70001B1;
   39.88 +          };
   39.89 +          [0] { // Traps
   39.90 +          } // end Traps
   39.91 +          [1] { // Attributes
   39.92 +            Attr(#10, 6) { // LineNumberTable at 0x0153
   39.93 +              [1] { // LineNumberTable
   39.94 +                0  2; //  at 0x015F
   39.95 +              }
   39.96 +            } // end LineNumberTable
   39.97 +          } // Attributes
   39.98 +        } // end Code
   39.99 +      } // Attributes
  39.100 +    } // Member
  39.101 +    ;
  39.102 +    { // Member at 0x015F
  39.103 +      0x0009; // access
  39.104 +      #11; // name_cpx
  39.105 +      #12; // sig_cpx
  39.106 +      [1] { // Attributes
  39.107 +        Attr(#9, 37) { // Code at 0x0167
  39.108 +          2; // max_stack
  39.109 +          1; // max_locals
  39.110 +          Bytes[9]{
  39.111 +            0xB200021203B60004;
  39.112 +            0xB1;
  39.113 +          };
  39.114 +          [0] { // Traps
  39.115 +          } // end Traps
  39.116 +          [1] { // Attributes
  39.117 +            Attr(#10, 10) { // LineNumberTable at 0x0182
  39.118 +              [2] { // LineNumberTable
  39.119 +                0  4; //  at 0x018E
  39.120 +                8  5; //  at 0x0192
  39.121 +              }
  39.122 +            } // end LineNumberTable
  39.123 +          } // Attributes
  39.124 +        } // end Code
  39.125 +      } // Attributes
  39.126 +    } // Member
  39.127 +  } // methods
  39.128 +
  39.129 +  [1] { // Attributes
  39.130 +    Attr(#13, 2) { // SourceFile at 0x0194
  39.131 +      #14;
  39.132 +    } // end SourceFile
  39.133 +  } // Attributes
  39.134 +} // end class emptyNameUtf8
    40.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    40.2 +++ b/test/runtime/classFileParserBug/emptySigUtf8.jcod	Tue Aug 09 13:24:03 2016 -0700
    40.3 @@ -0,0 +1,131 @@
    40.4 +/*
    40.5 + * Copyright (c) 2016, 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 +// This class has an illegal NameAndType at constant pool #4.  It's illegal because
   40.29 +// the type that it points to at #28 is a zero length Utf8 string which is not a
   40.30 +// valid signature.  Loading this class should cause a ClassFormatError exception.
   40.31 +class emptySigUtf8 {
   40.32 +  0xCAFEBABE;
   40.33 +  0; // minor version
   40.34 +  52; // version
   40.35 +  [29] { // Constant Pool
   40.36 +    ; // first element is empty
   40.37 +    Method #6 #15; // #1     at 0x0A
   40.38 +    Field #16 #17; // #2     at 0x0F
   40.39 +    String #18; // #3     at 0x14
   40.40 +    NameAndType #27 #28; // #4     at 0x9F
   40.41 +    class #21; // #5     at 0x1C
   40.42 +    class #22; // #6     at 0x1F
   40.43 +    Utf8 "<init>"; // #7     at 0x22
   40.44 +    Utf8 "()V"; // #8     at 0x2B
   40.45 +    Utf8 "Code"; // #9     at 0x2E
   40.46 +    Utf8 "LineNumberTable"; // #10     at 0x35
   40.47 +    Utf8 "main"; // #11     at 0x47
   40.48 +    Utf8 "([Ljava/lang/String;)V"; // #12     at 0x4E
   40.49 +    Utf8 "SourceFile"; // #13     at 0x67
   40.50 +    Utf8 "emptySigUtf8.java"; // #14     at 0x74
   40.51 +    NameAndType #7 #8; // #15     at 0x81
   40.52 +    class #23; // #16     at 0x86
   40.53 +    NameAndType #24 #25; // #17     at 0x89
   40.54 +    Utf8 "Hello World"; // #18     at 0x8E
   40.55 +    class #26; // #19     at 0x9C
   40.56 +    Method #19 #4; // #20     at 0x17
   40.57 +    Utf8 "emptySigUtf8"; // #21     at 0xA4
   40.58 +    Utf8 "java/lang/Object"; // #22     at 0xAC
   40.59 +    Utf8 "java/lang/System"; // #23     at 0xBF
   40.60 +    Utf8 "out"; // #24     at 0xD2
   40.61 +    Utf8 "Ljava/io/PrintStream;"; // #25     at 0xD8
   40.62 +    Utf8 "java/io/PrintStream"; // #26     at 0xF0
   40.63 +    Utf8 "hi"; // #27     at 0x0106
   40.64 +    Utf8 ""; // #28     at 0x0110
   40.65 +  } // Constant Pool
   40.66 +
   40.67 +  0x0021; // access
   40.68 +  #5;// this_cpx
   40.69 +  #6;// super_cpx
   40.70 +
   40.71 +  [0] { // Interfaces
   40.72 +  } // Interfaces
   40.73 +
   40.74 +  [0] { // fields
   40.75 +  } // fields
   40.76 +
   40.77 +  [2] { // methods
   40.78 +    { // Member at 0x0134
   40.79 +      0x0001; // access
   40.80 +      #7; // name_cpx
   40.81 +      #8; // sig_cpx
   40.82 +      [1] { // Attributes
   40.83 +        Attr(#9, 29) { // Code at 0x013C
   40.84 +          1; // max_stack
   40.85 +          1; // max_locals
   40.86 +          Bytes[5]{
   40.87 +            0x2AB70001B1;
   40.88 +          };
   40.89 +          [0] { // Traps
   40.90 +          } // end Traps
   40.91 +          [1] { // Attributes
   40.92 +            Attr(#10, 6) { // LineNumberTable at 0x0153
   40.93 +              [1] { // LineNumberTable
   40.94 +                0  2; //  at 0x015F
   40.95 +              }
   40.96 +            } // end LineNumberTable
   40.97 +          } // Attributes
   40.98 +        } // end Code
   40.99 +      } // Attributes
  40.100 +    } // Member
  40.101 +    ;
  40.102 +    { // Member at 0x015F
  40.103 +      0x0009; // access
  40.104 +      #11; // name_cpx
  40.105 +      #12; // sig_cpx
  40.106 +      [1] { // Attributes
  40.107 +        Attr(#9, 37) { // Code at 0x0167
  40.108 +          2; // max_stack
  40.109 +          1; // max_locals
  40.110 +          Bytes[9]{
  40.111 +            0xB200021203B60004;
  40.112 +            0xB1;
  40.113 +          };
  40.114 +          [0] { // Traps
  40.115 +          } // end Traps
  40.116 +          [1] { // Attributes
  40.117 +            Attr(#10, 10) { // LineNumberTable at 0x0182
  40.118 +              [2] { // LineNumberTable
  40.119 +                0  4; //  at 0x018E
  40.120 +                8  5; //  at 0x0192
  40.121 +              }
  40.122 +            } // end LineNumberTable
  40.123 +          } // Attributes
  40.124 +        } // end Code
  40.125 +      } // Attributes
  40.126 +    } // Member
  40.127 +  } // methods
  40.128 +
  40.129 +  [1] { // Attributes
  40.130 +    Attr(#13, 2) { // SourceFile at 0x0194
  40.131 +      #14;
  40.132 +    } // end SourceFile
  40.133 +  } // Attributes
  40.134 +} // end class emptySigUtf8
    41.1 --- a/test/testlibrary/com/oracle/java/testlibrary/OutputAnalyzer.java	Tue Aug 09 13:21:40 2016 -0700
    41.2 +++ b/test/testlibrary/com/oracle/java/testlibrary/OutputAnalyzer.java	Tue Aug 09 13:24:03 2016 -0700
    41.3 @@ -24,6 +24,8 @@
    41.4  package com.oracle.java.testlibrary;
    41.5  
    41.6  import java.io.IOException;
    41.7 +import java.util.Arrays;
    41.8 +import java.util.List;
    41.9  import java.util.regex.Matcher;
   41.10  import java.util.regex.Pattern;
   41.11  
   41.12 @@ -69,6 +71,58 @@
   41.13    }
   41.14  
   41.15    /**
   41.16 +   * Verify that the stdout contents of output buffer is empty
   41.17 +   *
   41.18 +   * @throws RuntimeException
   41.19 +   *             If stdout was not empty
   41.20 +   */
   41.21 +  public void stdoutShouldBeEmpty() {
   41.22 +    if (!getStdout().isEmpty()) {
   41.23 +      reportDiagnosticSummary();
   41.24 +      throw new RuntimeException("stdout was not empty");
   41.25 +    }
   41.26 +  }
   41.27 +
   41.28 +  /**
   41.29 +   * Verify that the stderr contents of output buffer is empty
   41.30 +   *
   41.31 +   * @throws RuntimeException
   41.32 +   *             If stderr was not empty
   41.33 +   */
   41.34 +  public void stderrShouldBeEmpty() {
   41.35 +    if (!getStderr().isEmpty()) {
   41.36 +      reportDiagnosticSummary();
   41.37 +      throw new RuntimeException("stderr was not empty");
   41.38 +    }
   41.39 +  }
   41.40 +
   41.41 +  /**
   41.42 +   * Verify that the stdout contents of output buffer is not empty
   41.43 +   *
   41.44 +   * @throws RuntimeException
   41.45 +   *             If stdout was empty
   41.46 +   */
   41.47 +  public void stdoutShouldNotBeEmpty() {
   41.48 +    if (getStdout().isEmpty()) {
   41.49 +      reportDiagnosticSummary();
   41.50 +      throw new RuntimeException("stdout was empty");
   41.51 +    }
   41.52 +  }
   41.53 +
   41.54 +  /**
   41.55 +   * Verify that the stderr contents of output buffer is not empty
   41.56 +   *
   41.57 +   * @throws RuntimeException
   41.58 +   *             If stderr was empty
   41.59 +   */
   41.60 +  public void stderrShouldNotBeEmpty() {
   41.61 +    if (getStderr().isEmpty()) {
   41.62 +      reportDiagnosticSummary();
   41.63 +      throw new RuntimeException("stderr was empty");
   41.64 +    }
   41.65 +  }
   41.66 +
   41.67 +    /**
   41.68     * Verify that the stdout and stderr contents of output buffer contains the string
   41.69     *
   41.70     * @param expectedString String that buffer should contain
   41.71 @@ -365,4 +419,18 @@
   41.72    public int getExitValue() {
   41.73      return exitValue;
   41.74    }
   41.75 +
   41.76 +  /**
   41.77 +   * Get the contents of the output buffer (stdout and stderr) as list of strings.
   41.78 +   * Output will be split by newlines.
   41.79 +   *
   41.80 +   * @return Contents of the output buffer as list of strings
   41.81 +   */
   41.82 +  public List<String> asLines() {
   41.83 +    return asLines(getOutput());
   41.84 +  }
   41.85 +
   41.86 +  private List<String> asLines(String buffer) {
   41.87 +    return Arrays.asList(buffer.split("(\\r\\n|\\n|\\r)"));
   41.88 +  }
   41.89  }
    42.1 --- a/test/testlibrary/com/oracle/java/testlibrary/ProcessTools.java	Tue Aug 09 13:21:40 2016 -0700
    42.2 +++ b/test/testlibrary/com/oracle/java/testlibrary/ProcessTools.java	Tue Aug 09 13:24:03 2016 -0700
    42.3 @@ -187,23 +187,36 @@
    42.4      return executeProcess(pb);
    42.5    }
    42.6  
    42.7 -  /**
    42.8 -   * Executes a process, waits for it to finish and returns the process output.
    42.9 -   * @param pb The ProcessBuilder to execute.
   42.10 -   * @return The output from the process.
   42.11 -   */
   42.12 -  public static OutputAnalyzer executeProcess(ProcessBuilder pb) throws Throwable {
   42.13 -    OutputAnalyzer output = null;
   42.14 -    try {
   42.15 -      output = new OutputAnalyzer(pb.start());
   42.16 -      return output;
   42.17 -    } catch (Throwable t) {
   42.18 -      System.out.println("executeProcess() failed: " + t);
   42.19 -      throw t;
   42.20 -    } finally {
   42.21 -      System.out.println(getProcessLog(pb, output));
   42.22 +    /**
   42.23 +     * Executes a process, waits for it to finish and returns the process output.
   42.24 +     * The process will have exited before this method returns.
   42.25 +     * @param pb The ProcessBuilder to execute.
   42.26 +     * @return The {@linkplain OutputAnalyzer} instance wrapping the process.
   42.27 +     */
   42.28 +    public static OutputAnalyzer executeProcess(ProcessBuilder pb) throws Exception {
   42.29 +        OutputAnalyzer output = null;
   42.30 +        Process p = null;
   42.31 +        boolean failed = false;
   42.32 +        try {
   42.33 +            p = pb.start();
   42.34 +            output = new OutputAnalyzer(p);
   42.35 +            p.waitFor();
   42.36 +
   42.37 +            return output;
   42.38 +        } catch (Throwable t) {
   42.39 +            if (p != null) {
   42.40 +                p.destroyForcibly().waitFor();
   42.41 +            }
   42.42 +
   42.43 +            failed = true;
   42.44 +            System.out.println("executeProcess() failed: " + t);
   42.45 +            throw t;
   42.46 +        } finally {
   42.47 +            if (failed) {
   42.48 +                System.err.println(getProcessLog(pb, output));
   42.49 +            }
   42.50 +        }
   42.51      }
   42.52 -  }
   42.53  
   42.54    /**
   42.55     * Executes a process, waits for it to finish and returns the process output.
    43.1 --- a/test/testlibrary_tests/whitebox/vm_flags/UintxTest.java	Tue Aug 09 13:21:40 2016 -0700
    43.2 +++ b/test/testlibrary_tests/whitebox/vm_flags/UintxTest.java	Tue Aug 09 13:24:03 2016 -0700
    43.3 @@ -34,7 +34,7 @@
    43.4  import com.oracle.java.testlibrary.Platform;
    43.5  
    43.6  public class UintxTest {
    43.7 -    private static final String FLAG_NAME = "TypeProfileLevel";
    43.8 +    private static final String FLAG_NAME = "VerifyGCStartAt";
    43.9      private static final Long[] TESTS = {0L, 100L, (long) Integer.MAX_VALUE,
   43.10          (1L << 32L) - 1L, 1L << 32L};
   43.11      private static final Long[] EXPECTED_64 = TESTS;
    44.1 --- a/test/testlibrary_tests/whitebox/vm_flags/VmFlagTest.java	Tue Aug 09 13:21:40 2016 -0700
    44.2 +++ b/test/testlibrary_tests/whitebox/vm_flags/VmFlagTest.java	Tue Aug 09 13:24:03 2016 -0700
    44.3 @@ -55,9 +55,7 @@
    44.4      }
    44.5  
    44.6      private T getValue() {
    44.7 -        T t = get.apply(flagName);
    44.8 -        System.out.println("T = " + t);
    44.9 -        return t;
   44.10 +        return get.apply(flagName);
   44.11      }
   44.12  
   44.13      protected static <T> void runTest(String existentFlag, T[] tests,

mercurial