src/hotspot/share/runtime/signature.cpp
changeset 51997 9ce37fa2e179
parent 49354 c6f2f91a1b4e
child 54124 5d48ae032588
equal deleted inserted replaced
51996:84743156e780 51997:9ce37fa2e179
    48   _signature       = signature;
    48   _signature       = signature;
    49   _parameter_index = 0;
    49   _parameter_index = 0;
    50 }
    50 }
    51 
    51 
    52 void SignatureIterator::expect(char c) {
    52 void SignatureIterator::expect(char c) {
    53   if (_signature->byte_at(_index) != c) fatal("expecting %c", c);
    53   if (_signature->char_at(_index) != c) fatal("expecting %c", c);
    54   _index++;
    54   _index++;
    55 }
    55 }
    56 
    56 
    57 int SignatureIterator::parse_type() {
    57 int SignatureIterator::parse_type() {
    58   // Note: This function could be simplified by using "return T_XXX_size;"
    58   // Note: This function could be simplified by using "return T_XXX_size;"
    59   //       instead of the assignment and the break statements. However, it
    59   //       instead of the assignment and the break statements. However, it
    60   //       seems that the product build for win32_i486 with MS VC++ 6.0 doesn't
    60   //       seems that the product build for win32_i486 with MS VC++ 6.0 doesn't
    61   //       work (stack underflow for some tests) - this seems to be a VC++ 6.0
    61   //       work (stack underflow for some tests) - this seems to be a VC++ 6.0
    62   //       compiler bug (was problem - gri 4/27/2000).
    62   //       compiler bug (was problem - gri 4/27/2000).
    63   int size = -1;
    63   int size = -1;
    64   switch(_signature->byte_at(_index)) {
    64   switch(_signature->char_at(_index)) {
    65     case 'B': do_byte  (); if (_parameter_index < 0 ) _return_type = T_BYTE;
    65     case 'B': do_byte  (); if (_parameter_index < 0 ) _return_type = T_BYTE;
    66               _index++; size = T_BYTE_size   ; break;
    66               _index++; size = T_BYTE_size   ; break;
    67     case 'C': do_char  (); if (_parameter_index < 0 ) _return_type = T_CHAR;
    67     case 'C': do_char  (); if (_parameter_index < 0 ) _return_type = T_CHAR;
    68               _index++; size = T_CHAR_size   ; break;
    68               _index++; size = T_CHAR_size   ; break;
    69     case 'D': do_double(); if (_parameter_index < 0 ) _return_type = T_DOUBLE;
    69     case 'D': do_double(); if (_parameter_index < 0 ) _return_type = T_DOUBLE;
    81     case 'V': do_void  (); if (_parameter_index < 0 ) _return_type = T_VOID;
    81     case 'V': do_void  (); if (_parameter_index < 0 ) _return_type = T_VOID;
    82               _index++; size = T_VOID_size;  ; break;
    82               _index++; size = T_VOID_size;  ; break;
    83     case 'L':
    83     case 'L':
    84       { int begin = ++_index;
    84       { int begin = ++_index;
    85         Symbol* sig = _signature;
    85         Symbol* sig = _signature;
    86         while (sig->byte_at(_index++) != ';') ;
    86         while (sig->char_at(_index++) != ';') ;
    87         do_object(begin, _index);
    87         do_object(begin, _index);
    88       }
    88       }
    89       if (_parameter_index < 0 ) _return_type = T_OBJECT;
    89       if (_parameter_index < 0 ) _return_type = T_OBJECT;
    90       size = T_OBJECT_size;
    90       size = T_OBJECT_size;
    91       break;
    91       break;
    92     case '[':
    92     case '[':
    93       { int begin = ++_index;
    93       { int begin = ++_index;
    94         Symbol* sig = _signature;
    94         Symbol* sig = _signature;
    95         while (sig->byte_at(_index) == '[') {
    95         while (sig->char_at(_index) == '[') {
    96           _index++;
    96           _index++;
    97         }
    97         }
    98         if (sig->byte_at(_index) == 'L') {
    98         if (sig->char_at(_index) == 'L') {
    99           while (sig->byte_at(_index++) != ';') ;
    99           while (sig->char_at(_index++) != ';') ;
   100         } else {
   100         } else {
   101           _index++;
   101           _index++;
   102         }
   102         }
   103         do_array(begin, _index);
   103         do_array(begin, _index);
   104        if (_parameter_index < 0 ) _return_type = T_ARRAY;
   104        if (_parameter_index < 0 ) _return_type = T_ARRAY;
   135 void SignatureIterator::iterate_parameters() {
   135 void SignatureIterator::iterate_parameters() {
   136   // Parse parameters
   136   // Parse parameters
   137   _index = 0;
   137   _index = 0;
   138   _parameter_index = 0;
   138   _parameter_index = 0;
   139   expect('(');
   139   expect('(');
   140   while (_signature->byte_at(_index) != ')') _parameter_index += parse_type();
   140   while (_signature->char_at(_index) != ')') _parameter_index += parse_type();
   141   expect(')');
   141   expect(')');
   142   _parameter_index = 0;
   142   _parameter_index = 0;
   143 }
   143 }
   144 
   144 
   145 // Optimized version of iterate_parameters when fingerprint is known
   145 // Optimized version of iterate_parameters when fingerprint is known
   215   expect('(');
   215   expect('(');
   216   Symbol* sig = _signature;
   216   Symbol* sig = _signature;
   217   // Need to skip over each type in the signature's argument list until a
   217   // Need to skip over each type in the signature's argument list until a
   218   // closing ')' is found., then get the return type.  We cannot just scan
   218   // closing ')' is found., then get the return type.  We cannot just scan
   219   // for the first ')' because ')' is a legal character in a type name.
   219   // for the first ')' because ')' is a legal character in a type name.
   220   while (sig->byte_at(_index) != ')') {
   220   while (sig->char_at(_index) != ')') {
   221     switch(sig->byte_at(_index)) {
   221     switch(sig->char_at(_index)) {
   222       case 'B':
   222       case 'B':
   223       case 'C':
   223       case 'C':
   224       case 'D':
   224       case 'D':
   225       case 'F':
   225       case 'F':
   226       case 'I':
   226       case 'I':
   232           _index++;
   232           _index++;
   233         }
   233         }
   234         break;
   234         break;
   235       case 'L':
   235       case 'L':
   236         {
   236         {
   237           while (sig->byte_at(_index++) != ';') ;
   237           while (sig->char_at(_index++) != ';') ;
   238         }
   238         }
   239         break;
   239         break;
   240       case '[':
   240       case '[':
   241         {
   241         {
   242           int begin = ++_index;
   242           int begin = ++_index;
   243           while (sig->byte_at(_index) == '[') {
   243           while (sig->char_at(_index) == '[') {
   244             _index++;
   244             _index++;
   245           }
   245           }
   246           if (sig->byte_at(_index) == 'L') {
   246           if (sig->char_at(_index) == 'L') {
   247             while (sig->byte_at(_index++) != ';') ;
   247             while (sig->char_at(_index++) != ';') ;
   248           } else {
   248           } else {
   249             _index++;
   249             _index++;
   250           }
   250           }
   251         }
   251         }
   252         break;
   252         break;
   267 void SignatureIterator::iterate() {
   267 void SignatureIterator::iterate() {
   268   // Parse parameters
   268   // Parse parameters
   269   _parameter_index = 0;
   269   _parameter_index = 0;
   270   _index = 0;
   270   _index = 0;
   271   expect('(');
   271   expect('(');
   272   while (_signature->byte_at(_index) != ')') _parameter_index += parse_type();
   272   while (_signature->char_at(_index) != ')') _parameter_index += parse_type();
   273   expect(')');
   273   expect(')');
   274   // Parse return type
   274   // Parse return type
   275   _parameter_index = -1;
   275   _parameter_index = -1;
   276   parse_type();
   276   parse_type();
   277   check_signature_end();
   277   check_signature_end();
   302 void SignatureStream::next_non_primitive(int t) {
   302 void SignatureStream::next_non_primitive(int t) {
   303   switch (t) {
   303   switch (t) {
   304     case 'L': {
   304     case 'L': {
   305       _type = T_OBJECT;
   305       _type = T_OBJECT;
   306       Symbol* sig = _signature;
   306       Symbol* sig = _signature;
   307       while (sig->byte_at(_end++) != ';');
   307       while (sig->char_at(_end++) != ';');
   308       break;
   308       break;
   309     }
   309     }
   310     case '[': {
   310     case '[': {
   311       _type = T_ARRAY;
   311       _type = T_ARRAY;
   312       Symbol* sig = _signature;
   312       Symbol* sig = _signature;
   313       char c = sig->byte_at(_end);
   313       char c = sig->char_at(_end);
   314       while ('0' <= c && c <= '9') c = sig->byte_at(_end++);
   314       while ('0' <= c && c <= '9') c = sig->char_at(_end++);
   315       while (sig->byte_at(_end) == '[') {
   315       while (sig->char_at(_end) == '[') {
   316         _end++;
   316         _end++;
   317         c = sig->byte_at(_end);
   317         c = sig->char_at(_end);
   318         while ('0' <= c && c <= '9') c = sig->byte_at(_end++);
   318         while ('0' <= c && c <= '9') c = sig->char_at(_end++);
   319       }
   319       }
   320       switch(sig->byte_at(_end)) {
   320       switch(sig->char_at(_end)) {
   321         case 'B':
   321         case 'B':
   322         case 'C':
   322         case 'C':
   323         case 'D':
   323         case 'D':
   324         case 'F':
   324         case 'F':
   325         case 'I':
   325         case 'I':
   326         case 'J':
   326         case 'J':
   327         case 'S':
   327         case 'S':
   328         case 'Z':_end++; break;
   328         case 'Z':_end++; break;
   329         default: {
   329         default: {
   330           while (sig->byte_at(_end++) != ';');
   330           while (sig->char_at(_end++) != ';');
   331           break;
   331           break;
   332         }
   332         }
   333       }
   333       }
   334       break;
   334       break;
   335     }
   335     }
   351 Symbol* SignatureStream::as_symbol(TRAPS) {
   351 Symbol* SignatureStream::as_symbol(TRAPS) {
   352   // Create a symbol from for string _begin _end
   352   // Create a symbol from for string _begin _end
   353   int begin = _begin;
   353   int begin = _begin;
   354   int end   = _end;
   354   int end   = _end;
   355 
   355 
   356   if (   _signature->byte_at(_begin) == 'L'
   356   if (   _signature->char_at(_begin) == 'L'
   357       && _signature->byte_at(_end-1) == ';') {
   357       && _signature->char_at(_end-1) == ';') {
   358     begin++;
   358     begin++;
   359     end--;
   359     end--;
   360   }
   360   }
   361 
   361 
   362   // Save names for cleaning up reference count at the end of
   362   // Save names for cleaning up reference count at the end of
   392   ResourceMark rm;
   392   ResourceMark rm;
   393 
   393 
   394   int begin = _begin;
   394   int begin = _begin;
   395   int end   = _end;
   395   int end   = _end;
   396 
   396 
   397   if (   _signature->byte_at(_begin) == 'L'
   397   if (   _signature->char_at(_begin) == 'L'
   398       && _signature->byte_at(_end-1) == ';') {
   398       && _signature->char_at(_end-1) == ';') {
   399     begin++;
   399     begin++;
   400     end--;
   400     end--;
   401   }
   401   }
   402 
   402 
   403   char* buffer = NEW_RESOURCE_ARRAY(char, end - begin);
   403   char* buffer = NEW_RESOURCE_ARRAY(char, end - begin);
   404   for (int index = begin; index < end; index++) {
   404   for (int index = begin; index < end; index++) {
   405     buffer[index - begin] = _signature->byte_at(index);
   405     buffer[index - begin] = _signature->char_at(index);
   406   }
   406   }
   407   Symbol* result = SymbolTable::probe(buffer, end - begin);
   407   Symbol* result = SymbolTable::probe(buffer, end - begin);
   408   return result;
   408   return result;
   409 }
   409 }
   410 
   410