hotspot/src/share/vm/ci/ciType.hpp
author kvn
Tue, 11 Mar 2008 11:25:13 -0700
changeset 217 c646ef2f5d58
parent 1 489c9b5090e2
child 5547 f4b087cbb361
permissions -rw-r--r--
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects Summary: Deoptimization code for reallocation and relocking scalar replaced objects has to be fixed. Reviewed-by: rasbold, never
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2000-2001 Sun Microsystems, Inc.  All Rights Reserved.
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
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
// ciType
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
// This class represents either a class (T_OBJECT), array (T_ARRAY),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
// or one of the primitive types such as T_INT.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
class ciType : public ciObject {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
  CI_PACKAGE_ACCESS
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
  friend class ciKlass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
  friend class ciReturnAddress;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
  BasicType _basic_type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
  ciType(BasicType t);     // for the primitive types only
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  ciType(KlassHandle k);   // for subclasses (reference types)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  ciType(ciKlass* klass);  // for unloaded types
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  const char* type_string() { return "ciType"; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  void print_impl(outputStream* st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  // Distinguished instances of primitive ciTypes..
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  static ciType* _basic_types[T_CONFLICT+1];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  BasicType basic_type() const              { return _basic_type; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  // Returns true iff the types are identical, or if both are klasses
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  // and the is_subtype_of relation holds between the klasses.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  bool is_subtype_of(ciType* type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  // Get the instance of java.lang.Class corresponding to this type.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  // There are mirrors for instance, array, and primitive types (incl. void).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  virtual ciInstance*    java_mirror();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  // Get the class which "boxes" (or "wraps") values of this type.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  // Example:  short is boxed by java.lang.Short, etc.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  // Returns self if it is a reference type.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  // Returns NULL for void, since null is used in such cases.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  ciKlass*  box_klass();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  // Returns true if this is not a klass or array (i.e., not a reference type).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  bool is_primitive_type() const            { return basic_type() != T_OBJECT && basic_type() != T_ARRAY; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  int size() const                          { return type2size[basic_type()]; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  bool is_void() const                      { return basic_type() == T_VOID; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  bool is_one_word() const                  { return size() == 1; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  bool is_two_word() const                  { return size() == 2; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  // What kind of ciObject is this?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  bool is_type()                            { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  bool is_classless() const                 { return is_primitive_type(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  virtual void print_name_on(outputStream* st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  void print_name() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
    print_name_on(tty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  static ciType* make(BasicType t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
// ciReturnAddress
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
// This class represents the type of a specific return address in the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
// bytecodes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
class ciReturnAddress : public ciType {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  CI_PACKAGE_ACCESS
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  // The bci of this return address.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  int _bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  ciReturnAddress(int bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  const char* type_string() { return "ciReturnAddress"; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  void print_impl(outputStream* st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  bool is_return_address()  { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  int  bci() { return _bci; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  static ciReturnAddress* make(int bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
};