< 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_VM_RUNTIME_SIGNATURE_HPP
  26 #define SHARE_VM_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 {


 421   public:
 422     // Returns true if the symbol is valid method or type signature
 423     static bool is_valid_signature(Symbol* sig);
 424 
 425     static bool is_valid_method_signature(Symbol* sig);
 426     static bool is_valid_type_signature(Symbol* sig);
 427   private:
 428 
 429     static ssize_t is_valid_type(const char*, ssize_t);
 430     static bool invalid_name_char(char);
 431 };
 432 
 433 // Used for adapter generation. One SigEntry is used per element of
 434 // the signature of the method. Value type arguments are treated
 435 // specially. See comment for ValueKlass::collect_fields().
 436 class SigEntry {
 437  public:
 438   BasicType _bt;
 439   int _offset;
 440     


 441   SigEntry()
 442     : _bt(T_ILLEGAL), _offset(-1) {
 443   }
 444   SigEntry(BasicType bt, int offset)
 445     : _bt(bt), _offset(offset) {}
 446 
 447   SigEntry(BasicType bt)
 448     : _bt(bt), _offset(-1) {}
 449   
 450   static int compare(SigEntry* e1, SigEntry* e2) {
 451     if (e1->_offset != e2->_offset) {
 452       return e1->_offset - e2->_offset;
 453     }
 454     assert((e1->_bt == T_LONG && (e2->_bt == T_LONG || e2->_bt == T_VOID)) ||
 455            (e1->_bt == T_DOUBLE && (e2->_bt == T_DOUBLE || e2->_bt == T_VOID)) ||
 456            e1->_bt == T_VALUETYPE || e2->_bt == T_VALUETYPE || e1->_bt == T_VOID || e2->_bt == T_VOID, "bad bt");
 457     if (e1->_bt == e2->_bt) {
 458       assert(e1->_bt == T_VALUETYPE || e1->_bt == T_VOID, "only ones with duplicate offsets");
 459       return 0;
 460     }
 461     if (e1->_bt == T_VOID ||
 462         e2->_bt == T_VALUETYPE) {
 463       return 1;
 464     }
 465     if (e1->_bt == T_VALUETYPE ||
 466         e2->_bt == T_VOID) {
 467       return -1;
 468     }
 469     ShouldNotReachHere();
 470     return 0;
 471   }
 472   static int count_fields(const GrowableArray<SigEntry>& sig_extended);
 473   static void fill_sig_bt(const GrowableArray<SigEntry>& sig_extended, BasicType* sig_bt_cc, int total_args_passed_cc, bool skip_vt);




 474 };
 475 
 476 #endif // SHARE_VM_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_VM_RUNTIME_SIGNATURE_HPP
  26 #define SHARE_VM_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 {


 422   public:
 423     // Returns true if the symbol is valid method or type signature
 424     static bool is_valid_signature(Symbol* sig);
 425 
 426     static bool is_valid_method_signature(Symbol* sig);
 427     static bool is_valid_type_signature(Symbol* sig);
 428   private:
 429 
 430     static ssize_t is_valid_type(const char*, ssize_t);
 431     static bool invalid_name_char(char);
 432 };
 433 
 434 // Used for adapter generation. One SigEntry is used per element of
 435 // the signature of the method. Value type arguments are treated
 436 // specially. See comment for ValueKlass::collect_fields().
 437 class SigEntry {
 438  public:
 439   BasicType _bt;
 440   int _offset;
 441 
 442   enum { ReservedOffset = -2 }; // Special offset to mark the reserved entry
 443 
 444   SigEntry()
 445     : _bt(T_ILLEGAL), _offset(-1) {
 446   }
 447   SigEntry(BasicType bt, int offset)
 448     : _bt(bt), _offset(offset) {}
 449 
 450   SigEntry(BasicType bt)
 451     : _bt(bt), _offset(-1) {}
 452 
 453   static int compare(SigEntry* e1, SigEntry* e2) {
 454     if (e1->_offset != e2->_offset) {
 455       return e1->_offset - e2->_offset;
 456     }
 457     assert((e1->_bt == T_LONG && (e2->_bt == T_LONG || e2->_bt == T_VOID)) ||
 458            (e1->_bt == T_DOUBLE && (e2->_bt == T_DOUBLE || e2->_bt == T_VOID)) ||
 459            e1->_bt == T_VALUETYPE || e2->_bt == T_VALUETYPE || e1->_bt == T_VOID || e2->_bt == T_VOID, "bad bt");
 460     if (e1->_bt == e2->_bt) {
 461       assert(e1->_bt == T_VALUETYPE || e1->_bt == T_VOID, "only ones with duplicate offsets");
 462       return 0;
 463     }
 464     if (e1->_bt == T_VOID ||
 465         e2->_bt == T_VALUETYPE) {
 466       return 1;
 467     }
 468     if (e1->_bt == T_VALUETYPE ||
 469         e2->_bt == T_VOID) {
 470       return -1;
 471     }
 472     ShouldNotReachHere();
 473     return 0;
 474   }
 475   static void add_entry(GrowableArray<SigEntry>* sig, BasicType bt, int offset = -1);
 476   static void insert_reserved_entry(GrowableArray<SigEntry>* sig, int i, BasicType bt);
 477   static bool is_reserved_entry(const GrowableArray<SigEntry>* sig, int i);
 478   static bool skip_value_delimiters(const GrowableArray<SigEntry>* sig, int i);
 479   static int fill_sig_bt(const GrowableArray<SigEntry>* sig, BasicType* sig_bt);
 480   static TempNewSymbol create_symbol(const GrowableArray<SigEntry>* sig);
 481 };
 482 
 483 #endif // SHARE_VM_RUNTIME_SIGNATURE_HPP
< prev index next >