src/share/vm/classfile/dictionary.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File

    *** old/src/share/vm/classfile/dictionary.cpp	Mon Jan 12 13:05:27 2015
    --- new/src/share/vm/classfile/dictionary.cpp	Mon Jan 12 13:05:27 2015

    *** 366,375 ****
    --- 366,383 ----

        unsigned int hash = compute_hash(class_name, loader_data);
        int index = hash_to_index(hash);
        DictionaryEntry* entry = new_entry(hash, obj(), loader_data);
        add_entry(index, entry);
    +
    + #ifndef PRODUCT
    + //#ifdef PRODUCT_TEST
    +   {
    +     _debug_all_insertion_count++;
    +     _debug_insertion_count++;
    +   }
    + #endif
      }

      // This routine does not lock the system dictionary.
      //

    *** 382,441 ****
    --- 390,507 ----
      // _buckets[index] is read here, so the caller will not see the new entry.
      DictionaryEntry* Dictionary::get_entry(int index, unsigned int hash,
                                             Symbol* class_name,
                                             ClassLoaderData* loader_data) {
        debug_only(_lookup_count++);
    +
    + #ifndef PRODUCT
    + //#ifdef PRODUCT_TEST
    +   jlong time = os::javaTimeNanos();
    +   _debug_all_lookup_count++;
    +   _debug_lookup_count++;
    + #endif
    +
    +   unsigned int count = 0;
        for (DictionaryEntry* entry = bucket(index);
                              entry != NULL;
                              entry = entry->next()) {
    +     count++;
          if (entry->hash() == hash && entry->equals(class_name, loader_data)) {
    +
    +       entry->_debug_lookups++;
    + #ifndef PRODUCT
    + //#ifdef PRODUCT_TEST
    +       {
    +         unsigned int duration = os::javaTimeNanos()-time;
    +         _debug_lookup_found_count++;
    +         _debug_lookup_found_max_duration = (_debug_lookup_found_max_duration > duration) ? _debug_lookup_found_max_duration : duration;
    +         _debug_lookup_found_total_duration += duration;
    +         _debug_chain_found_maximum_length = (_debug_chain_found_maximum_length > count) ? _debug_chain_found_maximum_length : count;
    +         _debug_chain_found_total_length += count;
    +
    +         long thread_id = os::current_thread_id();
    +         for (int i=0; i<1024; i++) {
    +           if (_debug_table_threads[i] == thread_id) {
    +             break;
    +           } else if (_debug_table_threads[i] == 0) {
    +             _debug_table_threads[i] = thread_id;
    +             break;
    +           }
    +         }
    +       }
    + #endif
    +
            return entry;
          }
          debug_only(_lookup_length++);
        }
    +
    + #ifndef PRODUCT
    + //#ifdef PRODUCT_TEST
    +   {
    +     unsigned int duration = os::javaTimeNanos()-time;
    +     _debug_lookup_failed_count++;
    +     _debug_lookup_failed_max_duration = (_debug_lookup_failed_max_duration > duration) ? _debug_lookup_failed_max_duration : duration;
    +     _debug_lookup_failed_total_duration += duration;
    +     _debug_chain_failed_maximum_length = (_debug_chain_failed_maximum_length > count) ? _debug_chain_failed_maximum_length : count;
    +     _debug_chain_failed_total_length += count;
    +   }
    + #endif
    +
        return NULL;
      }

    - Klass* Dictionary::find(int index, unsigned int hash, Symbol* name,
                                ClassLoaderData* loader_data, Handle protection_domain, TRAPS) {
    +
    +   int index = this->hash_to_index(hash);
        DictionaryEntry* entry = get_entry(index, hash, name, loader_data);
        if (entry != NULL && entry->is_valid_protection_domain(protection_domain)) {
          return entry->klass();
        } else {
    !     return (Klass*)NULL;
        }
      }

    - Klass* Dictionary::find_class(int index, unsigned int hash,
                                      Symbol* name, ClassLoaderData* loader_data) {
        assert_locked_or_safepoint(SystemDictionary_lock);
        assert (index == index_for(name, loader_data), "incorrect index?");

    +   int index = this->hash_to_index(hash);
        DictionaryEntry* entry = get_entry(index, hash, name, loader_data);
        return (entry != NULL) ? entry->klass() : (Klass*)NULL;
    +   if (entry != NULL) {
    +     return entry->klass();
    +   } else {
    +     return (Klass*)NULL;
    +   }
      }

      // Variant of find_class for shared classes.  No locking required, as
      // that table is static.

    - Klass* Dictionary::find_shared_class(int index, unsigned int hash,
                                             Symbol* name) {
        assert (index == index_for(name, NULL), "incorrect index?");

    +   int index = this->hash_to_index(hash);
        DictionaryEntry* entry = get_entry(index, hash, name, NULL);
        return (entry != NULL) ? entry->klass() : (Klass*)NULL;
    +   if (entry != NULL) {
    +     return entry->klass();
    +   } else {
    +     return (Klass*)NULL;
    +   }
      }

    - void Dictionary::add_protection_domain(int index, unsigned int hash,
                                             instanceKlassHandle klass,
                                             ClassLoaderData* loader_data, Handle protection_domain,
                                             TRAPS) {
        Symbol*  klass_name = klass->name();
    +   int index = this->hash_to_index(hash);
        DictionaryEntry* entry = get_entry(index, hash, klass_name, loader_data);

        assert(entry != NULL,"entry must be present, we just created it");
        assert(protection_domain() != NULL,
               "real protection domain should be present");

    *** 445,459 ****
    --- 511,529 ----
        assert(entry->contains_protection_domain(protection_domain()),
               "now protection domain should be present");
      }

    - bool Dictionary::is_valid_protection_domain(int index, unsigned int hash,
                                                  Symbol* name,
                                                  ClassLoaderData* loader_data,
                                                  Handle protection_domain) {
    +   int index = this->hash_to_index(hash);
        DictionaryEntry* entry = get_entry(index, hash, name, loader_data);
    +
    +   assert(entry != NULL,"entry must be present");
    +
        return entry->is_valid_protection_domain(protection_domain);
      }

      void Dictionary::reorder_dictionary() {

    *** 708,717 ****
    --- 778,790 ----

      void Dictionary::print(bool details) {
        ResourceMark rm;
        HandleMark   hm;

    +   dump_table(tty, "SystemDictionary");//gznote: here
    +   tty->cr();
    +
        if (details) {
          tty->print_cr("Java system dictionary (table_size=%d, classes=%d)",
                         table_size(), number_of_entries());
          tty->print_cr("^ indicates that initiating loader is different from "
                        "defining loader");

    *** 749,758 ****
    --- 822,834 ----
      }

      void Dictionary::verify() {
        guarantee(number_of_entries() >= 0, "Verify of system dictionary failed");

    +   MutexLocker mu(SystemDictionary_lock);
    +   int actual_count = 0;
    +
        int element_count = 0;
        for (int index = 0; index < table_size(); index++) {
          for (DictionaryEntry* probe = bucket(index);
                                probe != NULL;
                                probe = probe->next()) {

    *** 766,780 ****
    --- 842,855 ----
                      loader_data->class_loader() == NULL ||
                      loader_data->class_loader()->is_instance(),
                      "checking type of class_loader");
            e->verify();
            probe->verify_protection_domain_set();
    !       element_count++;
    !       actual_count++;
          }
        }
    !   guarantee(number_of_entries() == element_count,
                  "Verify of system dictionary failed");
    !   guarantee(number_of_entries() == actual_count, "should be equal");
        debug_only(verify_lookup_length((double)number_of_entries() / table_size()));

        _pd_cache_table->verify();
      }

src/share/vm/classfile/dictionary.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File