src/share/vm/c1/c1_ValueType.cpp

Sat, 01 Dec 2007 00:00:00 +0000

author
duke
date
Sat, 01 Dec 2007 00:00:00 +0000
changeset 435
a61af66fc99e
child 1424
148e5441d916
permissions
-rw-r--r--

Initial load

duke@435 1 /*
duke@435 2 * Copyright 1999-2005 Sun Microsystems, Inc. All Rights Reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 # include "incls/_precompiled.incl"
duke@435 26 # include "incls/_c1_ValueType.cpp.incl"
duke@435 27
duke@435 28
duke@435 29 // predefined types
duke@435 30 VoidType* voidType = NULL;
duke@435 31 IntType* intType = NULL;
duke@435 32 LongType* longType = NULL;
duke@435 33 FloatType* floatType = NULL;
duke@435 34 DoubleType* doubleType = NULL;
duke@435 35 ObjectType* objectType = NULL;
duke@435 36 ArrayType* arrayType = NULL;
duke@435 37 InstanceType* instanceType = NULL;
duke@435 38 ClassType* classType = NULL;
duke@435 39 AddressType* addressType = NULL;
duke@435 40 IllegalType* illegalType = NULL;
duke@435 41
duke@435 42
duke@435 43 // predefined constants
duke@435 44 IntConstant* intZero = NULL;
duke@435 45 IntConstant* intOne = NULL;
duke@435 46 ObjectConstant* objectNull = NULL;
duke@435 47
duke@435 48
duke@435 49 void ValueType::initialize() {
duke@435 50 // Note: Must initialize all types for each compilation
duke@435 51 // as they are allocated within a ResourceMark!
duke@435 52
duke@435 53 // types
duke@435 54 voidType = new VoidType();
duke@435 55 intType = new IntType();
duke@435 56 longType = new LongType();
duke@435 57 floatType = new FloatType();
duke@435 58 doubleType = new DoubleType();
duke@435 59 objectType = new ObjectType();
duke@435 60 arrayType = new ArrayType();
duke@435 61 instanceType = new InstanceType();
duke@435 62 classType = new ClassType();
duke@435 63 addressType = new AddressType();
duke@435 64 illegalType = new IllegalType();
duke@435 65
duke@435 66 // constants
duke@435 67 intZero = new IntConstant(0);
duke@435 68 intOne = new IntConstant(1);
duke@435 69 objectNull = new ObjectConstant(ciNullObject::make());
duke@435 70 };
duke@435 71
duke@435 72
duke@435 73 ValueType* ValueType::meet(ValueType* y) const {
duke@435 74 // incomplete & conservative solution for now - fix this!
duke@435 75 assert(tag() == y->tag(), "types must match");
duke@435 76 return base();
duke@435 77 }
duke@435 78
duke@435 79
duke@435 80 ValueType* ValueType::join(ValueType* y) const {
duke@435 81 Unimplemented();
duke@435 82 return NULL;
duke@435 83 }
duke@435 84
duke@435 85
duke@435 86
duke@435 87 jobject ObjectType::encoding() const {
duke@435 88 assert(is_constant(), "must be");
duke@435 89 return constant_value()->encoding();
duke@435 90 }
duke@435 91
duke@435 92 bool ObjectType::is_loaded() const {
duke@435 93 assert(is_constant(), "must be");
duke@435 94 return constant_value()->is_loaded();
duke@435 95 }
duke@435 96
duke@435 97 ciObject* ObjectConstant::constant_value() const { return _value; }
duke@435 98 ciObject* ArrayConstant::constant_value() const { return _value; }
duke@435 99 ciObject* InstanceConstant::constant_value() const { return _value; }
duke@435 100 ciObject* ClassConstant::constant_value() const { return _value; }
duke@435 101
duke@435 102
duke@435 103 ValueType* as_ValueType(BasicType type) {
duke@435 104 switch (type) {
duke@435 105 case T_VOID : return voidType;
duke@435 106 case T_BYTE : // fall through
duke@435 107 case T_CHAR : // fall through
duke@435 108 case T_SHORT : // fall through
duke@435 109 case T_BOOLEAN: // fall through
duke@435 110 case T_INT : return intType;
duke@435 111 case T_LONG : return longType;
duke@435 112 case T_FLOAT : return floatType;
duke@435 113 case T_DOUBLE : return doubleType;
duke@435 114 case T_ARRAY : return arrayType;
duke@435 115 case T_OBJECT : return objectType;
duke@435 116 case T_ADDRESS: return addressType;
duke@435 117 case T_ILLEGAL: return illegalType;
duke@435 118 }
duke@435 119 ShouldNotReachHere();
duke@435 120 return illegalType;
duke@435 121 }
duke@435 122
duke@435 123
duke@435 124 ValueType* as_ValueType(ciConstant value) {
duke@435 125 switch (value.basic_type()) {
duke@435 126 case T_BYTE : // fall through
duke@435 127 case T_CHAR : // fall through
duke@435 128 case T_SHORT : // fall through
duke@435 129 case T_BOOLEAN: // fall through
duke@435 130 case T_INT : return new IntConstant (value.as_int ());
duke@435 131 case T_LONG : return new LongConstant (value.as_long ());
duke@435 132 case T_FLOAT : return new FloatConstant (value.as_float ());
duke@435 133 case T_DOUBLE : return new DoubleConstant(value.as_double());
duke@435 134 case T_ARRAY : // fall through (ciConstant doesn't have an array accessor)
duke@435 135 case T_OBJECT : return new ObjectConstant(value.as_object());
duke@435 136 }
duke@435 137 ShouldNotReachHere();
duke@435 138 return illegalType;
duke@435 139 }
duke@435 140
duke@435 141
duke@435 142 BasicType as_BasicType(ValueType* type) {
duke@435 143 switch (type->tag()) {
duke@435 144 case voidTag: return T_VOID;
duke@435 145 case intTag: return T_INT;
duke@435 146 case longTag: return T_LONG;
duke@435 147 case floatTag: return T_FLOAT;
duke@435 148 case doubleTag: return T_DOUBLE;
duke@435 149 case objectTag: return T_OBJECT;
duke@435 150 case addressTag: return T_ADDRESS;
duke@435 151 case illegalTag: return T_ILLEGAL;
duke@435 152 }
duke@435 153 ShouldNotReachHere();
duke@435 154 return T_ILLEGAL;
duke@435 155 }

mercurial