changeset 52189:1fd0f300d4b7

8202201: All oop stores in the x64 interpreter are treated as volatile when using G1 Summary: ran out of registers, generated volatile and non-volatile branches. Reviewed-by: eosterlund, dholmes
author coleenp
date Thu, 20 Sep 2018 08:11:21 -0400
parents d23d7389142f
children 46eac084082d
files src/hotspot/cpu/x86/templateTable_x86.cpp src/hotspot/cpu/x86/templateTable_x86.hpp
diffstat 2 files changed, 46 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/cpu/x86/templateTable_x86.cpp	Wed Sep 12 14:08:15 2018 +0200
+++ b/src/hotspot/cpu/x86/templateTable_x86.cpp	Thu Sep 20 08:11:21 2018 -0400
@@ -2995,7 +2995,6 @@
 #ifdef ASSERT
   __ jmp(Done);
 
-
   __ bind(notDouble);
   __ stop("Bad state");
 #endif
@@ -3113,7 +3112,6 @@
   const Register obj   = rcx;
   const Register off   = rbx;
   const Register flags = rax;
-  const Register bc    = LP64_ONLY(c_rarg3) NOT_LP64(rcx);
 
   resolve_cache_and_index(byte_no, cache, index, sizeof(u2));
   jvmti_post_field_mod(cache, index, is_static);
@@ -3128,12 +3126,33 @@
   __ shrl(rdx, ConstantPoolCacheEntry::is_volatile_shift);
   __ andl(rdx, 0x1);
 
+  // Check for volatile store
+  __ testl(rdx, rdx);
+  __ jcc(Assembler::zero, notVolatile);
+
+  putfield_or_static_helper(byte_no, is_static, rc, obj, off, flags);
+  volatile_barrier(Assembler::Membar_mask_bits(Assembler::StoreLoad |
+                                               Assembler::StoreStore));
+  __ jmp(Done);
+  __ bind(notVolatile);
+
+  putfield_or_static_helper(byte_no, is_static, rc, obj, off, flags);
+
+  __ bind(Done);
+}
+
+void TemplateTable::putfield_or_static_helper(int byte_no, bool is_static, RewriteControl rc,
+                                              Register obj, Register off, Register flags) {
+
   // field addresses
   const Address field(obj, off, Address::times_1, 0*wordSize);
   NOT_LP64( const Address hi(obj, off, Address::times_1, 1*wordSize);)
 
   Label notByte, notBool, notInt, notShort, notChar,
         notLong, notFloat, notObj;
+  Label Done;
+
+  const Register bc    = LP64_ONLY(c_rarg3) NOT_LP64(rcx);
 
   __ shrl(flags, ConstantPoolCacheEntry::tos_state_shift);
 
@@ -3233,42 +3252,17 @@
   __ jcc(Assembler::notEqual, notLong);
 
   // ltos
-#ifdef _LP64
   {
     __ pop(ltos);
     if (!is_static) pop_and_check_object(obj);
     __ access_store_at(T_LONG, IN_HEAP, field, noreg /* ltos*/, noreg, noreg);
+#ifdef _LP64
     if (!is_static && rc == may_rewrite) {
       patch_bytecode(Bytecodes::_fast_lputfield, bc, rbx, true, byte_no);
     }
+#endif // _LP64
     __ jmp(Done);
   }
-#else
-  {
-    Label notVolatileLong;
-    __ testl(rdx, rdx);
-    __ jcc(Assembler::zero, notVolatileLong);
-
-    __ pop(ltos);  // overwrites rdx, do this after testing volatile.
-    if (!is_static) pop_and_check_object(obj);
-
-    // Replace with real volatile test
-    __ access_store_at(T_LONG, IN_HEAP | MO_RELAXED, field, noreg /* ltos */, noreg, noreg);
-    // volatile_barrier();
-    volatile_barrier(Assembler::Membar_mask_bits(Assembler::StoreLoad |
-                                                 Assembler::StoreStore));
-    // Don't rewrite volatile version
-    __ jmp(notVolatile);
-
-    __ bind(notVolatileLong);
-
-    __ pop(ltos);  // overwrites rdx
-    if (!is_static) pop_and_check_object(obj);
-    __ access_store_at(T_LONG, IN_HEAP, field, noreg /* ltos */, noreg, noreg);
-    // Don't rewrite to _fast_lputfield for potential volatile case.
-    __ jmp(notVolatile);
-  }
-#endif // _LP64
 
   __ bind(notLong);
   __ cmpl(flags, ftos);
@@ -3310,13 +3304,6 @@
 #endif
 
   __ bind(Done);
-
-  // Check for volatile store
-  __ testl(rdx, rdx);
-  __ jcc(Assembler::zero, notVolatile);
-  volatile_barrier(Assembler::Membar_mask_bits(Assembler::StoreLoad |
-                                               Assembler::StoreStore));
-  __ bind(notVolatile);
 }
 
 void TemplateTable::putfield(int byte_no) {
@@ -3412,7 +3399,7 @@
   // volatile_barrier(Assembler::Membar_mask_bits(Assembler::LoadStore |
   //                                              Assembler::StoreStore));
 
-  Label notVolatile;
+  Label notVolatile, Done;
   __ shrl(rdx, ConstantPoolCacheEntry::is_volatile_shift);
   __ andl(rdx, 0x1);
 
@@ -3422,6 +3409,23 @@
   // field address
   const Address field(rcx, rbx, Address::times_1);
 
+  // Check for volatile store
+  __ testl(rdx, rdx);
+  __ jcc(Assembler::zero, notVolatile);
+
+  fast_storefield_helper(field, rax);
+  volatile_barrier(Assembler::Membar_mask_bits(Assembler::StoreLoad |
+                                               Assembler::StoreStore));
+  __ jmp(Done);
+  __ bind(notVolatile);
+
+  fast_storefield_helper(field, rax);
+
+  __ bind(Done);
+}
+
+void TemplateTable::fast_storefield_helper(Address field, Register rax) {
+
   // access field
   switch (bytecode()) {
   case Bytecodes::_fast_aputfield:
@@ -3458,13 +3462,6 @@
   default:
     ShouldNotReachHere();
   }
-
-  // Check for volatile store
-  __ testl(rdx, rdx);
-  __ jcc(Assembler::zero, notVolatile);
-  volatile_barrier(Assembler::Membar_mask_bits(Assembler::StoreLoad |
-                                               Assembler::StoreStore));
-  __ bind(notVolatile);
 }
 
 void TemplateTable::fast_accessfield(TosState state) {
--- a/src/hotspot/cpu/x86/templateTable_x86.hpp	Wed Sep 12 14:08:15 2018 +0200
+++ b/src/hotspot/cpu/x86/templateTable_x86.hpp	Thu Sep 20 08:11:21 2018 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2018, 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
@@ -39,4 +39,8 @@
   static void index_check(Register array, Register index);
   static void index_check_without_pop(Register array, Register index);
 
+  static void putfield_or_static_helper(int byte_no, bool is_static, RewriteControl rc,
+                                        Register obj, Register off, Register flags);
+  static void fast_storefield_helper(Address field, Register rax);
+
 #endif // CPU_X86_VM_TEMPLATETABLE_X86_HPP