changeset 10506:85daf40cd00a

Merge
author lana
date Thu, 11 Feb 2016 16:05:39 -0800
parents 5d17092b6917 e88fb420b623
children 7232de4c17c3
files
diffstat 52 files changed, 540 insertions(+), 160 deletions(-) [+]
line wrap: on
line diff
--- a/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp	Thu Feb 11 14:39:54 2016 -0800
+++ b/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp	Thu Feb 11 16:05:39 2016 -0800
@@ -962,7 +962,7 @@
       __ lea(d, Address(d, count, Address::lsl(exact_log2(-step))));
     }
 
-    Label done, tail;
+    Label tail;
 
     __ cmp(count, 16/granularity);
     __ br(Assembler::LO, tail);
@@ -987,7 +987,8 @@
       }
       // rscratch2 is the byte adjustment needed to align s.
       __ cbz(rscratch2, aligned);
-      __ lsr(rscratch2, rscratch2, exact_log2(granularity));
+      int shift = exact_log2(granularity);
+      if (shift)  __ lsr(rscratch2, rscratch2, shift);
       __ sub(count, count, rscratch2);
 
 #if 0
--- a/src/cpu/sparc/vm/vm_version_sparc.cpp	Thu Feb 11 14:39:54 2016 -0800
+++ b/src/cpu/sparc/vm/vm_version_sparc.cpp	Thu Feb 11 16:05:39 2016 -0800
@@ -45,13 +45,6 @@
   if( cache_line_size > AllocatePrefetchStepSize )
     AllocatePrefetchStepSize = cache_line_size;
 
-  assert(AllocatePrefetchLines > 0, "invalid value");
-  if( AllocatePrefetchLines < 1 )     // set valid value in product VM
-    AllocatePrefetchLines = 3;
-  assert(AllocateInstancePrefetchLines > 0, "invalid value");
-  if( AllocateInstancePrefetchLines < 1 ) // set valid value in product VM
-    AllocateInstancePrefetchLines = 1;
-
   AllocatePrefetchDistance = allocate_prefetch_distance();
   AllocatePrefetchStyle    = allocate_prefetch_style();
 
