hotspot/src/share/vm/c1/c1_ValueType.hpp
author twisti
Tue, 24 Jul 2012 10:51:00 -0700
changeset 13391 30245956af37
parent 7397 5b173b4ca846
child 13728 882756847a04
permissions -rw-r--r--
7023639: JSR 292 method handle invocation needs a fast path for compiled code 6984705: JSR 292 method handle creation should not go through JNI Summary: remove assembly code for JDK 7 chained method handles Reviewed-by: jrose, twisti, kvn, mhaupt Contributed-by: John Rose <john.r.rose@oracle.com>, Christian Thalinger <christian.thalinger@oracle.com>, Michael Haupt <michael.haupt@oracle.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5707
diff changeset
     2
 * Copyright (c) 1999, 2010, 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: 5707
diff changeset
    25
#ifndef SHARE_VM_C1_C1_VALUETYPE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5707
diff changeset
    26
#define SHARE_VM_C1_C1_VALUETYPE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5707
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5707
diff changeset
    28
#include "c1/c1_Compilation.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5707
diff changeset
    29
#include "ci/ciConstant.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5707
diff changeset
    30
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
// type hierarchy
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
class ValueType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
class   VoidType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
class   IntType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
class     IntConstant;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
class     IntInterval;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
class   LongType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
class     LongConstant;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
class   FloatType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
class     FloatConstant;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
class   DoubleType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
class     DoubleConstant;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
class   ObjectType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
class     ObjectConstant;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
class     ArrayType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
class       ArrayConstant;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
class     InstanceType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
class       InstanceConstant;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
class     ClassType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
class       ClassConstant;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
class   AddressType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
class     AddressConstant;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
class   IllegalType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
// predefined types
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
extern VoidType*       voidType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
extern IntType*        intType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
extern LongType*       longType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
extern FloatType*      floatType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
extern DoubleType*     doubleType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
extern ObjectType*     objectType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
extern ArrayType*      arrayType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
extern InstanceType*   instanceType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
extern ClassType*      classType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
extern AddressType*    addressType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
extern IllegalType*    illegalType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
// predefined constants
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
extern IntConstant*    intZero;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
extern IntConstant*    intOne;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
extern ObjectConstant* objectNull;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
// tags
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
enum ValueTag {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  // all legal tags must come first
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  intTag,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  longTag,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  floatTag,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  doubleTag,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  objectTag,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  addressTag,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  number_of_legal_tags,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  // all other tags must follow afterwards
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  voidTag = number_of_legal_tags,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  illegalTag,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  number_of_tags
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
class ValueType: public CompilationResourceObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  const int _size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  const ValueTag _tag;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  ValueType();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  ValueType(ValueTag tag, int size): _tag(tag), _size(size) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  // initialization
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   103
  static void initialize(Arena* arena);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  virtual ValueType* base() const                = 0; // the 'canonical' type (e.g., intType for an IntConstant)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  ValueTag tag() const { return _tag; }          // the 'canonical' tag  (useful for type matching)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  int size() const {                             // the size of an object of the type in words
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
    assert(_size > -1, "shouldn't be asking for size");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
    return _size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  virtual const char tchar() const               = 0; // the type 'character' for printing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  virtual const char* name() const               = 0; // the type name for printing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  virtual bool is_constant() const               { return false; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  // testers
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  bool is_void()                                 { return tag() == voidTag;   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  bool is_int()                                  { return tag() == intTag;    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  bool is_long()                                 { return tag() == longTag;   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  bool is_float()                                { return tag() == floatTag;  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  bool is_double()                               { return tag() == doubleTag; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  bool is_object()                               { return as_ObjectType()   != NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  bool is_array()                                { return as_ArrayType()    != NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  bool is_instance()                             { return as_InstanceType() != NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  bool is_class()                                { return as_ClassType()    != NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  bool is_address()                              { return as_AddressType()  != NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  bool is_illegal()                              { return tag() == illegalTag; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  bool is_int_kind() const                       { return tag() == intTag || tag() == longTag; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  bool is_float_kind() const                     { return tag() == floatTag || tag() == doubleTag; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  bool is_object_kind() const                    { return tag() == objectTag; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  bool is_single_word() const                    { return _size == 1; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  bool is_double_word() const                    { return _size == 2; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  // casting
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  virtual VoidType*         as_VoidType()        { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  virtual IntType*          as_IntType()         { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  virtual LongType*         as_LongType()        { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  virtual FloatType*        as_FloatType()       { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  virtual DoubleType*       as_DoubleType()      { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  virtual ObjectType*       as_ObjectType()      { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  virtual ArrayType*        as_ArrayType()       { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  virtual InstanceType*     as_InstanceType()    { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  virtual ClassType*        as_ClassType()       { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  virtual AddressType*      as_AddressType()     { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  virtual IllegalType*      as_IllegalType()     { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  virtual IntConstant*      as_IntConstant()     { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  virtual LongConstant*     as_LongConstant()    { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  virtual FloatConstant*    as_FloatConstant()   { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  virtual DoubleConstant*   as_DoubleConstant()  { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  virtual ObjectConstant*   as_ObjectConstant()  { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  virtual InstanceConstant* as_InstanceConstant(){ return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  virtual ClassConstant*    as_ClassConstant()   { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  virtual ArrayConstant*    as_ArrayConstant()   { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  virtual AddressConstant*  as_AddressConstant() { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  // type operations
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  ValueType* meet(ValueType* y) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  ValueType* join(ValueType* y) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  // debugging
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  void print(outputStream* s = tty)              { s->print(name()); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
class VoidType: public ValueType {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  VoidType(): ValueType(voidTag, 0) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  virtual ValueType* base() const                { return voidType; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  virtual const char tchar() const               { return 'v'; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  virtual const char* name() const               { return "void"; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  virtual VoidType* as_VoidType()                { return this; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
class IntType: public ValueType {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  IntType(): ValueType(intTag, 1) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  virtual ValueType* base() const                { return intType; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  virtual const char tchar() const               { return 'i'; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  virtual const char* name() const               { return "int"; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  virtual IntType* as_IntType()                  { return this; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
class IntConstant: public IntType {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  jint _value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  IntConstant(jint value)                        { _value = value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  jint value() const                             { return _value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  virtual bool is_constant() const               { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  virtual IntConstant* as_IntConstant()          { return this; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
class IntInterval: public IntType {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  jint _beg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  jint _end;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  IntInterval(jint beg, jint end) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
    assert(beg <= end, "illegal interval");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
    _beg = beg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
    _end = end;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
  jint beg() const                               { return _beg; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  jint end() const                               { return _end; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  virtual bool is_interval() const               { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
class LongType: public ValueType {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
  LongType(): ValueType(longTag, 2) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  virtual ValueType* base() const                { return longType; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
  virtual const char tchar() const               { return 'l'; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
  virtual const char* name() const               { return "long"; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
  virtual LongType* as_LongType()                { return this; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
class LongConstant: public LongType {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  jlong _value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
  LongConstant(jlong value)                      { _value = value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  jlong value() const                            { return _value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  virtual bool is_constant() const               { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  virtual LongConstant* as_LongConstant()        { return this; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
class FloatType: public ValueType {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  FloatType(): ValueType(floatTag, 1) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
  virtual ValueType* base() const                { return floatType; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
  virtual const char tchar() const               { return 'f'; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
  virtual const char* name() const               { return "float"; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
  virtual FloatType* as_FloatType()              { return this; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
class FloatConstant: public FloatType {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  jfloat _value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  FloatConstant(jfloat value)                    { _value = value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
  jfloat value() const                           { return _value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
  virtual bool is_constant() const               { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  virtual FloatConstant* as_FloatConstant()      { return this; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
class DoubleType: public ValueType {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
  DoubleType(): ValueType(doubleTag, 2) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
  virtual ValueType* base() const                { return doubleType; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
  virtual const char tchar() const               { return 'd'; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
  virtual const char* name() const               { return "double"; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  virtual DoubleType* as_DoubleType()            { return this; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
class DoubleConstant: public DoubleType {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
  jdouble _value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
  DoubleConstant(jdouble value)                  { _value = value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
  jdouble value() const                          { return _value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
  virtual bool is_constant() const               { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  virtual DoubleConstant* as_DoubleConstant()    { return this; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
class ObjectType: public ValueType {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
  ObjectType(): ValueType(objectTag, 1) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  virtual ValueType* base() const                { return objectType; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
  virtual const char tchar() const               { return 'a'; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  virtual const char* name() const               { return "object"; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
  virtual ObjectType* as_ObjectType()            { return this; }
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 7397
diff changeset
   300
  virtual ciObject* constant_value() const       { ShouldNotReachHere(); return NULL; }
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 7397
diff changeset
   301
  virtual ciType* exact_type() const             { return NULL; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
  bool is_loaded() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
  jobject encoding() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
class ObjectConstant: public ObjectType {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
  ciObject* _value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
  ObjectConstant(ciObject* value)                { _value = value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
  ciObject* value() const                        { return _value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
  virtual bool is_constant() const               { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
  virtual ObjectConstant* as_ObjectConstant()    { return this; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
  virtual ciObject* constant_value() const;
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 7397
diff changeset
   319
  virtual ciType* exact_type() const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
class ArrayType: public ObjectType {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
  virtual ArrayType* as_ArrayType()              { return this; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
class ArrayConstant: public ArrayType {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
  ciArray* _value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
  ArrayConstant(ciArray* value)                  { _value = value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
  ciArray* value() const                         { return _value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
  virtual bool is_constant() const               { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
  virtual ArrayConstant* as_ArrayConstant()      { return this; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
  virtual ciObject* constant_value() const;
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 7397
diff changeset
   341
  virtual ciType* exact_type() const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
class InstanceType: public ObjectType {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
  virtual InstanceType* as_InstanceType()        { return this; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
class InstanceConstant: public InstanceType {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
  ciInstance* _value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
  InstanceConstant(ciInstance* value)            { _value = value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
  ciInstance* value() const                      { return _value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
  virtual bool is_constant() const               { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
  virtual InstanceConstant* as_InstanceConstant(){ return this; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
  virtual ciObject* constant_value() const;
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 7397
diff changeset
   363
  virtual ciType* exact_type() const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
class ClassType: public ObjectType {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
  virtual ClassType* as_ClassType()              { return this; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
class ClassConstant: public ClassType {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
  ciInstanceKlass* _value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
  ClassConstant(ciInstanceKlass* value)          { _value = value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
  ciInstanceKlass* value() const                 { return _value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
  virtual bool is_constant() const               { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
  virtual ClassConstant* as_ClassConstant()      { return this; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
  virtual ciObject* constant_value() const;
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 7397
diff changeset
   385
  virtual ciType* exact_type() const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
class AddressType: public ValueType {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
  AddressType(): ValueType(addressTag, 1) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
  virtual ValueType* base() const                { return addressType; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
  virtual const char tchar() const               { return 'r'; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
  virtual const char* name() const               { return "address"; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
  virtual AddressType* as_AddressType()          { return this; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
class AddressConstant: public AddressType {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
  jint _value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
  AddressConstant(jint value)                    { _value = value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
  jint value() const                             { return _value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
  virtual bool is_constant() const               { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
  virtual AddressConstant* as_AddressConstant()  { return this; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
class IllegalType: public ValueType {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
  IllegalType(): ValueType(illegalTag, -1) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
  virtual ValueType* base() const                { return illegalType; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
  virtual const char tchar() const               { return ' '; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
  virtual const char* name() const               { return "illegal"; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
  virtual IllegalType* as_IllegalType()          { return this; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
// conversion between ValueTypes, BasicTypes, and ciConstants
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
ValueType* as_ValueType(BasicType type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
ValueType* as_ValueType(ciConstant value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
BasicType  as_BasicType(ValueType* type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
inline ValueType* as_ValueType(ciType* type) { return as_ValueType(type->basic_type()); }
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5707
diff changeset
   430
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5707
diff changeset
   431
#endif // SHARE_VM_C1_C1_VALUETYPE_HPP