hotspot/src/share/vm/c1/c1_ValueType.cpp
author trims
Thu, 27 May 2010 19:08:38 -0700
changeset 5547 f4b087cbb361
parent 3908 24b55ad4c228
child 5707 6c66849ed24e
permissions -rw-r--r--
6941466: Oracle rebranding changes for Hotspot repositories Summary: Change all the Sun copyrights to Oracle copyright Reviewed-by: ohair
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3908
diff changeset
     2
 * Copyright (c) 1999, 2005, 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: 3908
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3908
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: 3908
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
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
# include "incls/_precompiled.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
# include "incls/_c1_ValueType.cpp.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
// predefined types
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
VoidType*       voidType     = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
IntType*        intType      = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
LongType*       longType     = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
FloatType*      floatType    = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
DoubleType*     doubleType   = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
ObjectType*     objectType   = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
ArrayType*      arrayType    = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
InstanceType*   instanceType = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
ClassType*      classType    = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
AddressType*    addressType  = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
IllegalType*    illegalType  = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
// predefined constants
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
IntConstant*    intZero      = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
IntConstant*    intOne       = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
ObjectConstant* objectNull   = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
void ValueType::initialize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  // Note: Must initialize all types for each compilation
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  //       as they are allocated within a ResourceMark!
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  // types
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  voidType     = new VoidType();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  intType      = new IntType();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  longType     = new LongType();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  floatType    = new FloatType();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  doubleType   = new DoubleType();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  objectType   = new ObjectType();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  arrayType    = new ArrayType();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  instanceType = new InstanceType();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  classType    = new ClassType();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  addressType  = new AddressType();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  illegalType  = new IllegalType();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  // constants
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  intZero     = new IntConstant(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  intOne      = new IntConstant(1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  objectNull  = new ObjectConstant(ciNullObject::make());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
ValueType* ValueType::meet(ValueType* y) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  // incomplete & conservative solution for now - fix this!
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  assert(tag() == y->tag(), "types must match");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  return base();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
ValueType* ValueType::join(ValueType* y) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  Unimplemented();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
jobject ObjectType::encoding() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  assert(is_constant(), "must be");
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
    89
  return constant_value()->constant_encoding();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
bool ObjectType::is_loaded() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  assert(is_constant(), "must be");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  return constant_value()->is_loaded();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
ciObject* ObjectConstant::constant_value() const                   { return _value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
ciObject* ArrayConstant::constant_value() const                    { return _value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
ciObject* InstanceConstant::constant_value() const                 { return _value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
ciObject* ClassConstant::constant_value() const                    { return _value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
ValueType* as_ValueType(BasicType type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  switch (type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
    case T_VOID   : return voidType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
    case T_BYTE   : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
    case T_CHAR   : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
    case T_SHORT  : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
    case T_BOOLEAN: // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
    case T_INT    : return intType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
    case T_LONG   : return longType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
    case T_FLOAT  : return floatType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
    case T_DOUBLE : return doubleType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
    case T_ARRAY  : return arrayType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
    case T_OBJECT : return objectType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
    case T_ADDRESS: return addressType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
    case T_ILLEGAL: return illegalType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  return illegalType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
ValueType* as_ValueType(ciConstant value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  switch (value.basic_type()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
    case T_BYTE   : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
    case T_CHAR   : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
    case T_SHORT  : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
    case T_BOOLEAN: // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
    case T_INT    : return new IntConstant   (value.as_int   ());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
    case T_LONG   : return new LongConstant  (value.as_long  ());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
    case T_FLOAT  : return new FloatConstant (value.as_float ());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
    case T_DOUBLE : return new DoubleConstant(value.as_double());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
    case T_ARRAY  : // fall through (ciConstant doesn't have an array accessor)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
    case T_OBJECT : return new ObjectConstant(value.as_object());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  return illegalType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
BasicType as_BasicType(ValueType* type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  switch (type->tag()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
    case voidTag:    return T_VOID;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
    case intTag:     return T_INT;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
    case longTag:    return T_LONG;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
    case floatTag:   return T_FLOAT;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
    case doubleTag:  return T_DOUBLE;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
    case objectTag:  return T_OBJECT;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
    case addressTag: return T_ADDRESS;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
    case illegalTag: return T_ILLEGAL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  return T_ILLEGAL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
}