--- a/src/cpu/x86/vm/sharedRuntime_x86_32.cpp	Thu Feb 11 14:39:54 2016 -0800
+++ b/src/cpu/x86/vm/sharedRuntime_x86_32.cpp	Thu Feb 11 16:05:39 2016 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -114,15 +114,20 @@
 
 OopMap* RegisterSaver::save_live_registers(MacroAssembler* masm, int additional_frame_words,
                                            int* total_frame_words, bool verify_fpu, bool save_vectors) {
-  int vect_words = 0;
   int num_xmm_regs = XMMRegisterImpl::number_of_registers;
+  int ymm_bytes = num_xmm_regs * 16;
+  int zmm_bytes = num_xmm_regs * 32;
 #ifdef COMPILER2
   if (save_vectors) {
-    assert(UseAVX > 0, "512bit vectors are supported only with EVEX");
-    assert(MaxVectorSize == 64, "only 512bit vectors are supported now");
-    // Save upper half of ZMM/YMM registers :
-    vect_words = 8 * 16 / wordSize;
-    additional_frame_words += vect_words;
+    assert(UseAVX > 0, "up to 512bit vectors are supported with EVEX");
+    assert(MaxVectorSize <= 64, "up to 512bit vectors are supported now");
+    // Save upper half of YMM registers
+    int vect_bytes = ymm_bytes;
+    if (UseAVX > 2) {
+      // Save upper half of ZMM registers as well
+      vect_bytes += zmm_bytes;
+    }
+    additional_frame_words += vect_bytes / wordSize;
   }
 #else
   assert(!save_vectors, "vectors are generated only by C2");
@@ -185,13 +190,14 @@
 
   off = xmm0_off;
   delta = xmm1_off - off;
-  if(UseSSE == 1) {           // Save the XMM state
+  if(UseSSE == 1) {
+    // Save the XMM state
     for (int n = 0; n < num_xmm_regs; n++) {
       __ movflt(Address(rsp, off*wordSize), as_XMMRegister(n));
       off += delta;
     }
   } else if(UseSSE >= 2) {
-    // Save whole 128bit (16 bytes) XMM regiters
+    // Save whole 128bit (16 bytes) XMM registers
     for (int n = 0; n < num_xmm_regs; n++) {
       __ movdqu(Address(rsp, off*wordSize), as_XMMRegister(n));
       off += delta;
@@ -199,13 +205,14 @@
   }
 
   if (save_vectors) {
-    assert(vect_words*wordSize == 128, "");
-    __ subptr(rsp, 128); // Save upper half of YMM registes
+    __ subptr(rsp, ymm_bytes);
+    // Save upper half of YMM registers
     for (int n = 0; n < num_xmm_regs; n++) {
       __ vextractf128h(Address(rsp, n*16), as_XMMRegister(n));
     }
     if (UseAVX > 2) {
-      __ subptr(rsp, 256); // Save upper half of ZMM registes
+      __ subptr(rsp, zmm_bytes);
+      // Save upper half of ZMM registers
       for (int n = 0; n < num_xmm_regs; n++) {
         __ vextractf64x4h(Address(rsp, n*32), as_XMMRegister(n), 1);
       }
@@ -255,48 +262,57 @@
 
 void RegisterSaver::restore_live_registers(MacroAssembler* masm, bool restore_vectors) {
   int num_xmm_regs = XMMRegisterImpl::number_of_registers;
+  int ymm_bytes = num_xmm_regs * 16;
+  int zmm_bytes = num_xmm_regs * 32;
   // Recover XMM & FPU state
   int additional_frame_bytes = 0;
 #ifdef COMPILER2
   if (restore_vectors) {
-    assert(UseAVX > 0, "512bit vectors are supported only with EVEX");
-    assert(MaxVectorSize == 64, "only 512bit vectors are supported now");
-    additional_frame_bytes = 128;
+    assert(UseAVX > 0, "up to 512bit vectors are supported with EVEX");
+    assert(MaxVectorSize <= 64, "up to 512bit vectors are supported now");
+    // Save upper half of YMM registers
+    additional_frame_bytes = ymm_bytes;
+    if (UseAVX > 2) {
+      // Save upper half of ZMM registers as well
+      additional_frame_bytes += zmm_bytes;
+    }
   }
 #else
   assert(!restore_vectors, "vectors are generated only by C2");
 #endif
 
+  int off = xmm0_off;
+  int delta = xmm1_off - off;
+
+  if (UseSSE == 1) {
+    // Restore XMM registers
+    assert(additional_frame_bytes == 0, "");
+    for (int n = 0; n < num_xmm_regs; n++) {
+      __ movflt(as_XMMRegister(n), Address(rsp, off*wordSize));
+      off += delta;
+    }
+  } else if (UseSSE >= 2) {
+    // Restore whole 128bit (16 bytes) XMM registers. Do this before restoring YMM and
+    // ZMM because the movdqu instruction zeros the upper part of the XMM register.
+    for (int n = 0; n < num_xmm_regs; n++) {
+      __ movdqu(as_XMMRegister(n), Address(rsp, off*wordSize+additional_frame_bytes));
+      off += delta;
+    }
+  }
+
   if (restore_vectors) {
-    assert(additional_frame_bytes == 128, "");
     if (UseAVX > 2) {
       // Restore upper half of ZMM registers.
       for (int n = 0; n < num_xmm_regs; n++) {
         __ vinsertf64x4h(as_XMMRegister(n), Address(rsp, n*32), 1);
       }
-      __ addptr(rsp, additional_frame_bytes*2); // Save upper half of ZMM registes
+      __ addptr(rsp, zmm_bytes);
     }
-    // Restore upper half of YMM registes.
+    // Restore upper half of YMM registers.
     for (int n = 0; n < num_xmm_regs; n++) {
       __ vinsertf128h(as_XMMRegister(n), Address(rsp, n*16));
     }
-    __ addptr(rsp, additional_frame_bytes); // Save upper half of YMM registes
-  }
-
-  int off = xmm0_off;
-  int delta = xmm1_off - off;
-
-  if (UseSSE == 1) {
-    for (int n = 0; n < num_xmm_regs; n++) {
-      __ movflt(as_XMMRegister(n), Address(rsp, off*wordSize));
-      off += delta;
-    }
-  } else if (UseSSE >= 2) {
-    // additional_frame_bytes only populated for the restore_vector case, else it is 0
-    for (int n = 0; n < num_xmm_regs; n++) {
-      __ movdqu(as_XMMRegister(n), Address(rsp, off*wordSize+additional_frame_bytes));
-      off += delta;
-    }
+    __ addptr(rsp, ymm_bytes);
   }
 
   __ pop_FPU_state();
@@ -306,7 +322,6 @@
   __ popa();
   // Get the rbp, described implicitly by the frame sender code (no oopMap)
   __ pop(rbp);
-
 }
 
 void RegisterSaver::restore_result_registers(MacroAssembler* masm) {
--- a/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Thu Feb 11 14:39:54 2016 -0800
+++ b/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Thu Feb 11 16:05:39 2016 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -150,8 +150,8 @@
   }
 #if defined(COMPILER2) || INCLUDE_JVMCI
   if (save_vectors) {
-    assert(UseAVX > 0, "512bit vectors are supported only with EVEX");
-    assert(MaxVectorSize == 64, "only 512bit vectors are supported now");
+    assert(UseAVX > 0, "up to 512bit vectors are supported with EVEX");
+    assert(MaxVectorSize <= 64, "up to 512bit vectors are supported now");
   }
 #else
   assert(!save_vectors, "vectors are generated only by C2 and JVMCI");
@@ -176,18 +176,18 @@
 
   // push cpu state handles this on EVEX enabled targets
   if (save_vectors) {
-    // Save upper half of YMM registes(0..15)
+    // Save upper half of YMM registers(0..15)
     int base_addr = XSAVE_AREA_YMM_BEGIN;
     for (int n = 0; n < 16; n++) {
       __ vextractf128h(Address(rsp, base_addr+n*16), as_XMMRegister(n));
     }
     if (VM_Version::supports_evex()) {
-      // Save upper half of ZMM registes(0..15)
+      // Save upper half of ZMM registers(0..15)
       base_addr = XSAVE_AREA_ZMM_BEGIN;
       for (int n = 0; n < 16; n++) {
         __ vextractf64x4h(Address(rsp, base_addr+n*32), as_XMMRegister(n), 1);
       }
-      // Save full ZMM registes(16..num_xmm_regs)
+      // Save full ZMM registers(16..num_xmm_regs)
       base_addr = XSAVE_AREA_UPPERBANK;
       off = 0;
       int vector_len = Assembler::AVX_512bit;
@@ -321,8 +321,8 @@
 
 #if defined(COMPILER2) || INCLUDE_JVMCI
   if (restore_vectors) {
-    assert(UseAVX > 0, "512bit vectors are supported only with EVEX");
-    assert(MaxVectorSize == 64, "only 512bit vectors are supported now");
+    assert(UseAVX > 0, "up to 512bit vectors are supported with EVEX");
+    assert(MaxVectorSize <= 64, "up to 512bit vectors are supported now");
   }
 #else
   assert(!restore_vectors, "vectors are generated only by C2");
@@ -330,18 +330,18 @@
 
   // On EVEX enabled targets everything is handled in pop fpu state
   if (restore_vectors) {
-    // Restore upper half of YMM registes (0..15)
+    // Restore upper half of YMM registers (0..15)
     int base_addr = XSAVE_AREA_YMM_BEGIN;
     for (int n = 0; n < 16; n++) {
       __ vinsertf128h(as_XMMRegister(n), Address(rsp,  base_addr+n*16));
     }
     if (VM_Version::supports_evex()) {
-      // Restore upper half of ZMM registes (0..15)
+      // Restore upper half of ZMM registers (0..15)
       base_addr = XSAVE_AREA_ZMM_BEGIN;
       for (int n = 0; n < 16; n++) {
         __ vinsertf64x4h(as_XMMRegister(n), Address(rsp, base_addr+n*32), 1);
       }
-      // Restore full ZMM registes(16..num_xmm_regs)
+      // Restore full ZMM registers(16..num_xmm_regs)
       base_addr = XSAVE_AREA_UPPERBANK;
       int vector_len = Assembler::AVX_512bit;
       int off = 0;
@@ -351,7 +351,7 @@
     }
   } else {
     if (VM_Version::supports_evex()) {
-      // Restore upper bank of ZMM registes(16..31) for double/float usage
+      // Restore upper bank of ZMM registers(16..31) for double/float usage
       int base_addr = XSAVE_AREA_UPPERBANK;
       int off = 0;
       for (int n = 16; n < num_xmm_regs; n++) {
--- a/src/cpu/x86/vm/vm_version_x86.cpp	Thu Feb 11 14:39:54 2016 -0800
+++ b/src/cpu/x86/vm/vm_version_x86.cpp	Thu Feb 11 16:05:39 2016 -0800
@@ -1163,13 +1163,6 @@
   if( cache_line_size > AllocatePrefetchStepSize )
     AllocatePrefetchStepSize = cache_line_size;
 
-  assert(AllocatePrefetchLines > 0, "invalid value");
-  if( AllocatePrefetchLines < 1 )     // set valid value in product VM
-    AllocatePrefetchLines = 3;
-  assert(AllocateInstancePrefetchLines > 0, "invalid value");
-  if( AllocateInstancePrefetchLines < 1 ) // set valid value in product VM
-    AllocateInstancePrefetchLines = 1;
-
   AllocatePrefetchDistance = allocate_prefetch_distance();
   AllocatePrefetchStyle    = allocate_prefetch_style();
 
@@ -1183,7 +1176,9 @@
     }
     if (supports_sse4_2() && supports_ht()) { // Nehalem based cpus
       AllocatePrefetchDistance = 192;
-      AllocatePrefetchLines = 4;
+      if (FLAG_IS_DEFAULT(AllocatePrefetchLines)) {
+        FLAG_SET_DEFAULT(AllocatePrefetchLines, 4);
+      }
     }
 #ifdef COMPILER2
     if (supports_sse4_2()) {
--- a/src/share/vm/ci/ciField.cpp	Thu Feb 11 14:39:54 2016 -0800
+++ b/src/share/vm/ci/ciField.cpp	Thu Feb 11 16:05:39 2016 -0800
@@ -72,7 +72,7 @@
 
   assert(ciObjectFactory::is_initialized(), "not a shared field");
 
-  assert(klass->get_instanceKlass()->is_linked(), "must be linked before using its constan-pool");
+  assert(klass->get_instanceKlass()->is_linked(), "must be linked before using its constant-pool");
 
   constantPoolHandle cpool(thread, klass->get_instanceKlass()->constants());
 
@@ -106,10 +106,31 @@
   // even though we may not need to.
   int holder_index = cpool->klass_ref_index_at(index);
   bool holder_is_accessible;
-  ciInstanceKlass* declared_holder =
-    ciEnv::current(thread)->get_klass_by_index(cpool, holder_index,
-                                               holder_is_accessible,
-                                               klass)->as_instance_klass();
+
+  ciKlass* generic_declared_holder = ciEnv::current(thread)->get_klass_by_index(cpool, holder_index,
+                                                                                holder_is_accessible,
+                                                                                klass);
+
+  if (generic_declared_holder->is_array_klass()) {
+    // If the declared holder of the field is an array class, assume that
+    // the canonical holder of that field is java.lang.Object. Arrays
+    // do not have fields; java.lang.Object is the only supertype of an
+    // array type that can declare fields and is therefore the canonical
+    // holder of the array type.
+    //
+    // Furthermore, the compilers assume that java.lang.Object does not
+    // have any fields. Therefore, the field is not looked up. Instead,
+    // the method returns partial information that will trigger special
+    // handling in ciField::will_link and will result in a
+    // java.lang.NoSuchFieldError exception being thrown by the compiled
+    // code (the expected behavior in this case).
+    _holder = ciEnv::current(thread)->Object_klass();
+    _offset = -1;
+    _is_constant = false;
+    return;
+  }
+
+  ciInstanceKlass* declared_holder = generic_declared_holder->as_instance_klass();
 
   // The declared holder of this field may not have been loaded.
   // Bail out with partial field information.
--- a/src/share/vm/opto/addnode.cpp	Thu Feb 11 14:39:54 2016 -0800
+++ b/src/share/vm/opto/addnode.cpp	Thu Feb 11 16:05:39 2016 -0800
@@ -61,7 +61,7 @@
 
 //------------------------------commute----------------------------------------
 // Commute operands to move loads and constants to the right.
-static bool commute( Node *add, int con_left, int con_right ) {
+static bool commute(Node *add, bool con_left, bool con_right) {
   Node *in1 = add->in(1);
   Node *in2 = add->in(2);
 
@@ -110,8 +110,8 @@
 Node *AddNode::Ideal(PhaseGVN *phase, bool can_reshape) {
   const Type *t1 = phase->type( in(1) );
   const Type *t2 = phase->type( in(2) );
-  int con_left  = t1->singleton();
-  int con_right = t2->singleton();
+  bool con_left  = t1->singleton();
+  bool con_right = t2->singleton();
 
   // Check for commutative operation desired
   if( commute(this,con_left,con_right) ) return this;
--- a/src/share/vm/opto/loopTransform.cpp	Thu Feb 11 14:39:54 2016 -0800
+++ b/src/share/vm/opto/loopTransform.cpp	Thu Feb 11 16:05:39 2016 -0800
@@ -3048,7 +3048,7 @@
   // state of the loop.  It's safe in this case to replace it with the
   // result_mem.
   _igvn.replace_node(store->in(MemNode::Memory), result_mem);
-  _igvn.replace_node(exit, result_ctrl);
+  lazy_replace(exit, result_ctrl);
   _igvn.replace_node(store, result_mem);
   // Any uses the increment outside of the loop become the loop limit.
   _igvn.replace_node(head->incr(), head->limit());
--- a/src/share/vm/opto/loopnode.cpp	Thu Feb 11 14:39:54 2016 -0800
+++ b/src/share/vm/opto/loopnode.cpp	Thu Feb 11 16:05:39 2016 -0800
@@ -755,8 +755,8 @@
     set_loop(iff2, get_loop(iffalse));
 
     // Lazy update of 'get_ctrl' mechanism.
-    lazy_replace_proj( iffalse, iff2 );
-    lazy_replace_proj( iftrue,  ift2 );
+    lazy_replace(iffalse, iff2);
+    lazy_replace(iftrue,  ift2);
 
     // Swap names
     iffalse = iff2;
--- a/src/share/vm/opto/loopnode.hpp	Thu Feb 11 14:39:54 2016 -0800
+++ b/src/share/vm/opto/loopnode.hpp	Thu Feb 11 16:05:39 2016 -0800
@@ -693,13 +693,18 @@
   }
 
 private:
-  Node *get_ctrl_no_update( Node *i ) const {
+  Node *get_ctrl_no_update_helper(Node *i) const {
+    assert(has_ctrl(i), "should be control, not loop");
+    return (Node*)(((intptr_t)_nodes[i->_idx]) & ~1);
+  }
+
+  Node *get_ctrl_no_update(Node *i) const {
     assert( has_ctrl(i), "" );
-    Node *n = (Node*)(((intptr_t)_nodes[i->_idx]) & ~1);
+    Node *n = get_ctrl_no_update_helper(i);
     if (!n->in(0)) {
       // Skip dead CFG nodes
       do {
-        n = (Node*)(((intptr_t)_nodes[n->_idx]) & ~1);
+        n = get_ctrl_no_update_helper(n);
       } while (!n->in(0));
       n = find_non_split_ctrl(n);
     }
@@ -721,22 +726,15 @@
   // from old_node to new_node to support the lazy update.  Reference
   // replaces loop reference, since that is not needed for dead node.
 public:
-  void lazy_update( Node *old_node, Node *new_node ) {
-    assert( old_node != new_node, "no cycles please" );
-    //old_node->set_req( 1, new_node /*NO DU INFO*/ );
-    // Nodes always have DU info now, so re-use the side array slot
-    // for this node to provide the forwarding pointer.
-    _nodes.map( old_node->_idx, (Node*)((intptr_t)new_node + 1) );
+  void lazy_update(Node *old_node, Node *new_node) {
+    assert(old_node != new_node, "no cycles please");
+    // Re-use the side array slot for this node to provide the
+    // forwarding pointer.
+    _nodes.map(old_node->_idx, (Node*)((intptr_t)new_node + 1));
   }
-  void lazy_replace( Node *old_node, Node *new_node ) {
-    _igvn.replace_node( old_node, new_node );
-    lazy_update( old_node, new_node );
-  }
-  void lazy_replace_proj( Node *old_node, Node *new_node ) {
-    assert( old_node->req() == 1, "use this for Projs" );
-    _igvn.hash_delete(old_node); // Must hash-delete before hacking edges
-    old_node->add_req( NULL );
-    lazy_replace( old_node, new_node );
+  void lazy_replace(Node *old_node, Node *new_node) {
+    _igvn.replace_node(old_node, new_node);
+    lazy_update(old_node, new_node);
   }
 
 private:
--- a/src/share/vm/opto/macro.cpp	Thu Feb 11 14:39:54 2016 -0800
+++ b/src/share/vm/opto/macro.cpp	Thu Feb 11 16:05:39 2016 -0800
@@ -2654,9 +2654,9 @@
   eliminate_macro_nodes();
 
   // Make sure expansion will not cause node limit to be exceeded.
-  // Worst case is a macro node gets expanded into about 50 nodes.
+  // Worst case is a macro node gets expanded into about 200 nodes.
   // Allow 50% more for optimization.
-  if (C->check_node_count(C->macro_count() * 75, "out of nodes before macro expansion" ) )
+  if (C->check_node_count(C->macro_count() * 300, "out of nodes before macro expansion" ) )
     return true;
 
   // Eliminate Opaque and LoopLimit nodes. Do it after all loop optimizations.
--- a/src/share/vm/opto/split_if.cpp	Thu Feb 11 14:39:54 2016 -0800
+++ b/src/share/vm/opto/split_if.cpp	Thu Feb 11 16:05:39 2016 -0800
@@ -472,7 +472,7 @@
 
     // Replace in the graph with lazy-update mechanism
     new_iff->set_req(0, new_iff); // hook self so it does not go dead
-    lazy_replace_proj( ifp, ifpx );
+    lazy_replace(ifp, ifpx);
     new_iff->set_req(0, region);
 
     // Record bits for later xforms
--- a/src/share/vm/opto/subnode.cpp	Thu Feb 11 14:39:54 2016 -0800
+++ b/src/share/vm/opto/subnode.cpp	Thu Feb 11 16:05:39 2016 -0800
@@ -1334,6 +1334,65 @@
     return new BoolNode( ncmp, _test.negate() );
   }
 
+  // Change ((x & m) u<= m) or ((m & x) u<= m) to always true
+  // Same with ((x & m) u< m+1) and ((m & x) u< m+1)
+  if (cop == Op_CmpU &&
+      cmp1->Opcode() == Op_AndI) {
+    Node* bound = NULL;
+    if (_test._test == BoolTest::le) {
+      bound = cmp2;
+    } else if (_test._test == BoolTest::lt &&
+               cmp2->Opcode() == Op_AddI &&
+               cmp2->in(2)->find_int_con(0) == 1) {
+      bound = cmp2->in(1);
+    }
+    if (cmp1->in(2) == bound || cmp1->in(1) == bound) {
+      return ConINode::make(1);
+    }
+  }
+
+  // Change ((x & (m - 1)) u< m) into (m > 0)
+  // This is the off-by-one variant of the above
+  if (cop == Op_CmpU &&
+      _test._test == BoolTest::lt &&
+      cmp1->Opcode() == Op_AndI) {
+    Node* l = cmp1->in(1);
+    Node* r = cmp1->in(2);
+    for (int repeat = 0; repeat < 2; repeat++) {
+      bool match = r->Opcode() == Op_AddI && r->in(2)->find_int_con(0) == -1 &&
+                   r->in(1) == cmp2;
+      if (match) {
+        // arraylength known to be non-negative, so a (arraylength != 0) is sufficient,
+        // but to be compatible with the array range check pattern, use (arraylength u> 0)
+        Node* ncmp = cmp2->Opcode() == Op_LoadRange
+                     ? phase->transform(new CmpUNode(cmp2, phase->intcon(0)))
+                     : phase->transform(new CmpINode(cmp2, phase->intcon(0)));
+        return new BoolNode(ncmp, BoolTest::gt);
+      } else {
+        // commute and try again
+        l = cmp1->in(2);
+        r = cmp1->in(1);
+      }
+    }
+  }
+
+  // Change (arraylength <= 0) or (arraylength == 0)
+  //   into (arraylength u<= 0)
+  // Also change (arraylength != 0) into (arraylength u> 0)
+  // The latter version matches the code pattern generated for
+  // array range checks, which will more likely be optimized later.
+  if (cop == Op_CmpI &&
+      cmp1->Opcode() == Op_LoadRange &&
+      cmp2->find_int_con(-1) == 0) {
+    if (_test._test == BoolTest::le || _test._test == BoolTest::eq) {
+      Node* ncmp = phase->transform(new CmpUNode(cmp1, cmp2));
+      return new BoolNode(ncmp, BoolTest::le);
+    } else if (_test._test == BoolTest::ne) {
+      Node* ncmp = phase->transform(new CmpUNode(cmp1, cmp2));
+      return new BoolNode(ncmp, BoolTest::gt);
+    }
+  }
+
   // Change "bool eq/ne (cmp (Conv2B X) 0)" into "bool eq/ne (cmp X 0)".
   // This is a standard idiom for branching on a boolean value.
   Node *c2b = cmp1;
@@ -1496,4 +1555,3 @@
   double d = t1->getd();
   return TypeD::make( StubRoutines::intrinsic_log10( d ) );
 }
-
--- a/src/share/vm/runtime/commandLineFlagConstraintsCompiler.cpp	Thu Feb 11 14:39:54 2016 -0800
+++ b/src/share/vm/runtime/commandLineFlagConstraintsCompiler.cpp	Thu Feb 11 16:05:39 2016 -0800
@@ -118,27 +118,46 @@
 }
 
 Flag::Error AllocatePrefetchStepSizeConstraintFunc(intx value, bool verbose) {
-  if (value < 1 || value > max_jint) {
+  intx max_value = 512;
+  if (value < 1 || value > max_value) {
     CommandLineError::print(verbose,
                             "AllocatePrefetchStepSize (" INTX_FORMAT ") "
                             "must be between 1 and %d\n",
                             AllocatePrefetchStepSize,
-                            max_jint);
+                            max_value);
     return Flag::VIOLATES_CONSTRAINT;
   }
 
   if (AllocatePrefetchDistance % AllocatePrefetchStepSize != 0) {
-     CommandLineError::print(verbose,
-                             "AllocatePrefetchDistance (" INTX_FORMAT ") "
-                             "%% AllocatePrefetchStepSize (" INTX_FORMAT ") "
-                             "= " INTX_FORMAT " "
-                             "must be 0\n",
-                             AllocatePrefetchDistance, AllocatePrefetchStepSize,
-                             AllocatePrefetchDistance % AllocatePrefetchStepSize);
-     return Flag::VIOLATES_CONSTRAINT;
-   }
+    CommandLineError::print(verbose,
+                            "AllocatePrefetchDistance (" INTX_FORMAT ") "
+                            "%% AllocatePrefetchStepSize (" INTX_FORMAT ") "
+                            "= " INTX_FORMAT " "
+                            "must be 0\n",
+                            AllocatePrefetchDistance, AllocatePrefetchStepSize,
+                            AllocatePrefetchDistance % AllocatePrefetchStepSize);
+    return Flag::VIOLATES_CONSTRAINT;
+  }
 
-   return Flag::SUCCESS;
+  /* The limit of 64 for the quotient of AllocatePrefetchDistance and AllocatePrefetchSize
+   * originates from the limit of 64 for AllocatePrefetchLines/AllocateInstancePrefetchLines.
+   * If AllocatePrefetchStyle == 2, the quotient from above is used in PhaseMacroExpand::prefetch_allocation()
+   * to determine the number of lines to prefetch. For other values of AllocatePrefetchStyle,
+   * AllocatePrefetchDistance and AllocatePrefetchSize is used. For consistency, all these
+   * quantities must have the same limit (64 in this case).
+   */
+  if (AllocatePrefetchDistance / AllocatePrefetchStepSize > 64) {
+    CommandLineError::print(verbose,
+                            "AllocatePrefetchDistance (" INTX_FORMAT ") too large or "
+                            "AllocatePrefetchStepSize (" INTX_FORMAT ") too small; "
+                            "try decreasing/increasing values so that "
+                            "AllocatePrefetchDistance / AllocatePrefetchStepSize <= 64\n",
+                            AllocatePrefetchDistance, AllocatePrefetchStepSize,
+                            AllocatePrefetchDistance % AllocatePrefetchStepSize);
+    return Flag::VIOLATES_CONSTRAINT;
+  }
+
+  return Flag::SUCCESS;
 }
 
 Flag::Error CompileThresholdConstraintFunc(intx value, bool verbose) {
--- a/src/share/vm/runtime/globals.hpp	Thu Feb 11 14:39:54 2016 -0800
+++ b/src/share/vm/runtime/globals.hpp	Thu Feb 11 16:05:39 2016 -0800
@@ -2966,16 +2966,16 @@
                                                                             \
   product(intx,  AllocatePrefetchLines, 3,                                  \
           "Number of lines to prefetch ahead of array allocation pointer")  \
-          range(1, max_jint / 2)                                            \
+          range(1, 64)                                                      \
                                                                             \
   product(intx,  AllocateInstancePrefetchLines, 1,                          \
           "Number of lines to prefetch ahead of instance allocation "       \
           "pointer")                                                        \
-          range(1, max_jint / 2)                                            \
+          range(1, 64)                                                      \
                                                                             \
   product(intx,  AllocatePrefetchStepSize, 16,                              \
           "Step size in bytes of sequential prefetch instructions")         \
-          range(1, max_jint)                                                \
+          range(1, 512)                                                     \
           constraint(AllocatePrefetchStepSizeConstraintFunc,AfterMemoryInit)\
                                                                             \
   product(intx,  AllocatePrefetchInstr, 0,                                  \
--- a/test/compiler/compilercontrol/TestCompilerDirectivesCompatibilityBase.java	Thu Feb 11 14:39:54 2016 -0800
+++ b/test/compiler/compilercontrol/TestCompilerDirectivesCompatibilityBase.java	Thu Feb 11 16:05:39 2016 -0800
@@ -24,7 +24,7 @@
 /*
  * @test TestCompilerDirectivesCompatibilityBase
  * @bug 8137167
- * @library /testlibrary /../../test/lib
+ * @library /testlibrary /test/lib
  * @modules java.base/sun.misc
  *          java.compiler
  *          java.management
--- a/test/compiler/compilercontrol/TestCompilerDirectivesCompatibilityCommandOff.java	Thu Feb 11 14:39:54 2016 -0800
+++ b/test/compiler/compilercontrol/TestCompilerDirectivesCompatibilityCommandOff.java	Thu Feb 11 16:05:39 2016 -0800
@@ -24,7 +24,7 @@
 /*
  * @test TestCompilerDirectivesCompatibilityCommandOff
  * @bug 8137167
- * @library /testlibrary /../../test/lib
+ * @library /testlibrary /test/lib
  * @modules java.base/sun.misc
  *          java.compiler
  *          java.management
--- a/test/compiler/compilercontrol/TestCompilerDirectivesCompatibilityCommandOn.java	Thu Feb 11 14:39:54 2016 -0800
+++ b/test/compiler/compilercontrol/TestCompilerDirectivesCompatibilityCommandOn.java	Thu Feb 11 16:05:39 2016 -0800
@@ -24,7 +24,7 @@
 /*
  * @test TestCompilerDirectivesCompatibilityCommandOn
  * @bug 8137167
- * @library /testlibrary /../../test/lib
+ * @library /testlibrary /test/lib
  * @modules java.base/sun.misc
  *          java.compiler
  *          java.management
--- a/test/compiler/compilercontrol/TestCompilerDirectivesCompatibilityFlag.java	Thu Feb 11 14:39:54 2016 -0800
+++ b/test/compiler/compilercontrol/TestCompilerDirectivesCompatibilityFlag.java	Thu Feb 11 16:05:39 2016 -0800
@@ -24,7 +24,7 @@
 /*
  * @test TestCompilerDirectivesCompatibilityFlag
  * @bug 8137167
- * @library /testlibrary /../../test/lib
+ * @library /testlibrary /test/lib
  * @modules java.base/sun.misc
  *          java.compiler
  *          java.management
--- a/test/compiler/compilercontrol/commandfile/CompileOnlyTest.java	Thu Feb 11 14:39:54 2016 -0800
+++ b/test/compiler/compilercontrol/commandfile/CompileOnlyTest.java	Thu Feb 11 16:05:39 2016 -0800
@@ -25,7 +25,7 @@
  * @test
  * @bug 8137167
  * @summary Tests CompileCommand=compileonly
- * @library /testlibrary /../../test/lib /compiler/testlibrary ../share /
+ * @library /testlibrary /test/lib /compiler/testlibrary ../share /
  * @build compiler.compilercontrol.commandfile.CompileOnlyTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
  *        compiler.testlibrary.CompilerUtils compiler.compilercontrol.share.actions.*
--- a/test/compiler/compilercontrol/commandfile/ExcludeTest.java	Thu Feb 11 14:39:54 2016 -0800
+++ b/test/compiler/compilercontrol/commandfile/ExcludeTest.java	Thu Feb 11 16:05:39 2016 -0800
@@ -25,7 +25,7 @@
  * @test
  * @bug 8137167
  * @summary Tests CompileCommand=exclude
- * @library /testlibrary /../../test/lib /compiler/testlibrary ../share /
+ * @library /testlibrary /test/lib /compiler/testlibrary ../share /
  * @build compiler.compilercontrol.commandfile.ExcludeTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
  *        compiler.testlibrary.CompilerUtils compiler.compilercontrol.share.actions.*
--- a/test/compiler/compilercontrol/commandfile/LogTest.java	Thu Feb 11 14:39:54 2016 -0800
+++ b/test/compiler/compilercontrol/commandfile/LogTest.java	Thu Feb 11 16:05:39 2016 -0800
@@ -25,7 +25,7 @@
  * @test
  * @bug 8137167
  * @summary Tests CompileCommand=log
- * @library /testlibrary /../../test/lib /compiler/testlibrary ../share /
+ * @library /testlibrary /test/lib /compiler/testlibrary ../share /
  * @build compiler.compilercontrol.commandfile.LogTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
  *        compiler.testlibrary.CompilerUtils compiler.compilercontrol.share.actions.*
--- a/test/compiler/compilercontrol/commandfile/PrintTest.java	Thu Feb 11 14:39:54 2016 -0800
+++ b/test/compiler/compilercontrol/commandfile/PrintTest.java	Thu Feb 11 16:05:39 2016 -0800
@@ -25,7 +25,7 @@
  * @test
  * @bug 8137167
  * @summary Tests CompileCommand=print
- * @library /testlibrary /../../test/lib /compiler/testlibrary ../share /
+ * @library /testlibrary /test/lib /compiler/testlibrary ../share /
  * @build compiler.compilercontrol.commandfile.PrintTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
  *        compiler.testlibrary.CompilerUtils compiler.compilercontrol.share.actions.*
--- a/test/compiler/compilercontrol/commands/CompileOnlyTest.java	Thu Feb 11 14:39:54 2016 -0800
+++ b/test/compiler/compilercontrol/commands/CompileOnlyTest.java	Thu Feb 11 16:05:39 2016 -0800
@@ -25,7 +25,7 @@
  * @test
  * @bug 8137167
  * @summary Tests CompileCommand=compileonly
- * @library /testlibrary /../../test/lib /compiler/testlibrary ../share /
+ * @library /testlibrary /test/lib /compiler/testlibrary ../share /
  * @build compiler.compilercontrol.commands.CompileOnlyTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
  *        compiler.testlibrary.CompilerUtils compiler.compilercontrol.share.actions.*
--- a/test/compiler/compilercontrol/commands/ExcludeTest.java	Thu Feb 11 14:39:54 2016 -0800
+++ b/test/compiler/compilercontrol/commands/ExcludeTest.java	Thu Feb 11 16:05:39 2016 -0800
@@ -25,7 +25,7 @@
  * @test
  * @bug 8137167
  * @summary Tests CompileCommand=exclude
- * @library /testlibrary /../../test/lib /compiler/testlibrary ../share /
+ * @library /testlibrary /test/lib /compiler/testlibrary ../share /
  * @build compiler.compilercontrol.commands.ExcludeTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
  *        compiler.testlibrary.CompilerUtils compiler.compilercontrol.share.actions.*
--- a/test/compiler/compilercontrol/commands/LogTest.java	Thu Feb 11 14:39:54 2016 -0800
+++ b/test/compiler/compilercontrol/commands/LogTest.java	Thu Feb 11 16:05:39 2016 -0800
@@ -25,7 +25,7 @@
  * @test
  * @bug 8137167
  * @summary Tests CompileCommand=log
- * @library /testlibrary /../../test/lib /compiler/testlibrary ../share /
+ * @library /testlibrary /test/lib /compiler/testlibrary ../share /
  * @build compiler.compilercontrol.commands.LogTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
  *        compiler.testlibrary.CompilerUtils compiler.compilercontrol.share.actions.*
--- a/test/compiler/compilercontrol/commands/PrintTest.java	Thu Feb 11 14:39:54 2016 -0800
+++ b/test/compiler/compilercontrol/commands/PrintTest.java	Thu Feb 11 16:05:39 2016 -0800
@@ -25,7 +25,7 @@
  * @test
  * @bug 8137167
  * @summary Tests CompileCommand=print
- * @library /testlibrary /../../test/lib /compiler/testlibrary ../share /
+ * @library /testlibrary /test/lib /compiler/testlibrary ../share /
  * @build compiler.compilercontrol.commands.PrintTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
  *        compiler.testlibrary.CompilerUtils compiler.compilercontrol.share.actions.*
--- a/test/compiler/compilercontrol/directives/CompileOnlyTest.java	Thu Feb 11 14:39:54 2016 -0800
+++ b/test/compiler/compilercontrol/directives/CompileOnlyTest.java	Thu Feb 11 16:05:39 2016 -0800
@@ -25,7 +25,7 @@
  * @test
  * @bug 8137167
  * @summary Tests directives to be able to compile only specified  methods
- * @library /testlibrary /../../test/lib /compiler/testlibrary ../share /
+ * @library /testlibrary /test/lib /compiler/testlibrary ../share /
  * @build compiler.compilercontrol.directives.CompileOnlyTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
  *        compiler.testlibrary.CompilerUtils compiler.compilercontrol.share.actions.*
--- a/test/compiler/compilercontrol/directives/ExcludeTest.java	Thu Feb 11 14:39:54 2016 -0800
+++ b/test/compiler/compilercontrol/directives/ExcludeTest.java	Thu Feb 11 16:05:39 2016 -0800
@@ -25,7 +25,7 @@
  * @test
  * @bug 8137167
  * @summary Tests directives to be able to exclude methods from compilation
- * @library /testlibrary /../../test/lib /compiler/testlibrary ../share /
+ * @library /testlibrary /test/lib /compiler/testlibrary ../share /
  * @build compiler.compilercontrol.directives.ExcludeTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
  *        compiler.testlibrary.CompilerUtils compiler.compilercontrol.share.actions.*
--- a/test/compiler/compilercontrol/directives/LogTest.java	Thu Feb 11 14:39:54 2016 -0800
+++ b/test/compiler/compilercontrol/directives/LogTest.java	Thu Feb 11 16:05:39 2016 -0800
@@ -25,7 +25,7 @@
  * @test
  * @bug 8137167
  * @summary Tests directives to be able to turn on LogCompilation
- * @library /testlibrary /../../test/lib /compiler/testlibrary ../share /
+ * @library /testlibrary /test/lib /compiler/testlibrary ../share /
  * @build compiler.compilercontrol.directives.LogTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
  *        compiler.testlibrary.CompilerUtils compiler.compilercontrol.share.actions.*
--- a/test/compiler/compilercontrol/directives/PrintTest.java	Thu Feb 11 14:39:54 2016 -0800
+++ b/test/compiler/compilercontrol/directives/PrintTest.java	Thu Feb 11 16:05:39 2016 -0800
@@ -25,7 +25,7 @@
  * @test
  * @bug 8137167
  * @summary Tests directives to be able to turn on print_assembly
- * @library /testlibrary /../../test/lib /compiler/testlibrary ../share /
+ * @library /testlibrary /test/lib /compiler/testlibrary ../share /
  * @build compiler.compilercontrol.directives.PrintTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
  *        compiler.testlibrary.CompilerUtils compiler.compilercontrol.share.actions.*
--- a/test/compiler/compilercontrol/jcmd/AddAndRemoveTest.java	Thu Feb 11 14:39:54 2016 -0800
+++ b/test/compiler/compilercontrol/jcmd/AddAndRemoveTest.java	Thu Feb 11 16:05:39 2016 -0800
@@ -25,7 +25,7 @@
  * @test
  * @bug 8137167
  * @summary Tests directives to be able to add and remove directives
- * @library /testlibrary /../../test/lib /compiler/testlibrary ../share /
+ * @library /testlibrary /test/lib /compiler/testlibrary ../share /
  * @build compiler.compilercontrol.jcmd.AddAndRemoveTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
  *        compiler.testlibrary.CompilerUtils compiler.compilercontrol.share.actions.*
--- a/test/compiler/compilercontrol/jcmd/AddCompileOnlyTest.java	Thu Feb 11 14:39:54 2016 -0800
+++ b/test/compiler/compilercontrol/jcmd/AddCompileOnlyTest.java	Thu Feb 11 16:05:39 2016 -0800
@@ -25,7 +25,7 @@
  * @test
  * @bug 8137167
  * @summary Tests jcmd to be able to add a directive to compile only specified methods
- * @library /testlibrary /../../test/lib /compiler/testlibrary ../share /
+ * @library /testlibrary /test/lib /compiler/testlibrary ../share /
  * @build compiler.compilercontrol.jcmd.AddCompileOnlyTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
  *        compiler.testlibrary.CompilerUtils compiler.compilercontrol.share.actions.*
--- a/test/compiler/compilercontrol/jcmd/AddExcludeTest.java	Thu Feb 11 14:39:54 2016 -0800
+++ b/test/compiler/compilercontrol/jcmd/AddExcludeTest.java	Thu Feb 11 16:05:39 2016 -0800
@@ -25,7 +25,7 @@
  * @test
  * @bug 8137167
  * @summary Tests jcmd to be able to add a directive to exclude only specified methods
- * @library /testlibrary /../../test/lib /compiler/testlibrary ../share /
+ * @library /testlibrary /test/lib /compiler/testlibrary ../share /
  * @build compiler.compilercontrol.jcmd.AddExcludeTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
  *        compiler.testlibrary.CompilerUtils compiler.compilercontrol.share.actions.*
--- a/test/compiler/compilercontrol/jcmd/AddLogTest.java	Thu Feb 11 14:39:54 2016 -0800
+++ b/test/compiler/compilercontrol/jcmd/AddLogTest.java	Thu Feb 11 16:05:39 2016 -0800
@@ -25,7 +25,7 @@
  * @test
  * @bug 8137167
  * @summary Tests jcmd to be able to add a directive to log only specified methods
- * @library /testlibrary /../../test/lib /compiler/testlibrary ../share /
+ * @library /testlibrary /test/lib /compiler/testlibrary ../share /
  * @build compiler.compilercontrol.jcmd.AddLogTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
  *        compiler.testlibrary.CompilerUtils compiler.compilercontrol.share.actions.*
--- a/test/compiler/compilercontrol/jcmd/AddPrintAssemblyTest.java	Thu Feb 11 14:39:54 2016 -0800
+++ b/test/compiler/compilercontrol/jcmd/AddPrintAssemblyTest.java	Thu Feb 11 16:05:39 2016 -0800
@@ -26,7 +26,7 @@
  * @bug 8137167
  * @summary Tests jcmd to be able to add a directive to print assembly
  *          only for specified methods
- * @library /testlibrary /../../test/lib /compiler/testlibrary ../share /
+ * @library /testlibrary /test/lib /compiler/testlibrary ../share /
  * @build compiler.compilercontrol.jcmd.AddPrintAssemblyTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
  *        compiler.testlibrary.CompilerUtils compiler.compilercontrol.share.actions.*
--- a/test/compiler/compilercontrol/mixed/RandomCommandsTest.java	Thu Feb 11 14:39:54 2016 -0800
+++ b/test/compiler/compilercontrol/mixed/RandomCommandsTest.java	Thu Feb 11 16:05:39 2016 -0800
@@ -25,7 +25,7 @@
  * @test
  * @bug 8137167
  * @summary Randomly generates commands with random types
- * @library /testlibrary /../../test/lib /compiler/testlibrary ../share /
+ * @library /testlibrary /test/lib /compiler/testlibrary ../share /
  * @build compiler.compilercontrol.mixed.RandomCommandsTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
  *        compiler.testlibrary.CompilerUtils compiler.compilercontrol.share.actions.*
--- a/test/compiler/compilercontrol/mixed/RandomValidCommandsTest.java	Thu Feb 11 14:39:54 2016 -0800
+++ b/test/compiler/compilercontrol/mixed/RandomValidCommandsTest.java	Thu Feb 11 16:05:39 2016 -0800
@@ -25,7 +25,7 @@
  * @test
  * @bug 8137167
  * @summary Randomly generates valid commands with random types
- * @library /testlibrary /../../test/lib /compiler/testlibrary ../share /
+ * @library /testlibrary /test/lib /compiler/testlibrary ../share /
  * @build compiler.compilercontrol.mixed.RandomValidCommandsTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
  *        compiler.testlibrary.CompilerUtils compiler.compilercontrol.share.actions.*
--- a/test/compiler/compilercontrol/share/scenario/Command.java	Thu Feb 11 14:39:54 2016 -0800
+++ b/test/compiler/compilercontrol/share/scenario/Command.java	Thu Feb 11 16:05:39 2016 -0800
@@ -32,8 +32,8 @@
 public enum Command {
     COMPILEONLY("compileonly", ".*", "-Xbatch"),
     EXCLUDE("exclude", "", "-Xbatch"),
-    INLINE("inline", ".*"),
-    DONTINLINE("dontinline", ""),
+    INLINE("inline", ".*", "-Xbatch"),
+    DONTINLINE("dontinline", "", "-Xbatch"),
     LOG("log", "", "-XX:+UnlockDiagnosticVMOptions",
             "-XX:+LogCompilation", "-XX:LogFile=" + LogProcessor.LOG_FILE),
     PRINT("print", ""),
--- a/test/compiler/cpuflags/TestAESIntrinsicsOnSupportedConfig.java	Thu Feb 11 14:39:54 2016 -0800
+++ b/test/compiler/cpuflags/TestAESIntrinsicsOnSupportedConfig.java	Thu Feb 11 16:05:39 2016 -0800
@@ -27,7 +27,7 @@
 
 /*
  * @test
- * @library /testlibrary /../../test/lib /compiler/whitebox
+ * @library /testlibrary /test/lib /compiler/whitebox
  *          /compiler/testlibrary /compiler/codegen/7184394
  * @modules java.base/sun.misc
  *          java.management
--- a/test/compiler/cpuflags/TestAESIntrinsicsOnUnsupportedConfig.java	Thu Feb 11 14:39:54 2016 -0800
+++ b/test/compiler/cpuflags/TestAESIntrinsicsOnUnsupportedConfig.java	Thu Feb 11 16:05:39 2016 -0800
@@ -28,7 +28,7 @@
 
 /*
  * @test
- * @library /testlibrary /../../test/lib /compiler/whitebox
+ * @library /testlibrary /test/lib /compiler/whitebox
  *          /compiler/testlibrary /compiler/codegen/7184394
  * @modules java.base/sun.misc
  *          java.management
--- a/test/compiler/intrinsics/IntrinsicDisabledTest.java	Thu Feb 11 14:39:54 2016 -0800
+++ b/test/compiler/intrinsics/IntrinsicDisabledTest.java	Thu Feb 11 16:05:39 2016 -0800
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug 8138651
- * @library /testlibrary /../../test/lib
+ * @library /testlibrary /test/lib
  * @build IntrinsicDisabledTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/test/compiler/intrinsics/montgomerymultiply/MontgomeryMultiplyTest.java	Thu Feb 11 14:39:54 2016 -0800
+++ b/test/compiler/intrinsics/montgomerymultiply/MontgomeryMultiplyTest.java	Thu Feb 11 16:05:39 2016 -0800
@@ -42,7 +42,7 @@
  * @test
  * @bug 8130150 8131779 8139907
  * @summary Verify that the Montgomery multiply and square intrinsic works and correctly checks their arguments.
- * @library /testlibrary /../../test/lib
+ * @library /testlibrary /test/lib
  * @library /testlibrary
  * @build MontgomeryMultiplyTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
--- a/test/compiler/intrinsics/string/TestStringIntrinsics2.java	Thu Feb 11 14:39:54 2016 -0800
+++ b/test/compiler/intrinsics/string/TestStringIntrinsics2.java	Thu Feb 11 16:05:39 2016 -0800
@@ -26,7 +26,7 @@
  * @test
  * @bug 8145336
  * @summary PPC64: fix string intrinsics after CompactStrings change
- * @library /testlibrary /../../test/lib
+ * @library /testlibrary /test/lib
  * @build sun.hotspot.WhiteBox
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compiler/loopopts/TestArraysFillDeadControl.java	Thu Feb 11 16:05:39 2016 -0800
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+/**
+ * @test
+ * @bug 8147645
+ * @summary Array.fill intrinsification code doesn't mark replaced control as dead
+ * @run main/othervm  -XX:-TieredCompilation -XX:CompileCommand=dontinline,TestArraysFillDeadControl::dont_inline TestArraysFillDeadControl
+ *
+ */
+
+import java.util.Arrays;
+
+public class TestArraysFillDeadControl {
+
+    static void dont_inline() {
+    }
+
+    static int i = 1;
+
+    public static void main(String[] args) {
+        for (int j = 0; j < 200000; j++) {
+            int[] a = new int[2];
+            int b = i;
+
+            Arrays.fill(a, 1);
+            Arrays.fill(a, 1+b);
+
+            dont_inline();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compiler/rangechecks/PowerOf2SizedArraysChecks.java	Thu Feb 11 16:05:39 2016 -0800
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+/**
+ * @test
+ * @bug 8003585
+ * @summary strength reduce or eliminate range checks for power-of-two sized arrays
+ * @run main/othervm -XX:CompileCommand=compileonly,PowerOf2SizedArraysChecks::test* -XX:-BackgroundCompilation PowerOf2SizedArraysChecks
+ *
+ */
+
+import java.util.function.*;
+
+public class PowerOf2SizedArraysChecks {
+
+    static void check_result(String name, int x, int m, boolean expected, boolean res) {
+        if (expected != res) {
+            throw new RuntimeException("Bad result in " + name + " for x =  " + x + " m = " + m + " expected " + expected  + " got " + res);
+        }
+    }
+
+    static void helper(String name, BiFunction<Integer, int[], Boolean> test, int[] x_values, int[] m_values, boolean[][] expected) {
+        for (int i = 0; i < x_values.length; i++) {
+            int x = x_values[i];
+            for (int j = 0; j < m_values.length; j++) {
+                int m = m_values[j];
+                int[] array = new int[m];
+                boolean res = test.apply(x, array);
+                check_result(name, x, m, expected[i][j], res);
+            }
+        }
+    }
+
+    static void check_result(String name, int m, boolean expected, boolean res) {
+        if (expected != res) {
+            throw new RuntimeException("Bad result in " + name + " for m = " + m + " expected " + expected  + " got " + res);
+        }
+    }
+
+    static void helper2(String name, Function<int[], Boolean> test, int[] m_values, boolean[] expected) {
+        for (int j = 0; j < m_values.length; j++) {
+            int m = m_values[j];
+            int[] array = new int[m];
+            boolean res = test.apply(array);
+            check_result(name, m, expected[j], res);
+        }
+    }
+
+    // ((x & m) u<= m) is always true
+    static boolean test1(int x, int[] array) {
+        int m = array.length;
+        if ((x & m) < 0 || (x & m) > m) {
+            return false;
+        }
+        return true;
+    }
+
+    // ((x & (m - 1)) u< m) iff (m > 0)
+    static boolean test2(int x, int[] array) {
+        int m = array.length;
+        if ((x & (m-1)) < 0 || (x & (m-1)) >= m) {
+            return false;
+        }
+        return true;
+    }
+
+    static boolean test3(int x, int[] array) {
+        try {
+            int v = array[x & (array.length-1)];
+        } catch(ArrayIndexOutOfBoundsException aioobe) {
+            return false;
+        }
+        return true;
+    }
+
+    // arraylength <= 0 to arraylength u<= 0
+    static boolean test4(int[] array) {
+        if (array.length <= 0) {
+            return false;
+        }
+        return true;
+    }
+
+    // arraylength == 0 to arraylength u<= 0
+    static boolean test5(int[] array) {
+        if (array.length == 0) {
+            return false;
+        }
+        return true;
+    }
+
+    // arraylength != 0 to arraylength u> 0
+    static boolean test6(int[] array) {
+        if (array.length != 0) {
+            return false;
+        }
+        return true;
+    }
+
+    static public void main(String[] args) {
+        int[] x_values = {-10, -5, 0, 5, 8, 16, 100};
+        int[] m_values = { 16, 10, 0 };
+
+        boolean[][] test1_expected = new boolean[x_values.length][m_values.length];
+        for (int i = 0; i < x_values.length; i++) {
+            for (int j = 0; j < m_values.length; j++) {
+                test1_expected[i][j] = true;
+            }
+        }
+
+        boolean[][] test2_expected = new boolean[x_values.length][m_values.length];
+        for (int i = 0; i < x_values.length; i++) {
+            for (int j = 0; j < m_values.length; j++) {
+                test2_expected[i][j] = (m_values[j] > 0);
+            }
+        }
+
+        boolean[] test4_expected = new boolean[m_values.length];
+        for (int i = 0; i < m_values.length; i++) {
+            test4_expected[i] = (m_values[i] > 0);
+        }
+        boolean[] test5_expected = new boolean[m_values.length];
+        for (int i = 0; i < m_values.length; i++) {
+            test5_expected[i] = (m_values[i] != 0);
+        }
+        boolean[] test6_expected = new boolean[m_values.length];
+        for (int i = 0; i < m_values.length; i++) {
+            test6_expected[i] = (m_values[i] == 0);
+        }
+
+        for (int i = 0; i < 20000; i++) {
+            helper("test1", PowerOf2SizedArraysChecks::test1, x_values, m_values, test1_expected);
+            helper("test2", PowerOf2SizedArraysChecks::test2, x_values, m_values, test2_expected);
+            helper("test3", PowerOf2SizedArraysChecks::test3, x_values, m_values, test2_expected);
+            helper2("test4", PowerOf2SizedArraysChecks::test4, m_values, test4_expected);
+            helper2("test5", PowerOf2SizedArraysChecks::test5, m_values, test5_expected);
+            helper2("test6", PowerOf2SizedArraysChecks::test6, m_values, test6_expected);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compiler/runtime/safepoints/TestRegisterRestoring.java	Thu Feb 11 16:05:39 2016 -0800
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+
+/**
+ * @test
+ * @bug 8148490
+ * @summary Test correct saving and restoring of vector registers at safepoints.
+ * @run main/othervm -Xbatch -XX:-TieredCompilation -XX:CompileCommand=exclude,TestRegisterRestoring::main -XX:+SafepointALot TestRegisterRestoring
+ */
+public class TestRegisterRestoring {
+  public static void main(String args[]) throws Exception {
+    // Initialize
+    float[] array = new float[100];
+    for (int i = 0; i < array.length; ++i) {
+      array[i] = 0;
+    }
+    // Test
+    for (int j = 0; j < 20_000; ++j) {
+      increment(array);
+      // Check result
+      for (int i = 0; i < array.length; i++) {
+        if (array[i] != 10_000) {
+          throw new RuntimeException("Test failed: array[" + i + "] = " + array[i] + " but should be 10.000");
+        }
+        array[i] = 0;
+      }
+    }
+  }
+
+  static void increment(float[] array) {
+    // Loop with safepoint
+    for (long l = 0; l < 10_000; l++) {
+      // Vectorized loop
+      for (int i = 0; i < array.length; ++i) {
+        array[i] += 1;
+      }
+    }
+  }
+}
+
--- a/test/compiler/stable/TestStableMemoryBarrier.java	Thu Feb 11 14:39:54 2016 -0800
+++ b/test/compiler/stable/TestStableMemoryBarrier.java	Thu Feb 11 16:05:39 2016 -0800
@@ -27,7 +27,7 @@
  * @test TestStableMemoryBarrier
  * @bug 8139758
  * @summary tests memory barrier correctly inserted for stable fields
- * @library /testlibrary /../../test/lib
+ * @library /testlibrary /test/lib
  *
  * @run main/bootclasspath -Xcomp -XX:CompileOnly=::testCompile
  *                   java.lang.invoke.TestStableMemoryBarrier
--- a/test/compiler/types/TestMeetIncompatibleInterfaceArrays.java	Thu Feb 11 14:39:54 2016 -0800
+++ b/test/compiler/types/TestMeetIncompatibleInterfaceArrays.java	Thu Feb 11 16:05:39 2016 -0800
@@ -27,7 +27,7 @@
  * @summary C2 can not handle returns with inccompatible interface arrays
  * @modules java.base/jdk.internal.org.objectweb.asm
  *          java.base/sun.misc
- * @library /testlibrary /../../test/lib
+ * @library /testlibrary /test/lib
  * @build sun.hotspot.WhiteBox
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/test/compiler/whitebox/AllocationCodeBlobTest.java	Thu Feb 11 14:39:54 2016 -0800
+++ b/test/compiler/whitebox/AllocationCodeBlobTest.java	Thu Feb 11 16:05:39 2016 -0800
@@ -92,33 +92,36 @@
 
     private void test() {
         System.out.printf("type %s%n", type);
+
+        // Measure the code cache usage after allocate/free.
         long start = getUsage();
-        long addr = WHITE_BOX.allocateCodeBlob(SIZE, type.id);
-        Asserts.assertNE(0, addr, "allocation failed");
+        long addr1 = WHITE_BOX.allocateCodeBlob(SIZE, type.id);
+        long firstAllocation = getUsage();
+        WHITE_BOX.freeCodeBlob(addr1);
+        long firstFree = getUsage();
+        long addr2 = WHITE_BOX.allocateCodeBlob(SIZE, type.id);
+        long secondAllocation = getUsage();
+        WHITE_BOX.freeCodeBlob(addr2);
 
-        long firstAllocation = getUsage();
+        // The following code may trigger resolving of invokedynamic
+        // instructions and therefore method handle intrinsic creation
+        // in the code cache. Make sure this is executed after measuring
+        // the code cache usage.
+        Asserts.assertNE(0, addr1, "first allocation failed");
+        Asserts.assertNE(0, addr2, "second allocation failed");
         Asserts.assertLTE(start + SIZE, firstAllocation,
                 "allocation should increase memory usage: "
                 + start + " + " + SIZE + " <= " + firstAllocation);
-
-        WHITE_BOX.freeCodeBlob(addr);
-        long firstFree = getUsage();
         Asserts.assertLTE(firstFree, firstAllocation,
                 "free shouldn't increase memory usage: "
                 + firstFree + " <= " + firstAllocation);
-
-        addr = WHITE_BOX.allocateCodeBlob(SIZE, type.id);
-        Asserts.assertNE(0, addr, "allocation failed");
-
-        long secondAllocation = getUsage();
         Asserts.assertEQ(firstAllocation, secondAllocation);
 
-        WHITE_BOX.freeCodeBlob(addr);
         System.out.println("allocating till possible...");
         ArrayList<Long> blobs = new ArrayList<>();
         int size = (int) (CODE_CACHE_SIZE >> 7);
-        while ((addr = WHITE_BOX.allocateCodeBlob(size, type.id)) != 0) {
-            blobs.add(addr);
+        while ((addr1 = WHITE_BOX.allocateCodeBlob(size, type.id)) != 0) {
+            blobs.add(addr1);
         }
         for (Long blob : blobs) {
             WHITE_BOX.freeCodeBlob(blob);
--- a/test/gc/g1/TestPLABOutput.java	Thu Feb 11 14:39:54 2016 -0800
+++ b/test/gc/g1/TestPLABOutput.java	Thu Feb 11 16:05:39 2016 -0800
@@ -27,7 +27,7 @@
  * @summary Check that G1 does not report empty PLAB statistics in the first evacuation.
  * @requires vm.gc=="G1" | vm.gc=="null"
  * @key gc
- * @library /testlibrary /../../test/lib
+ * @library /testlibrary /test/lib
  * @build sun.hotspot.WhiteBox
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  * @run driver TestPLABOutput
--- a/test/testlibrary_tests/whitebox/vm_flags/IntxTest.java	Thu Feb 11 14:39:54 2016 -0800
+++ b/test/testlibrary_tests/whitebox/vm_flags/IntxTest.java	Thu Feb 11 16:05:39 2016 -0800
@@ -24,6 +24,7 @@
 /*
  * @test IntxTest
  * @bug 8028756
+ * @ignore 8148758
  * @library /testlibrary /test/lib
  * @modules java.management/sun.management
  * @build IntxTest