< prev index next >

src/hotspot/share/runtime/signature.hpp

Print this page




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_RUNTIME_SIGNATURE_HPP
  26 #define SHARE_RUNTIME_SIGNATURE_HPP
  27 

  28 #include "memory/allocation.hpp"
  29 #include "oops/method.hpp"
  30 
  31 // SignatureIterators iterate over a Java signature (or parts of it).
  32 // (Syntax according to: "The Java Virtual Machine Specification" by
  33 // Tim Lindholm & Frank Yellin; section 4.3 Descriptors; p. 89ff.)
  34 //
  35 // Example: Iterating over ([Lfoo;D)I using
  36 //                         0123456789
  37 //
  38 // iterate_parameters() calls: do_array(2, 7); do_double();
  39 // iterate_returntype() calls:                              do_int();
  40 // iterate()            calls: do_array(2, 7); do_double(); do_int();
  41 //
  42 // is_return_type()        is: false         ; false      ; true
  43 //
  44 // NOTE: The new optimizer has an alternate, for-loop based signature
  45 // iterator implemented in opto/type.cpp, TypeTuple::make().
  46 
  47 class SignatureIterator: public ResourceObj {


  96   void iterate_returntype();           // iterates over returntype only
  97   void iterate();                      // iterates over whole signature
  98   // Returns the word index of the current parameter;
  99   int  parameter_index() const         { return _parameter_index; }
 100   bool is_return_type() const          { return parameter_index() < 0; }
 101   BasicType get_ret_type() const       { return _return_type; }
 102 
 103   // Basic types
 104   virtual void do_bool  ()             = 0;
 105   virtual void do_char  ()             = 0;
 106   virtual void do_float ()             = 0;
 107   virtual void do_double()             = 0;
 108   virtual void do_byte  ()             = 0;
 109   virtual void do_short ()             = 0;
 110   virtual void do_int   ()             = 0;
 111   virtual void do_long  ()             = 0;
 112   virtual void do_void  ()             = 0;
 113 
 114   // Object types (begin indexes the first character of the entry, end indexes the first character after the entry)
 115   virtual void do_object(int begin, int end) = 0;

 116   virtual void do_array (int begin, int end) = 0;
 117 
 118   static bool is_static(uint64_t fingerprint) {
 119     assert(fingerprint != (uint64_t)CONST64(-1), "invalid fingerprint");
 120     return fingerprint & is_static_bit;
 121   }
 122   static BasicType return_type(uint64_t fingerprint) {
 123     assert(fingerprint != (uint64_t)CONST64(-1), "invalid fingerprint");
 124     return (BasicType) ((fingerprint >> static_feature_size) & result_feature_mask);
 125   }
 126 };
 127 
 128 
 129 // Specialized SignatureIterators: Used to compute signature specific values.
 130 
 131 class SignatureTypeNames : public SignatureIterator {
 132  protected:
 133   virtual void type_name(const char* name)   = 0;
 134 
 135   void do_bool()                       { type_name("jboolean"); }
 136   void do_char()                       { type_name("jchar"   ); }
 137   void do_float()                      { type_name("jfloat"  ); }
 138   void do_double()                     { type_name("jdouble" ); }
 139   void do_byte()                       { type_name("jbyte"   ); }
 140   void do_short()                      { type_name("jshort"  ); }
 141   void do_int()                        { type_name("jint"    ); }
 142   void do_long()                       { type_name("jlong"   ); }
 143   void do_void()                       { type_name("void"    ); }
 144   void do_object(int begin, int end)   { type_name("jobject" ); }

 145   void do_array (int begin, int end)   { type_name("jobject" ); }
 146 
 147  public:
 148   SignatureTypeNames(Symbol* signature) : SignatureIterator(signature) {}
 149 };
 150 
 151 
 152 class SignatureInfo: public SignatureIterator {
 153  protected:
 154   bool      _has_iterated;             // need this because iterate cannot be called in constructor (set is virtual!)
 155   bool      _has_iterated_return;
 156   int       _size;
 157 
 158   void lazy_iterate_parameters()       { if (!_has_iterated) { iterate_parameters(); _has_iterated = true; } }
 159   void lazy_iterate_return()           { if (!_has_iterated_return) { iterate_returntype(); _has_iterated_return = true; } }
 160 
 161   virtual void set(int size, BasicType type) = 0;
 162 
 163   void do_bool  ()                     { set(T_BOOLEAN_size, T_BOOLEAN); }
 164   void do_char  ()                     { set(T_CHAR_size   , T_CHAR   ); }
 165   void do_float ()                     { set(T_FLOAT_size  , T_FLOAT  ); }
 166   void do_double()                     { set(T_DOUBLE_size , T_DOUBLE ); }
 167   void do_byte  ()                     { set(T_BYTE_size   , T_BYTE   ); }
 168   void do_short ()                     { set(T_SHORT_size  , T_SHORT  ); }
 169   void do_int   ()                     { set(T_INT_size    , T_INT    ); }
 170   void do_long  ()                     { set(T_LONG_size   , T_LONG   ); }
 171   void do_void  ()                     { set(T_VOID_size   , T_VOID   ); }
 172   void do_object(int begin, int end)   { set(T_OBJECT_size , T_OBJECT ); }

 173   void do_array (int begin, int end)   { set(T_ARRAY_size  , T_ARRAY  ); }
 174 
 175  public:
 176   SignatureInfo(Symbol* signature) : SignatureIterator(signature) {
 177     _has_iterated = _has_iterated_return = false;
 178     _size         = 0;
 179     _return_type  = T_ILLEGAL;
 180   }
 181 
 182 };
 183 
 184 
 185 // Specialized SignatureIterator: Used to compute the argument size.
 186 
 187 class ArgumentSizeComputer: public SignatureInfo {
 188  private:
 189   void set(int size, BasicType type)   { _size += size; }
 190  public:
 191   ArgumentSizeComputer(Symbol* signature) : SignatureInfo(signature) {}
 192 


 219 // Fingerprinter computes a unique ID for a given method. The ID
 220 // is a bitvector characterizing the methods signature (incl. the receiver).
 221 class Fingerprinter: public SignatureIterator {
 222  private:
 223   uint64_t _fingerprint;
 224   int _shift_count;
 225   methodHandle mh;
 226 
 227  public:
 228 
 229   void do_bool()    { _fingerprint |= (((uint64_t)bool_parm) << _shift_count); _shift_count += parameter_feature_size; }
 230   void do_char()    { _fingerprint |= (((uint64_t)char_parm) << _shift_count); _shift_count += parameter_feature_size; }
 231   void do_byte()    { _fingerprint |= (((uint64_t)byte_parm) << _shift_count); _shift_count += parameter_feature_size; }
 232   void do_short()   { _fingerprint |= (((uint64_t)short_parm) << _shift_count); _shift_count += parameter_feature_size; }
 233   void do_int()     { _fingerprint |= (((uint64_t)int_parm) << _shift_count); _shift_count += parameter_feature_size; }
 234   void do_long()    { _fingerprint |= (((uint64_t)long_parm) << _shift_count); _shift_count += parameter_feature_size; }
 235   void do_float()   { _fingerprint |= (((uint64_t)float_parm) << _shift_count); _shift_count += parameter_feature_size; }
 236   void do_double()  { _fingerprint |= (((uint64_t)double_parm) << _shift_count); _shift_count += parameter_feature_size; }
 237 
 238   void do_object(int begin, int end)  { _fingerprint |= (((uint64_t)obj_parm) << _shift_count); _shift_count += parameter_feature_size; }

 239   void do_array (int begin, int end)  { _fingerprint |= (((uint64_t)obj_parm) << _shift_count); _shift_count += parameter_feature_size; }
 240 
 241   void do_void()    { ShouldNotReachHere(); }
 242 
 243   Fingerprinter(const methodHandle& method) : SignatureIterator(method->signature()) {
 244     mh = method;
 245     _fingerprint = 0;
 246   }
 247 
 248   uint64_t fingerprint() {
 249     // See if we fingerprinted this method already
 250     if (mh->constMethod()->fingerprint() != CONST64(0)) {
 251       return mh->constMethod()->fingerprint();
 252     }
 253 
 254     if (mh->size_of_parameters() > max_size_of_parameters ) {
 255       _fingerprint = (uint64_t)CONST64(-1);
 256       mh->constMethod()->set_fingerprint(_fingerprint);
 257       return _fingerprint;
 258     }


 284 
 285   void do_bool  ()                     { pass_int();    _jni_offset++; _offset++;       }
 286   void do_char  ()                     { pass_int();    _jni_offset++; _offset++;       }
 287   void do_float ()                     { pass_float();  _jni_offset++; _offset++;       }
 288 #ifdef _LP64
 289   void do_double()                     { pass_double(); _jni_offset++; _offset += 2;    }
 290 #else
 291   void do_double()                     { pass_double(); _jni_offset += 2; _offset += 2; }
 292 #endif
 293   void do_byte  ()                     { pass_int();    _jni_offset++; _offset++;       }
 294   void do_short ()                     { pass_int();    _jni_offset++; _offset++;       }
 295   void do_int   ()                     { pass_int();    _jni_offset++; _offset++;       }
 296 #ifdef _LP64
 297   void do_long  ()                     { pass_long();   _jni_offset++; _offset += 2;    }
 298 #else
 299   void do_long  ()                     { pass_long();   _jni_offset += 2; _offset += 2; }
 300 #endif
 301   void do_void  ()                     { ShouldNotReachHere();                               }
 302   void do_object(int begin, int end)   { pass_object(); _jni_offset++; _offset++;        }
 303   void do_array (int begin, int end)   { pass_object(); _jni_offset++; _offset++;        }

 304 
 305  public:
 306   methodHandle method() const          { return _method; }
 307   int          offset() const          { return _offset; }
 308   int      jni_offset() const          { return _jni_offset + _prepended; }
 309 //  int     java_offset() const          { return method()->size_of_parameters() - _offset - 1; }
 310   bool      is_static() const          { return method()->is_static(); }
 311   virtual void pass_int()              = 0;
 312   virtual void pass_long()             = 0;
 313   virtual void pass_object()           = 0;

 314   virtual void pass_float()            = 0;
 315 #ifdef _LP64
 316   virtual void pass_double()           = 0;
 317 #else
 318   virtual void pass_double()           { pass_long(); }  // may be same as long
 319 #endif
 320 
 321   NativeSignatureIterator(const methodHandle& method) : SignatureIterator(method->signature()) {
 322     _method = method;
 323     _offset = 0;
 324     _jni_offset = 0;
 325 
 326     const int JNIEnv_words = 1;
 327     const int mirror_words = 1;
 328     _prepended = !is_static() ? JNIEnv_words : JNIEnv_words + mirror_words;
 329   }
 330 
 331   // iterate() calles the 2 virtual methods according to the following invocation syntax:
 332   //
 333   // {pass_int | pass_long | pass_object}


 409   int       raw_length() { return _end - _begin; }
 410 
 411   // return same as_symbol except allocation of new symbols is avoided.
 412   Symbol* as_symbol_or_null();
 413 
 414   // count the number of references in the signature
 415   int reference_parameter_count();
 416 };
 417 
 418 class SignatureVerifier : public StackObj {
 419   public:
 420     // Returns true if the symbol is valid method or type signature
 421     static bool is_valid_signature(Symbol* sig);
 422 
 423     static bool is_valid_method_signature(Symbol* sig);
 424     static bool is_valid_type_signature(Symbol* sig);
 425   private:
 426 
 427     static ssize_t is_valid_type(const char*, ssize_t);
 428     static bool invalid_name_char(char);



























































 429 };
 430 
 431 #endif // SHARE_RUNTIME_SIGNATURE_HPP


   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_RUNTIME_SIGNATURE_HPP
  26 #define SHARE_RUNTIME_SIGNATURE_HPP
  27 
  28 #include "classfile/symbolTable.hpp"
  29 #include "memory/allocation.hpp"
  30 #include "oops/method.hpp"
  31 
  32 // SignatureIterators iterate over a Java signature (or parts of it).
  33 // (Syntax according to: "The Java Virtual Machine Specification" by
  34 // Tim Lindholm & Frank Yellin; section 4.3 Descriptors; p. 89ff.)
  35 //
  36 // Example: Iterating over ([Lfoo;D)I using
  37 //                         0123456789
  38 //
  39 // iterate_parameters() calls: do_array(2, 7); do_double();
  40 // iterate_returntype() calls:                              do_int();
  41 // iterate()            calls: do_array(2, 7); do_double(); do_int();
  42 //
  43 // is_return_type()        is: false         ; false      ; true
  44 //
  45 // NOTE: The new optimizer has an alternate, for-loop based signature
  46 // iterator implemented in opto/type.cpp, TypeTuple::make().
  47 
  48 class SignatureIterator: public ResourceObj {


  97   void iterate_returntype();           // iterates over returntype only
  98   void iterate();                      // iterates over whole signature
  99   // Returns the word index of the current parameter;
 100   int  parameter_index() const         { return _parameter_index; }
 101   bool is_return_type() const          { return parameter_index() < 0; }
 102   BasicType get_ret_type() const       { return _return_type; }
 103 
 104   // Basic types
 105   virtual void do_bool  ()             = 0;
 106   virtual void do_char  ()             = 0;
 107   virtual void do_float ()             = 0;
 108   virtual void do_double()             = 0;
 109   virtual void do_byte  ()             = 0;
 110   virtual void do_short ()             = 0;
 111   virtual void do_int   ()             = 0;
 112   virtual void do_long  ()             = 0;
 113   virtual void do_void  ()             = 0;
 114 
 115   // Object types (begin indexes the first character of the entry, end indexes the first character after the entry)
 116   virtual void do_object(int begin, int end) = 0;
 117   virtual void do_valuetype(int begin, int end) = 0;
 118   virtual void do_array (int begin, int end) = 0;
 119 
 120   static bool is_static(uint64_t fingerprint) {
 121     assert(fingerprint != (uint64_t)CONST64(-1), "invalid fingerprint");
 122     return fingerprint & is_static_bit;
 123   }
 124   static BasicType return_type(uint64_t fingerprint) {
 125     assert(fingerprint != (uint64_t)CONST64(-1), "invalid fingerprint");
 126     return (BasicType) ((fingerprint >> static_feature_size) & result_feature_mask);
 127   }
 128 };
 129 
 130 
 131 // Specialized SignatureIterators: Used to compute signature specific values.
 132 
 133 class SignatureTypeNames : public SignatureIterator {
 134  protected:
 135   virtual void type_name(const char* name)   = 0;
 136 
 137   void do_bool()                       { type_name("jboolean"); }
 138   void do_char()                       { type_name("jchar"   ); }
 139   void do_float()                      { type_name("jfloat"  ); }
 140   void do_double()                     { type_name("jdouble" ); }
 141   void do_byte()                       { type_name("jbyte"   ); }
 142   void do_short()                      { type_name("jshort"  ); }
 143   void do_int()                        { type_name("jint"    ); }
 144   void do_long()                       { type_name("jlong"   ); }
 145   void do_void()                       { type_name("void"    ); }
 146   void do_object(int begin, int end)   { type_name("jobject" ); }
 147   void do_valuetype(int begin, int end) { type_name("jobject"); }
 148   void do_array (int begin, int end)   { type_name("jobject" ); }
 149 
 150  public:
 151   SignatureTypeNames(Symbol* signature) : SignatureIterator(signature) {}
 152 };
 153 
 154 
 155 class SignatureInfo: public SignatureIterator {
 156  protected:
 157   bool      _has_iterated;             // need this because iterate cannot be called in constructor (set is virtual!)
 158   bool      _has_iterated_return;
 159   int       _size;
 160 
 161   void lazy_iterate_parameters()       { if (!_has_iterated) { iterate_parameters(); _has_iterated = true; } }
 162   void lazy_iterate_return()           { if (!_has_iterated_return) { iterate_returntype(); _has_iterated_return = true; } }
 163 
 164   virtual void set(int size, BasicType type) = 0;
 165 
 166   void do_bool  ()                     { set(T_BOOLEAN_size, T_BOOLEAN); }
 167   void do_char  ()                     { set(T_CHAR_size   , T_CHAR   ); }
 168   void do_float ()                     { set(T_FLOAT_size  , T_FLOAT  ); }
 169   void do_double()                     { set(T_DOUBLE_size , T_DOUBLE ); }
 170   void do_byte  ()                     { set(T_BYTE_size   , T_BYTE   ); }
 171   void do_short ()                     { set(T_SHORT_size  , T_SHORT  ); }
 172   void do_int   ()                     { set(T_INT_size    , T_INT    ); }
 173   void do_long  ()                     { set(T_LONG_size   , T_LONG   ); }
 174   void do_void  ()                     { set(T_VOID_size   , T_VOID   ); }
 175   void do_object(int begin, int end)   { set(T_OBJECT_size , T_OBJECT ); }
 176   void do_valuetype(int begin, int end) { set(T_VALUETYPE_size, T_VALUETYPE ); }
 177   void do_array (int begin, int end)   { set(T_ARRAY_size  , T_ARRAY  ); }
 178 
 179  public:
 180   SignatureInfo(Symbol* signature) : SignatureIterator(signature) {
 181     _has_iterated = _has_iterated_return = false;
 182     _size         = 0;
 183     _return_type  = T_ILLEGAL;
 184   }
 185 
 186 };
 187 
 188 
 189 // Specialized SignatureIterator: Used to compute the argument size.
 190 
 191 class ArgumentSizeComputer: public SignatureInfo {
 192  private:
 193   void set(int size, BasicType type)   { _size += size; }
 194  public:
 195   ArgumentSizeComputer(Symbol* signature) : SignatureInfo(signature) {}
 196 


 223 // Fingerprinter computes a unique ID for a given method. The ID
 224 // is a bitvector characterizing the methods signature (incl. the receiver).
 225 class Fingerprinter: public SignatureIterator {
 226  private:
 227   uint64_t _fingerprint;
 228   int _shift_count;
 229   methodHandle mh;
 230 
 231  public:
 232 
 233   void do_bool()    { _fingerprint |= (((uint64_t)bool_parm) << _shift_count); _shift_count += parameter_feature_size; }
 234   void do_char()    { _fingerprint |= (((uint64_t)char_parm) << _shift_count); _shift_count += parameter_feature_size; }
 235   void do_byte()    { _fingerprint |= (((uint64_t)byte_parm) << _shift_count); _shift_count += parameter_feature_size; }
 236   void do_short()   { _fingerprint |= (((uint64_t)short_parm) << _shift_count); _shift_count += parameter_feature_size; }
 237   void do_int()     { _fingerprint |= (((uint64_t)int_parm) << _shift_count); _shift_count += parameter_feature_size; }
 238   void do_long()    { _fingerprint |= (((uint64_t)long_parm) << _shift_count); _shift_count += parameter_feature_size; }
 239   void do_float()   { _fingerprint |= (((uint64_t)float_parm) << _shift_count); _shift_count += parameter_feature_size; }
 240   void do_double()  { _fingerprint |= (((uint64_t)double_parm) << _shift_count); _shift_count += parameter_feature_size; }
 241 
 242   void do_object(int begin, int end)  { _fingerprint |= (((uint64_t)obj_parm) << _shift_count); _shift_count += parameter_feature_size; }
 243   void do_valuetype(int begin, int end)  { _fingerprint |= (((uint64_t)obj_parm) << _shift_count); _shift_count += parameter_feature_size; }
 244   void do_array (int begin, int end)  { _fingerprint |= (((uint64_t)obj_parm) << _shift_count); _shift_count += parameter_feature_size; }
 245 
 246   void do_void()    { ShouldNotReachHere(); }
 247 
 248   Fingerprinter(const methodHandle& method) : SignatureIterator(method->signature()) {
 249     mh = method;
 250     _fingerprint = 0;
 251   }
 252 
 253   uint64_t fingerprint() {
 254     // See if we fingerprinted this method already
 255     if (mh->constMethod()->fingerprint() != CONST64(0)) {
 256       return mh->constMethod()->fingerprint();
 257     }
 258 
 259     if (mh->size_of_parameters() > max_size_of_parameters ) {
 260       _fingerprint = (uint64_t)CONST64(-1);
 261       mh->constMethod()->set_fingerprint(_fingerprint);
 262       return _fingerprint;
 263     }


 289 
 290   void do_bool  ()                     { pass_int();    _jni_offset++; _offset++;       }
 291   void do_char  ()                     { pass_int();    _jni_offset++; _offset++;       }
 292   void do_float ()                     { pass_float();  _jni_offset++; _offset++;       }
 293 #ifdef _LP64
 294   void do_double()                     { pass_double(); _jni_offset++; _offset += 2;    }
 295 #else
 296   void do_double()                     { pass_double(); _jni_offset += 2; _offset += 2; }
 297 #endif
 298   void do_byte  ()                     { pass_int();    _jni_offset++; _offset++;       }
 299   void do_short ()                     { pass_int();    _jni_offset++; _offset++;       }
 300   void do_int   ()                     { pass_int();    _jni_offset++; _offset++;       }
 301 #ifdef _LP64
 302   void do_long  ()                     { pass_long();   _jni_offset++; _offset += 2;    }
 303 #else
 304   void do_long  ()                     { pass_long();   _jni_offset += 2; _offset += 2; }
 305 #endif
 306   void do_void  ()                     { ShouldNotReachHere();                               }
 307   void do_object(int begin, int end)   { pass_object(); _jni_offset++; _offset++;        }
 308   void do_array (int begin, int end)   { pass_object(); _jni_offset++; _offset++;        }
 309   void do_valuetype(int begin, int end){ pass_valuetype();  _jni_offset++; _offset++;        }
 310 
 311  public:
 312   methodHandle method() const          { return _method; }
 313   int          offset() const          { return _offset; }
 314   int      jni_offset() const          { return _jni_offset + _prepended; }
 315 //  int     java_offset() const          { return method()->size_of_parameters() - _offset - 1; }
 316   bool      is_static() const          { return method()->is_static(); }
 317   virtual void pass_int()              = 0;
 318   virtual void pass_long()             = 0;
 319   virtual void pass_object()           = 0;
 320   virtual void pass_valuetype()        = 0;
 321   virtual void pass_float()            = 0;
 322 #ifdef _LP64
 323   virtual void pass_double()           = 0;
 324 #else
 325   virtual void pass_double()           { pass_long(); }  // may be same as long
 326 #endif
 327 
 328   NativeSignatureIterator(const methodHandle& method) : SignatureIterator(method->signature()) {
 329     _method = method;
 330     _offset = 0;
 331     _jni_offset = 0;
 332 
 333     const int JNIEnv_words = 1;
 334     const int mirror_words = 1;
 335     _prepended = !is_static() ? JNIEnv_words : JNIEnv_words + mirror_words;
 336   }
 337 
 338   // iterate() calles the 2 virtual methods according to the following invocation syntax:
 339   //
 340   // {pass_int | pass_long | pass_object}


 416   int       raw_length() { return _end - _begin; }
 417 
 418   // return same as_symbol except allocation of new symbols is avoided.
 419   Symbol* as_symbol_or_null();
 420 
 421   // count the number of references in the signature
 422   int reference_parameter_count();
 423 };
 424 
 425 class SignatureVerifier : public StackObj {
 426   public:
 427     // Returns true if the symbol is valid method or type signature
 428     static bool is_valid_signature(Symbol* sig);
 429 
 430     static bool is_valid_method_signature(Symbol* sig);
 431     static bool is_valid_type_signature(Symbol* sig);
 432   private:
 433 
 434     static ssize_t is_valid_type(const char*, ssize_t);
 435     static bool invalid_name_char(char);
 436 };
 437 
 438 class SigEntryFilter;
 439 typedef GrowableArrayFilterIterator<SigEntry, SigEntryFilter> ExtendedSignature;
 440 
 441 // Used for adapter generation. One SigEntry is used per element of
 442 // the signature of the method. Value type arguments are treated
 443 // specially. See comment for ValueKlass::collect_fields().
 444 class SigEntry {
 445  public:
 446   BasicType _bt;
 447   int _offset;
 448 
 449   enum { ReservedOffset = -2 }; // Special offset to mark the reserved entry
 450 
 451   SigEntry()
 452     : _bt(T_ILLEGAL), _offset(-1) {
 453   }
 454   SigEntry(BasicType bt, int offset)
 455     : _bt(bt), _offset(offset) {}
 456 
 457   SigEntry(BasicType bt)
 458     : _bt(bt), _offset(-1) {}
 459 
 460   static int compare(SigEntry* e1, SigEntry* e2) {
 461     if (e1->_offset != e2->_offset) {
 462       return e1->_offset - e2->_offset;
 463     }
 464     assert((e1->_bt == T_LONG && (e2->_bt == T_LONG || e2->_bt == T_VOID)) ||
 465            (e1->_bt == T_DOUBLE && (e2->_bt == T_DOUBLE || e2->_bt == T_VOID)) ||
 466            e1->_bt == T_VALUETYPE || e2->_bt == T_VALUETYPE || e1->_bt == T_VOID || e2->_bt == T_VOID, "bad bt");
 467     if (e1->_bt == e2->_bt) {
 468       assert(e1->_bt == T_VALUETYPE || e1->_bt == T_VOID, "only ones with duplicate offsets");
 469       return 0;
 470     }
 471     if (e1->_bt == T_VOID ||
 472         e2->_bt == T_VALUETYPE) {
 473       return 1;
 474     }
 475     if (e1->_bt == T_VALUETYPE ||
 476         e2->_bt == T_VOID) {
 477       return -1;
 478     }
 479     ShouldNotReachHere();
 480     return 0;
 481   }
 482   static void add_entry(GrowableArray<SigEntry>* sig, BasicType bt, int offset = -1);
 483   static void insert_reserved_entry(GrowableArray<SigEntry>* sig, int i, BasicType bt);
 484   static bool is_reserved_entry(const GrowableArray<SigEntry>* sig, int i);
 485   static bool skip_value_delimiters(const GrowableArray<SigEntry>* sig, int i);
 486   static int fill_sig_bt(const GrowableArray<SigEntry>* sig, BasicType* sig_bt);
 487   static TempNewSymbol create_symbol(const GrowableArray<SigEntry>* sig);
 488 
 489   static bool next_is_reserved(ExtendedSignature& sig, BasicType& bt, bool can_be_void = false);
 490 };
 491 
 492 class SigEntryFilter {
 493 public:
 494   bool operator()(const SigEntry& entry) { return entry._bt != T_VALUETYPE && entry._bt != T_VOID; }
 495 };
 496 
 497 #endif // SHARE_RUNTIME_SIGNATURE_HPP
< prev index next >