273 // embedded Java vtable follows here 274 // embedded Java itables follows here 275 // embedded static fields follows here 276 // embedded nonstatic oop-map blocks follows here 277 // embedded implementor of this interface follows here 278 // The embedded implementor only exists if the current klass is an 279 // iterface. The possible values of the implementor fall into following 280 // three cases: 281 // NULL: no implementor. 282 // A Klass* that's not itself: one implementor. 283 // Itself: more than one implementors. 284 // embedded host klass follows here 285 // The embedded host klass only exists in an anonymous class for 286 // dynamic language support (JSR 292 enabled). The host class grants 287 // its access privileges to this class also. The host class is either 288 // named, or a previously loaded anonymous class. A non-anonymous class 289 // or an anonymous class loaded through normal classloading does not 290 // have this embedded field. 291 // 292 293 friend class SystemDictionary; 294 295 public: 296 bool has_nonstatic_fields() const { 297 return (_misc_flags & _misc_has_nonstatic_fields) != 0; 298 } 299 void set_has_nonstatic_fields(bool b) { 300 if (b) { 301 _misc_flags |= _misc_has_nonstatic_fields; 302 } else { 303 _misc_flags &= ~_misc_has_nonstatic_fields; 304 } 305 } 306 307 // field sizes 308 int nonstatic_field_size() const { return _nonstatic_field_size; } 309 void set_nonstatic_field_size(int size) { _nonstatic_field_size = size; } 310 311 int static_field_size() const { return _static_field_size; } 312 void set_static_field_size(int size) { _static_field_size = size; } 313 314 int static_oop_field_count() const { return (int)_static_oop_field_count; } 315 void set_static_oop_field_count(u2 size) { _static_oop_field_count = size; } 1243 int offset() const { return _offset; } 1244 JNIid* next() { return _next; } 1245 // Constructor 1246 JNIid(Klass* holder, int offset, JNIid* next); 1247 // Identifier lookup 1248 JNIid* find(int offset); 1249 1250 bool find_local_field(fieldDescriptor* fd) { 1251 return InstanceKlass::cast(holder())->find_local_field_from_offset(offset(), true, fd); 1252 } 1253 1254 static void deallocate(JNIid* id); 1255 // Debugging 1256 #ifdef ASSERT 1257 bool is_static_field_id() const { return _is_static_field_id; } 1258 void set_is_static_field_id() { _is_static_field_id = true; } 1259 #endif 1260 void verify(Klass* holder); 1261 }; 1262 1263 1264 // 1265 // nmethodBucket is used to record dependent nmethods for 1266 // deoptimization. nmethod dependencies are actually <klass, method> 1267 // pairs but we really only care about the klass part for purposes of 1268 // finding nmethods which might need to be deoptimized. Instead of 1269 // recording the method, a count of how many times a particular nmethod 1270 // was recorded is kept. This ensures that any recording errors are 1271 // noticed since an nmethod should be removed as many times are it's 1272 // added. 1273 // 1274 class nmethodBucket: public CHeapObj<mtClass> { 1275 friend class VMStructs; 1276 private: 1277 nmethod* _nmethod; 1278 int _count; 1279 nmethodBucket* _next; 1280 1281 public: 1282 nmethodBucket(nmethod* nmethod, nmethodBucket* next) { 1283 _nmethod = nmethod; 1284 _next = next; 1285 _count = 1; 1286 } 1287 int count() { return _count; } 1288 int increment() { _count += 1; return _count; } 1289 int decrement(); 1290 nmethodBucket* next() { return _next; } 1291 void set_next(nmethodBucket* b) { _next = b; } 1292 nmethod* get_nmethod() { return _nmethod; } 1293 1294 static int mark_dependent_nmethods(nmethodBucket* deps, DepChange& changes); 1295 static nmethodBucket* add_dependent_nmethod(nmethodBucket* deps, nmethod* nm); 1296 static bool remove_dependent_nmethod(nmethodBucket* deps, nmethod* nm); 1297 static nmethodBucket* clean_dependent_nmethods(nmethodBucket* deps); 1298 #ifndef PRODUCT 1299 static void print_dependent_nmethods(nmethodBucket* deps, bool verbose); 1300 static bool is_dependent_nmethod(nmethodBucket* deps, nmethod* nm); 1301 #endif //PRODUCT 1302 }; 1303 1304 // An iterator that's used to access the inner classes indices in the 1305 // InstanceKlass::_inner_classes array. 1306 class InnerClassesIterator : public StackObj { 1307 private: 1308 Array<jushort>* _inner_classes; 1309 int _length; 1310 int _idx; 1311 public: 1312 1313 InnerClassesIterator(instanceKlassHandle k) { 1314 _inner_classes = k->inner_classes(); 1315 if (k->inner_classes() != NULL) { 1316 _length = _inner_classes->length(); 1317 // The inner class array's length should be the multiple of 1318 // inner_class_next_offset if it only contains the InnerClasses | 273 // embedded Java vtable follows here 274 // embedded Java itables follows here 275 // embedded static fields follows here 276 // embedded nonstatic oop-map blocks follows here 277 // embedded implementor of this interface follows here 278 // The embedded implementor only exists if the current klass is an 279 // iterface. The possible values of the implementor fall into following 280 // three cases: 281 // NULL: no implementor. 282 // A Klass* that's not itself: one implementor. 283 // Itself: more than one implementors. 284 // embedded host klass follows here 285 // The embedded host klass only exists in an anonymous class for 286 // dynamic language support (JSR 292 enabled). The host class grants 287 // its access privileges to this class also. The host class is either 288 // named, or a previously loaded anonymous class. A non-anonymous class 289 // or an anonymous class loaded through normal classloading does not 290 // have this embedded field. 291 // 292 293 // TODO 294 bool _set_finals; 295 296 friend class SystemDictionary; 297 298 public: 299 bool set_finals() { return _set_finals; } 300 void set_finals(bool b) { _set_finals = b; } 301 302 bool has_nonstatic_fields() const { 303 return (_misc_flags & _misc_has_nonstatic_fields) != 0; 304 } 305 void set_has_nonstatic_fields(bool b) { 306 if (b) { 307 _misc_flags |= _misc_has_nonstatic_fields; 308 } else { 309 _misc_flags &= ~_misc_has_nonstatic_fields; 310 } 311 } 312 313 // field sizes 314 int nonstatic_field_size() const { return _nonstatic_field_size; } 315 void set_nonstatic_field_size(int size) { _nonstatic_field_size = size; } 316 317 int static_field_size() const { return _static_field_size; } 318 void set_static_field_size(int size) { _static_field_size = size; } 319 320 int static_oop_field_count() const { return (int)_static_oop_field_count; } 321 void set_static_oop_field_count(u2 size) { _static_oop_field_count = size; } 1249 int offset() const { return _offset; } 1250 JNIid* next() { return _next; } 1251 // Constructor 1252 JNIid(Klass* holder, int offset, JNIid* next); 1253 // Identifier lookup 1254 JNIid* find(int offset); 1255 1256 bool find_local_field(fieldDescriptor* fd) { 1257 return InstanceKlass::cast(holder())->find_local_field_from_offset(offset(), true, fd); 1258 } 1259 1260 static void deallocate(JNIid* id); 1261 // Debugging 1262 #ifdef ASSERT 1263 bool is_static_field_id() const { return _is_static_field_id; } 1264 void set_is_static_field_id() { _is_static_field_id = true; } 1265 #endif 1266 void verify(Klass* holder); 1267 }; 1268 1269 class nmethodBucketEntry : public CHeapObj<mtClass> { 1270 friend class VMStructs; 1271 private: 1272 nmethod* _nmethod; 1273 int _count; 1274 nmethodBucketEntry* _next; 1275 public: 1276 nmethodBucketEntry(nmethod* nmethod, nmethodBucketEntry* next) { 1277 _nmethod = nmethod; 1278 _next = next; 1279 _count = 1; 1280 } 1281 int count() { return _count; } 1282 int increment() { _count += 1; return _count; } 1283 int decrement(); 1284 nmethodBucketEntry* next() { return _next; } 1285 void set_next(nmethodBucketEntry* b) { _next = b; } 1286 nmethod* get_nmethod() { return _nmethod; } 1287 1288 static int mark_dependent_nmethods(nmethodBucketEntry* deps, DepChange& changes); 1289 static nmethodBucketEntry* add_dependent_nmethod(nmethodBucketEntry* deps, nmethod* nm); 1290 static bool remove_dependent_nmethod(nmethodBucketEntry* deps, nmethod* nm, bool& found); 1291 static nmethodBucketEntry* clean_dependent_nmethods(nmethodBucketEntry* deps); 1292 1293 #ifndef PRODUCT 1294 static void verify(nmethodBucketEntry* deps); 1295 static void print_dependent_nmethods(nmethodBucketEntry* deps, bool verbose); 1296 static bool is_dependent_nmethod(nmethodBucketEntry* deps, nmethod* nm); 1297 #endif //PRODUCT 1298 }; 1299 1300 // 1301 // nmethodBucket is used to record dependent nmethods for 1302 // deoptimization. nmethod dependencies are actually <klass, method> 1303 // pairs but we really only care about the klass part for purposes of 1304 // finding nmethods which might need to be deoptimized. Instead of 1305 // recording the method, a count of how many times a particular nmethod 1306 // was recorded is kept. This ensures that any recording errors are 1307 // noticed since an nmethod should be removed as many times are it's 1308 // added. 1309 // 1310 class nmethodBucket: public CHeapObj<mtClass> { 1311 friend class VMStructs; 1312 private: 1313 enum { 1314 FIRST_Bucket = 0, 1315 KlassBucket = FIRST_Bucket, 1316 CallSiteBucket, 1317 ConstantFieldBucket, 1318 Bucket_LIMIT 1319 }; 1320 1321 nmethodBucketEntry* _buckets[Bucket_LIMIT]; 1322 1323 nmethodBucket() { 1324 for (int i = FIRST_Bucket; i < Bucket_LIMIT; i++) { 1325 _buckets[i] = NULL; 1326 } 1327 } 1328 static int bucket_index(DepChange& changes); 1329 1330 public: 1331 1332 static int mark_dependent_nmethods(nmethodBucket* deps, DepChange& changes); 1333 static nmethodBucket* add_dependent_nmethod(nmethodBucket* deps, nmethod* nm); 1334 static bool remove_dependent_nmethod(nmethodBucket* deps, nmethod* nm); 1335 static nmethodBucket* clean_dependent_nmethods(nmethodBucket* deps); 1336 static int release(nmethodBucket* deps); 1337 #ifndef PRODUCT 1338 static void verify(nmethodBucket* deps); 1339 static void print_dependent_nmethods(nmethodBucket* deps, bool verbose); 1340 static bool is_dependent_nmethod(nmethodBucket* deps, nmethod* nm); 1341 #endif //PRODUCT 1342 }; 1343 1344 // An iterator that's used to access the inner classes indices in the 1345 // InstanceKlass::_inner_classes array. 1346 class InnerClassesIterator : public StackObj { 1347 private: 1348 Array<jushort>* _inner_classes; 1349 int _length; 1350 int _idx; 1351 public: 1352 1353 InnerClassesIterator(instanceKlassHandle k) { 1354 _inner_classes = k->inner_classes(); 1355 if (k->inner_classes() != NULL) { 1356 _length = _inner_classes->length(); 1357 // The inner class array's length should be the multiple of 1358 // inner_class_next_offset if it only contains the InnerClasses |