330 return k;
331 }
332 _current_class_index = (_current_class_index + 1) % table_size();
333 _current_class_entry = bucket(_current_class_index);
334 }
335 // never reached
336 }
337
338
339 // Add a loaded class to the system dictionary.
340 // Readers of the SystemDictionary aren't always locked, so _buckets
341 // is volatile. The store of the next field in the constructor is
342 // also cast to volatile; we do this to ensure store order is maintained
343 // by the compilers.
344
345 void Dictionary::add_klass(Symbol* class_name, ClassLoaderData* loader_data,
346 KlassHandle obj) {
347 assert_locked_or_safepoint(SystemDictionary_lock);
348 assert(obj() != NULL, "adding NULL obj");
349 assert(obj()->name() == class_name, "sanity check on name");
350
351 unsigned int hash = compute_hash(class_name, loader_data);
352 int index = hash_to_index(hash);
353 DictionaryEntry* entry = new_entry(hash, obj(), loader_data);
354 add_entry(index, entry);
355 }
356
357
358 // This routine does not lock the system dictionary.
359 //
360 // Since readers don't hold a lock, we must make sure that system
361 // dictionary entries are only removed at a safepoint (when only one
362 // thread is running), and are added to in a safe way (all links must
363 // be updated in an MT-safe manner).
364 //
365 // Callers should be aware that an entry could be added just after
366 // _buckets[index] is read here, so the caller will not see the new entry.
367 DictionaryEntry* Dictionary::get_entry(int index, unsigned int hash,
368 Symbol* class_name,
369 ClassLoaderData* loader_data) {
|
330 return k;
331 }
332 _current_class_index = (_current_class_index + 1) % table_size();
333 _current_class_entry = bucket(_current_class_index);
334 }
335 // never reached
336 }
337
338
339 // Add a loaded class to the system dictionary.
340 // Readers of the SystemDictionary aren't always locked, so _buckets
341 // is volatile. The store of the next field in the constructor is
342 // also cast to volatile; we do this to ensure store order is maintained
343 // by the compilers.
344
345 void Dictionary::add_klass(Symbol* class_name, ClassLoaderData* loader_data,
346 KlassHandle obj) {
347 assert_locked_or_safepoint(SystemDictionary_lock);
348 assert(obj() != NULL, "adding NULL obj");
349 assert(obj()->name() == class_name, "sanity check on name");
350 assert(loader_data != NULL, "Must be non-NULL");
351
352 unsigned int hash = compute_hash(class_name, loader_data);
353 int index = hash_to_index(hash);
354 DictionaryEntry* entry = new_entry(hash, obj(), loader_data);
355 add_entry(index, entry);
356 }
357
358
359 // This routine does not lock the system dictionary.
360 //
361 // Since readers don't hold a lock, we must make sure that system
362 // dictionary entries are only removed at a safepoint (when only one
363 // thread is running), and are added to in a safe way (all links must
364 // be updated in an MT-safe manner).
365 //
366 // Callers should be aware that an entry could be added just after
367 // _buckets[index] is read here, so the caller will not see the new entry.
368 DictionaryEntry* Dictionary::get_entry(int index, unsigned int hash,
369 Symbol* class_name,
370 ClassLoaderData* loader_data) {
|