changeset 8620:bfece9d042eb

8087218: Constant fold loads from final instance fields in VM anonymous classes Reviewed-by: jrose, rbackman
author vlivanov
date Mon, 15 Jun 2015 15:27:04 +0300
parents a88735af82a4
children 636250d14884
files src/share/vm/ci/ciField.cpp src/share/vm/ci/ciInstanceKlass.cpp src/share/vm/ci/ciInstanceKlass.hpp
diffstat 3 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/ci/ciField.cpp	Wed Jun 17 16:22:38 2015 +0300
+++ b/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/src/share/vm/ci/ciInstanceKlass.cpp	Wed Jun 17 16:22:38 2015 +0300
+++ b/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/src/share/vm/ci/ciInstanceKlass.hpp	Wed Jun 17 16:22:38 2015 +0300
+++ b/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);