1945 class AdapterHandlerTable : public BasicHashtable { |
1945 class AdapterHandlerTable : public BasicHashtable { |
1946 friend class AdapterHandlerTableIterator; |
1946 friend class AdapterHandlerTableIterator; |
1947 |
1947 |
1948 private: |
1948 private: |
1949 |
1949 |
1950 #ifdef ASSERT |
1950 #ifndef PRODUCT |
1951 static int _lookups; // number of calls to lookup |
1951 static int _lookups; // number of calls to lookup |
1952 static int _buckets; // number of buckets checked |
1952 static int _buckets; // number of buckets checked |
1953 static int _equals; // number of buckets checked with matching hash |
1953 static int _equals; // number of buckets checked with matching hash |
1954 static int _hits; // number of successful lookups |
1954 static int _hits; // number of successful lookups |
1955 static int _compact; // number of equals calls with compact signature |
1955 static int _compact; // number of equals calls with compact signature |
1981 BasicHashtable::free_entry(entry); |
1981 BasicHashtable::free_entry(entry); |
1982 } |
1982 } |
1983 |
1983 |
1984 // Find a entry with the same fingerprint if it exists |
1984 // Find a entry with the same fingerprint if it exists |
1985 AdapterHandlerEntry* lookup(int total_args_passed, BasicType* sig_bt) { |
1985 AdapterHandlerEntry* lookup(int total_args_passed, BasicType* sig_bt) { |
1986 debug_only(_lookups++); |
1986 NOT_PRODUCT(_lookups++); |
1987 AdapterFingerPrint fp(total_args_passed, sig_bt); |
1987 AdapterFingerPrint fp(total_args_passed, sig_bt); |
1988 unsigned int hash = fp.compute_hash(); |
1988 unsigned int hash = fp.compute_hash(); |
1989 int index = hash_to_index(hash); |
1989 int index = hash_to_index(hash); |
1990 for (AdapterHandlerEntry* e = bucket(index); e != NULL; e = e->next()) { |
1990 for (AdapterHandlerEntry* e = bucket(index); e != NULL; e = e->next()) { |
1991 debug_only(_buckets++); |
1991 NOT_PRODUCT(_buckets++); |
1992 if (e->hash() == hash) { |
1992 if (e->hash() == hash) { |
1993 debug_only(_equals++); |
1993 NOT_PRODUCT(_equals++); |
1994 if (fp.equals(e->fingerprint())) { |
1994 if (fp.equals(e->fingerprint())) { |
1995 #ifdef ASSERT |
1995 #ifndef PRODUCT |
1996 if (fp.is_compact()) _compact++; |
1996 if (fp.is_compact()) _compact++; |
1997 _hits++; |
1997 _hits++; |
1998 #endif |
1998 #endif |
1999 return e; |
1999 return e; |
2000 } |
2000 } |
2001 } |
2001 } |
2002 } |
2002 } |
2003 return NULL; |
2003 return NULL; |
2004 } |
2004 } |
2005 |
2005 |
|
2006 #ifndef PRODUCT |
2006 void print_statistics() { |
2007 void print_statistics() { |
2007 ResourceMark rm; |
2008 ResourceMark rm; |
2008 int longest = 0; |
2009 int longest = 0; |
2009 int empty = 0; |
2010 int empty = 0; |
2010 int total = 0; |
2011 int total = 0; |
2019 if (count > longest) longest = count; |
2020 if (count > longest) longest = count; |
2020 total += count; |
2021 total += count; |
2021 } |
2022 } |
2022 tty->print_cr("AdapterHandlerTable: empty %d longest %d total %d average %f", |
2023 tty->print_cr("AdapterHandlerTable: empty %d longest %d total %d average %f", |
2023 empty, longest, total, total / (double)nonempty); |
2024 empty, longest, total, total / (double)nonempty); |
2024 #ifdef ASSERT |
|
2025 tty->print_cr("AdapterHandlerTable: lookups %d buckets %d equals %d hits %d compact %d", |
2025 tty->print_cr("AdapterHandlerTable: lookups %d buckets %d equals %d hits %d compact %d", |
2026 _lookups, _buckets, _equals, _hits, _compact); |
2026 _lookups, _buckets, _equals, _hits, _compact); |
|
2027 } |
2027 #endif |
2028 #endif |
2028 } |
|
2029 }; |
2029 }; |
2030 |
2030 |
2031 |
2031 |
2032 #ifdef ASSERT |
2032 #ifndef PRODUCT |
2033 |
2033 |
2034 int AdapterHandlerTable::_lookups; |
2034 int AdapterHandlerTable::_lookups; |
2035 int AdapterHandlerTable::_buckets; |
2035 int AdapterHandlerTable::_buckets; |
2036 int AdapterHandlerTable::_equals; |
2036 int AdapterHandlerTable::_equals; |
2037 int AdapterHandlerTable::_hits; |
2037 int AdapterHandlerTable::_hits; |