src/hotspot/share/ci/ciType.hpp
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 46329 hotspot/src/share/vm/ci/ciType.hpp@53ccc37bda19
child 53244 9807daeb47c4
permissions -rw-r--r--
8187443: Forest Consolidation: Move files to unified layout Reviewed-by: darcy, ihse
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 22234
diff changeset
     2
 * Copyright (c) 2000, 2017, 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: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
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: 1
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
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#ifndef SHARE_VM_CI_CITYPE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_CI_CITYPE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 7397
diff changeset
    28
#include "ci/ciMetadata.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
// ciType
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
// This class represents either a class (T_OBJECT), array (T_ARRAY),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
// or one of the primitive types such as T_INT.
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 7397
diff changeset
    34
class ciType : public ciMetadata {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
  CI_PACKAGE_ACCESS
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
  friend class ciKlass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
  friend class ciReturnAddress;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  BasicType _basic_type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 7397
diff changeset
    42
  ciType(BasicType t);     // for primitive and unloaded types
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 22234
diff changeset
    43
  ciType(Klass* k);        // for subclasses (reference types)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  const char* type_string() { return "ciType"; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  void print_impl(outputStream* st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  // Distinguished instances of primitive ciTypes..
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  static ciType* _basic_types[T_CONFLICT+1];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  BasicType basic_type() const              { return _basic_type; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  // Returns true iff the types are identical, or if both are klasses
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  // and the is_subtype_of relation holds between the klasses.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  bool is_subtype_of(ciType* type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  // Get the instance of java.lang.Class corresponding to this type.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  // There are mirrors for instance, array, and primitive types (incl. void).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  virtual ciInstance*    java_mirror();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  // Get the class which "boxes" (or "wraps") values of this type.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  // Example:  short is boxed by java.lang.Short, etc.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  // Returns self if it is a reference type.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  // Returns NULL for void, since null is used in such cases.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  ciKlass*  box_klass();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  // Returns true if this is not a klass or array (i.e., not a reference type).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  bool is_primitive_type() const            { return basic_type() != T_OBJECT && basic_type() != T_ARRAY; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  int size() const                          { return type2size[basic_type()]; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  bool is_void() const                      { return basic_type() == T_VOID; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  bool is_one_word() const                  { return size() == 1; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  bool is_two_word() const                  { return size() == 2; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  // What kind of ciObject is this?
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 7397
diff changeset
    77
  bool is_type() const                      { return true; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  bool is_classless() const                 { return is_primitive_type(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
15210
eb42543a7050 8006109: test/java/util/AbstractSequentialList/AddAll.java fails: assert(rtype == ctype) failed: mismatched return types
twisti
parents: 13728
diff changeset
    80
  const char* name();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  virtual void print_name_on(outputStream* st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  void print_name() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
    print_name_on(tty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  static ciType* make(BasicType t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
// ciReturnAddress
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
// This class represents the type of a specific return address in the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
// bytecodes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
class ciReturnAddress : public ciType {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  CI_PACKAGE_ACCESS
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  // The bci of this return address.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  int _bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  ciReturnAddress(int bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  const char* type_string() { return "ciReturnAddress"; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  void print_impl(outputStream* st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
public:
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 7397
diff changeset
   108
  bool is_return_address() const { return true; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  int  bci() { return _bci; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  static ciReturnAddress* make(int bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   114
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   115
#endif // SHARE_VM_CI_CITYPE_HPP