hotspot/src/share/vm/classfile/vmSymbols.cpp
changeset 34666 1c7168ea0034
parent 33638 ef49ed90010b
child 35135 dd2ce9021031
equal deleted inserted replaced
34665:9fdcc78b5398 34666:1c7168ea0034
    32 
    32 
    33 Symbol* vmSymbols::_symbols[vmSymbols::SID_LIMIT];
    33 Symbol* vmSymbols::_symbols[vmSymbols::SID_LIMIT];
    34 
    34 
    35 Symbol* vmSymbols::_type_signatures[T_VOID+1] = { NULL /*, NULL...*/ };
    35 Symbol* vmSymbols::_type_signatures[T_VOID+1] = { NULL /*, NULL...*/ };
    36 
    36 
    37 inline int compare_symbol(Symbol* a, Symbol* b) {
    37 inline int compare_symbol(const Symbol* a, const Symbol* b) {
    38   if (a == b)  return 0;
    38   if (a == b)  return 0;
    39   // follow the natural address order:
    39   // follow the natural address order:
    40   return (address)a > (address)b ? +1 : -1;
    40   return (address)a > (address)b ? +1 : -1;
    41 }
    41 }
    42 
    42 
    43 static vmSymbols::SID vm_symbol_index[vmSymbols::SID_LIMIT];
    43 static vmSymbols::SID vm_symbol_index[vmSymbols::SID_LIMIT];
    44 extern "C" {
    44 extern "C" {
    45   static int compare_vmsymbol_sid(const void* void_a, const void* void_b) {
    45   static int compare_vmsymbol_sid(const void* void_a, const void* void_b) {
    46     Symbol* a = vmSymbols::symbol_at(*((vmSymbols::SID*) void_a));
    46     const Symbol* a = vmSymbols::symbol_at(*((vmSymbols::SID*) void_a));
    47     Symbol* b = vmSymbols::symbol_at(*((vmSymbols::SID*) void_b));
    47     const Symbol* b = vmSymbols::symbol_at(*((vmSymbols::SID*) void_b));
    48     return compare_symbol(a, b);
    48     return compare_symbol(a, b);
    49   }
    49   }
    50 }
    50 }
    51 
    51 
    52 #ifdef ASSERT
    52 #ifdef ASSERT
   186                  (SID_LIMIT - FIRST_SID) * sizeof(_symbols[0]));
   186                  (SID_LIMIT - FIRST_SID) * sizeof(_symbols[0]));
   187   soc->do_region((u_char*)_type_signatures, sizeof(_type_signatures));
   187   soc->do_region((u_char*)_type_signatures, sizeof(_type_signatures));
   188 }
   188 }
   189 
   189 
   190 
   190 
   191 BasicType vmSymbols::signature_type(Symbol* s) {
   191 BasicType vmSymbols::signature_type(const Symbol* s) {
   192   assert(s != NULL, "checking");
   192   assert(s != NULL, "checking");
   193   for (int i = T_BOOLEAN; i < T_VOID+1; i++) {
   193   for (int i = T_BOOLEAN; i < T_VOID+1; i++) {
   194     if (s == _type_signatures[i]) {
   194     if (s == _type_signatures[i]) {
   195       return (BasicType)i;
   195       return (BasicType)i;
   196     }
   196     }
   204 #ifndef PRODUCT
   204 #ifndef PRODUCT
   205 static int find_sid_calls, find_sid_probes;
   205 static int find_sid_calls, find_sid_probes;
   206 // (Typical counts are calls=7000 and probes=17000.)
   206 // (Typical counts are calls=7000 and probes=17000.)
   207 #endif
   207 #endif
   208 
   208 
   209 vmSymbols::SID vmSymbols::find_sid(Symbol* symbol) {
   209 vmSymbols::SID vmSymbols::find_sid(const Symbol* symbol) {
   210   // Handle the majority of misses by a bounds check.
   210   // Handle the majority of misses by a bounds check.
   211   // Then, use a binary search over the index.
   211   // Then, use a binary search over the index.
   212   // Expected trip count is less than log2_SID_LIMIT, about eight.
   212   // Expected trip count is less than log2_SID_LIMIT, about eight.
   213   // This is slow but acceptable, given that calls are not
   213   // This is slow but acceptable, given that calls are not
   214   // dynamically common.  (Method*::intrinsic_id has a cache.)
   214   // dynamically common.  (Method*::intrinsic_id has a cache.)