src/hotspot/share/runtime/signature.hpp
author lfoltan
Mon, 21 Oct 2019 13:13:16 -0400
changeset 58722 cba8afa5cfed
parent 54847 59ea39bb2809
permissions -rw-r--r--
8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently Summary: Increase the use of type signature constants instead of hard coded characters within the JVM. Reviewed-by: coleenp, dholmes, fparain Contributed-by: lois.foltan@oracle.com, john.r.rose@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 51997
diff changeset
     2
 * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5421
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5421
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5421
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 51997
diff changeset
    25
#ifndef SHARE_RUNTIME_SIGNATURE_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 51997
diff changeset
    26
#define SHARE_RUNTIME_SIGNATURE_HPP
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    28
#include "memory/allocation.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
    29
#include "oops/method.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    30
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
// SignatureIterators iterate over a Java signature (or parts of it).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
// (Syntax according to: "The Java Virtual Machine Specification" by
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
// Tim Lindholm & Frank Yellin; section 4.3 Descriptors; p. 89ff.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
// Example: Iterating over ([Lfoo;D)I using
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
//                         0123456789
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
// iterate_parameters() calls: do_array(2, 7); do_double();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
// iterate_returntype() calls:                              do_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
// iterate()            calls: do_array(2, 7); do_double(); do_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
// is_return_type()        is: false         ; false      ; true
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
// NOTE: The new optimizer has an alternate, for-loop based signature
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
// iterator implemented in opto/type.cpp, TypeTuple::make().
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
class SignatureIterator: public ResourceObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
 protected:
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    49
  Symbol*      _signature;             // the signature to iterate over
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  int          _index;                 // the current character index (only valid during iteration)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  int          _parameter_index;       // the current parameter index (0 outside iteration phase)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  BasicType    _return_type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  void expect(char c);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  int  parse_type();                   // returns the parameter size in words (0 for void)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  void check_signature_end();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  // Definitions used in generating and iterating the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  // bit field form of the signature generated by the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  // Fingerprinter.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  enum {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
    static_feature_size    = 1,
31382
8d526a6991e1 8087133: Improve sharing of native wrappers in SignatureHandlerLibrary
bdelsart
parents: 27471
diff changeset
    64
    is_static_bit          = 1,
8d526a6991e1 8087133: Improve sharing of native wrappers in SignatureHandlerLibrary
bdelsart
parents: 27471
diff changeset
    65
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
    result_feature_size    = 4,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
    result_feature_mask    = 0xF,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
    parameter_feature_size = 4,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
    parameter_feature_mask = 0xF,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
      bool_parm            = 1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
      byte_parm            = 2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
      char_parm            = 3,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
      short_parm           = 4,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
      int_parm             = 5,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
      long_parm            = 6,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
      float_parm           = 7,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
      double_parm          = 8,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
      obj_parm             = 9,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
      done_parm            = 10,  // marker for end of parameters
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
    // max parameters is wordsize minus
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
    //    The sign bit, termination field, the result and static bit fields
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
    max_size_of_parameters = (BitsPerLong-1 -
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
                              result_feature_size - parameter_feature_size -
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
                              static_feature_size) / parameter_feature_size
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  // Constructors
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    90
  SignatureIterator(Symbol* signature);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  // Iteration
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  void iterate_parameters();           // iterates over parameters only
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  void iterate_parameters( uint64_t fingerprint );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  void iterate_returntype();           // iterates over returntype only
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  void iterate();                      // iterates over whole signature
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  // Returns the word index of the current parameter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  int  parameter_index() const         { return _parameter_index; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  bool is_return_type() const          { return parameter_index() < 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  BasicType get_ret_type() const       { return _return_type; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  // Basic types
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  virtual void do_bool  ()             = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  virtual void do_char  ()             = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  virtual void do_float ()             = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  virtual void do_double()             = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  virtual void do_byte  ()             = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  virtual void do_short ()             = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  virtual void do_int   ()             = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  virtual void do_long  ()             = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  virtual void do_void  ()             = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  // Object types (begin indexes the first character of the entry, end indexes the first character after the entry)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  virtual void do_object(int begin, int end) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  virtual void do_array (int begin, int end) = 0;
31382
8d526a6991e1 8087133: Improve sharing of native wrappers in SignatureHandlerLibrary
bdelsart
parents: 27471
diff changeset
   116
