src/hotspot/share/classfile/javaClasses.cpp
changeset 49329 04ed29f9ef33
parent 49192 6734eeef4283
child 49340 4e82736053ae
equal deleted inserted replaced
49328:6a86f0deb479 49329:04ed29f9ef33
    34 #include "code/pcDesc.hpp"
    34 #include "code/pcDesc.hpp"
    35 #include "interpreter/interpreter.hpp"
    35 #include "interpreter/interpreter.hpp"
    36 #include "logging/log.hpp"
    36 #include "logging/log.hpp"
    37 #include "logging/logStream.hpp"
    37 #include "logging/logStream.hpp"
    38 #include "memory/oopFactory.hpp"
    38 #include "memory/oopFactory.hpp"
       
    39 #include "memory/metaspaceShared.hpp"
    39 #include "memory/resourceArea.hpp"
    40 #include "memory/resourceArea.hpp"
    40 #include "memory/universe.inline.hpp"
    41 #include "memory/universe.inline.hpp"
    41 #include "oops/fieldStreams.hpp"
    42 #include "oops/fieldStreams.hpp"
    42 #include "oops/instanceKlass.hpp"
    43 #include "oops/instanceKlass.hpp"
    43 #include "oops/instanceMirrorKlass.hpp"
    44 #include "oops/instanceMirrorKlass.hpp"
    65 #endif
    66 #endif
    66 
    67 
    67 #define INJECTED_FIELD_COMPUTE_OFFSET(klass, name, signature, may_be_java)    \
    68 #define INJECTED_FIELD_COMPUTE_OFFSET(klass, name, signature, may_be_java)    \
    68   klass::_##name##_offset = JavaClasses::compute_injected_offset(JavaClasses::klass##_##name##_enum);
    69   klass::_##name##_offset = JavaClasses::compute_injected_offset(JavaClasses::klass##_##name##_enum);
    69 
    70 
       
    71 #if INCLUDE_CDS
       
    72 #define INJECTED_FIELD_SERIALIZE_OFFSET(klass, name, signature, may_be_java) \
       
    73   f->do_u4((u4*)&_##name##_offset);
       
    74 #endif
       
    75 
    70 #define DECLARE_INJECTED_FIELD(klass, name, signature, may_be_java)           \
    76 #define DECLARE_INJECTED_FIELD(klass, name, signature, may_be_java)           \
    71   { SystemDictionary::WK_KLASS_ENUM_NAME(klass), vmSymbols::VM_SYMBOL_ENUM_NAME(name##_name), vmSymbols::VM_SYMBOL_ENUM_NAME(signature), may_be_java },
    77   { SystemDictionary::WK_KLASS_ENUM_NAME(klass), vmSymbols::VM_SYMBOL_ENUM_NAME(name##_name), vmSymbols::VM_SYMBOL_ENUM_NAME(signature), may_be_java },
    72 
    78 
    73 InjectedField JavaClasses::_injected_fields[] = {
    79 InjectedField JavaClasses::_injected_fields[] = {
    74   ALL_INJECTED_FIELDS(DECLARE_INJECTED_FIELD)
    80   ALL_INJECTED_FIELDS(DECLARE_INJECTED_FIELD)
   168 
   174 
   169 bool java_lang_String::is_instance(oop obj) {
   175 bool java_lang_String::is_instance(oop obj) {
   170   return is_instance_inlined(obj);
   176   return is_instance_inlined(obj);
   171 }
   177 }
   172 
   178 
       
   179 #if INCLUDE_CDS
       
   180 #define FIELD_SERIALIZE_OFFSET(offset, klass, name, signature, is_static) \
       
   181   f->do_u4((u4*)&offset)
       
   182 
       
   183 #define FIELD_SERIALIZE_OFFSET_OPTIONAL(offset, klass, name, signature) \
       
   184   f->do_u4((u4*)&offset)
       
   185 #endif
       
   186 
       
   187 #define FIELD_COMPUTE_OFFSET(offset, klass, name, signature, is_static) \
       
   188   compute_offset(offset, klass, name, vmSymbols::signature(), is_static)
       
   189 
       
   190 #define FIELD_COMPUTE_OFFSET_OPTIONAL(offset, klass, name, signature) \
       
   191   compute_optional_offset(offset, klass, name, vmSymbols::signature())
       
   192 
       
   193 #define STRING_FIELDS_DO(macro) \
       
   194   macro(value_offset, k, vmSymbols::value_name(), byte_array_signature, false); \
       
   195   macro(hash_offset,  k, "hash",                  int_signature,        false); \
       
   196   macro(coder_offset, k, "coder",                 byte_signature,       false)
       
   197 
   173 void java_lang_String::compute_offsets() {
   198 void java_lang_String::compute_offsets() {
   174   assert(!initialized, "offsets should be initialized only once");
   199   if (initialized) {
       
   200     return;
       
   201   }
   175 
   202 
   176   InstanceKlass* k = SystemDictionary::String_klass();
   203   InstanceKlass* k = SystemDictionary::String_klass();
   177   compute_offset(value_offset,           k, vmSymbols::value_name(),  vmSymbols::byte_array_signature());
   204   STRING_FIELDS_DO(FIELD_COMPUTE_OFFSET);
   178   compute_offset(hash_offset,            k, "hash",   vmSymbols::int_signature());
       
   179   compute_offset(coder_offset,           k, "coder",  vmSymbols::byte_signature());
       
   180 
   205 
   181   initialized = true;
   206   initialized = true;
   182 }
   207 }
       
   208 
       
   209 #if INCLUDE_CDS
       
   210 void java_lang_String::serialize(SerializeClosure* f) {
       
   211   STRING_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
       
   212   f->do_u4((u4*)&initialized);
       
   213 }
       
   214 #endif
   183 
   215 
   184 class CompactStringsFixup : public FieldClosure {
   216 class CompactStringsFixup : public FieldClosure {
   185 private:
   217 private:
   186   bool _value;
   218   bool _value;
   187 
   219 
   729       case T_LONG:
   761       case T_LONG:
   730         mirror()->long_field_put(fd->offset(), fd->long_initial_value());
   762         mirror()->long_field_put(fd->offset(), fd->long_initial_value());
   731         break;
   763         break;
   732       case T_OBJECT:
   764       case T_OBJECT:
   733         {
   765         {
   734           #ifdef ASSERT
   766           assert(fd->signature() == vmSymbols::string_signature(),
   735           TempNewSymbol sym = SymbolTable::new_symbol("Ljava/lang/String;", CHECK);
   767                  "just checking");
   736           assert(fd->signature() == sym, "just checking");
   768           if (DumpSharedSpaces && oopDesc::is_archive_object(mirror())) {
   737           #endif
   769             // Archive the String field and update the pointer.
   738           oop string = fd->string_initial_value(CHECK);
   770             oop s = mirror()->obj_field(fd->offset());
   739           mirror()->obj_field_put(fd->offset(), string);
   771             oop archived_s = StringTable::create_archived_string(s, CHECK);
       
   772             mirror()->obj_field_put(fd->offset(), archived_s);
       
   773           } else {
       
   774             oop string = fd->string_initial_value(CHECK);
       
   775             mirror()->obj_field_put(fd->offset(), string);
       
   776           }
   740         }
   777         }
   741         break;
   778         break;
   742       default:
   779       default:
   743         THROW_MSG(vmSymbols::java_lang_ClassFormatError(),
   780         THROW_MSG(vmSymbols::java_lang_ClassFormatError(),
   744                   "Illegal ConstantValue attribute in class file");
   781                   "Illegal ConstantValue attribute in class file");
   760         if (fs.access_flags().is_static()) {
   797         if (fs.access_flags().is_static()) {
   761           int real_offset = fs.offset() + InstanceMirrorKlass::offset_of_static_fields();
   798           int real_offset = fs.offset() + InstanceMirrorKlass::offset_of_static_fields();
   762           fs.set_offset(real_offset);
   799           fs.set_offset(real_offset);
   763         }
   800         }
   764       }
   801       }
       
   802     }
       
   803   }
       
   804 
       
   805   if (k->is_shared() && k->has_raw_archived_mirror()) {
       
   806     if (MetaspaceShared::open_archive_heap_region_mapped()) {
       
   807       oop m = k->archived_java_mirror();
       
   808       assert(m != NULL, "archived mirror is NULL");
       
   809       assert(oopDesc::is_archive_object(m), "must be archived mirror object");
       
   810       Handle m_h(THREAD, m);
       
   811       // restore_archived_mirror() clears the klass' _has_raw_archived_mirror flag
       
   812       restore_archived_mirror(k, m_h, Handle(), Handle(), Handle(), CHECK);
       
   813       return;
       
   814     } else {
       
   815       k->set_java_mirror_handle(NULL);
       
   816       k->clear_has_raw_archived_mirror();
   765     }
   817     }
   766   }
   818   }
   767   create_mirror(k, Handle(), Handle(), Handle(), CHECK);
   819   create_mirror(k, Handle(), Handle(), Handle(), CHECK);
   768 }
   820 }
   769 
   821 
   913   } else {
   965   } else {
   914     assert(fixup_mirror_list() != NULL, "fixup_mirror_list not initialized");
   966     assert(fixup_mirror_list() != NULL, "fixup_mirror_list not initialized");
   915     fixup_mirror_list()->push(k);
   967     fixup_mirror_list()->push(k);
   916   }
   968   }
   917 }
   969 }
       
   970 
       
   971 #if INCLUDE_CDS_JAVA_HEAP
       
   972 // Clears mirror fields. Static final fields with initial values are reloaded
       
   973 // from constant pool. The object identity hash is in the object header and is
       
   974 // not affected.
       
   975 class ResetMirrorField: public FieldClosure {
       
   976  private:
       
   977   Handle _m;
       
   978 
       
   979  public:
       
   980   ResetMirrorField(Handle mirror) : _m(mirror) {}
       
   981 
       
   982   void do_field(fieldDescriptor* fd) {
       
   983     assert(DumpSharedSpaces, "dump time only");
       
   984     assert(_m.not_null(), "Mirror cannot be NULL");
       
   985 
       
   986     if (fd->is_static() && fd->has_initial_value()) {
       
   987       initialize_static_field(fd, _m, Thread::current());
       
   988       return;
       
   989     }
       
   990 
       
   991     BasicType ft = fd->field_type();
       
   992     switch (ft) {
       
   993       case T_BYTE:
       
   994         _m()->byte_field_put(fd->offset(), 0);
       
   995         break;
       
   996       case T_CHAR:
       
   997         _m()->char_field_put(fd->offset(), 0);
       
   998         break;
       
   999       case T_DOUBLE:
       
  1000         _m()->double_field_put(fd->offset(), 0);
       
  1001         break;
       
  1002       case T_FLOAT:
       
  1003         _m()->float_field_put(fd->offset(), 0);
       
  1004         break;
       
  1005       case T_INT:
       
  1006         _m()->int_field_put(fd->offset(), 0);
       
  1007         break;
       
  1008       case T_LONG:
       
  1009         _m()->long_field_put(fd->offset(), 0);
       
  1010         break;
       
  1011       case T_SHORT:
       
  1012         _m()->short_field_put(fd->offset(), 0);
       
  1013         break;
       
  1014       case T_BOOLEAN:
       
  1015         _m()->bool_field_put(fd->offset(), false);
       
  1016         break;
       
  1017       case T_ARRAY:
       
  1018       case T_OBJECT: {
       
  1019         // It might be useful to cache the String field, but
       
  1020         // for now just clear out any reference field
       
  1021         oop o = _m()->obj_field(fd->offset());
       
  1022         _m()->obj_field_put(fd->offset(), NULL);
       
  1023         break;
       
  1024       }
       
  1025       default:
       
  1026         ShouldNotReachHere();
       
  1027         break;
       
  1028      }
       
  1029   }
       
  1030 };
       
  1031 
       
  1032 void java_lang_Class::archive_basic_type_mirrors(TRAPS) {
       
  1033   assert(MetaspaceShared::is_heap_object_archiving_allowed(),
       
  1034          "MetaspaceShared::is_heap_object_archiving_allowed() must be true");
       
  1035 
       
  1036   for (int t = 0; t <= T_VOID; t++) {
       
  1037     oop m = Universe::_mirrors[t];
       
  1038     if (m != NULL) {
       
  1039       // Update the field at _array_klass_offset to point to the relocated array klass.
       
  1040       oop archived_m = MetaspaceShared::archive_heap_object(m, THREAD);
       
  1041       Klass *ak = (Klass*)(archived_m->metadata_field(_array_klass_offset));
       
  1042       assert(ak != NULL || t == T_VOID, "should not be NULL");
       
  1043       if (ak != NULL) {
       
  1044         Klass *reloc_ak = MetaspaceShared::get_relocated_klass(ak);
       
  1045         archived_m->metadata_field_put(_array_klass_offset, reloc_ak);
       
  1046       }
       
  1047 
       
  1048       // Clear the fields. Just to be safe
       
  1049       Klass *k = m->klass();
       
  1050       Handle archived_mirror_h(THREAD, archived_m);
       
  1051       ResetMirrorField reset(archived_mirror_h);
       
  1052       InstanceKlass::cast(k)->do_nonstatic_fields(&reset);
       
  1053 
       
  1054       log_trace(cds, mirror)("Archived %s mirror object from " PTR_FORMAT " ==> " PTR_FORMAT,
       
  1055                              type2name((BasicType)t), p2i(Universe::_mirrors[t]), p2i(archived_m));
       
  1056 
       
  1057       Universe::_mirrors[t] = archived_m;
       
  1058     }
       
  1059   }
       
  1060 
       
  1061   assert(Universe::_mirrors[T_INT] != NULL &&
       
  1062          Universe::_mirrors[T_FLOAT] != NULL &&
       
  1063          Universe::_mirrors[T_DOUBLE] != NULL &&
       
  1064          Universe::_mirrors[T_BYTE] != NULL &&
       
  1065          Universe::_mirrors[T_BOOLEAN] != NULL &&
       
  1066          Universe::_mirrors[T_CHAR] != NULL &&
       
  1067          Universe::_mirrors[T_LONG] != NULL &&
       
  1068          Universe::_mirrors[T_SHORT] != NULL &&
       
  1069          Universe::_mirrors[T_VOID] != NULL, "sanity");
       
  1070 
       
  1071   Universe::set_int_mirror(Universe::_mirrors[T_INT]);
       
  1072   Universe::set_float_mirror(Universe::_mirrors[T_FLOAT]);
       
  1073   Universe::set_double_mirror(Universe::_mirrors[T_DOUBLE]);
       
  1074   Universe::set_byte_mirror(Universe::_mirrors[T_BYTE]);
       
  1075   Universe::set_bool_mirror(Universe::_mirrors[T_BOOLEAN]);
       
  1076   Universe::set_char_mirror(Universe::_mirrors[T_CHAR]);
       
  1077   Universe::set_long_mirror(Universe::_mirrors[T_LONG]);
       
  1078   Universe::set_short_mirror(Universe::_mirrors[T_SHORT]);
       
  1079   Universe::set_void_mirror(Universe::_mirrors[T_VOID]);
       
  1080 }
       
  1081 
       
  1082 //
       
  1083 // After the mirror object is successfully archived, the archived
       
  1084 // klass is set with _has_archived_raw_mirror flag.
       
  1085 //
       
  1086 // The _has_archived_raw_mirror flag is cleared at runtime when the
       
  1087 // archived mirror is restored. If archived java heap data cannot
       
  1088 // be used at runtime, new mirror object is created for the shared
       
  1089 // class. The _has_archived_raw_mirror is cleared also during the process.
       
  1090 oop java_lang_Class::archive_mirror(Klass* k, TRAPS) {
       
  1091   assert(MetaspaceShared::is_heap_object_archiving_allowed(),
       
  1092          "MetaspaceShared::is_heap_object_archiving_allowed() must be true");
       
  1093 
       
  1094   // Mirror is already archived
       
  1095   if (k->has_raw_archived_mirror()) {
       
  1096     assert(k->archived_java_mirror_raw() != NULL, "no archived mirror");
       
  1097     return k->archived_java_mirror_raw();
       
  1098   }
       
  1099 
       
  1100   // No mirror
       
  1101   oop mirror = k->java_mirror();
       
  1102   if (mirror == NULL) {
       
  1103     return NULL;
       
  1104   }
       
  1105 
       
  1106   if (k->is_instance_klass()) {
       
  1107     InstanceKlass *ik = InstanceKlass::cast(k);
       
  1108     assert(ik->signers() == NULL && !k->has_signer_and_not_archived(),
       
  1109            "class with signer cannot be supported");
       
  1110 
       
  1111     if (!(ik->is_shared_boot_class() || ik->is_shared_platform_class() ||
       
  1112           ik->is_shared_app_class())) {
       
  1113       // Archiving mirror for classes from non-builtin loaders is not
       
  1114       // supported. Clear the _java_mirror within the archived class.
       
  1115       k->set_java_mirror_handle(NULL);
       
  1116       return NULL;
       
  1117     }
       
  1118   }
       
  1119 
       
  1120   // Now start archiving the mirror object
       
  1121   oop archived_mirror = MetaspaceShared::archive_heap_object(mirror, THREAD);
       
  1122   if (archived_mirror == NULL) {
       
  1123     return NULL;
       
  1124   }
       
  1125 
       
  1126   archived_mirror = process_archived_mirror(k, mirror, archived_mirror, THREAD);
       
  1127   if (archived_mirror == NULL) {
       
  1128     return NULL;
       
  1129   }
       
  1130 
       
  1131   k->set_archived_java_mirror_raw(archived_mirror);
       
  1132 
       
  1133   k->set_has_raw_archived_mirror();
       
  1134 
       
  1135   ResourceMark rm;
       
  1136   log_trace(cds, mirror)("Archived %s mirror object from " PTR_FORMAT " ==> " PTR_FORMAT,
       
  1137                          k->external_name(), p2i(mirror), p2i(archived_mirror));
       
  1138 
       
  1139   return archived_mirror;
       
  1140 }
       
  1141 
       
  1142 // The process is based on create_mirror().
       
  1143 oop java_lang_Class::process_archived_mirror(Klass* k, oop mirror,
       
  1144                                              oop archived_mirror,
       
  1145                                              Thread *THREAD) {
       
  1146   // Clear nonstatic fields in archived mirror. Some of the fields will be set
       
  1147   // to archived metadata and objects below.
       
  1148   Klass *c = archived_mirror->klass();
       
  1149   Handle archived_mirror_h(THREAD, archived_mirror);
       
  1150   ResetMirrorField reset(archived_mirror_h);
       
  1151   InstanceKlass::cast(c)->do_nonstatic_fields(&reset);
       
  1152 
       
  1153   if (k->is_array_klass()) {
       
  1154     oop archived_comp_mirror;
       
  1155     if (k->is_typeArray_klass()) {
       
  1156       // The primitive type mirrors are already archived. Get the archived mirror.
       
  1157       oop comp_mirror = java_lang_Class::component_mirror(mirror);
       
  1158       archived_comp_mirror = MetaspaceShared::find_archived_heap_object(comp_mirror);
       
  1159       assert(archived_comp_mirror != NULL, "Must be");
       
  1160     } else {
       
  1161       assert(k->is_objArray_klass(), "Must be");
       
  1162       Klass* element_klass = ObjArrayKlass::cast(k)->element_klass();
       
  1163       assert(element_klass != NULL, "Must have an element klass");
       
  1164       archived_comp_mirror = archive_mirror(element_klass, THREAD);
       
  1165       if (archived_comp_mirror == NULL) {
       
  1166         return NULL;
       
  1167       }
       
  1168     }
       
  1169     java_lang_Class::set_component_mirror(archived_mirror, archived_comp_mirror);
       
  1170   } else {
       
  1171     assert(k->is_instance_klass(), "Must be");
       
  1172 
       
  1173     // Reset local static fields in the mirror
       
  1174     InstanceKlass::cast(k)->do_local_static_fields(&reset);
       
  1175 
       
  1176     java_lang_Class:set_init_lock(archived_mirror, NULL);
       
  1177 
       
  1178     set_protection_domain(archived_mirror, NULL);
       
  1179   }
       
  1180 
       
  1181   // clear class loader and mirror_module_field
       
  1182   set_class_loader(archived_mirror, NULL);
       
  1183   set_module(archived_mirror, NULL);
       
  1184 
       
  1185   // The archived mirror's field at _klass_offset is still pointing to the original
       
  1186   // klass. Updated the field in the archived mirror to point to the relocated
       
  1187   // klass in the archive.
       
  1188   Klass *reloc_k = MetaspaceShared::get_relocated_klass(as_Klass(mirror));
       
  1189   log_debug(cds, mirror)("Relocate mirror metadata field at _klass_offset from " PTR_FORMAT " ==> " PTR_FORMAT,
       
  1190                          p2i(as_Klass(mirror)), p2i(reloc_k));
       
  1191   archived_mirror->metadata_field_put(_klass_offset, reloc_k);
       
  1192 
       
  1193   // The field at _array_klass_offset is pointing to the original one dimension
       
  1194   // higher array klass if exists. Relocate the pointer.
       
  1195   Klass *arr = array_klass_acquire(mirror);
       
  1196   if (arr != NULL) {
       
  1197     Klass *reloc_arr = MetaspaceShared::get_relocated_klass(arr);
       
  1198     log_debug(cds, mirror)("Relocate mirror metadata field at _array_klass_offset from " PTR_FORMAT " ==> " PTR_FORMAT,
       
  1199                            p2i(arr), p2i(reloc_arr));
       
  1200     archived_mirror->metadata_field_put(_array_klass_offset, reloc_arr);
       
  1201   }
       
  1202   return archived_mirror;
       
  1203 }
       
  1204 
       
  1205 // After the archived mirror object is restored, the shared klass'
       
  1206 // _has_raw_archived_mirror flag is cleared
       
  1207 void java_lang_Class::restore_archived_mirror(Klass *k, Handle mirror,
       
  1208                                               Handle class_loader, Handle module,
       
  1209                                               Handle protection_domain, TRAPS) {
       
  1210 
       
  1211   // The java.lang.Class field offsets were archived and reloaded from archive.
       
  1212   // No need to put classes on the fixup_mirror_list before java.lang.Class
       
  1213   // is loaded.
       
  1214 
       
  1215   if (!k->is_array_klass()) {
       
  1216     // - local static final fields with initial values were initialized at dump time
       
  1217 
       
  1218     // create the init_lock
       
  1219     typeArrayOop r = oopFactory::new_typeArray(T_INT, 0, CHECK);
       
  1220     set_init_lock(mirror(), r);
       
  1221 
       
  1222     if (protection_domain.not_null()) {
       
  1223       set_protection_domain(mirror(), protection_domain());
       
  1224     }
       
  1225   }
       
  1226 
       
  1227   assert(class_loader() == k->class_loader(), "should be same");
       
  1228   if (class_loader.not_null()) {
       
  1229     set_class_loader(mirror(), class_loader());
       
  1230   }
       
  1231 
       
  1232   k->set_java_mirror(mirror);
       
  1233   k->clear_has_raw_archived_mirror();
       
  1234 
       
  1235   set_mirror_module_field(k, mirror, module, THREAD);
       
  1236 
       
  1237   ResourceMark rm;
       
  1238   log_trace(cds, mirror)("Restored %s archived mirror " PTR_FORMAT, k->external_name(), p2i(mirror()));
       
  1239 }
       
  1240 #endif // INCLUDE_CDS_JAVA_HEAP
   918 
  1241 
   919 void java_lang_Class::fixup_module_field(Klass* k, Handle module) {
  1242 void java_lang_Class::fixup_module_field(Klass* k, Handle module) {
   920   assert(_module_offset != 0, "must have been computed already");
  1243   assert(_module_offset != 0, "must have been computed already");
   921   java_lang_Class::set_module(k->java_mirror(), module());
  1244   java_lang_Class::set_module(k->java_mirror(), module());
   922 }
  1245 }
  1165 }
  1488 }
  1166 
  1489 
  1167 bool java_lang_Class::offsets_computed = false;
  1490 bool java_lang_Class::offsets_computed = false;
  1168 int  java_lang_Class::classRedefinedCount_offset = -1;
  1491 int  java_lang_Class::classRedefinedCount_offset = -1;
  1169 
  1492 
       
  1493 #define CLASS_FIELDS_DO(macro) \
       
  1494   macro(classRedefinedCount_offset, k, "classRedefinedCount", int_signature,         false) ; \
       
  1495   macro(_class_loader_offset,       k, "classLoader",         classloader_signature, false); \
       
  1496   macro(_component_mirror_offset,   k, "componentType",       class_signature,       false); \
       
  1497   macro(_module_offset,             k, "module",              module_signature,      false)
       
  1498 
  1170 void java_lang_Class::compute_offsets() {
  1499 void java_lang_Class::compute_offsets() {
  1171   assert(!offsets_computed, "offsets should be initialized only once");
  1500   if (offsets_computed) {
       
  1501     return;
       
  1502   }
       
  1503 
  1172   offsets_computed = true;
  1504   offsets_computed = true;
  1173 
  1505 
  1174   InstanceKlass* k = SystemDictionary::Class_klass();
  1506   InstanceKlass* k = SystemDictionary::Class_klass();
  1175   compute_offset(classRedefinedCount_offset, k, "classRedefinedCount", vmSymbols::int_signature());
  1507   CLASS_FIELDS_DO(FIELD_COMPUTE_OFFSET);
  1176   compute_offset(_class_loader_offset,       k, "classLoader", vmSymbols::classloader_signature());
       
  1177   compute_offset(_component_mirror_offset,   k, "componentType", vmSymbols::class_signature());
       
  1178   compute_offset(_module_offset,             k, "module", vmSymbols::module_signature());
       
  1179 
  1508 
  1180   // Init lock is a C union with component_mirror.  Only instanceKlass mirrors have
  1509   // Init lock is a C union with component_mirror.  Only instanceKlass mirrors have
  1181   // init_lock and only ArrayKlass mirrors have component_mirror.  Since both are oops
  1510   // init_lock and only ArrayKlass mirrors have component_mirror.  Since both are oops
  1182   // GC treats them the same.
  1511   // GC treats them the same.
  1183   _init_lock_offset = _component_mirror_offset;
  1512   _init_lock_offset = _component_mirror_offset;
  1184 
  1513 
  1185   CLASS_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
  1514   CLASS_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
  1186 }
  1515 }
       
  1516 
       
  1517 #if INCLUDE_CDS
       
  1518 void java_lang_Class::serialize(SerializeClosure* f) {
       
  1519   f->do_u4((u4*)&offsets_computed);
       
  1520   f->do_u4((u4*)&_init_lock_offset);
       
  1521 
       
  1522   CLASS_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
       
  1523 
       
  1524   CLASS_INJECTED_FIELDS(INJECTED_FIELD_SERIALIZE_OFFSET);
       
  1525 }
       
  1526 #endif
  1187 
  1527 
  1188 int java_lang_Class::classRedefinedCount(oop the_class_mirror) {
  1528 int java_lang_Class::classRedefinedCount(oop the_class_mirror) {
  1189   if (classRedefinedCount_offset == -1) {
  1529   if (classRedefinedCount_offset == -1) {
  1190     // If we don't have an offset for it then just return -1 as a marker.
  1530     // If we don't have an offset for it then just return -1 as a marker.
  1191     return -1;
  1531     return -1;
  1224 int java_lang_Thread::_tid_offset = 0;
  1564 int java_lang_Thread::_tid_offset = 0;
  1225 int java_lang_Thread::_thread_status_offset = 0;
  1565 int java_lang_Thread::_thread_status_offset = 0;
  1226 int java_lang_Thread::_park_blocker_offset = 0;
  1566 int java_lang_Thread::_park_blocker_offset = 0;
  1227 int java_lang_Thread::_park_event_offset = 0 ;
  1567 int java_lang_Thread::_park_event_offset = 0 ;
  1228 
  1568 
       
  1569 #define THREAD_FIELDS_DO(macro) \
       
  1570   macro(_name_offset,          k, vmSymbols::name_name(), string_signature, false); \
       
  1571   macro(_group_offset,         k, vmSymbols::group_name(), threadgroup_signature, false); \
       
  1572   macro(_contextClassLoader_offset, k, vmSymbols::contextClassLoader_name(), classloader_signature, false); \
       
  1573   macro(_inheritedAccessControlContext_offset, k, vmSymbols::inheritedAccessControlContext_name(), accesscontrolcontext_signature, false); \
       
  1574   macro(_priority_offset,      k, vmSymbols::priority_name(), int_signature, false); \
       
  1575   macro(_daemon_offset,        k, vmSymbols::daemon_name(), bool_signature, false); \
       
  1576   macro(_eetop_offset,         k, "eetop", long_signature, false); \
       
  1577   macro(_stillborn_offset,     k, "stillborn", bool_signature, false); \
       
  1578   macro(_stackSize_offset,     k, "stackSize", long_signature, false); \
       
  1579   macro(_tid_offset,           k, "tid", long_signature, false); \
       
  1580   macro(_thread_status_offset, k, "threadStatus", int_signature, false); \
       
  1581   macro(_park_blocker_offset,  k, "parkBlocker", object_signature, false); \
       
  1582   macro(_park_event_offset,    k, "nativeParkEventPointer", long_signature, false)
  1229 
  1583 
  1230 void java_lang_Thread::compute_offsets() {
  1584 void java_lang_Thread::compute_offsets() {
  1231   assert(_group_offset == 0, "offsets should be initialized only once");
  1585   assert(_group_offset == 0, "offsets should be initialized only once");
  1232 
  1586 
  1233   InstanceKlass* k = SystemDictionary::Thread_klass();
  1587   InstanceKlass* k = SystemDictionary::Thread_klass();
  1234   compute_offset(_name_offset,      k, vmSymbols::name_name(),      vmSymbols::string_signature());
  1588   THREAD_FIELDS_DO(FIELD_COMPUTE_OFFSET);
  1235   compute_offset(_group_offset,     k, vmSymbols::group_name(),     vmSymbols::threadgroup_signature());
  1589 }
  1236   compute_offset(_contextClassLoader_offset, k, vmSymbols::contextClassLoader_name(),
  1590 
  1237                  vmSymbols::classloader_signature());
  1591 #if INCLUDE_CDS
  1238   compute_offset(_inheritedAccessControlContext_offset, k, vmSymbols::inheritedAccessControlContext_name(),
  1592 void java_lang_Thread::serialize(SerializeClosure* f) {
  1239                  vmSymbols::accesscontrolcontext_signature());
  1593   THREAD_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
  1240   compute_offset(_priority_offset,  k, vmSymbols::priority_name(),  vmSymbols::int_signature());
  1594 }
  1241   compute_offset(_daemon_offset,    k, vmSymbols::daemon_name(),    vmSymbols::bool_signature());
  1595 #endif
  1242   compute_offset(_eetop_offset,     k, "eetop", vmSymbols::long_signature());
       
  1243   compute_offset(_stillborn_offset, k, "stillborn", vmSymbols::bool_signature());
       
  1244   compute_offset(_stackSize_offset, k, "stackSize", vmSymbols::long_signature());
       
  1245   compute_offset(_tid_offset,       k, "tid", vmSymbols::long_signature());
       
  1246   compute_offset(_thread_status_offset, k, "threadStatus", vmSymbols::int_signature());
       
  1247   compute_offset(_park_blocker_offset,  k, "parkBlocker", vmSymbols::object_signature());
       
  1248   compute_offset(_park_event_offset,    k, "nativeParkEventPointer", vmSymbols::long_signature());
       
  1249 }
       
  1250 
       
  1251 
  1596 
  1252 JavaThread* java_lang_Thread::thread(oop java_thread) {
  1597 JavaThread* java_lang_Thread::thread(oop java_thread) {
  1253   return (JavaThread*)java_thread->address_field(_eetop_offset);
  1598   return (JavaThread*)java_thread->address_field(_eetop_offset);
  1254 }
  1599 }
  1255 
  1600 
  1475 bool java_lang_ThreadGroup::is_daemon(oop java_thread_group) {
  1820 bool java_lang_ThreadGroup::is_daemon(oop java_thread_group) {
  1476   assert(oopDesc::is_oop(java_thread_group), "thread group must be oop");
  1821   assert(oopDesc::is_oop(java_thread_group), "thread group must be oop");
  1477   return java_thread_group->bool_field(_daemon_offset) != 0;
  1822   return java_thread_group->bool_field(_daemon_offset) != 0;
  1478 }
  1823 }
  1479 
  1824 
       
  1825 #define THREADGROUP_FIELDS_DO(macro) \
       
  1826   macro(_parent_offset,      k, vmSymbols::parent_name(),      threadgroup_signature,       false); \
       
  1827   macro(_name_offset,        k, vmSymbols::name_name(),        string_signature,            false); \
       
  1828   macro(_threads_offset,     k, vmSymbols::threads_name(),     thread_array_signature,      false); \
       
  1829   macro(_groups_offset,      k, vmSymbols::groups_name(),      threadgroup_array_signature, false); \
       
  1830   macro(_maxPriority_offset, k, vmSymbols::maxPriority_name(), int_signature,               false); \
       
  1831   macro(_destroyed_offset,   k, vmSymbols::destroyed_name(),   bool_signature,              false); \
       
  1832   macro(_daemon_offset,      k, vmSymbols::daemon_name(),      bool_signature,              false); \
       
  1833   macro(_nthreads_offset,    k, vmSymbols::nthreads_name(),    int_signature,               false); \
       
  1834   macro(_ngroups_offset,     k, vmSymbols::ngroups_name(),     int_signature,               false)
       
  1835 
  1480 void java_lang_ThreadGroup::compute_offsets() {
  1836 void java_lang_ThreadGroup::compute_offsets() {
  1481   assert(_parent_offset == 0, "offsets should be initialized only once");
  1837   assert(_parent_offset == 0, "offsets should be initialized only once");
  1482 
  1838 
  1483   InstanceKlass* k = SystemDictionary::ThreadGroup_klass();
  1839   InstanceKlass* k = SystemDictionary::ThreadGroup_klass();
  1484 
  1840   THREADGROUP_FIELDS_DO(FIELD_COMPUTE_OFFSET);
  1485   compute_offset(_parent_offset,      k, vmSymbols::parent_name(),      vmSymbols::threadgroup_signature());
  1841 }
  1486   compute_offset(_name_offset,        k, vmSymbols::name_name(),        vmSymbols::string_signature());
  1842 
  1487   compute_offset(_threads_offset,     k, vmSymbols::threads_name(),     vmSymbols::thread_array_signature());
  1843 #if INCLUDE_CDS
  1488   compute_offset(_groups_offset,      k, vmSymbols::groups_name(),      vmSymbols::threadgroup_array_signature());
  1844 void java_lang_ThreadGroup::serialize(SerializeClosure* f) {
  1489   compute_offset(_maxPriority_offset, k, vmSymbols::maxPriority_name(), vmSymbols::int_signature());
  1845   THREADGROUP_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
  1490   compute_offset(_destroyed_offset,   k, vmSymbols::destroyed_name(),   vmSymbols::bool_signature());
  1846 }
  1491   compute_offset(_daemon_offset,      k, vmSymbols::daemon_name(),      vmSymbols::bool_signature());
  1847 #endif
  1492   compute_offset(_nthreads_offset,    k, vmSymbols::nthreads_name(),    vmSymbols::int_signature());
  1848 
  1493   compute_offset(_ngroups_offset,     k, vmSymbols::ngroups_name(),     vmSymbols::int_signature());
  1849 #define THROWABLE_FIELDS_DO(macro) \
  1494 }
  1850   macro(backtrace_offset,     k, "backtrace",     object_signature,                  false); \
  1495 
  1851   macro(detailMessage_offset, k, "detailMessage", string_signature,                  false); \
       
  1852   macro(stackTrace_offset,    k, "stackTrace",    java_lang_StackTraceElement_array, false); \
       
  1853   macro(depth_offset,         k, "depth",         int_signature,                     false); \
       
  1854   macro(static_unassigned_stacktrace_offset, k, "UNASSIGNED_STACK", java_lang_StackTraceElement_array, true)
  1496 
  1855 
  1497 void java_lang_Throwable::compute_offsets() {
  1856 void java_lang_Throwable::compute_offsets() {
  1498   InstanceKlass* k = SystemDictionary::Throwable_klass();
  1857   InstanceKlass* k = SystemDictionary::Throwable_klass();
  1499   compute_offset(backtrace_offset,     k, "backtrace", vmSymbols::object_signature());
  1858   THROWABLE_FIELDS_DO(FIELD_COMPUTE_OFFSET);
  1500   compute_offset(detailMessage_offset, k, "detailMessage", vmSymbols::string_signature());
  1859 }
  1501   compute_offset(stackTrace_offset,    k, "stackTrace",    vmSymbols::java_lang_StackTraceElement_array());
  1860 
  1502   compute_offset(depth_offset,         k, "depth", vmSymbols::int_signature());
  1861 #if INCLUDE_CDS
  1503   compute_offset(static_unassigned_stacktrace_offset, k, "UNASSIGNED_STACK", vmSymbols::java_lang_StackTraceElement_array(),
  1862 void java_lang_Throwable::serialize(SerializeClosure* f) {
  1504                  /*is_static*/true);
  1863   THROWABLE_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
  1505 }
  1864 }
       
  1865 #endif
  1506 
  1866 
  1507 oop java_lang_Throwable::unassigned_stacktrace() {
  1867 oop java_lang_Throwable::unassigned_stacktrace() {
  1508   InstanceKlass* ik = SystemDictionary::Throwable_klass();
  1868   InstanceKlass* ik = SystemDictionary::Throwable_klass();
  1509   address addr = ik->static_field_addr(static_unassigned_stacktrace_offset);
  1869   address addr = ik->static_field_addr(static_unassigned_stacktrace_offset);
  1510   if (UseCompressedOops) {
  1870   if (UseCompressedOops) {
  2266   short bci = stackFrame->short_field(_bci_offset);
  2626   short bci = stackFrame->short_field(_bci_offset);
  2267   Symbol* name = method->name();
  2627   Symbol* name = method->name();
  2268   java_lang_StackTraceElement::fill_in(stack_trace_element, holder, method, version, bci, name, CHECK);
  2628   java_lang_StackTraceElement::fill_in(stack_trace_element, holder, method, version, bci, name, CHECK);
  2269 }
  2629 }
  2270 
  2630 
       
  2631 #define STACKFRAMEINFO_FIELDS_DO(macro) \
       
  2632   macro(_memberName_offset,     k, "memberName",  object_signature, false); \
       
  2633   macro(_bci_offset,            k, "bci",         short_signature,  false)
       
  2634 
  2271 void java_lang_StackFrameInfo::compute_offsets() {
  2635 void java_lang_StackFrameInfo::compute_offsets() {
  2272   InstanceKlass* k = SystemDictionary::StackFrameInfo_klass();
  2636   InstanceKlass* k = SystemDictionary::StackFrameInfo_klass();
  2273   compute_offset(_memberName_offset,     k, "memberName",  vmSymbols::object_signature());
  2637   STACKFRAMEINFO_FIELDS_DO(FIELD_COMPUTE_OFFSET);
  2274   compute_offset(_bci_offset,            k, "bci",         vmSymbols::short_signature());
       
  2275   STACKFRAMEINFO_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
  2638   STACKFRAMEINFO_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
  2276 }
  2639 }
       
  2640 
       
  2641 #if INCLUDE_CDS
       
  2642 void java_lang_StackFrameInfo::serialize(SerializeClosure* f) {
       
  2643   STACKFRAMEINFO_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
       
  2644   STACKFRAMEINFO_INJECTED_FIELDS(INJECTED_FIELD_SERIALIZE_OFFSET);
       
  2645 }
       
  2646 #endif
       
  2647 
       
  2648 #define LIVESTACKFRAMEINFO_FIELDS_DO(macro) \
       
  2649   macro(_monitors_offset,   k, "monitors",    object_array_signature, false); \
       
  2650   macro(_locals_offset,     k, "locals",      object_array_signature, false); \
       
  2651   macro(_operands_offset,   k, "operands",    object_array_signature, false); \
       
  2652   macro(_mode_offset,       k, "mode",        int_signature,          false)
  2277 
  2653 
  2278 void java_lang_LiveStackFrameInfo::compute_offsets() {
  2654 void java_lang_LiveStackFrameInfo::compute_offsets() {
  2279   InstanceKlass* k = SystemDictionary::LiveStackFrameInfo_klass();
  2655   InstanceKlass* k = SystemDictionary::LiveStackFrameInfo_klass();
  2280   compute_offset(_monitors_offset,   k, "monitors",    vmSymbols::object_array_signature());
  2656   LIVESTACKFRAMEINFO_FIELDS_DO(FIELD_COMPUTE_OFFSET);
  2281   compute_offset(_locals_offset,     k, "locals",      vmSymbols::object_array_signature());
  2657 }
  2282   compute_offset(_operands_offset,   k, "operands",    vmSymbols::object_array_signature());
  2658 
  2283   compute_offset(_mode_offset,       k, "mode",        vmSymbols::int_signature());
  2659 #if INCLUDE_CDS
  2284 }
  2660 void java_lang_LiveStackFrameInfo::serialize(SerializeClosure* f) {
       
  2661   LIVESTACKFRAMEINFO_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
       
  2662 }
       
  2663 #endif
       
  2664 
       
  2665 #define ACCESSIBLEOBJECT_FIELDS_DO(macro) \
       
  2666   macro(override_offset, k, "override", bool_signature, false)
  2285 
  2667 
  2286 void java_lang_reflect_AccessibleObject::compute_offsets() {
  2668 void java_lang_reflect_AccessibleObject::compute_offsets() {
  2287   InstanceKlass* k = SystemDictionary::reflect_AccessibleObject_klass();
  2669   InstanceKlass* k = SystemDictionary::reflect_AccessibleObject_klass();
  2288   compute_offset(override_offset, k, "override", vmSymbols::bool_signature());
  2670   ACCESSIBLEOBJECT_FIELDS_DO(FIELD_COMPUTE_OFFSET);
  2289 }
  2671 }
       
  2672 
       
  2673 #if INCLUDE_CDS
       
  2674 void java_lang_reflect_AccessibleObject::serialize(SerializeClosure* f) {
       
  2675   ACCESSIBLEOBJECT_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
       
  2676 }
       
  2677 #endif
  2290 
  2678 
  2291 jboolean java_lang_reflect_AccessibleObject::override(oop reflect) {
  2679 jboolean java_lang_reflect_AccessibleObject::override(oop reflect) {
  2292   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
  2680   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
  2293   return (jboolean) reflect->bool_field(override_offset);
  2681   return (jboolean) reflect->bool_field(override_offset);
  2294 }
  2682 }
  2295 
  2683 
  2296 void java_lang_reflect_AccessibleObject::set_override(oop reflect, jboolean value) {
  2684 void java_lang_reflect_AccessibleObject::set_override(oop reflect, jboolean value) {
  2297   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
  2685   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
  2298   reflect->bool_field_put(override_offset, (int) value);
  2686   reflect->bool_field_put(override_offset, (int) value);
  2299 }
  2687 }
       
  2688 
       
  2689 #define METHOD_FIELDS_DO(macro) \
       
  2690   macro(clazz_offset,          k, vmSymbols::clazz_name(),          class_signature,       false); \
       
  2691   macro(name_offset,           k, vmSymbols::name_name(),           string_signature,      false); \
       
  2692   macro(returnType_offset,     k, vmSymbols::returnType_name(),     class_signature,       false); \
       
  2693   macro(parameterTypes_offset, k, vmSymbols::parameterTypes_name(), class_array_signature, false); \
       
  2694   macro(exceptionTypes_offset, k, vmSymbols::exceptionTypes_name(), class_array_signature, false); \
       
  2695   macro(slot_offset,           k, vmSymbols::slot_name(),           int_signature,         false); \
       
  2696   macro(modifiers_offset,      k, vmSymbols::modifiers_name(),      int_signature,         false); \
       
  2697   macro##_OPTIONAL(signature_offset,             k, vmSymbols::signature_name(),             string_signature); \
       
  2698   macro##_OPTIONAL(annotations_offset,           k, vmSymbols::annotations_name(),           byte_array_signature); \
       
  2699   macro##_OPTIONAL(parameter_annotations_offset, k, vmSymbols::parameter_annotations_name(), byte_array_signature); \
       
  2700   macro##_OPTIONAL(annotation_default_offset,    k, vmSymbols::annotation_default_name(),    byte_array_signature); \
       
  2701   macro##_OPTIONAL(type_annotations_offset,      k, vmSymbols::type_annotations_name(),      byte_array_signature)
  2300 
  2702 
  2301 void java_lang_reflect_Method::compute_offsets() {
  2703 void java_lang_reflect_Method::compute_offsets() {
  2302   InstanceKlass* k = SystemDictionary::reflect_Method_klass();
  2704   InstanceKlass* k = SystemDictionary::reflect_Method_klass();
  2303   compute_offset(clazz_offset,          k, vmSymbols::clazz_name(),          vmSymbols::class_signature());
       
  2304   compute_offset(name_offset,           k, vmSymbols::name_name(),           vmSymbols::string_signature());
       
  2305   compute_offset(returnType_offset,     k, vmSymbols::returnType_name(),     vmSymbols::class_signature());
       
  2306   compute_offset(parameterTypes_offset, k, vmSymbols::parameterTypes_name(), vmSymbols::class_array_signature());
       
  2307   compute_offset(exceptionTypes_offset, k, vmSymbols::exceptionTypes_name(), vmSymbols::class_array_signature());
       
  2308   compute_offset(slot_offset,           k, vmSymbols::slot_name(),           vmSymbols::int_signature());
       
  2309   compute_offset(modifiers_offset,      k, vmSymbols::modifiers_name(),      vmSymbols::int_signature());
       
  2310   // The generic signature and annotations fields are only present in 1.5
  2705   // The generic signature and annotations fields are only present in 1.5
  2311   signature_offset = -1;
  2706   signature_offset = -1;
  2312   annotations_offset = -1;
  2707   annotations_offset = -1;
  2313   parameter_annotations_offset = -1;
  2708   parameter_annotations_offset = -1;
  2314   annotation_default_offset = -1;
  2709   annotation_default_offset = -1;
  2315   type_annotations_offset = -1;
  2710   type_annotations_offset = -1;
  2316   compute_optional_offset(signature_offset,             k, vmSymbols::signature_name(),             vmSymbols::string_signature());
  2711   METHOD_FIELDS_DO(FIELD_COMPUTE_OFFSET);
  2317   compute_optional_offset(annotations_offset,           k, vmSymbols::annotations_name(),           vmSymbols::byte_array_signature());
  2712 }
  2318   compute_optional_offset(parameter_annotations_offset, k, vmSymbols::parameter_annotations_name(), vmSymbols::byte_array_signature());
  2713 
  2319   compute_optional_offset(annotation_default_offset,    k, vmSymbols::annotation_default_name(),    vmSymbols::byte_array_signature());
  2714 #if INCLUDE_CDS
  2320   compute_optional_offset(type_annotations_offset,      k, vmSymbols::type_annotations_name(),      vmSymbols::byte_array_signature());
  2715 void java_lang_reflect_Method::serialize(SerializeClosure* f) {
  2321 }
  2716   METHOD_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
       
  2717 }
       
  2718 #endif
  2322 
  2719 
  2323 Handle java_lang_reflect_Method::create(TRAPS) {
  2720 Handle java_lang_reflect_Method::create(TRAPS) {
  2324   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
  2721   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
  2325   Klass* klass = SystemDictionary::reflect_Method_klass();
  2722   Klass* klass = SystemDictionary::reflect_Method_klass();
  2326   // This class is eagerly initialized during VM initialization, since we keep a refence
  2723   // This class is eagerly initialized during VM initialization, since we keep a refence
  2477   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
  2874   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
  2478   assert(has_type_annotations_field(), "type_annotations field must be present");
  2875   assert(has_type_annotations_field(), "type_annotations field must be present");
  2479   method->obj_field_put(type_annotations_offset, value);
  2876   method->obj_field_put(type_annotations_offset, value);
  2480 }
  2877 }
  2481 
  2878 
       
  2879 #define CONSTRUCTOR_FIELDS_DO(macro) \
       
  2880   macro(clazz_offset,          k, vmSymbols::clazz_name(),          class_signature,       false); \
       
  2881   macro(parameterTypes_offset, k, vmSymbols::parameterTypes_name(), class_array_signature, false); \
       
  2882   macro(exceptionTypes_offset, k, vmSymbols::exceptionTypes_name(), class_array_signature, false); \
       
  2883   macro(slot_offset,           k, vmSymbols::slot_name(),           int_signature,         false); \
       
  2884   macro(modifiers_offset,      k, vmSymbols::modifiers_name(),      int_signature,         false); \
       
  2885   macro##_OPTIONAL(signature_offset,             k, vmSymbols::signature_name(),             string_signature); \
       
  2886   macro##_OPTIONAL(annotations_offset,           k, vmSymbols::annotations_name(),           byte_array_signature); \
       
  2887   macro##_OPTIONAL(parameter_annotations_offset, k, vmSymbols::parameter_annotations_name(), byte_array_signature); \
       
  2888   macro##_OPTIONAL(type_annotations_offset,      k, vmSymbols::type_annotations_name(),      byte_array_signature)
       
  2889 
       
  2890 
  2482 void java_lang_reflect_Constructor::compute_offsets() {
  2891 void java_lang_reflect_Constructor::compute_offsets() {
  2483   InstanceKlass* k = SystemDictionary::reflect_Constructor_klass();
  2892   InstanceKlass* k = SystemDictionary::reflect_Constructor_klass();
  2484   compute_offset(clazz_offset,          k, vmSymbols::clazz_name(),          vmSymbols::class_signature());
       
  2485   compute_offset(parameterTypes_offset, k, vmSymbols::parameterTypes_name(), vmSymbols::class_array_signature());
       
  2486   compute_offset(exceptionTypes_offset, k, vmSymbols::exceptionTypes_name(), vmSymbols::class_array_signature());
       
  2487   compute_offset(slot_offset,           k, vmSymbols::slot_name(),           vmSymbols::int_signature());
       
  2488   compute_offset(modifiers_offset,      k, vmSymbols::modifiers_name(),      vmSymbols::int_signature());
       
  2489   // The generic signature and annotations fields are only present in 1.5
  2893   // The generic signature and annotations fields are only present in 1.5
  2490   signature_offset = -1;
  2894   signature_offset = -1;
  2491   annotations_offset = -1;
  2895   annotations_offset = -1;
  2492   parameter_annotations_offset = -1;
  2896   parameter_annotations_offset = -1;
  2493   type_annotations_offset = -1;
  2897   type_annotations_offset = -1;
  2494   compute_optional_offset(signature_offset,             k, vmSymbols::signature_name(),             vmSymbols::string_signature());
  2898   CONSTRUCTOR_FIELDS_DO(FIELD_COMPUTE_OFFSET);
  2495   compute_optional_offset(annotations_offset,           k, vmSymbols::annotations_name(),           vmSymbols::byte_array_signature());
  2899 }
  2496   compute_optional_offset(parameter_annotations_offset, k, vmSymbols::parameter_annotations_name(), vmSymbols::byte_array_signature());
  2900 
  2497   compute_optional_offset(type_annotations_offset,      k, vmSymbols::type_annotations_name(),      vmSymbols::byte_array_signature());
  2901 #if INCLUDE_CDS
  2498 }
  2902 void java_lang_reflect_Constructor::serialize(SerializeClosure* f) {
       
  2903   CONSTRUCTOR_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
       
  2904 }
       
  2905 #endif
  2499 
  2906 
  2500 Handle java_lang_reflect_Constructor::create(TRAPS) {
  2907 Handle java_lang_reflect_Constructor::create(TRAPS) {
  2501   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
  2908   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
  2502   Symbol* name = vmSymbols::java_lang_reflect_Constructor();
  2909   Symbol* name = vmSymbols::java_lang_reflect_Constructor();
  2503   Klass* k = SystemDictionary::resolve_or_fail(name, true, CHECK_NH);
  2910   Klass* k = SystemDictionary::resolve_or_fail(name, true, CHECK_NH);
  2619   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
  3026   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
  2620   assert(has_type_annotations_field(), "type_annotations field must be present");
  3027   assert(has_type_annotations_field(), "type_annotations field must be present");
  2621   constructor->obj_field_put(type_annotations_offset, value);
  3028   constructor->obj_field_put(type_annotations_offset, value);
  2622 }
  3029 }
  2623 
  3030 
       
  3031 #define FIELD_FIELDS_DO(macro) \
       
  3032   macro(clazz_offset,     k, vmSymbols::clazz_name(),     class_signature,  false); \
       
  3033   macro(name_offset,      k, vmSymbols::name_name(),      string_signature, false); \
       
  3034   macro(type_offset,      k, vmSymbols::type_name(),      class_signature,  false); \
       
  3035   macro(slot_offset,      k, vmSymbols::slot_name(),      int_signature,    false); \
       
  3036   macro(modifiers_offset, k, vmSymbols::modifiers_name(), int_signature,    false); \
       
  3037   macro##_OPTIONAL(signature_offset,        k, vmSymbols::signature_name(), string_signature); \
       
  3038   macro##_OPTIONAL(annotations_offset,      k, vmSymbols::annotations_name(),  byte_array_signature); \
       
  3039   macro##_OPTIONAL(type_annotations_offset, k, vmSymbols::type_annotations_name(),  byte_array_signature)
       
  3040 
  2624 void java_lang_reflect_Field::compute_offsets() {
  3041 void java_lang_reflect_Field::compute_offsets() {
  2625   InstanceKlass* k = SystemDictionary::reflect_Field_klass();
  3042   InstanceKlass* k = SystemDictionary::reflect_Field_klass();
  2626   compute_offset(clazz_offset,     k, vmSymbols::clazz_name(),     vmSymbols::class_signature());
       
  2627   compute_offset(name_offset,      k, vmSymbols::name_name(),      vmSymbols::string_signature());
       
  2628   compute_offset(type_offset,      k, vmSymbols::type_name(),      vmSymbols::class_signature());
       
  2629   compute_offset(slot_offset,      k, vmSymbols::slot_name(),      vmSymbols::int_signature());
       
  2630   compute_offset(modifiers_offset, k, vmSymbols::modifiers_name(), vmSymbols::int_signature());
       
  2631   // The generic signature and annotations fields are only present in 1.5
  3043   // The generic signature and annotations fields are only present in 1.5
  2632   signature_offset = -1;
  3044   signature_offset = -1;
  2633   annotations_offset = -1;
  3045   annotations_offset = -1;
  2634   type_annotations_offset = -1;
  3046   type_annotations_offset = -1;
  2635   compute_optional_offset(signature_offset, k, vmSymbols::signature_name(), vmSymbols::string_signature());
  3047   FIELD_FIELDS_DO(FIELD_COMPUTE_OFFSET);
  2636   compute_optional_offset(annotations_offset,  k, vmSymbols::annotations_name(),  vmSymbols::byte_array_signature());
  3048 }
  2637   compute_optional_offset(type_annotations_offset,  k, vmSymbols::type_annotations_name(),  vmSymbols::byte_array_signature());
  3049 
  2638 }
  3050 #if INCLUDE_CDS
       
  3051 void java_lang_reflect_Field::serialize(SerializeClosure* f) {
       
  3052   FIELD_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
       
  3053 }
       
  3054 #endif
  2639 
  3055 
  2640 Handle java_lang_reflect_Field::create(TRAPS) {
  3056 Handle java_lang_reflect_Field::create(TRAPS) {
  2641   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
  3057   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
  2642   Symbol* name = vmSymbols::java_lang_reflect_Field();
  3058   Symbol* name = vmSymbols::java_lang_reflect_Field();
  2643   Klass* k = SystemDictionary::resolve_or_fail(name, true, CHECK_NH);
  3059   Klass* k = SystemDictionary::resolve_or_fail(name, true, CHECK_NH);
  2743   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
  3159   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
  2744   assert(has_type_annotations_field(), "type_annotations field must be present");
  3160   assert(has_type_annotations_field(), "type_annotations field must be present");
  2745   field->obj_field_put(type_annotations_offset, value);
  3161   field->obj_field_put(type_annotations_offset, value);
  2746 }
  3162 }
  2747 
  3163 
       
  3164 #define CONSTANTPOOL_FIELDS_DO(macro) \
       
  3165   macro(_oop_offset, k, "constantPoolOop", object_signature, false)
       
  3166 
  2748 void reflect_ConstantPool::compute_offsets() {
  3167 void reflect_ConstantPool::compute_offsets() {
  2749   InstanceKlass* k = SystemDictionary::reflect_ConstantPool_klass();
  3168   InstanceKlass* k = SystemDictionary::reflect_ConstantPool_klass();
  2750   // The field is called ConstantPool* in the sun.reflect.ConstantPool class.
  3169   // The field is called ConstantPool* in the sun.reflect.ConstantPool class.
  2751   compute_offset(_oop_offset, k, "constantPoolOop", vmSymbols::object_signature());
  3170   CONSTANTPOOL_FIELDS_DO(FIELD_COMPUTE_OFFSET);
  2752 }
  3171 }
       
  3172 
       
  3173 #if INCLUDE_CDS
       
  3174 void reflect_ConstantPool::serialize(SerializeClosure* f) {
       
  3175   CONSTANTPOOL_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
       
  3176 }
       
  3177 #endif
       
  3178 
       
  3179 #define PARAMETER_FIELDS_DO(macro) \
       
  3180   macro(name_offset,        k, vmSymbols::name_name(),        string_signature, false); \
       
  3181   macro(modifiers_offset,   k, vmSymbols::modifiers_name(),   int_signature,    false); \
       
  3182   macro(index_offset,       k, vmSymbols::index_name(),       int_signature,    false); \
       
  3183   macro(executable_offset,  k, vmSymbols::executable_name(),  executable_signature, false)
  2753 
  3184 
  2754 void java_lang_reflect_Parameter::compute_offsets() {
  3185 void java_lang_reflect_Parameter::compute_offsets() {
  2755   InstanceKlass* k = SystemDictionary::reflect_Parameter_klass();
  3186   InstanceKlass* k = SystemDictionary::reflect_Parameter_klass();
  2756   compute_offset(name_offset,        k, vmSymbols::name_name(),        vmSymbols::string_signature());
  3187   PARAMETER_FIELDS_DO(FIELD_COMPUTE_OFFSET);
  2757   compute_offset(modifiers_offset,   k, vmSymbols::modifiers_name(),   vmSymbols::int_signature());
  3188 }
  2758   compute_offset(index_offset,       k, vmSymbols::index_name(),       vmSymbols::int_signature());
  3189 
  2759   compute_offset(executable_offset,  k, vmSymbols::executable_name(),  vmSymbols::executable_signature());
  3190 #if INCLUDE_CDS
  2760 }
  3191 void java_lang_reflect_Parameter::serialize(SerializeClosure* f) {
       
  3192   PARAMETER_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
       
  3193 }
       
  3194 #endif
  2761 
  3195 
  2762 Handle java_lang_reflect_Parameter::create(TRAPS) {
  3196 Handle java_lang_reflect_Parameter::create(TRAPS) {
  2763   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
  3197   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
  2764   Symbol* name = vmSymbols::java_lang_reflect_Parameter();
  3198   Symbol* name = vmSymbols::java_lang_reflect_Parameter();
  2765   Klass* k = SystemDictionary::resolve_or_fail(name, true, CHECK_NH);
  3199   Klass* k = SystemDictionary::resolve_or_fail(name, true, CHECK_NH);
  2827                           vmSymbols::java_lang_module_init_signature(),
  3261                           vmSymbols::java_lang_module_init_signature(),
  2828                           loader, module_name, CHECK_NH);
  3262                           loader, module_name, CHECK_NH);
  2829   return jlmh;
  3263   return jlmh;
  2830 }
  3264 }
  2831 
  3265 
       
  3266 #define MODULE_FIELDS_DO(macro) \
       
  3267   macro(loader_offset,  k, vmSymbols::loader_name(),  classloader_signature, false); \
       
  3268   macro(name_offset,    k, vmSymbols::name_name(),    string_signature,      false)
       
  3269 
  2832 void java_lang_Module::compute_offsets() {
  3270 void java_lang_Module::compute_offsets() {
  2833   InstanceKlass* k = SystemDictionary::Module_klass();
  3271   InstanceKlass* k = SystemDictionary::Module_klass();
  2834   compute_offset(loader_offset,  k, vmSymbols::loader_name(),  vmSymbols::classloader_signature());
  3272   MODULE_FIELDS_DO(FIELD_COMPUTE_OFFSET);
  2835   compute_offset(name_offset,    k, vmSymbols::name_name(),    vmSymbols::string_signature());
       
  2836   MODULE_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
  3273   MODULE_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
  2837 }
  3274 }
  2838 
  3275 
       
  3276 #if INCLUDE_CDS
       
  3277 void java_lang_Module::serialize(SerializeClosure* f) {
       
  3278   MODULE_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
       
  3279   MODULE_INJECTED_FIELDS(INJECTED_FIELD_SERIALIZE_OFFSET);
       
  3280 }
       
  3281 #endif
  2839 
  3282 
  2840 oop java_lang_Module::loader(oop module) {
  3283 oop java_lang_Module::loader(oop module) {
  2841   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
  3284   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
  2842   return module->obj_field(loader_offset);
  3285   return module->obj_field(loader_offset);
  2843 }
  3286 }
  2910   // no longer done in the future, this will have to change to save
  3353   // no longer done in the future, this will have to change to save
  2911   // the original.
  3354   // the original.
  2912   return InstanceKlass::cast(k)->constants();
  3355   return InstanceKlass::cast(k)->constants();
  2913 }
  3356 }
  2914 
  3357 
       
  3358 #define UNSAFESTATICFIELDACCESSORIMPL_FIELDS_DO(macro) \
       
  3359   macro(_base_offset, k, "base", object_signature, false)
       
  3360 
  2915 void reflect_UnsafeStaticFieldAccessorImpl::compute_offsets() {
  3361 void reflect_UnsafeStaticFieldAccessorImpl::compute_offsets() {
  2916   InstanceKlass* k = SystemDictionary::reflect_UnsafeStaticFieldAccessorImpl_klass();
  3362   InstanceKlass* k = SystemDictionary::reflect_UnsafeStaticFieldAccessorImpl_klass();
  2917   compute_offset(_base_offset, k, "base", vmSymbols::object_signature());
  3363   UNSAFESTATICFIELDACCESSORIMPL_FIELDS_DO(FIELD_COMPUTE_OFFSET);
  2918 }
  3364 }
       
  3365 
       
  3366 #if INCLUDE_CDS
       
  3367 void reflect_UnsafeStaticFieldAccessorImpl::serialize(SerializeClosure* f) {
       
  3368   UNSAFESTATICFIELDACCESSORIMPL_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
       
  3369 }
       
  3370 #endif
  2919 
  3371 
  2920 oop java_lang_boxing_object::initialize_and_allocate(BasicType type, TRAPS) {
  3372 oop java_lang_boxing_object::initialize_and_allocate(BasicType type, TRAPS) {
  2921   Klass* k = SystemDictionary::box_klass(type);
  3373   Klass* k = SystemDictionary::box_klass(type);
  2922   if (k == NULL)  return NULL;
  3374   if (k == NULL)  return NULL;
  2923   InstanceKlass* ik = InstanceKlass::cast(k);
  3375   InstanceKlass* ik = InstanceKlass::cast(k);
  3072 }
  3524 }
  3073 
  3525 
  3074 // Support for java_lang_ref_SoftReference
  3526 // Support for java_lang_ref_SoftReference
  3075 //
  3527 //
  3076 
  3528 
       
  3529 #define SOFTREFERENCE_FIELDS_DO(macro) \
       
  3530   macro(timestamp_offset,    k, "timestamp", long_signature, false); \
       
  3531   macro(static_clock_offset, k, "clock",     long_signature, true)
       
  3532 
  3077 void java_lang_ref_SoftReference::compute_offsets() {
  3533 void java_lang_ref_SoftReference::compute_offsets() {
  3078   InstanceKlass* k = SystemDictionary::SoftReference_klass();
  3534   InstanceKlass* k = SystemDictionary::SoftReference_klass();
  3079   compute_offset(timestamp_offset,    k, "timestamp", vmSymbols::long_signature());
  3535   SOFTREFERENCE_FIELDS_DO(FIELD_COMPUTE_OFFSET);
  3080   compute_offset(static_clock_offset, k, "clock",     vmSymbols::long_signature(), true);
  3536 }
  3081 }
  3537 
       
  3538 #if INCLUDE_CDS
       
  3539 void java_lang_ref_SoftReference::serialize(SerializeClosure* f) {
       
  3540   SOFTREFERENCE_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
       
  3541 }
       
  3542 #endif
  3082 
  3543 
  3083 jlong java_lang_ref_SoftReference::timestamp(oop ref) {
  3544 jlong java_lang_ref_SoftReference::timestamp(oop ref) {
  3084   return ref->long_field(timestamp_offset);
  3545   return ref->long_field(timestamp_offset);
  3085 }
  3546 }
  3086 
  3547 
  3105   assert(oopDesc::is_oop(dmh) && java_lang_invoke_DirectMethodHandle::is_instance(dmh),
  3566   assert(oopDesc::is_oop(dmh) && java_lang_invoke_DirectMethodHandle::is_instance(dmh),
  3106          "a DirectMethodHandle oop is expected");
  3567          "a DirectMethodHandle oop is expected");
  3107   return dmh->obj_field(member_offset_in_bytes());
  3568   return dmh->obj_field(member_offset_in_bytes());
  3108 }
  3569 }
  3109 
  3570 
       
  3571 #define DIRECTMETHODHANDLE_FIELDS_DO(macro) \
       
  3572   macro(_member_offset, k, "member", java_lang_invoke_MemberName_signature, false)
       
  3573 
  3110 void java_lang_invoke_DirectMethodHandle::compute_offsets() {
  3574 void java_lang_invoke_DirectMethodHandle::compute_offsets() {
  3111   InstanceKlass* k = SystemDictionary::DirectMethodHandle_klass();
  3575   InstanceKlass* k = SystemDictionary::DirectMethodHandle_klass();
  3112   compute_offset(_member_offset, k, "member", vmSymbols::java_lang_invoke_MemberName_signature());
  3576   DIRECTMETHODHANDLE_FIELDS_DO(FIELD_COMPUTE_OFFSET);
  3113 }
  3577 }
       
  3578 
       
  3579 #if INCLUDE_CDS
       
  3580 void java_lang_invoke_DirectMethodHandle::serialize(SerializeClosure* f) {
       
  3581   DIRECTMETHODHANDLE_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
       
  3582 }
       
  3583 #endif
  3114 
  3584 
  3115 // Support for java_lang_invoke_MethodHandle
  3585 // Support for java_lang_invoke_MethodHandle
  3116 
  3586 
  3117 int java_lang_invoke_MethodHandle::_type_offset;
  3587 int java_lang_invoke_MethodHandle::_type_offset;
  3118 int java_lang_invoke_MethodHandle::_form_offset;
  3588 int java_lang_invoke_MethodHandle::_form_offset;
  3127 int java_lang_invoke_ResolvedMethodName::_vmtarget_offset;
  3597 int java_lang_invoke_ResolvedMethodName::_vmtarget_offset;
  3128 int java_lang_invoke_ResolvedMethodName::_vmholder_offset;
  3598 int java_lang_invoke_ResolvedMethodName::_vmholder_offset;
  3129 
  3599 
  3130 int java_lang_invoke_LambdaForm::_vmentry_offset;
  3600 int java_lang_invoke_LambdaForm::_vmentry_offset;
  3131 
  3601 
       
  3602 #define METHODHANDLE_FIELDS_DO(macro) \
       
  3603   macro(_type_offset, k, vmSymbols::type_name(), java_lang_invoke_MethodType_signature, false); \
       
  3604   macro(_form_offset, k, "form",                 java_lang_invoke_LambdaForm_signature, false)
       
  3605 
  3132 void java_lang_invoke_MethodHandle::compute_offsets() {
  3606 void java_lang_invoke_MethodHandle::compute_offsets() {
  3133   InstanceKlass* k = SystemDictionary::MethodHandle_klass();
  3607   InstanceKlass* k = SystemDictionary::MethodHandle_klass();
  3134   compute_offset(_type_offset, k, vmSymbols::type_name(), vmSymbols::java_lang_invoke_MethodType_signature());
  3608   METHODHANDLE_FIELDS_DO(FIELD_COMPUTE_OFFSET);
  3135   compute_offset(_form_offset, k, "form", vmSymbols::java_lang_invoke_LambdaForm_signature());
  3609 }
  3136 }
  3610 
       
  3611 #if INCLUDE_CDS
       
  3612 void java_lang_invoke_MethodHandle::serialize(SerializeClosure* f) {
       
  3613   METHODHANDLE_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
       
  3614 }
       
  3615 #endif
       
  3616 
       
  3617 #define MEMBERNAME_FIELDS_DO(macro) \
       
  3618   macro(_clazz_offset,   k, vmSymbols::clazz_name(),   class_signature,  false); \
       
  3619   macro(_name_offset,    k, vmSymbols::name_name(),    string_signature, false); \
       
  3620   macro(_type_offset,    k, vmSymbols::type_name(),    object_signature, false); \
       
  3621   macro(_flags_offset,   k, vmSymbols::flags_name(),   int_signature,    false); \
       
  3622   macro(_method_offset,  k, vmSymbols::method_name(),  java_lang_invoke_ResolvedMethodName_signature, false)
  3137 
  3623 
  3138 void java_lang_invoke_MemberName::compute_offsets() {
  3624 void java_lang_invoke_MemberName::compute_offsets() {
  3139   InstanceKlass* k = SystemDictionary::MemberName_klass();
  3625   InstanceKlass* k = SystemDictionary::MemberName_klass();
  3140   compute_offset(_clazz_offset,   k, vmSymbols::clazz_name(),   vmSymbols::class_signature());
  3626   MEMBERNAME_FIELDS_DO(FIELD_COMPUTE_OFFSET);
  3141   compute_offset(_name_offset,    k, vmSymbols::name_name(),    vmSymbols::string_signature());
       
  3142   compute_offset(_type_offset,    k, vmSymbols::type_name(),    vmSymbols::object_signature());
       
  3143   compute_offset(_flags_offset,   k, vmSymbols::flags_name(),   vmSymbols::int_signature());
       
  3144   compute_offset(_method_offset,  k, vmSymbols::method_name(),  vmSymbols::java_lang_invoke_ResolvedMethodName_signature());
       
  3145   MEMBERNAME_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
  3627   MEMBERNAME_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
  3146 }
  3628 }
       
  3629 
       
  3630 #if INCLUDE_CDS
       
  3631 void java_lang_invoke_MemberName::serialize(SerializeClosure* f) {
       
  3632   MEMBERNAME_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
       
  3633   MEMBERNAME_INJECTED_FIELDS(INJECTED_FIELD_SERIALIZE_OFFSET);
       
  3634 }
       
  3635 #endif
  3147 
  3636 
  3148 void java_lang_invoke_ResolvedMethodName::compute_offsets() {
  3637 void java_lang_invoke_ResolvedMethodName::compute_offsets() {
  3149   InstanceKlass* k = SystemDictionary::ResolvedMethodName_klass();
  3638   InstanceKlass* k = SystemDictionary::ResolvedMethodName_klass();
  3150   assert(k != NULL, "jdk mismatch");
  3639   assert(k != NULL, "jdk mismatch");
  3151   RESOLVEDMETHOD_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
  3640   RESOLVEDMETHOD_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
  3152 }
  3641 }
  3153 
  3642 
       
  3643 #if INCLUDE_CDS
       
  3644 void java_lang_invoke_ResolvedMethodName::serialize(SerializeClosure* f) {
       
  3645   RESOLVEDMETHOD_INJECTED_FIELDS(INJECTED_FIELD_SERIALIZE_OFFSET);
       
  3646 }
       
  3647 #endif
       
  3648 
       
  3649 #define LAMBDAFORM_FIELDS_DO(macro) \
       
  3650   macro(_vmentry_offset, k, "vmentry", java_lang_invoke_MemberName_signature, false)
       
  3651 
  3154 void java_lang_invoke_LambdaForm::compute_offsets() {
  3652 void java_lang_invoke_LambdaForm::compute_offsets() {
  3155   InstanceKlass* k = SystemDictionary::LambdaForm_klass();
  3653   InstanceKlass* k = SystemDictionary::LambdaForm_klass();
  3156   assert (k != NULL, "jdk mismatch");
  3654   assert (k != NULL, "jdk mismatch");
  3157   compute_offset(_vmentry_offset, k, "vmentry", vmSymbols::java_lang_invoke_MemberName_signature());
  3655   LAMBDAFORM_FIELDS_DO(FIELD_COMPUTE_OFFSET);
  3158 }
  3656 }
       
  3657 
       
  3658 #if INCLUDE_CDS
       
  3659 void java_lang_invoke_LambdaForm::serialize(SerializeClosure* f) {
       
  3660   LAMBDAFORM_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
       
  3661 }
       
  3662 #endif
  3159 
  3663 
  3160 bool java_lang_invoke_LambdaForm::is_instance(oop obj) {
  3664 bool java_lang_invoke_LambdaForm::is_instance(oop obj) {
  3161   return obj != NULL && is_subclass(obj->klass());
  3665   return obj != NULL && is_subclass(obj->klass());
  3162 }
  3666 }
  3163 
  3667 
  3292 // Support for java_lang_invoke_MethodType
  3796 // Support for java_lang_invoke_MethodType
  3293 
  3797 
  3294 int java_lang_invoke_MethodType::_rtype_offset;
  3798 int java_lang_invoke_MethodType::_rtype_offset;
  3295 int java_lang_invoke_MethodType::_ptypes_offset;
  3799 int java_lang_invoke_MethodType::_ptypes_offset;
  3296 
  3800 
       
  3801 #define METHODTYPE_FIELDS_DO(macro) \
       
  3802   macro(_rtype_offset,  k, "rtype",  class_signature,       false); \
       
  3803   macro(_ptypes_offset, k, "ptypes", class_array_signature, false)
       
  3804 
  3297 void java_lang_invoke_MethodType::compute_offsets() {
  3805 void java_lang_invoke_MethodType::compute_offsets() {
  3298   InstanceKlass* k = SystemDictionary::MethodType_klass();
  3806   InstanceKlass* k = SystemDictionary::MethodType_klass();
  3299   compute_offset(_rtype_offset,  k, "rtype",  vmSymbols::class_signature());
  3807   METHODTYPE_FIELDS_DO(FIELD_COMPUTE_OFFSET);
  3300   compute_offset(_ptypes_offset, k, "ptypes", vmSymbols::class_array_signature());
  3808 }
  3301 }
  3809 
       
  3810 #if INCLUDE_CDS
       
  3811 void java_lang_invoke_MethodType::serialize(SerializeClosure* f) {
       
  3812   METHODTYPE_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
       
  3813 }
       
  3814 #endif
  3302 
  3815 
  3303 void java_lang_invoke_MethodType::print_signature(oop mt, outputStream* st) {
  3816 void java_lang_invoke_MethodType::print_signature(oop mt, outputStream* st) {
  3304   st->print("(");
  3817   st->print("(");
  3305   objArrayOop pts = ptypes(mt);
  3818   objArrayOop pts = ptypes(mt);
  3306   for (int i = 0, limit = pts->length(); i < limit; i++) {
  3819   for (int i = 0, limit = pts->length(); i < limit; i++) {
  3377 // Support for java_lang_invoke_CallSite
  3890 // Support for java_lang_invoke_CallSite
  3378 
  3891 
  3379 int java_lang_invoke_CallSite::_target_offset;
  3892 int java_lang_invoke_CallSite::_target_offset;
  3380 int java_lang_invoke_CallSite::_context_offset;
  3893 int java_lang_invoke_CallSite::_context_offset;
  3381 
  3894 
       
  3895 #define CALLSITE_FIELDS_DO(macro) \
       
  3896   macro(_target_offset,  k, "target", java_lang_invoke_MethodHandle_signature, false); \
       
  3897   macro(_context_offset, k, "context", java_lang_invoke_MethodHandleNatives_CallSiteContext_signature, false)
       
  3898 
  3382 void java_lang_invoke_CallSite::compute_offsets() {
  3899 void java_lang_invoke_CallSite::compute_offsets() {
  3383   InstanceKlass* k = SystemDictionary::CallSite_klass();
  3900   InstanceKlass* k = SystemDictionary::CallSite_klass();
  3384   compute_offset(_target_offset,  k, "target", vmSymbols::java_lang_invoke_MethodHandle_signature());
  3901   CALLSITE_FIELDS_DO(FIELD_COMPUTE_OFFSET);
  3385   compute_offset(_context_offset, k, "context",
  3902 }
  3386                  vmSymbols::java_lang_invoke_MethodHandleNatives_CallSiteContext_signature());
  3903 
  3387 }
  3904 #if INCLUDE_CDS
       
  3905 void java_lang_invoke_CallSite::serialize(SerializeClosure* f) {
       
  3906   CALLSITE_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
       
  3907 }
       
  3908 #endif
  3388 
  3909 
  3389 oop java_lang_invoke_CallSite::context(oop call_site) {
  3910 oop java_lang_invoke_CallSite::context(oop call_site) {
  3390   assert(java_lang_invoke_CallSite::is_instance(call_site), "");
  3911   assert(java_lang_invoke_CallSite::is_instance(call_site), "");
  3391 
  3912 
  3392   oop dep_oop = call_site->obj_field(_context_offset);
  3913   oop dep_oop = call_site->obj_field(_context_offset);
  3399 
  3920 
  3400 void java_lang_invoke_MethodHandleNatives_CallSiteContext::compute_offsets() {
  3921 void java_lang_invoke_MethodHandleNatives_CallSiteContext::compute_offsets() {
  3401   InstanceKlass* k = SystemDictionary::Context_klass();
  3922   InstanceKlass* k = SystemDictionary::Context_klass();
  3402   CALLSITECONTEXT_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
  3923   CALLSITECONTEXT_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
  3403 }
  3924 }
       
  3925 
       
  3926 #if INCLUDE_CDS
       
  3927 void java_lang_invoke_MethodHandleNatives_CallSiteContext::serialize(SerializeClosure* f) {
       
  3928   CALLSITECONTEXT_INJECTED_FIELDS(INJECTED_FIELD_SERIALIZE_OFFSET);
       
  3929 }
       
  3930 #endif
  3404 
  3931 
  3405 DependencyContext java_lang_invoke_MethodHandleNatives_CallSiteContext::vmdependencies(oop call_site) {
  3932 DependencyContext java_lang_invoke_MethodHandleNatives_CallSiteContext::vmdependencies(oop call_site) {
  3406   assert(java_lang_invoke_MethodHandleNatives_CallSiteContext::is_instance(call_site), "");
  3933   assert(java_lang_invoke_MethodHandleNatives_CallSiteContext::is_instance(call_site), "");
  3407   intptr_t* vmdeps_addr = (intptr_t*)call_site->field_addr(_vmdependencies_offset);
  3934   intptr_t* vmdeps_addr = (intptr_t*)call_site->field_addr(_vmdependencies_offset);
  3408   DependencyContext dep_ctx(vmdeps_addr);
  3935   DependencyContext dep_ctx(vmdeps_addr);
  3414 int java_security_AccessControlContext::_context_offset = 0;
  3941 int java_security_AccessControlContext::_context_offset = 0;
  3415 int java_security_AccessControlContext::_privilegedContext_offset = 0;
  3942 int java_security_AccessControlContext::_privilegedContext_offset = 0;
  3416 int java_security_AccessControlContext::_isPrivileged_offset = 0;
  3943 int java_security_AccessControlContext::_isPrivileged_offset = 0;
  3417 int java_security_AccessControlContext::_isAuthorized_offset = -1;
  3944 int java_security_AccessControlContext::_isAuthorized_offset = -1;
  3418 
  3945 
       
  3946 #define ACCESSCONTROLCONTEXT_FIELDS_DO(macro) \
       
  3947   macro(_context_offset,           k, "context",      protectiondomain_signature, false); \
       
  3948   macro(_privilegedContext_offset, k, "privilegedContext", accesscontrolcontext_signature, false); \
       
  3949   macro(_isPrivileged_offset,      k, "isPrivileged", bool_signature, false); \
       
  3950   macro(_isAuthorized_offset,      k, "isAuthorized", bool_signature, false)
       
  3951 
  3419 void java_security_AccessControlContext::compute_offsets() {
  3952 void java_security_AccessControlContext::compute_offsets() {
  3420   assert(_isPrivileged_offset == 0, "offsets should be initialized only once");
  3953   assert(_isPrivileged_offset == 0, "offsets should be initialized only once");
  3421   InstanceKlass* k = SystemDictionary::AccessControlContext_klass();
  3954   InstanceKlass* k = SystemDictionary::AccessControlContext_klass();
  3422 
  3955   ACCESSCONTROLCONTEXT_FIELDS_DO(FIELD_COMPUTE_OFFSET);
  3423   compute_offset(_context_offset,           k, "context",      vmSymbols::protectiondomain_signature());
  3956 }
  3424   compute_offset(_privilegedContext_offset, k, "privilegedContext", vmSymbols::accesscontrolcontext_signature());
  3957 
  3425   compute_offset(_isPrivileged_offset,      k, "isPrivileged", vmSymbols::bool_signature());
  3958 #if INCLUDE_CDS
  3426   compute_offset(_isAuthorized_offset,      k, "isAuthorized", vmSymbols::bool_signature());
  3959 void java_security_AccessControlContext::serialize(SerializeClosure* f) {
  3427 }
  3960   ACCESSCONTROLCONTEXT_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
  3428 
  3961 }
       
  3962 #endif
  3429 
  3963 
  3430 bool java_security_AccessControlContext::is_authorized(Handle context) {
  3964 bool java_security_AccessControlContext::is_authorized(Handle context) {
  3431   assert(context.not_null() && context->klass() == SystemDictionary::AccessControlContext_klass(), "Invalid type");
  3965   assert(context.not_null() && context->klass() == SystemDictionary::AccessControlContext_klass(), "Invalid type");
  3432   assert(_isAuthorized_offset != -1, "should be set");
  3966   assert(_isAuthorized_offset != -1, "should be set");
  3433   return context->bool_field(_isAuthorized_offset) != 0;
  3967   return context->bool_field(_isAuthorized_offset) != 0;
  3467 ClassLoaderData* java_lang_ClassLoader::cmpxchg_loader_data(ClassLoaderData* new_data, oop loader, ClassLoaderData* expected_data) {
  4001 ClassLoaderData* java_lang_ClassLoader::cmpxchg_loader_data(ClassLoaderData* new_data, oop loader, ClassLoaderData* expected_data) {
  3468   assert(loader != NULL && oopDesc::is_oop(loader), "loader must be oop");
  4002   assert(loader != NULL && oopDesc::is_oop(loader), "loader must be oop");
  3469   return HeapAccess<>::atomic_cmpxchg_at(new_data, loader, _loader_data_offset, expected_data);
  4003   return HeapAccess<>::atomic_cmpxchg_at(new_data, loader, _loader_data_offset, expected_data);
  3470 }
  4004 }
  3471 
  4005 
       
  4006 #define CLASSLOADER_FIELDS_DO(macro) \
       
  4007   macro(parallelCapable_offset, k1, "parallelLockMap",      concurrenthashmap_signature, false); \
       
  4008   macro(name_offset,            k1, vmSymbols::name_name(), string_signature, false); \
       
  4009   macro(unnamedModule_offset,   k1, "unnamedModule",        module_signature, false); \
       
  4010   macro(parent_offset,          k1, "parent",               classloader_signature, false)
       
  4011 
  3472 void java_lang_ClassLoader::compute_offsets() {
  4012 void java_lang_ClassLoader::compute_offsets() {
  3473   assert(!offsets_computed, "offsets should be initialized only once");
  4013   assert(!offsets_computed, "offsets should be initialized only once");
  3474   offsets_computed = true;
  4014   offsets_computed = true;
  3475 
  4015 
  3476   InstanceKlass* k1 = SystemDictionary::ClassLoader_klass();
  4016   InstanceKlass* k1 = SystemDictionary::ClassLoader_klass();
  3477   compute_offset(parallelCapable_offset,
  4017   CLASSLOADER_FIELDS_DO(FIELD_COMPUTE_OFFSET);
  3478     k1, "parallelLockMap", vmSymbols::concurrenthashmap_signature());
       
  3479 
       
  3480   compute_offset(name_offset,
       
  3481     k1, vmSymbols::name_name(), vmSymbols::string_signature());
       
  3482 
       
  3483   compute_offset(unnamedModule_offset,
       
  3484     k1, "unnamedModule", vmSymbols::module_signature());
       
  3485 
       
  3486   compute_offset(parent_offset, k1, "parent", vmSymbols::classloader_signature());
       
  3487 
  4018 
  3488   CLASSLOADER_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
  4019   CLASSLOADER_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
  3489 }
  4020 }
       
  4021 
       
  4022 #if INCLUDE_CDS
       
  4023 void java_lang_ClassLoader::serialize(SerializeClosure* f) {
       
  4024   CLASSLOADER_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
       
  4025   CLASSLOADER_INJECTED_FIELDS(INJECTED_FIELD_SERIALIZE_OFFSET);
       
  4026 }
       
  4027 #endif
  3490 
  4028 
  3491 oop java_lang_ClassLoader::parent(oop loader) {
  4029 oop java_lang_ClassLoader::parent(oop loader) {
  3492   assert(is_instance(loader), "loader must be oop");
  4030   assert(is_instance(loader), "loader must be oop");
  3493   return loader->obj_field(parent_offset);
  4031   return loader->obj_field(parent_offset);
  3494 }
  4032 }
  3569   return loader->obj_field(unnamedModule_offset);
  4107   return loader->obj_field(unnamedModule_offset);
  3570 }
  4108 }
  3571 
  4109 
  3572 // Support for java_lang_System
  4110 // Support for java_lang_System
  3573 //
  4111 //
       
  4112 #define SYSTEM_FIELDS_DO(macro) \
       
  4113   macro(static_in_offset,  k, "in",  input_stream_signature, true); \
       
  4114   macro(static_out_offset, k, "out", print_stream_signature, true); \
       
  4115   macro(static_err_offset, k, "err", print_stream_signature, true); \
       
  4116   macro(static_security_offset, k, "security", security_manager_signature, true)
       
  4117 
  3574 void java_lang_System::compute_offsets() {
  4118 void java_lang_System::compute_offsets() {
  3575   InstanceKlass* k = SystemDictionary::System_klass();
  4119   InstanceKlass* k = SystemDictionary::System_klass();
  3576   compute_offset(static_in_offset,  k, "in",  vmSymbols::input_stream_signature(), true);
  4120   SYSTEM_FIELDS_DO(FIELD_COMPUTE_OFFSET);
  3577   compute_offset(static_out_offset, k, "out", vmSymbols::print_stream_signature(), true);
  4121 }
  3578   compute_offset(static_err_offset, k, "err", vmSymbols::print_stream_signature(), true);
  4122 
  3579   compute_offset(static_security_offset, k, "security", vmSymbols::security_manager_signature(), true);
  4123 #if INCLUDE_CDS
  3580 }
  4124 void java_lang_System::serialize(SerializeClosure* f) {
       
  4125    SYSTEM_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
       
  4126 }
       
  4127 #endif
  3581 
  4128 
  3582 int java_lang_System::in_offset_in_bytes() { return static_in_offset; }
  4129 int java_lang_System::in_offset_in_bytes() { return static_in_offset; }
  3583 int java_lang_System::out_offset_in_bytes() { return static_out_offset; }
  4130 int java_lang_System::out_offset_in_bytes() { return static_out_offset; }
  3584 int java_lang_System::err_offset_in_bytes() { return static_err_offset; }
  4131 int java_lang_System::err_offset_in_bytes() { return static_err_offset; }
  3585 
  4132 
  3681 int java_nio_Buffer::_limit_offset;
  4228 int java_nio_Buffer::_limit_offset;
  3682 int java_util_concurrent_locks_AbstractOwnableSynchronizer::_owner_offset = 0;
  4229 int java_util_concurrent_locks_AbstractOwnableSynchronizer::_owner_offset = 0;
  3683 int reflect_ConstantPool::_oop_offset;
  4230 int reflect_ConstantPool::_oop_offset;
  3684 int reflect_UnsafeStaticFieldAccessorImpl::_base_offset;
  4231 int reflect_UnsafeStaticFieldAccessorImpl::_base_offset;
  3685 
  4232 
       
  4233 #define STACKTRACEELEMENT_FIELDS_DO(macro) \
       
  4234   macro(declaringClassObject_offset,  k, "declaringClassObject", class_signature, false); \
       
  4235   macro(classLoaderName_offset, k, "classLoaderName", string_signature, false); \
       
  4236   macro(moduleName_offset,      k, "moduleName",      string_signature, false); \
       
  4237   macro(moduleVersion_offset,   k, "moduleVersion",   string_signature, false); \
       
  4238   macro(declaringClass_offset,  k, "declaringClass",  string_signature, false); \
       
  4239   macro(methodName_offset,      k, "methodName",      string_signature, false); \
       
  4240   macro(fileName_offset,        k, "fileName",        string_signature, false); \
       
  4241   macro(lineNumber_offset,      k, "lineNumber",      int_signature,    false)
  3686 
  4242 
  3687 // Support for java_lang_StackTraceElement
  4243 // Support for java_lang_StackTraceElement
  3688 void java_lang_StackTraceElement::compute_offsets() {
  4244 void java_lang_StackTraceElement::compute_offsets() {
  3689   InstanceKlass* k = SystemDictionary::StackTraceElement_klass();
  4245   InstanceKlass* k = SystemDictionary::StackTraceElement_klass();
  3690   compute_offset(declaringClassObject_offset,  k, "declaringClassObject", vmSymbols::class_signature());
  4246   STACKTRACEELEMENT_FIELDS_DO(FIELD_COMPUTE_OFFSET);
  3691   compute_offset(classLoaderName_offset, k, "classLoaderName", vmSymbols::string_signature());
  4247 }
  3692   compute_offset(moduleName_offset,      k, "moduleName",      vmSymbols::string_signature());
  4248 
  3693   compute_offset(moduleVersion_offset,   k, "moduleVersion",   vmSymbols::string_signature());
  4249 #if INCLUDE_CDS
  3694   compute_offset(declaringClass_offset,  k, "declaringClass",  vmSymbols::string_signature());
  4250 void java_lang_StackTraceElement::serialize(SerializeClosure* f) {
  3695   compute_offset(methodName_offset,      k, "methodName",      vmSymbols::string_signature());
  4251   STACKTRACEELEMENT_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
  3696   compute_offset(fileName_offset,        k, "fileName",        vmSymbols::string_signature());
  4252 }
  3697   compute_offset(lineNumber_offset,      k, "lineNumber",      vmSymbols::int_signature());
  4253 #endif
  3698 }
       
  3699 
  4254 
  3700 void java_lang_StackTraceElement::set_fileName(oop element, oop value) {
  4255 void java_lang_StackTraceElement::set_fileName(oop element, oop value) {
  3701   element->obj_field_put(fileName_offset, value);
  4256   element->obj_field_put(fileName_offset, value);
  3702 }
  4257 }
  3703 
  4258 
  3752 void java_lang_LiveStackFrameInfo::set_mode(oop element, int value) {
  4307 void java_lang_LiveStackFrameInfo::set_mode(oop element, int value) {
  3753   element->int_field_put(_mode_offset, value);
  4308   element->int_field_put(_mode_offset, value);
  3754 }
  4309 }
  3755 
  4310 
  3756 // Support for java Assertions - java_lang_AssertionStatusDirectives.
  4311 // Support for java Assertions - java_lang_AssertionStatusDirectives.
       
  4312 #define ASSERTIONSTATUSDIRECTIVES_FIELDS_DO(macro) \
       
  4313   macro(classes_offset,        k, "classes",        string_array_signature, false); \
       
  4314   macro(classEnabled_offset,   k, "classEnabled",   bool_array_signature, false); \
       
  4315   macro(packages_offset,       k, "packages",       string_array_signature, false); \
       
  4316   macro(packageEnabled_offset, k, "packageEnabled", bool_array_signature,   false); \
       
  4317   macro(deflt_offset,          k, "deflt",          bool_signature,         false)
  3757 
  4318 
  3758 void java_lang_AssertionStatusDirectives::compute_offsets() {
  4319 void java_lang_AssertionStatusDirectives::compute_offsets() {
  3759   InstanceKlass* k = SystemDictionary::AssertionStatusDirectives_klass();
  4320   InstanceKlass* k = SystemDictionary::AssertionStatusDirectives_klass();
  3760   compute_offset(classes_offset,        k, "classes",        vmSymbols::string_array_signature());
  4321   ASSERTIONSTATUSDIRECTIVES_FIELDS_DO(FIELD_COMPUTE_OFFSET);
  3761   compute_offset(classEnabled_offset,   k, "classEnabled",   vmSymbols::bool_array_signature());
  4322 }
  3762   compute_offset(packages_offset,       k, "packages",       vmSymbols::string_array_signature());
  4323 
  3763   compute_offset(packageEnabled_offset, k, "packageEnabled", vmSymbols::bool_array_signature());
  4324 #if INCLUDE_CDS
  3764   compute_offset(deflt_offset,          k, "deflt",          vmSymbols::bool_signature());
  4325 void java_lang_AssertionStatusDirectives::serialize(SerializeClosure* f) {
  3765 }
  4326   ASSERTIONSTATUSDIRECTIVES_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
  3766 
  4327 }
       
  4328 #endif
  3767 
  4329 
  3768 void java_lang_AssertionStatusDirectives::set_classes(oop o, oop val) {
  4330 void java_lang_AssertionStatusDirectives::set_classes(oop o, oop val) {
  3769   o->obj_field_put(classes_offset, val);
  4331   o->obj_field_put(classes_offset, val);
  3770 }
  4332 }
  3771 
  4333 
  3789 // Support for intrinsification of java.nio.Buffer.checkIndex
  4351 // Support for intrinsification of java.nio.Buffer.checkIndex
  3790 int java_nio_Buffer::limit_offset() {
  4352 int java_nio_Buffer::limit_offset() {
  3791   return _limit_offset;
  4353   return _limit_offset;
  3792 }
  4354 }
  3793 
  4355 
       
  4356 #define BUFFER_FIELDS_DO(macro) \
       
  4357   macro(_limit_offset, k, "limit", int_signature, false)
  3794 
  4358 
  3795 void java_nio_Buffer::compute_offsets() {
  4359 void java_nio_Buffer::compute_offsets() {
  3796   InstanceKlass* k = SystemDictionary::nio_Buffer_klass();
  4360   InstanceKlass* k = SystemDictionary::nio_Buffer_klass();
  3797   assert(k != NULL, "must be loaded in 1.4+");
  4361   assert(k != NULL, "must be loaded in 1.4+");
  3798   compute_offset(_limit_offset, k, "limit", vmSymbols::int_signature());
  4362   BUFFER_FIELDS_DO(FIELD_COMPUTE_OFFSET);
  3799 }
  4363 }
       
  4364 
       
  4365 #if INCLUDE_CDS
       
  4366 void java_nio_Buffer::serialize(SerializeClosure* f) {
       
  4367   BUFFER_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
       
  4368 }
       
  4369 #endif
  3800 
  4370 
  3801 void java_util_concurrent_locks_AbstractOwnableSynchronizer::initialize(TRAPS) {
  4371 void java_util_concurrent_locks_AbstractOwnableSynchronizer::initialize(TRAPS) {
  3802   if (_owner_offset != 0) return;
  4372   if (_owner_offset != 0) return;
  3803 
  4373 
  3804   SystemDictionary::load_abstract_ownable_synchronizer_klass(CHECK);
  4374   SystemDictionary::load_abstract_ownable_synchronizer_klass(CHECK);
  3833 }
  4403 }
  3834 
  4404 
  3835 
  4405 
  3836 // Compute non-hard-coded field offsets of all the classes in this file
  4406 // Compute non-hard-coded field offsets of all the classes in this file
  3837 void JavaClasses::compute_offsets() {
  4407 void JavaClasses::compute_offsets() {
       
  4408   if (UseSharedSpaces) {
       
  4409     return; // field offsets are loaded from archive
       
  4410   }
       
  4411 
  3838   // java_lang_Class::compute_offsets was called earlier in bootstrap
  4412   // java_lang_Class::compute_offsets was called earlier in bootstrap
  3839   java_lang_System::compute_offsets();
  4413   java_lang_System::compute_offsets();
  3840   java_lang_ClassLoader::compute_offsets();
  4414   java_lang_ClassLoader::compute_offsets();
  3841   java_lang_Throwable::compute_offsets();
  4415   java_lang_Throwable::compute_offsets();
  3842   java_lang_Thread::compute_offsets();
  4416   java_lang_Thread::compute_offsets();