Merge
authorjiangli
Tue, 18 Oct 2016 17:38:17 -0400
changeset 41740 5ce9b71d69d4
parent 41739 4a4b9f6a4306 (current diff)
parent 41738 3e3250e8a871 (diff)
child 41741 2f5b8bbcb18c
child 41742 9ecf02bc1662
Merge
--- a/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp	Mon Oct 10 20:50:33 2016 -0400
+++ b/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp	Tue Oct 18 17:38:17 2016 -0400
@@ -2743,7 +2743,7 @@
     __ align(CodeEntryAlignment);
     StubCodeMark mark(this, "StubRoutines", "cipherBlockChaining_encryptAESCrypt");
 
-    Label L_loadkeys_44, L_loadkeys_52, L_aes_loop, L_rounds_44, L_rounds_52;
+    Label L_loadkeys_44, L_loadkeys_52, L_aes_loop, L_rounds_44, L_rounds_52, _L_finish;
 
     const Register from        = c_rarg0;  // source array address
     const Register to          = c_rarg1;  // destination array address
@@ -2754,9 +2754,12 @@
     const Register keylen      = rscratch1;
 
     address start = __ pc();
+
       __ enter();
 
-      __ mov(rscratch2, len_reg);
+      __ subsw(rscratch2, len_reg, zr);
+      __ br(Assembler::LE, _L_finish);
+
       __ ldrw(keylen, Address(key, arrayOopDesc::length_offset_in_bytes() - arrayOopDesc::base_offset_in_bytes(T_INT)));
 
       __ ld1(v0, __ T16B, rvec);
@@ -2814,11 +2817,13 @@
       __ eor(v0, __ T16B, v0, v31);
 
       __ st1(v0, __ T16B, __ post(to, 16));
-      __ sub(len_reg, len_reg, 16);
-      __ cbnz(len_reg, L_aes_loop);
+
+      __ subw(len_reg, len_reg, 16);
+      __ cbnzw(len_reg, L_aes_loop);
 
       __ st1(v0, __ T16B, rvec);
 
+    __ BIND(_L_finish);
       __ mov(r0, rscratch2);
 
       __ leave();
@@ -2844,7 +2849,7 @@
     __ align(CodeEntryAlignment);
     StubCodeMark mark(this, "StubRoutines", "cipherBlockChaining_decryptAESCrypt");
 
-    Label L_loadkeys_44, L_loadkeys_52, L_aes_loop, L_rounds_44, L_rounds_52;
+    Label L_loadkeys_44, L_loadkeys_52, L_aes_loop, L_rounds_44, L_rounds_52, _L_finish;
 
     const Register from        = c_rarg0;  // source array address
     const Register to          = c_rarg1;  // destination array address
@@ -2855,9 +2860,12 @@
     const Register keylen      = rscratch1;
 
     address start = __ pc();
+
       __ enter();
 
-      __ mov(rscratch2, len_reg);
+      __ subsw(rscratch2, len_reg, zr);
+      __ br(Assembler::LE, _L_finish);
+
       __ ldrw(keylen, Address(key, arrayOopDesc::length_offset_in_bytes() - arrayOopDesc::base_offset_in_bytes(T_INT)));
 
       __ ld1(v2, __ T16B, rvec);
@@ -2920,11 +2928,12 @@
       __ st1(v0, __ T16B, __ post(to, 16));
       __ orr(v2, __ T16B, v1, v1);
 
-      __ sub(len_reg, len_reg, 16);
-      __ cbnz(len_reg, L_aes_loop);
+      __ subw(len_reg, len_reg, 16);
+      __ cbnzw(len_reg, L_aes_loop);
 
       __ st1(v2, __ T16B, rvec);
 
+    __ BIND(_L_finish);
       __ mov(r0, rscratch2);
 
       __ leave();
--- a/hotspot/src/cpu/aarch64/vm/templateInterpreterGenerator_aarch64.cpp	Mon Oct 10 20:50:33 2016 -0400
+++ b/hotspot/src/cpu/aarch64/vm/templateInterpreterGenerator_aarch64.cpp	Tue Oct 18 17:38:17 2016 -0400
@@ -454,8 +454,9 @@
   __ str(zr, Address(rfp, frame::interpreter_frame_last_sp_offset * wordSize));
 
 #if INCLUDE_JVMCI
