changeset 35544:c7ec868d0923

8133612: new clone logic added in 8042235 is missing from compiler intrinsics Reviewed-by: roland
author vlivanov
date Fri, 18 Dec 2015 20:23:28 +0300
parents 0961315f4016
children a8f29dfd62b2
files hotspot/src/share/vm/oops/klass.cpp hotspot/src/share/vm/oops/klass.hpp hotspot/src/share/vm/opto/library_call.cpp hotspot/src/share/vm/runtime/vmStructs.cpp hotspot/src/share/vm/utilities/accessFlags.hpp
diffstat 5 files changed, 26 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/hotspot/src/share/vm/oops/klass.cpp	Fri Dec 18 20:23:27 2015 +0300
+++ b/hotspot/src/share/vm/oops/klass.cpp	Fri Dec 18 20:23:28 2015 +0300
@@ -44,6 +44,20 @@
 #include "gc/g1/g1SATBCardTableModRefBS.hpp"
 #endif // INCLUDE_ALL_GCS
 
+bool Klass::is_cloneable() const {
+  return _access_flags.is_cloneable_fast() ||
+         is_subtype_of(SystemDictionary::Cloneable_klass());
+}
+
+void Klass::set_is_cloneable() {
+  if (name() != vmSymbols::java_lang_invoke_MemberName()) {
+    _access_flags.set_is_cloneable_fast();
+  } else {
+    assert(is_final(), "no subclasses allowed");
+    // MemberName cloning should not be intrinsified and always happen in JVM_Clone.
+  }
+}
+
 void Klass::set_name(Symbol* n) {
   _name = n;
   if (_name != NULL) _name->increment_refcount();
--- a/hotspot/src/share/vm/oops/klass.hpp	Fri Dec 18 20:23:27 2015 +0300
+++ b/hotspot/src/share/vm/oops/klass.hpp	Fri Dec 18 20:23:28 2015 +0300
@@ -524,13 +524,14 @@
   bool has_final_method() const         { return _access_flags.has_final_method(); }
   void set_has_finalizer()              { _access_flags.set_has_finalizer(); }
   void set_has_final_method()           { _access_flags.set_has_final_method(); }
-  bool is_cloneable() const             { return _access_flags.is_cloneable(); }
-  void set_is_cloneable()               { _access_flags.set_is_cloneable(); }
   bool has_vanilla_constructor() const  { return _access_flags.has_vanilla_constructor(); }
   void set_has_vanilla_constructor()    { _access_flags.set_has_vanilla_constructor(); }
   bool has_miranda_methods () const     { return access_flags().has_miranda_methods(); }
   void set_has_miranda_methods()        { _access_flags.set_has_miranda_methods(); }
 
+  bool is_cloneable() const;
+  void set_is_cloneable();
+
   // Biased locking support
   // Note: the prototype header is always set up to be at least the
   // prototype markOop. If biased locking is enabled it may further be
--- a/hotspot/src/share/vm/opto/library_call.cpp	Fri Dec 18 20:23:27 2015 +0300
+++ b/hotspot/src/share/vm/opto/library_call.cpp	Fri Dec 18 20:23:28 2015 +0300
@@ -3151,7 +3151,7 @@
 }
 
 //--------------------(inline_native_Class_query helpers)---------------------
-// Use this for JVM_ACC_INTERFACE, JVM_ACC_IS_CLONEABLE, JVM_ACC_HAS_FINALIZER.
+// Use this for JVM_ACC_INTERFACE, JVM_ACC_IS_CLONEABLE_FAST, JVM_ACC_HAS_FINALIZER.
 // Fall through if (mods & mask) == bits, take the guard otherwise.
 Node* LibraryCallKit::generate_access_flags_guard(Node* kls, int modifier_mask, int modifier_bits, RegionNode* region) {
   // Branch around if the given klass has the given modifier bit set.
@@ -4489,14 +4489,14 @@
         generate_virtual_guard(obj_klass, slow_region);
       }
 
-      // The object must be cloneable and must not have a finalizer.
+      // The object must be easily cloneable and must not have a finalizer.
       // Both of these conditions may be checked in a single test.