8d526a6991e1 8087133: Improve sharing of native wrappers in SignatureHandlerLibrary
bdelsart
parents: 27471
diff changeset
   117
  static bool is_static(uint64_t fingerprint) {
8d526a6991e1 8087133: Improve sharing of native wrappers in SignatureHandlerLibrary
bdelsart
parents: 27471
diff changeset
   118
    assert(fingerprint != (uint64_t)CONST64(-1), "invalid fingerprint");
8d526a6991e1 8087133: Improve sharing of native wrappers in SignatureHandlerLibrary
bdelsart
parents: 27471
diff changeset
   119
    return fingerprint & is_static_bit;
8d526a6991e1 8087133: Improve sharing of native wrappers in SignatureHandlerLibrary
bdelsart
parents: 27471
diff changeset
   120
  }
8d526a6991e1 8087133: Improve sharing of native wrappers in SignatureHandlerLibrary
bdelsart
parents: 27471
diff changeset
   121
  static BasicType return_type(uint64_t fingerprint) {
8d526a6991e1 8087133: Improve sharing of native wrappers in SignatureHandlerLibrary
bdelsart
parents: 27471
diff changeset
   122
    assert(fingerprint != (uint64_t)CONST64(-1), "invalid fingerprint");
8d526a6991e1 8087133: Improve sharing of native wrappers in SignatureHandlerLibrary
bdelsart
parents: 27471
diff changeset
   123
    return (BasicType) ((fingerprint >> static_feature_size) & result_feature_mask);
8d526a6991e1 8087133: Improve sharing of native wrappers in SignatureHandlerLibrary
bdelsart
parents: 27471
diff changeset
   124
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
// Specialized SignatureIterators: Used to compute signature specific values.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
class SignatureTypeNames : public SignatureIterator {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  virtual void type_name(const char* name)   = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  void do_bool()                       { type_name("jboolean"); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  void do_char()                       { type_name("jchar"   ); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  void do_float()                      { type_name("jfloat"  ); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  void do_double()                     { type_name("jdouble" ); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  void do_byte()                       { type_name("jbyte"   ); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  void do_short()                      { type_name("jshort"  ); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  void do_int()                        { type_name("jint"    ); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  void do_long()                       { type_name("jlong"   ); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  void do_void()                       { type_name("void"    ); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  void do_object(int begin, int end)   { type_name("jobject" ); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  void do_array (int begin, int end)   { type_name("jobject" ); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
 public:
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   147
  SignatureTypeNames(Symbol* signature) : SignatureIterator(signature) {}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
class SignatureInfo: public SignatureIterator {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  bool      _has_iterated;             // need this because iterate cannot be called in constructor (set is virtual!)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  bool      _has_iterated_return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  int       _size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  void lazy_iterate_parameters()       { if (!_has_iterated) { iterate_parameters(); _has_iterated = true; } }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  void lazy_iterate_return()           { if (!_has_iterated_return) { iterate_returntype(); _has_iterated_return = true; } }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  virtual void set(int size, BasicType type) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  void do_bool  ()                     { set(T_BOOLEAN_size, T_BOOLEAN); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  void do_char  ()                     { set(T_CHAR_size   , T_CHAR   ); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  void do_float ()                     { set(T_FLOAT_size  , T_FLOAT  ); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  void do_double()                     { set(T_DOUBLE_size , T_DOUBLE ); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  void do_byte  ()                     { set(T_BYTE_size   , T_BYTE   ); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  void do_short ()                     { set(T_SHORT_size  , T_SHORT  ); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  void do_int   ()                     { set(T_INT_size    , T_INT    ); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  void do_long  ()                     { set(T_LONG_size   , T_LONG   ); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  void do_void  ()                     { set(T_VOID_size   , T_VOID   ); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  void do_object(int begin, int end)   { set(T_OBJECT_size , T_OBJECT ); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  void do_array (int begin, int end)   { set(T_ARRAY_size  , T_ARRAY  ); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
 public:
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   175
  SignatureInfo(Symbol* signature) : SignatureIterator(signature) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
    _has_iterated = _has_iterated_return = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
    _size         = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
    _return_type  = T_ILLEGAL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
// Specialized SignatureIterator: Used to compute the argument size.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
class ArgumentSizeComputer: public SignatureInfo {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  void set(int size, BasicType type)   { _size += size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
 public:
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   190
  ArgumentSizeComputer(Symbol* signature) : SignatureInfo(signature) {}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  int       size()                     { lazy_iterate_parameters(); return _size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
class ArgumentCount: public SignatureInfo {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  void set(int size, BasicType type)   { _size ++; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
 public:
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   200
  ArgumentCount(Symbol* signature) : SignatureInfo(signature) {}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  int       size()                     { lazy_iterate_parameters(); return _size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
// Specialized SignatureIterator: Used to compute the result type.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
class ResultTypeFinder: public SignatureInfo {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  void set(int size, BasicType type)   { _return_type = type; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  BasicType type()                     { lazy_iterate_return(); return _return_type; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   214
  ResultTypeFinder(Symbol* signature) : SignatureInfo(signature) {}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
// Fingerprinter computes a unique ID for a given method. The ID
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
// is a bitvector characterizing the methods signature (incl. the receiver).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
class Fingerprinter: public SignatureIterator {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  uint64_t _fingerprint;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
  int _shift_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  methodHandle mh;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
  void do_bool()    { _fingerprint |= (((uint64_t)bool_parm) << _shift_count); _shift_count += parameter_feature_size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
  void do_char()    { _fingerprint |= (((uint64_t)char_parm) << _shift_count); _shift_count += parameter_feature_size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
  void do_byte()    { _fingerprint |= (((uint64_t)byte_parm) << _shift_count); _shift_count += parameter_feature_size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
  void do_short()   { _fingerprint |= (((uint64_t)short_parm) << _shift_count); _shift_count += parameter_feature_size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
  void do_int()     { _fingerprint |= (((uint64_t)int_parm) << _shift_count); _shift_count += parameter_feature_size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  void do_long()    { _fingerprint |= (((uint64_t)long_parm) << _shift_count); _shift_count += parameter_feature_size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  void do_float()   { _fingerprint |= (((uint64_t)float_parm) << _shift_count); _shift_count += parameter_feature_size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  void do_double()  { _fingerprint |= (((uint64_t)double_parm) << _shift_count); _shift_count += parameter_feature_size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  void do_object(int begin, int end)  { _fingerprint |= (((uint64_t)obj_parm) << _shift_count); _shift_count += parameter_feature_size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  void do_array (int begin, int end)  { _fingerprint |= (((uint64_t)obj_parm) << _shift_count); _shift_count += parameter_feature_size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  void do_void()    { ShouldNotReachHere(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
33593
60764a78fa5c 8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents: 31382
diff changeset
   242
  Fingerprinter(const methodHandle& method) : SignatureIterator(method->signature()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
    mh = method;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
    _fingerprint = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  uint64_t fingerprint() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
    // See if we fingerprinted this method already
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
    if (mh->constMethod()->fingerprint() != CONST64(0)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
      return mh->constMethod()->fingerprint();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
    if (mh->size_of_parameters() > max_size_of_parameters ) {
27471
6e56277909f1 8062370: Various minor code improvements
goetz
parents: 22234
diff changeset
   254
      _fingerprint = (uint64_t)CONST64(-1);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
      mh->constMethod()->set_fingerprint(_fingerprint);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
      return _fingerprint;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
    assert( (int)mh->result_type() <= (int)result_feature_mask, "bad result type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
    _fingerprint = mh->result_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
    _fingerprint <<= static_feature_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
    if (mh->is_static())  _fingerprint |= 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
    _shift_count = result_feature_size + static_feature_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
    iterate_parameters();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
    _fingerprint |= ((uint64_t)done_parm) << _shift_count;// mark end of sig
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
    mh->constMethod()->set_fingerprint(_fingerprint);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
    return _fingerprint;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
// Specialized SignatureIterator: Used for native call purposes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
class NativeSignatureIterator: public SignatureIterator {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
  methodHandle _method;
2131
98f9cef66a34 6810672: Comment typos
twisti
parents: 1
diff changeset
   277
// We need separate JNI and Java offset values because in 64 bit mode,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
// the argument offsets are not in sync with the Java stack.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
// For example a long takes up 1 "C" stack entry but 2 Java stack entries.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
  int          _offset;                // The java stack offset
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
  int          _prepended;             // number of prepended JNI parameters (1 JNIEnv, plus 1 mirror if static)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
  int          _jni_offset;            // the current parameter offset, starting with 0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
  void do_bool  ()                     { pass_int();    _jni_offset++; _offset++;       }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
  void do_char  ()                     { pass_int();    _jni_offset++; _offset++;       }
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents: 2131
diff changeset
   286
  void do_float ()                     { pass_float();  _jni_offset++; _offset++;       }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
  void do_double()                     { pass_double(); _jni_offset++; _offset += 2;    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
  void do_double()                     { pass_double(); _jni_offset += 2; _offset += 2; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
  void do_byte  ()                     { pass_int();    _jni_offset++; _offset++;       }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
  void do_short ()                     { pass_int();    _jni_offset++; _offset++;       }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  void do_int   ()                     { pass_int();    _jni_offset++; _offset++;       }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  void do_long  ()                     { pass_long();   _jni_offset++; _offset += 2;    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  void do_long  ()                     { pass_long();   _jni_offset += 2; _offset += 2; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  void do_void  ()                     { ShouldNotReachHere();                               }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
  void do_object(int begin, int end)   { pass_object(); _jni_offset++; _offset++;        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
  void do_array (int begin, int end)   { pass_object(); _jni_offset++; _offset++;        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
  methodHandle method() const          { return _method; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
  int          offset() const          { return _offset; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
  int      jni_offset() const          { return _jni_offset + _prepended; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
//  int     java_offset() const          { return method()->size_of_parameters() - _offset - 1; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
  bool      is_static() const          { return method()->is_static(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
  virtual void pass_int()              = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
  virtual void pass_long()             = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
  virtual void pass_object()           = 0;
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents: 2131
diff changeset
   313
  virtual void pass_float()            = 0;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
  virtual void pass_double()           = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
  virtual void pass_double()           { pass_long(); }  // may be same as long
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
33593
60764a78fa5c 8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents: 31382
diff changeset
   320
  NativeSignatureIterator(const methodHandle& method) : SignatureIterator(method->signature()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
    _method = method;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
    _offset = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
    _jni_offset = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
    const int JNIEnv_words = 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
    const int mirror_words = 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
    _prepended = !is_static() ? JNIEnv_words : JNIEnv_words + mirror_words;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
  // iterate() calles the 2 virtual methods according to the following invocation syntax:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
  // {pass_int | pass_long | pass_object}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
  // Arguments are handled from left to right (receiver first, if any).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
  // The offset() values refer to the Java stack offsets but are 0 based and increasing.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
  // The java_offset() values count down to 0, and refer to the Java TOS.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
  // The jni_offset() values increase from 1 or 2, and refer to C arguments.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
  void iterate() { iterate(Fingerprinter(method()).fingerprint());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
  // Optimized path if we have the bitvector form of signature
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
  void iterate( uint64_t fingerprint ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
    if (!is_static()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
      // handle receiver (not handled by iterate because not in signature)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
      pass_object(); _jni_offset++; _offset++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
    SignatureIterator::iterate_parameters( fingerprint );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
// Handy stream for iterating over signature
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
class SignatureStream : public StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
 private:
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   360
  Symbol*      _signature;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
  int          _begin;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
  int          _end;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
  BasicType    _type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
  bool         _at_return_type;
54133
829bf950287e 8220366: Optimize Symbol handling in ClassVerifier and SignatureStream
redestad
parents: 54124
diff changeset
   365
  Symbol*      _previous_name;     // cache the previously looked up symbol to avoid lookups
829bf950287e 8220366: Optimize Symbol handling in ClassVerifier and SignatureStream
redestad
parents: 54124
diff changeset
   366
  GrowableArray<Symbol*>* _names;  // symbols created while parsing that need to be dereferenced
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
  bool at_return_type() const                    { return _at_return_type; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
  bool is_done() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
  void next_non_primitive(int t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
  void next() {
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   372
    Symbol* sig = _signature;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
    int len = sig->utf8_length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
    if (_end >= len) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
      _end = len + 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
      return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
    _begin = _end;
51997
9ce37fa2e179 8209138: Symbol constructor uses u1 as the element type of its name argument
hseigel
parents: 49354
diff changeset
   380
    int t = sig->char_at(_begin);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
    switch (t) {
58722
cba8afa5cfed 8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents: 54847
diff changeset
   382
      case JVM_SIGNATURE_BYTE:    _type = T_BYTE;    break;
cba8afa5cfed 8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents: 54847
diff changeset
   383
      case JVM_SIGNATURE_CHAR:    _type = T_CHAR;    break;
cba8afa5cfed 8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents: 54847
diff changeset
   384
      case JVM_SIGNATURE_DOUBLE:  _type = T_DOUBLE;  break;
cba8afa5cfed 8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents: 54847
diff changeset
   385
      case JVM_SIGNATURE_FLOAT:   _type = T_FLOAT;   break;
cba8afa5cfed 8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents: 54847
diff changeset
   386
      case JVM_SIGNATURE_INT:     _type = T_INT;     break;
cba8afa5cfed 8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents: 54847
diff changeset
   387
      case JVM_SIGNATURE_LONG:    _type = T_LONG;    break;
cba8afa5cfed 8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents: 54847
diff changeset
   388
      case JVM_SIGNATURE_SHORT:   _type = T_SHORT;   break;
cba8afa5cfed 8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents: 54847
diff changeset
   389
      case JVM_SIGNATURE_BOOLEAN: _type = T_BOOLEAN; break;
cba8afa5cfed 8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents: 54847
diff changeset
   390
      case JVM_SIGNATURE_VOID:    _type = T_VOID;    break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
      default : next_non_primitive(t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
                return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
    _end++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   397
  SignatureStream(Symbol* signature, bool is_method = true);
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   398
  ~SignatureStream();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
  bool is_object() const;                        // True if this argument is an object
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
  bool is_array() const;                         // True if this argument is an array
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
  BasicType type() const                         { return _type; }
54847
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 54133
diff changeset
   403
  Symbol* as_symbol();
54133
829bf950287e 8220366: Optimize Symbol handling in ClassVerifier and SignatureStream
redestad
parents: 54124
diff changeset
   404
  enum FailureMode { ReturnNull, NCDFError };
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   405
  Klass* as_klass(Handle class_loader, Handle protection_domain, FailureMode failure_mode, TRAPS);
5421
e294db54fc0d 6939196: method handle signatures off the boot class path get linkage errors
jrose
parents: 4013
diff changeset
   406
  oop as_java_mirror(Handle class_loader, Handle protection_domain, FailureMode failure_mode, TRAPS);
51997
9ce37fa2e179 8209138: Symbol constructor uses u1 as the element type of its name argument
hseigel
parents: 49354
diff changeset
   407
  const u1* raw_bytes()  { return _signature->bytes() + _begin; }
9ce37fa2e179 8209138: Symbol constructor uses u1 as the element type of its name argument
hseigel
parents: 49354
diff changeset
   408
  int       raw_length() { return _end - _begin; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
  // return same as_symbol except allocation of new symbols is avoided.
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   411
  Symbol* as_symbol_or_null();
20702
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 13728
diff changeset
   412
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 13728
diff changeset
   413
  // count the number of references in the signature
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 13728
diff changeset
   414
  int reference_parameter_count();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
54124
5d48ae032588 8219579: Remove redundant signature parsing from the verifier
hseigel
parents: 53244
diff changeset
   417
#ifdef ASSERT
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
class SignatureVerifier : public StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
  public:
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   420
    static bool is_valid_method_signature(Symbol* sig);
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   421
    static bool is_valid_type_signature(Symbol* sig);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
  private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
    static ssize_t is_valid_type(const char*, ssize_t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
};
54124
5d48ae032588 8219579: Remove redundant signature parsing from the verifier
hseigel
parents: 53244
diff changeset
   425
#endif
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 51997
diff changeset
   426
#endif // SHARE_RUNTIME_SIGNATURE_HPP