8087218: Constant fold loads from final instance fields in VM anonymous classes
authorvlivanov
Mon, 15 Jun 2015 15:27:04 +0300
changeset 31519 bb26c50aadd0
parent 31518 2c9bfffb1b71
child 31520 4a6cbcae9f46
8087218: Constant fold loads from final instance fields in VM anonymous classes Reviewed-by: jrose, rbackman
hotspot/src/share/vm/ci/ciField.cpp
hotspot/src/share/vm/ci/ciInstanceKlass.cpp
hotspot/src/share/vm/ci/ciInstanceKlass.hpp
--- a/hotspot/src/share/vm/ci/ciField.cpp	Wed Jun 17 16:22:38 2015 +0300
+++ b/hotspot/src/share/vm/ci/ciField.cpp	Mon Jun 15 15:27:04 2015 +0300
@@ -186,6 +186,10 @@
   // Even if general trusting is disabled, trust system-built closures in these packages.
   if (holder->is_in_package("java/lang/invoke") || holder->is_in_package("sun/invoke"))
     return true;
+  // Trust VM anonymous classes. They are private API (sun.misc.Unsafe) and can't be serialized,
+  // so there is no hacking of finals going on with them.
+  if (holder->is_anonymous())
+    return true;
   return TrustFinalNonStaticFields;
 }
 
--- a/hotspot/src/share/vm/ci/ciInstanceKlass.cpp	Wed Jun 17 16:22:38 2015 +0300
+++ b/hotspot/src/share/vm/ci/ciInstanceKlass.cpp	Mon Jun 15 15:27:04 2015 +0300
@@ -58,6 +58,7 @@
   _nonstatic_field_size = ik->nonstatic_field_size();
   _has_nonstatic_fields = ik->has_nonstatic_fields();
   _has_default_methods = ik->has_default_methods();
+  _is_anonymous = ik->is_anonymous();
   _nonstatic_fields = NULL; // initialized lazily by compute_nonstatic_fields:
   _has_injected_fields = -1;
   _implementor = NULL; // we will fill these lazily
@@ -101,6 +102,7 @@
   _has_nonstatic_fields = false;
   _nonstatic_fields = NULL;
   _has_injected_fields = -1;
+  _is_anonymous = false;
   _loader = loader;
   _protection_domain = protection_domain;
   _is_shared = false;
--- a/hotspot/src/share/vm/ci/ciInstanceKlass.hpp	Wed Jun 17 16:22:38 2015 +0300
+++ b/hotspot/src/share/vm/ci/ciInstanceKlass.hpp	Mon Jun 15 15:27:04 2015 +0300
@@ -53,6 +53,7 @@
   bool                   _has_subklass;
   bool                   _has_nonstatic_fields;
   bool                   _has_default_methods;
+  bool                   _is_anonymous;
 
   ciFlags                _flags;
   jint                   _nonstatic_field_size;
@@ -179,6 +180,10 @@
     return _has_default_methods;
   }
 
+  bool is_anonymous() {
+    return _is_anonymous;
+  }
+
   ciInstanceKlass* get_canonical_holder(int offset);
   ciField* get_field_by_offset(int field_offset, bool is_static);
   ciField* get_field_by_name(ciSymbol* name, ciSymbol* signature, bool is_static);