src/share/vm/ci/ciType.hpp

changeset 435
a61af66fc99e
child 1907
c18cbe5936b8
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/ci/ciType.hpp	Sat Dec 01 00:00:00 2007 +0000
     1.3 @@ -0,0 +1,108 @@
     1.4 +/*
     1.5 + * Copyright 2000-2001 Sun Microsystems, Inc.  All Rights Reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
    1.24 + * have any questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +// ciType
    1.29 +//
    1.30 +// This class represents either a class (T_OBJECT), array (T_ARRAY),
    1.31 +// or one of the primitive types such as T_INT.
    1.32 +class ciType : public ciObject {
    1.33 +  CI_PACKAGE_ACCESS
    1.34 +  friend class ciKlass;
    1.35 +  friend class ciReturnAddress;
    1.36 +
    1.37 +private:
    1.38 +  BasicType _basic_type;
    1.39 +
    1.40 +  ciType(BasicType t);     // for the primitive types only
    1.41 +  ciType(KlassHandle k);   // for subclasses (reference types)
    1.42 +  ciType(ciKlass* klass);  // for unloaded types
    1.43 +
    1.44 +  const char* type_string() { return "ciType"; }
    1.45 +
    1.46 +  void print_impl(outputStream* st);
    1.47 +
    1.48 +  // Distinguished instances of primitive ciTypes..
    1.49 +  static ciType* _basic_types[T_CONFLICT+1];
    1.50 +
    1.51 +public:
    1.52 +  BasicType basic_type() const              { return _basic_type; }
    1.53 +
    1.54 +  // Returns true iff the types are identical, or if both are klasses
    1.55 +  // and the is_subtype_of relation holds between the klasses.
    1.56 +  bool is_subtype_of(ciType* type);
    1.57 +
    1.58 +  // Get the instance of java.lang.Class corresponding to this type.
    1.59 +  // There are mirrors for instance, array, and primitive types (incl. void).
    1.60 +  virtual ciInstance*    java_mirror();
    1.61 +
    1.62 +  // Get the class which "boxes" (or "wraps") values of this type.
    1.63 +  // Example:  short is boxed by java.lang.Short, etc.
    1.64 +  // Returns self if it is a reference type.
    1.65 +  // Returns NULL for void, since null is used in such cases.
    1.66 +  ciKlass*  box_klass();
    1.67 +
    1.68 +  // Returns true if this is not a klass or array (i.e., not a reference type).
    1.69 +  bool is_primitive_type() const            { return basic_type() != T_OBJECT && basic_type() != T_ARRAY; }
    1.70 +  int size() const                          { return type2size[basic_type()]; }
    1.71 +  bool is_void() const                      { return basic_type() == T_VOID; }
    1.72 +  bool is_one_word() const                  { return size() == 1; }
    1.73 +  bool is_two_word() const                  { return size() == 2; }
    1.74 +
    1.75 +  // What kind of ciObject is this?
    1.76 +  bool is_type()                            { return true; }
    1.77 +  bool is_classless() const                 { return is_primitive_type(); }
    1.78 +
    1.79 +  virtual void print_name_on(outputStream* st);
    1.80 +  void print_name() {
    1.81 +    print_name_on(tty);
    1.82 +  }
    1.83 +
    1.84 +  static ciType* make(BasicType t);
    1.85 +};
    1.86 +
    1.87 +
    1.88 +// ciReturnAddress
    1.89 +//
    1.90 +// This class represents the type of a specific return address in the
    1.91 +// bytecodes.
    1.92 +class ciReturnAddress : public ciType {
    1.93 +  CI_PACKAGE_ACCESS
    1.94 +
    1.95 +private:
    1.96 +  // The bci of this return address.
    1.97 +  int _bci;
    1.98 +
    1.99 +  ciReturnAddress(int bci);
   1.100 +
   1.101 +  const char* type_string() { return "ciReturnAddress"; }
   1.102 +
   1.103 +  void print_impl(outputStream* st);
   1.104 +
   1.105 +public:
   1.106 +  bool is_return_address()  { return true; }
   1.107 +
   1.108 +  int  bci() { return _bci; }
   1.109 +
   1.110 +  static ciReturnAddress* make(int bci);
   1.111 +};

mercurial