-  // Check if we need to take lock at entry of synchronized method.
-  if (UseJVMCICompiler) {
+  // Check if we need to take lock at entry of synchronized method.  This can
+  // only occur on method entry so emit it only for vtos with step 0.
+  if (UseJVMCICompiler && state == vtos && step == 0) {
     Label L;
     __ ldr(rscratch1, Address(rthread, Thread::pending_exception_offset()));
     __ cbz(rscratch1, L);
@@ -464,8 +465,17 @@
     // Take lock.
     lock_method();
     __ bind(L);
+  } else {
+#ifdef ASSERT
+    if (UseJVMCICompiler) {
+      Label L;
+      __ ldr(rscratch1, Address(rthread, Thread::pending_exception_offset()));
+      __ cbz(rscratch1, L);
+      __ stop("unexpected pending monitor in deopt entry");
+      __ bind(L);
+    }
+#endif
   }
-#endif
   // handle exceptions
   {
     Label L;
--- a/hotspot/src/cpu/sparc/vm/templateInterpreterGenerator_sparc.cpp	Mon Oct 10 20:50:33 2016 -0400
+++ b/hotspot/src/cpu/sparc/vm/templateInterpreterGenerator_sparc.cpp	Tue Oct 18 17:38:17 2016 -0400
@@ -384,8 +384,9 @@
   address entry = __ pc();
   __ get_constant_pool_cache(LcpoolCache); // load LcpoolCache
 #if INCLUDE_JVMCI
-  // Check if we need to take lock at entry of synchronized method.
-  if (UseJVMCICompiler) {
+  // Check if we need to take lock at entry of synchronized method.  This can
+  // only occur on method entry so emit it only for vtos with step 0.
+  if (UseJVMCICompiler && state == vtos && step == 0) {
     Label L;
     Address pending_monitor_enter_addr(G2_thread, JavaThread::pending_monitorenter_offset());
     __ ldbool(pending_monitor_enter_addr, Gtemp);  // Load if pending monitor enter
@@ -395,6 +396,17 @@
     // Take lock.
     lock_method();
     __ bind(L);
+  } else {
+#ifdef ASSERT
+    if (UseJVMCICompiler) {
+      Label L;
+      Address pending_monitor_enter_addr(G2_thread, JavaThread::pending_monitorenter_offset());
+      __ ldbool(pending_monitor_enter_addr, Gtemp);  // Load if pending monitor enter
+      __ cmp_and_br_short(Gtemp, G0, Assembler::equal, Assembler::pn, L);
+      __ stop("unexpected pending monitor in deopt entry");
+      __ bind(L);
+    }
+#endif
   }
 #endif
   { Label L;
--- a/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86.cpp	Mon Oct 10 20:50:33 2016 -0400
+++ b/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86.cpp	Tue Oct 18 17:38:17 2016 -0400
@@ -254,8 +254,9 @@
   const Register thread = NOT_LP64(rcx) LP64_ONLY(r15_thread);
   NOT_LP64(__ get_thread(thread));
 #if INCLUDE_JVMCI
-  // Check if we need to take lock at entry of synchronized method.
-  if (UseJVMCICompiler) {
+  // Check if we need to take lock at entry of synchronized method.  This can
+  // only occur on method entry so emit it only for vtos with step 0.
+  if (UseJVMCICompiler && state == vtos && step == 0) {
     Label L;
     __ cmpb(Address(thread, JavaThread::pending_monitorenter_offset()), 0);
     __ jcc(Assembler::zero, L);
@@ -266,6 +267,16 @@
     // Take lock.
     lock_method();
     __ bind(L);
+  } else {
+#ifdef ASSERT
+    if (UseJVMCICompiler) {
+      Label L;
+      __ cmpb(Address(r15_thread, JavaThread::pending_monitorenter_offset()), 0);
+      __ jccb(Assembler::zero, L);
+      __ stop("unexpected pending monitor in deopt entry");
+      __ bind(L);
+    }
+#endif
   }
 #endif
   // handle exceptions
--- a/hotspot/src/share/vm/gc/g1/g1BiasedArray.cpp	Mon Oct 10 20:50:33 2016 -0400
+++ b/hotspot/src/share/vm/gc/g1/g1BiasedArray.cpp	Tue Oct 18 17:38:17 2016 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -53,99 +53,4 @@
             biased_index, bias(), length());
 }
 
-class TestMappedArray : public G1BiasedMappedArray<int> {
-protected:
-  virtual int default_value() const { return 0xBAADBABE; }
-public:
-  static void test_biasedarray() {
-    const size_t REGION_SIZE_IN_WORDS = 512;
-    const size_t NUM_REGIONS = 20;
-    HeapWord* fake_heap = (HeapWord*)LP64_ONLY(0xBAAA00000) NOT_LP64(0xBA000000); // Any value that is non-zero
-
-    TestMappedArray array;
-    array.initialize(fake_heap, fake_heap + REGION_SIZE_IN_WORDS * NUM_REGIONS,
-            REGION_SIZE_IN_WORDS * HeapWordSize);
-    // Check address calculation (bounds)
-    assert(array.bottom_address_mapped() == fake_heap,
-           "bottom mapped address should be " PTR_FORMAT ", but is " PTR_FORMAT, p2i(fake_heap), p2i(array.bottom_address_mapped()));
-    assert(array.end_address_mapped() == (fake_heap + REGION_SIZE_IN_WORDS * NUM_REGIONS), "must be");
-
-    int* bottom = array.address_mapped_to(fake_heap);
-    assert((void*)bottom == (void*) array.base(), "must be");
-    int* end = array.address_mapped_to(fake_heap + REGION_SIZE_IN_WORDS * NUM_REGIONS);
-    assert((void*)end == (void*)(array.base() + array.length()), "must be");
-    // The entire array should contain default value elements
-    for (int* current = bottom; current < end; current++) {
-      assert(*current == array.default_value(), "must be");
-    }
-
-    // Test setting values in the table
-
-    HeapWord* region_start_address = fake_heap + REGION_SIZE_IN_WORDS * (NUM_REGIONS / 2);
-    HeapWord* region_end_address = fake_heap + (REGION_SIZE_IN_WORDS * (NUM_REGIONS / 2) + REGION_SIZE_IN_WORDS - 1);
-
-    // Set/get by address tests: invert some value; first retrieve one
-    int actual_value = array.get_by_index(NUM_REGIONS / 2);
-    array.set_by_index(NUM_REGIONS / 2, ~actual_value);
-    // Get the same value by address, should correspond to the start of the "region"
-    int value = array.get_by_address(region_start_address);
-    assert(value == ~actual_value, "must be");
-    // Get the same value by address, at one HeapWord before the start
-    value = array.get_by_address(region_start_address - 1);
-    assert(value == array.default_value(), "must be");
-    // Get the same value by address, at the end of the "region"
-    value = array.get_by_address(region_end_address);
-    assert(value == ~actual_value, "must be");
-    // Make sure the next value maps to another index
-    value = array.get_by_address(region_end_address + 1);
-    assert(value == array.default_value(), "must be");
-
-    // Reset the value in the array
-    array.set_by_address(region_start_address + (region_end_address - region_start_address) / 2, actual_value);
-
-    // The entire array should have the default value again
-    for (int* current = bottom; current < end; current++) {
-      assert(*current == array.default_value(), "must be");
-    }
-
-    // Set/get by index tests: invert some value
-    idx_t index = NUM_REGIONS / 2;
-    actual_value = array.get_by_index(index);
-    array.set_by_index(index, ~actual_value);
-
-    value = array.get_by_index(index);
-    assert(value == ~actual_value, "must be");
-
-    value = array.get_by_index(index - 1);
-    assert(value == array.default_value(), "must be");
-
-    value = array.get_by_index(index + 1);
-    assert(value == array.default_value(), "must be");
-
-    array.set_by_index(0, 0);
-    value = array.get_by_index(0);
-    assert(value == 0, "must be");
-
-    array.set_by_index(array.length() - 1, 0);
-    value = array.get_by_index(array.length() - 1);
-    assert(value == 0, "must be");
-
-    array.set_by_index(index, 0);
-
-    // The array should have three zeros, and default values otherwise
-    size_t num_zeros = 0;
-    for (int* current = bottom; current < end; current++) {
-      assert(*current == array.default_value() || *current == 0, "must be");
-      if (*current == 0) {
-        num_zeros++;
-      }
-    }
-    assert(num_zeros == 3, "must be");
-  }
-};
-
-void TestG1BiasedArray_test() {
-  TestMappedArray::test_biasedarray();
-}
-
 #endif
--- a/hotspot/src/share/vm/utilities/internalVMTests.cpp	Mon Oct 10 20:50:33 2016 -0400
+++ b/hotspot/src/share/vm/utilities/internalVMTests.cpp	Tue Oct 18 17:38:17 2016 -0400
@@ -64,7 +64,6 @@
   run_unit_test(VMStructs_test);
 #endif
 #if INCLUDE_ALL_GCS
-  run_unit_test(TestG1BiasedArray_test);
   run_unit_test(TestBufferingOopClosure_test);
   if (UseG1GC) {
     run_unit_test(FreeRegionList_test);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/native/gc/g1/test_g1BiasedArray.cpp	Tue Oct 18 17:38:17 2016 -0400
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2013, 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.
+ */
+
+#include "precompiled.hpp"
+#include "gc/g1/g1BiasedArray.hpp"
+#include "unittest.hpp"
+
+class TestMappedArray : public G1BiasedMappedArray<int> {
+public:
+  virtual int default_value() const {
+    return 0xBAADBABE;
+  }
+  int* my_address_mapped_to(HeapWord* address) {
+    return address_mapped_to(address);
+  }
+};
+
+TEST_VM(G1BiasedArray, simple) {
+  const size_t REGION_SIZE_IN_WORDS = 512;
+  const size_t NUM_REGIONS = 20;
+  // Any value that is non-zero
+  HeapWord* fake_heap =
+          (HeapWord*) LP64_ONLY(0xBAAA00000) NOT_LP64(0xBA000000);
+
+  TestMappedArray array;
+  array.initialize(fake_heap, fake_heap + REGION_SIZE_IN_WORDS * NUM_REGIONS,
+          REGION_SIZE_IN_WORDS * HeapWordSize);
+  const int DEFAULT_VALUE = array.default_value();
+
+  // Check address calculation (bounds)
+  ASSERT_EQ(fake_heap, array.bottom_address_mapped())
+          << "bottom mapped address should be "
+          << p2i(array.bottom_address_mapped())
+          << ", but is "
+          << p2i(fake_heap);
+  ASSERT_EQ(fake_heap + REGION_SIZE_IN_WORDS * NUM_REGIONS,
+          array.end_address_mapped());
+
+  int* bottom = array.my_address_mapped_to(fake_heap);
+  ASSERT_EQ((void*) bottom, (void*) array.base());
+  int* end = array.my_address_mapped_to(fake_heap +
+          REGION_SIZE_IN_WORDS * NUM_REGIONS);
+  ASSERT_EQ((void*) end, (void*) (array.base() + array.length()));
+  // The entire array should contain default value elements
+  for (int* current = bottom; current < end; current++) {
+    ASSERT_EQ(DEFAULT_VALUE, *current);
+  }
+
+  // Test setting values in the table
+  HeapWord* region_start_address =
+          fake_heap + REGION_SIZE_IN_WORDS * (NUM_REGIONS / 2);
+  HeapWord* region_end_address =
+          fake_heap + (REGION_SIZE_IN_WORDS * (NUM_REGIONS / 2) +
+          REGION_SIZE_IN_WORDS - 1);
+
+  // Set/get by address tests: invert some value; first retrieve one
+  int actual_value = array.get_by_index(NUM_REGIONS / 2);
+  array.set_by_index(NUM_REGIONS / 2, ~actual_value);
+  // Get the same value by address, should correspond to the start of the "region"
+  int value = array.get_by_address(region_start_address);
+  ASSERT_EQ(value, ~actual_value);
+  // Get the same value by address, at one HeapWord before the start
+  value = array.get_by_address(region_start_address - 1);
+  ASSERT_EQ(DEFAULT_VALUE, value);
+  // Get the same value by address, at the end of the "region"
+  value = array.get_by_address(region_end_address);
+  ASSERT_EQ(value, ~actual_value);
+  // Make sure the next value maps to another index
+  value = array.get_by_address(region_end_address + 1);
+  ASSERT_EQ(DEFAULT_VALUE, value);
+
+  // Reset the value in the array
+  array.set_by_address(region_start_address +
+          (region_end_address - region_start_address) / 2,
+          actual_value);
+
+  // The entire array should have the default value again
+  for (int* current = bottom; current < end; current++) {
+    ASSERT_EQ(DEFAULT_VALUE, *current);
+  }
+
+  // Set/get by index tests: invert some value
+  size_t index = NUM_REGIONS / 2;
+  actual_value = array.get_by_index(index);
+  array.set_by_index(index, ~actual_value);
+
+  value = array.get_by_index(index);
+  ASSERT_EQ(~actual_value, value);
+
+  value = array.get_by_index(index - 1);
+  ASSERT_EQ(DEFAULT_VALUE, value);
+
+  value = array.get_by_index(index + 1);
+  ASSERT_EQ(DEFAULT_VALUE, value);
+
+  array.set_by_index(0, 0);
+  value = array.get_by_index(0);
+  ASSERT_EQ(0, value);
+
+  array.set_by_index(array.length() - 1, 0);
+  value = array.get_by_index(array.length() - 1);
+  ASSERT_EQ(0, value);
+
+  array.set_by_index(index, 0);
+
+  // The array should have three zeros, and default values otherwise
+  size_t num_zeros = 0;
+  for (int* current = bottom; current < end; current++) {
+    ASSERT_TRUE(*current == DEFAULT_VALUE || *current == 0);
+    if (*current == 0) {
+      num_zeros++;
+    }
+  }
+  ASSERT_EQ((size_t) 3, num_zeros);
+}
+