src/share/vm/runtime/sharedRuntime.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 6926697 Sdiff src/share/vm/runtime

src/share/vm/runtime/sharedRuntime.cpp

Print this page




1930              _value._compact[1] == other->_value._compact[1] &&
1931              _value._compact[2] == other->_value._compact[2];
1932     } else {
1933       for (int i = 0; i < _length; i++) {
1934         if (_value._fingerprint[i] != other->_value._fingerprint[i]) {
1935           return false;
1936         }
1937       }
1938     }
1939     return true;
1940   }
1941 };
1942 
1943 
1944 // A hashtable mapping from AdapterFingerPrints to AdapterHandlerEntries
1945 class AdapterHandlerTable : public BasicHashtable {
1946   friend class AdapterHandlerTableIterator;
1947 
1948  private:
1949 
1950 #ifdef ASSERT
1951   static int _lookups; // number of calls to lookup
1952   static int _buckets; // number of buckets checked
1953   static int _equals;  // number of buckets checked with matching hash
1954   static int _hits;    // number of successful lookups
1955   static int _compact; // number of equals calls with compact signature
1956 #endif
1957 
1958   AdapterHandlerEntry* bucket(int i) {
1959     return (AdapterHandlerEntry*)BasicHashtable::bucket(i);
1960   }
1961 
1962  public:
1963   AdapterHandlerTable()
1964     : BasicHashtable(293, sizeof(AdapterHandlerEntry)) { }
1965 
1966   // Create a new entry suitable for insertion in the table
1967   AdapterHandlerEntry* new_entry(AdapterFingerPrint* fingerprint, address i2c_entry, address c2i_entry, address c2i_unverified_entry) {
1968     AdapterHandlerEntry* entry = (AdapterHandlerEntry*)BasicHashtable::new_entry(fingerprint->compute_hash());
1969     entry->init(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry);
1970     return entry;
1971   }
1972 
1973   // Insert an entry into the table
1974   void add(AdapterHandlerEntry* entry) {
1975     int index = hash_to_index(entry->hash());
1976     add_entry(index, entry);
1977   }
1978 
1979   void free_entry(AdapterHandlerEntry* entry) {
1980     entry->deallocate();
1981     BasicHashtable::free_entry(entry);
1982   }
1983 
1984   // Find a entry with the same fingerprint if it exists
1985   AdapterHandlerEntry* lookup(int total_args_passed, BasicType* sig_bt) {
1986     debug_only(_lookups++);
1987     AdapterFingerPrint fp(total_args_passed, sig_bt);
1988     unsigned int hash = fp.compute_hash();
1989     int index = hash_to_index(hash);
1990     for (AdapterHandlerEntry* e = bucket(index); e != NULL; e = e->next()) {
1991       debug_only(_buckets++);
1992       if (e->hash() == hash) {
1993         debug_only(_equals++);
1994         if (fp.equals(e->fingerprint())) {
1995 #ifdef ASSERT
1996           if (fp.is_compact()) _compact++;
1997           _hits++;
1998 #endif
1999           return e;
2000         }
2001       }
2002     }
2003     return NULL;
2004   }
2005 

2006   void print_statistics() {
2007     ResourceMark rm;
2008     int longest = 0;
2009     int empty = 0;
2010     int total = 0;
2011     int nonempty = 0;
2012     for (int index = 0; index < table_size(); index++) {
2013       int count = 0;
2014       for (AdapterHandlerEntry* e = bucket(index); e != NULL; e = e->next()) {
2015         count++;
2016       }
2017       if (count != 0) nonempty++;
2018       if (count == 0) empty++;
2019       if (count > longest) longest = count;
2020       total += count;
2021     }
2022     tty->print_cr("AdapterHandlerTable: empty %d longest %d total %d average %f",
2023                   empty, longest, total, total / (double)nonempty);
2024 #ifdef ASSERT
2025     tty->print_cr("AdapterHandlerTable: lookups %d buckets %d equals %d hits %d compact %d",
2026                   _lookups, _buckets, _equals, _hits, _compact);
2027 #endif
2028   }

2029 };
2030 
2031 
2032 #ifdef ASSERT
2033 
2034 int AdapterHandlerTable::_lookups;
2035 int AdapterHandlerTable::_buckets;
2036 int AdapterHandlerTable::_equals;
2037 int AdapterHandlerTable::_hits;
2038 int AdapterHandlerTable::_compact;
2039 
2040 class AdapterHandlerTableIterator : public StackObj {
2041  private:
2042   AdapterHandlerTable* _table;
2043   int _index;
2044   AdapterHandlerEntry* _current;
2045 
2046   void scan() {
2047     while (_index < _table->table_size()) {
2048       AdapterHandlerEntry* a = _table->bucket(_index);
2049       if (a != NULL) {
2050         _current = a;
2051         return;
2052       }




1930              _value._compact[1] == other->_value._compact[1] &&
1931              _value._compact[2] == other->_value._compact[2];
1932     } else {
1933       for (int i = 0; i < _length; i++) {
1934         if (_value._fingerprint[i] != other->_value._fingerprint[i]) {
1935           return false;
1936         }
1937       }
1938     }
1939     return true;
1940   }
1941 };
1942 
1943 
1944 // A hashtable mapping from AdapterFingerPrints to AdapterHandlerEntries
1945 class AdapterHandlerTable : public BasicHashtable {
1946   friend class AdapterHandlerTableIterator;
1947 
1948  private:
1949 
1950 #ifndef PRODUCT
1951   static int _lookups; // number of calls to lookup
1952   static int _buckets; // number of buckets checked
1953   static int _equals;  // number of buckets checked with matching hash
1954   static int _hits;    // number of successful lookups
1955   static int _compact; // number of equals calls with compact signature
1956 #endif
1957 
1958   AdapterHandlerEntry* bucket(int i) {
1959     return (AdapterHandlerEntry*)BasicHashtable::bucket(i);
1960   }
1961 
1962  public:
1963   AdapterHandlerTable()
1964     : BasicHashtable(293, sizeof(AdapterHandlerEntry)) { }
1965 
1966   // Create a new entry suitable for insertion in the table
1967   AdapterHandlerEntry* new_entry(AdapterFingerPrint* fingerprint, address i2c_entry, address c2i_entry, address c2i_unverified_entry) {
1968     AdapterHandlerEntry* entry = (AdapterHandlerEntry*)BasicHashtable::new_entry(fingerprint->compute_hash());
1969     entry->init(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry);
1970     return entry;
1971   }
1972 
1973   // Insert an entry into the table
1974   void add(AdapterHandlerEntry* entry) {
1975     int index = hash_to_index(entry->hash());
1976     add_entry(index, entry);
1977   }
1978 
1979   void free_entry(AdapterHandlerEntry* entry) {
1980     entry->deallocate();
1981     BasicHashtable::free_entry(entry);
1982   }
1983 
1984   // Find a entry with the same fingerprint if it exists
1985   AdapterHandlerEntry* lookup(int total_args_passed, BasicType* sig_bt) {
1986     NOT_PRODUCT(_lookups++);
1987     AdapterFingerPrint fp(total_args_passed, sig_bt);
1988     unsigned int hash = fp.compute_hash();
1989     int index = hash_to_index(hash);
1990     for (AdapterHandlerEntry* e = bucket(index); e != NULL; e = e->next()) {
1991       NOT_PRODUCT(_buckets++);
1992       if (e->hash() == hash) {
1993         NOT_PRODUCT(_equals++);
1994         if (fp.equals(e->fingerprint())) {
1995 #ifndef PRODUCT
1996           if (fp.is_compact()) _compact++;
1997           _hits++;
1998 #endif
1999           return e;
2000         }
2001       }
2002     }
2003     return NULL;
2004   }
2005 
2006 #ifndef PRODUCT
2007   void print_statistics() {
2008     ResourceMark rm;
2009     int longest = 0;
2010     int empty = 0;
2011     int total = 0;
2012     int nonempty = 0;
2013     for (int index = 0; index < table_size(); index++) {
2014       int count = 0;
2015       for (AdapterHandlerEntry* e = bucket(index); e != NULL; e = e->next()) {
2016         count++;
2017       }
2018       if (count != 0) nonempty++;
2019       if (count == 0) empty++;
2020       if (count > longest) longest = count;
2021       total += count;
2022     }
2023     tty->print_cr("AdapterHandlerTable: empty %d longest %d total %d average %f",
2024                   empty, longest, total, total / (double)nonempty);

2025     tty->print_cr("AdapterHandlerTable: lookups %d buckets %d equals %d hits %d compact %d",
2026                   _lookups, _buckets, _equals, _hits, _compact);

2027   }
2028 #endif
2029 };
2030 
2031 
2032 #ifndef PRODUCT
2033 
2034 int AdapterHandlerTable::_lookups;
2035 int AdapterHandlerTable::_buckets;
2036 int AdapterHandlerTable::_equals;
2037 int AdapterHandlerTable::_hits;
2038 int AdapterHandlerTable::_compact;
2039 
2040 class AdapterHandlerTableIterator : public StackObj {
2041  private:
2042   AdapterHandlerTable* _table;
2043   int _index;
2044   AdapterHandlerEntry* _current;
2045 
2046   void scan() {
2047     while (_index < _table->table_size()) {
2048       AdapterHandlerEntry* a = _table->bucket(_index);
2049       if (a != NULL) {
2050         _current = a;
2051         return;
2052       }


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