8047737: Move array component mirror to instance of java/lang/Class
authorcoleenp
Wed, 02 Jul 2014 15:22:18 -0400
changeset 25465 17a6bddcfa5d
parent 25464 309af3e40a0f
child 25467 d2061076d5a0
8047737: Move array component mirror to instance of java/lang/Class Summary: Add field in java.lang.Class for componentType to simplify oop processing in JVM Reviewed-by: fparain, twisti
hotspot/src/share/vm/classfile/javaClasses.cpp
hotspot/src/share/vm/classfile/javaClasses.hpp
hotspot/src/share/vm/classfile/vmSymbols.hpp
--- a/hotspot/src/share/vm/classfile/javaClasses.cpp	Wed Jul 02 15:17:11 2014 +0200
+++ b/hotspot/src/share/vm/classfile/javaClasses.cpp	Wed Jul 02 15:22:18 2014 -0400
@@ -618,6 +618,8 @@
       assert(comp_mirror.not_null(), "must have a mirror");
 
       // Two-way link between the array klass and its component mirror:
+      // (array_klass) k -> mirror -> component_mirror -> array_klass -> k
+      set_component_mirror(mirror(), comp_mirror());
       ArrayKlass::cast(k())->set_component_mirror(comp_mirror());
       set_array_klass(comp_mirror(), k());
     } else {
@@ -679,6 +681,16 @@
   java_class->obj_field_put(_protection_domain_offset, pd);
 }
 
+void java_lang_Class::set_component_mirror(oop java_class, oop comp_mirror) {
+  if (_component_mirror_offset != 0) {
+    java_class->obj_field_put(_component_mirror_offset, comp_mirror);
+  }
+}
+oop java_lang_Class::component_mirror(oop java_class) {
+  assert(_component_mirror_offset != 0, "must be set");
+  return java_class->obj_field(_component_mirror_offset);
+}
+
 oop java_lang_Class::init_lock(oop java_class) {
   assert(_init_lock_offset != 0, "must be set");
   return java_class->obj_field(_init_lock_offset);
@@ -875,6 +887,10 @@
                  klass_oop, vmSymbols::classLoader_name(),
                  vmSymbols::classloader_signature());
 
+  compute_optional_offset(_component_mirror_offset,
+                 klass_oop, vmSymbols::componentType_name(),
+                 vmSymbols::class_signature());
+
   CLASS_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
 }
 
@@ -3097,6 +3113,7 @@
 int java_lang_Class::_static_oop_field_count_offset;
 int java_lang_Class::_class_loader_offset;
 int java_lang_Class::_protection_domain_offset;
+int java_lang_Class::_component_mirror_offset;
 int java_lang_Class::_init_lock_offset;
 int java_lang_Class::_signers_offset;
 GrowableArray<Klass*>* java_lang_Class::_fixup_mirror_list = NULL;
--- a/hotspot/src/share/vm/classfile/javaClasses.hpp	Wed Jul 02 15:17:11 2014 +0200
+++ b/hotspot/src/share/vm/classfile/javaClasses.hpp	Wed Jul 02 15:22:18 2014 -0400
@@ -241,6 +241,7 @@
   static int _init_lock_offset;
   static int _signers_offset;
   static int _class_loader_offset;
+  static int _component_mirror_offset;
 
   static bool offsets_computed;
   static int classRedefinedCount_offset;
@@ -250,6 +251,7 @@
   static void set_init_lock(oop java_class, oop init_lock);
   static void set_protection_domain(oop java_class, oop protection_domain);
   static void set_class_loader(oop java_class, oop class_loader);
+  static void set_component_mirror(oop java_class, oop comp_mirror);
   static void initialize_mirror_fields(KlassHandle k, Handle mirror, Handle protection_domain, TRAPS);
  public:
   static void compute_offsets();
@@ -291,6 +293,7 @@
   // Support for embedded per-class oops
   static oop  protection_domain(oop java_class);
   static oop  init_lock(oop java_class);
+  static oop  component_mirror(oop java_class);
   static objArrayOop  signers(oop java_class);
   static void set_signers(oop java_class, objArrayOop signers);
 
--- a/hotspot/src/share/vm/classfile/vmSymbols.hpp	Wed Jul 02 15:17:11 2014 +0200
+++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp	Wed Jul 02 15:22:18 2014 -0400
@@ -573,6 +573,7 @@
   template(serializeAgentPropertiesToByteArray_name,   "serializeAgentPropertiesToByteArray")                     \
   template(classRedefinedCount_name,                   "classRedefinedCount")                                     \
   template(classLoader_name,                           "classLoader")                                             \
+  template(componentType_name,                         "componentType")                                           \
                                                                                                                   \
   /* trace signatures */                                                                                          \
   TRACE_TEMPLATES(template)                                                                                       \