< prev index next >

src/hotspot/share/runtime/signature.hpp

Print this page
rev 54022 : 8220366: Optimize Symbol handling in ClassVerifier and SignatureStream
Reviewed-by: TBD


  73       char_parm            = 3,
  74       short_parm           = 4,
  75       int_parm             = 5,
  76       long_parm            = 6,
  77       float_parm           = 7,
  78       double_parm          = 8,
  79       obj_parm             = 9,
  80       done_parm            = 10,  // marker for end of parameters
  81 
  82     // max parameters is wordsize minus
  83     //    The sign bit, termination field, the result and static bit fields
  84     max_size_of_parameters = (BitsPerLong-1 -
  85                               result_feature_size - parameter_feature_size -
  86                               static_feature_size) / parameter_feature_size
  87   };
  88 
  89   // Constructors
  90   SignatureIterator(Symbol* signature);
  91 
  92   // Iteration
  93   void dispatch_field();               // dispatches once for field signatures
  94   void iterate_parameters();           // iterates over parameters only
  95   void iterate_parameters( uint64_t fingerprint );
  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 


 346 
 347     if (!is_static()) {
 348       // handle receiver (not handled by iterate because not in signature)
 349       pass_object(); _jni_offset++; _offset++;
 350     }
 351 
 352     SignatureIterator::iterate_parameters( fingerprint );
 353   }
 354 };
 355 
 356 
 357 // Handy stream for iterating over signature
 358 
 359 class SignatureStream : public StackObj {
 360  private:
 361   Symbol*      _signature;
 362   int          _begin;
 363   int          _end;
 364   BasicType    _type;
 365   bool         _at_return_type;
 366   GrowableArray<Symbol*>* _names;  // symbols created while parsing signature
 367 
 368  public:
 369   bool at_return_type() const                    { return _at_return_type; }
 370   bool is_done() const;
 371   void next_non_primitive(int t);
 372   void next() {
 373     Symbol* sig = _signature;
 374     int len = sig->utf8_length();
 375     if (_end >= len) {
 376       _end = len + 1;
 377       return;
 378     }
 379 
 380     _begin = _end;
 381     int t = sig->char_at(_begin);
 382     switch (t) {
 383       case 'B': _type = T_BYTE;    break;
 384       case 'C': _type = T_CHAR;    break;
 385       case 'D': _type = T_DOUBLE;  break;
 386       case 'F': _type = T_FLOAT;   break;
 387       case 'I': _type = T_INT;     break;
 388       case 'J': _type = T_LONG;    break;
 389       case 'S': _type = T_SHORT;   break;
 390       case 'Z': _type = T_BOOLEAN; break;
 391       case 'V': _type = T_VOID;    break;
 392       default : next_non_primitive(t);
 393                 return;
 394     }
 395     _end++;
 396   }
 397 
 398   SignatureStream(Symbol* signature, bool is_method = true);
 399   ~SignatureStream();
 400 
 401   bool is_object() const;                        // True if this argument is an object
 402   bool is_array() const;                         // True if this argument is an array
 403   BasicType type() const                         { return _type; }
 404   Symbol* as_symbol(TRAPS);
 405   enum FailureMode { ReturnNull, CNFException, NCDFError };
 406   Klass* as_klass(Handle class_loader, Handle protection_domain, FailureMode failure_mode, TRAPS);
 407   oop as_java_mirror(Handle class_loader, Handle protection_domain, FailureMode failure_mode, TRAPS);
 408   const u1* raw_bytes()  { return _signature->bytes() + _begin; }
 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


  73       char_parm            = 3,
  74       short_parm           = 4,
  75       int_parm             = 5,
  76       long_parm            = 6,
  77       float_parm           = 7,
  78       double_parm          = 8,
  79       obj_parm             = 9,
  80       done_parm            = 10,  // marker for end of parameters
  81 
  82     // max parameters is wordsize minus
  83     //    The sign bit, termination field, the result and static bit fields
  84     max_size_of_parameters = (BitsPerLong-1 -
  85                               result_feature_size - parameter_feature_size -
  86                               static_feature_size) / parameter_feature_size
  87   };
  88 
  89   // Constructors
  90   SignatureIterator(Symbol* signature);
  91 
  92   // Iteration

  93   void iterate_parameters();           // iterates over parameters only
  94   void iterate_parameters( uint64_t fingerprint );
  95   void iterate_returntype();           // iterates over returntype only
  96   void iterate();                      // iterates over whole signature
  97   // Returns the word index of the current parameter;
  98   int  parameter_index() const         { return _parameter_index; }
  99   bool is_return_type() const          { return parameter_index() < 0; }
 100   BasicType get_ret_type() const       { return _return_type; }
 101 
 102   // Basic types
 103   virtual void do_bool  ()             = 0;
 104   virtual void do_char  ()             = 0;
 105   virtual void do_float ()             = 0;
 106   virtual void do_double()             = 0;
 107   virtual void do_byte  ()             = 0;
 108   virtual void do_short ()             = 0;
 109   virtual void do_int   ()             = 0;
 110   virtual void do_long  ()             = 0;
 111   virtual void do_void  ()             = 0;
 112 


 345 
 346     if (!is_static()) {
 347       // handle receiver (not handled by iterate because not in signature)
 348       pass_object(); _jni_offset++; _offset++;
 349     }
 350 
 351     SignatureIterator::iterate_parameters( fingerprint );
 352   }
 353 };
 354 
 355 
 356 // Handy stream for iterating over signature
 357 
 358 class SignatureStream : public StackObj {
 359  private:
 360   Symbol*      _signature;
 361   int          _begin;
 362   int          _end;
 363   BasicType    _type;
 364   bool         _at_return_type;
 365   Symbol*      _previous_name;     // cache the previously looked up symbol to avoid lookups
 366   GrowableArray<Symbol*>* _names;  // symbols created while parsing that need to be dereferenced
 367  public:
 368   bool at_return_type() const                    { return _at_return_type; }
 369   bool is_done() const;
 370   void next_non_primitive(int t);
 371   void next() {
 372     Symbol* sig = _signature;
 373     int len = sig->utf8_length();
 374     if (_end >= len) {
 375       _end = len + 1;
 376       return;
 377     }
 378 
 379     _begin = _end;
 380     int t = sig->char_at(_begin);
 381     switch (t) {
 382       case 'B': _type = T_BYTE;    break;
 383       case 'C': _type = T_CHAR;    break;
 384       case 'D': _type = T_DOUBLE;  break;
 385       case 'F': _type = T_FLOAT;   break;
 386       case 'I': _type = T_INT;     break;
 387       case 'J': _type = T_LONG;    break;
 388       case 'S': _type = T_SHORT;   break;
 389       case 'Z': _type = T_BOOLEAN; break;
 390       case 'V': _type = T_VOID;    break;
 391       default : next_non_primitive(t);
 392                 return;
 393     }
 394     _end++;
 395   }
 396 
 397   SignatureStream(Symbol* signature, bool is_method = true);
 398   ~SignatureStream();
 399 
 400   bool is_object() const;                        // True if this argument is an object
 401   bool is_array() const;                         // True if this argument is an array
 402   BasicType type() const                         { return _type; }
 403   Symbol* as_symbol(TRAPS);
 404   enum FailureMode { ReturnNull, NCDFError };
 405   Klass* as_klass(Handle class_loader, Handle protection_domain, FailureMode failure_mode, TRAPS);
 406   oop as_java_mirror(Handle class_loader, Handle protection_domain, FailureMode failure_mode, TRAPS);
 407   const u1* raw_bytes()  { return _signature->bytes() + _begin; }
 408   int       raw_length() { return _end - _begin; }
 409 
 410   // return same as_symbol except allocation of new symbols is avoided.
 411   Symbol* as_symbol_or_null();
 412 
 413   // count the number of references in the signature
 414   int reference_parameter_count();
 415 };
 416 
 417 class SignatureVerifier : public StackObj {
 418   public:
 419     // Returns true if the symbol is valid method or type signature
 420     static bool is_valid_signature(Symbol* sig);
 421 
 422     static bool is_valid_method_signature(Symbol* sig);
 423     static bool is_valid_type_signature(Symbol* sig);
 424   private:

 425     static ssize_t is_valid_type(const char*, ssize_t);

 426 };
 427 
 428 #endif // SHARE_RUNTIME_SIGNATURE_HPP
< prev index next >