-      // We could optimize the cloneable test further, but we don't care.
+      // We could optimize the test further, but we don't care.
       generate_access_flags_guard(obj_klass,
                                   // Test both conditions:
-                                  JVM_ACC_IS_CLONEABLE | JVM_ACC_HAS_FINALIZER,
+                                  JVM_ACC_IS_CLONEABLE_FAST | JVM_ACC_HAS_FINALIZER,
                                   // Must be cloneable but not finalizer:
-                                  JVM_ACC_IS_CLONEABLE,
+                                  JVM_ACC_IS_CLONEABLE_FAST,
                                   slow_region);
     }
 
--- a/hotspot/src/share/vm/runtime/vmStructs.cpp	Fri Dec 18 20:23:27 2015 +0300
+++ b/hotspot/src/share/vm/runtime/vmStructs.cpp	Fri Dec 18 20:23:28 2015 +0300
@@ -2397,7 +2397,7 @@
   declare_constant(JVM_ACC_HAS_MIRANDA_METHODS)                           \
   declare_constant(JVM_ACC_HAS_VANILLA_CONSTRUCTOR)                       \
   declare_constant(JVM_ACC_HAS_FINALIZER)                                 \
-  declare_constant(JVM_ACC_IS_CLONEABLE)                                  \
+  declare_constant(JVM_ACC_IS_CLONEABLE_FAST)                             \
   declare_constant(JVM_ACC_HAS_LOCAL_VARIABLE_TABLE)                      \
   declare_constant(JVM_ACC_PROMOTED_FLAGS)                                \
   declare_constant(JVM_ACC_FIELD_ACCESS_WATCHED)                          \
--- a/hotspot/src/share/vm/utilities/accessFlags.hpp	Fri Dec 18 20:23:27 2015 +0300
+++ b/hotspot/src/share/vm/utilities/accessFlags.hpp	Fri Dec 18 20:23:28 2015 +0300
@@ -61,7 +61,7 @@
   JVM_ACC_HAS_MIRANDA_METHODS     = 0x10000000,     // True if this class has miranda methods in it's vtable
   JVM_ACC_HAS_VANILLA_CONSTRUCTOR = 0x20000000,     // True if klass has a vanilla default constructor
   JVM_ACC_HAS_FINALIZER           = 0x40000000,     // True if klass has a non-empty finalize() method
-  JVM_ACC_IS_CLONEABLE            = (int)0x80000000,// True if klass supports the Clonable interface
+  JVM_ACC_IS_CLONEABLE_FAST       = (int)0x80000000,// True if klass implements the Cloneable interface and can be optimized in generated code
   JVM_ACC_HAS_FINAL_METHOD        = 0x01000000,     // True if klass has final method
 
   // Klass* and Method* flags
@@ -143,7 +143,7 @@
   bool has_vanilla_constructor () const { return (_flags & JVM_ACC_HAS_VANILLA_CONSTRUCTOR) != 0; }
   bool has_finalizer           () const { return (_flags & JVM_ACC_HAS_FINALIZER          ) != 0; }
   bool has_final_method        () const { return (_flags & JVM_ACC_HAS_FINAL_METHOD       ) != 0; }
-  bool is_cloneable            () const { return (_flags & JVM_ACC_IS_CLONEABLE           ) != 0; }
+  bool is_cloneable_fast       () const { return (_flags & JVM_ACC_IS_CLONEABLE_FAST      ) != 0; }
   // Klass* and Method* flags
   bool has_localvariable_table () const { return (_flags & JVM_ACC_HAS_LOCAL_VARIABLE_TABLE) != 0; }
   void set_has_localvariable_table()    { atomic_set_bits(JVM_ACC_HAS_LOCAL_VARIABLE_TABLE); }
@@ -210,7 +210,7 @@
   void set_has_vanilla_constructor()   { atomic_set_bits(JVM_ACC_HAS_VANILLA_CONSTRUCTOR); }
   void set_has_finalizer()             { atomic_set_bits(JVM_ACC_HAS_FINALIZER);           }
   void set_has_final_method()          { atomic_set_bits(JVM_ACC_HAS_FINAL_METHOD);        }
-  void set_is_cloneable()              { atomic_set_bits(JVM_ACC_IS_CLONEABLE);            }
+  void set_is_cloneable_fast()         { atomic_set_bits(JVM_ACC_IS_CLONEABLE_FAST);       }
   void set_has_miranda_methods()       { atomic_set_bits(JVM_ACC_HAS_MIRANDA_METHODS);     }
 
  public: