src/share/vm/c1/c1_ValueType.cpp

Tue, 11 Sep 2012 16:20:57 +0200

author
roland
date
Tue, 11 Sep 2012 16:20:57 +0200
changeset 4051
8a02ca5e5576
parent 4037
da91efe96a93
child 6876
710a3c8b516e
child 8203
2b597b92442b
permissions
-rw-r--r--

7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
Summary: C1 needs knowledge of T_METADATA at the LIR level.
Reviewed-by: kvn, coleenp

duke@435 1 /*
coleenp@4037 2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. 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 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #include "precompiled.hpp"
stefank@2314 26 #include "c1/c1_ValueType.hpp"
stefank@2314 27 #include "ci/ciArray.hpp"
stefank@2314 28 #include "ci/ciInstance.hpp"
stefank@2314 29 #include "ci/ciNullObject.hpp"
duke@435 30
duke@435 31
duke@435 32 // predefined types
duke@435 33 VoidType* voidType = NULL;
duke@435 34 IntType* intType = NULL;
duke@435 35 LongType* longType = NULL;
duke@435 36 FloatType* floatType = NULL;
duke@435 37 DoubleType* doubleType = NULL;
duke@435 38 ObjectType* objectType = NULL;
duke@435 39 ArrayType* arrayType = NULL;
duke@435 40 InstanceType* instanceType = NULL;
duke@435 41 ClassType* classType = NULL;
duke@435 42 AddressType* addressType = NULL;
duke@435 43 IllegalType* illegalType = NULL;
duke@435 44
duke@435 45
duke@435 46 // predefined constants
duke@435 47 IntConstant* intZero = NULL;
duke@435 48 IntConstant* intOne = NULL;
duke@435 49 ObjectConstant* objectNull = NULL;
duke@435 50
duke@435 51
iveresov@1939 52 void ValueType::initialize(Arena* arena) {
duke@435 53 // Note: Must initialize all types for each compilation
duke@435 54 // as they are allocated within a ResourceMark!
duke@435 55
duke@435 56 // types
iveresov@1939 57 voidType = new (arena) VoidType();
iveresov@1939 58 intType = new (arena) IntType();
iveresov@1939 59 longType = new (arena) LongType();
iveresov@1939 60 floatType = new (arena) FloatType();
iveresov@1939 61 doubleType = new (arena) DoubleType();
iveresov@1939 62 objectType = new (arena) ObjectType();
iveresov@1939 63 arrayType = new (arena) ArrayType();
iveresov@1939 64 instanceType = new (arena) InstanceType();
iveresov@1939 65 classType = new (arena) ClassType();
iveresov@1939 66 addressType = new (arena) AddressType();
iveresov@1939 67 illegalType = new (arena) IllegalType();
duke@435 68
iveresov@1939 69 intZero = new (arena) IntConstant(0);
iveresov@1939 70 intOne = new (arena) IntConstant(1);
iveresov@1939 71 objectNull = new (arena) ObjectConstant(ciNullObject::make());
duke@435 72 };
duke@435 73
duke@435 74
duke@435 75 ValueType* ValueType::meet(ValueType* y) const {
duke@435 76 // incomplete & conservative solution for now - fix this!
duke@435 77 assert(tag() == y->tag(), "types must match");
duke@435 78 return base();
duke@435 79 }
duke@435 80
duke@435 81
duke@435 82 ValueType* ValueType::join(ValueType* y) const {
duke@435 83 Unimplemented();
duke@435 84 return NULL;
duke@435 85 }
duke@435 86
duke@435 87
twisti@3969 88 ciType* ObjectConstant::exact_type() const {
twisti@3969 89 ciObject* c = constant_value();
twisti@3969 90 return (c != NULL && !c->is_null_object()) ? c->klass() : NULL;
twisti@3969 91 }
twisti@3969 92 ciType* ArrayConstant::exact_type() const {
twisti@3969 93 ciObject* c = constant_value();
twisti@3969 94 return (c != NULL && !c->is_null_object()) ? c->klass() : NULL;
twisti@3969 95 }
twisti@3969 96 ciType* InstanceConstant::exact_type() const {
twisti@3969 97 ciObject* c = constant_value();
twisti@3969 98 return (c != NULL && !c->is_null_object()) ? c->klass() : NULL;
twisti@3969 99 }
twisti@3969 100 ciType* ClassConstant::exact_type() const {
coleenp@4037 101 return Compilation::current()->env()->Class_klass();
twisti@3969 102 }
twisti@3969 103
duke@435 104
coleenp@4037 105 jobject ObjectType::encoding() const {
coleenp@4037 106 assert(is_constant(), "must be");
coleenp@4037 107 return constant_value()->constant_encoding();
coleenp@4037 108 }
coleenp@4037 109
coleenp@4037 110 bool ObjectType::is_loaded() const {
coleenp@4037 111 assert(is_constant(), "must be");
coleenp@4037 112 return constant_value()->is_loaded();
coleenp@4037 113 }
coleenp@4037 114
coleenp@4037 115 bool MetadataType::is_loaded() const {
coleenp@4037 116 assert(is_constant(), "must be");
coleenp@4037 117 return constant_value()->is_loaded();
coleenp@4037 118 }
coleenp@4037 119
coleenp@4037 120 ciObject* ObjectConstant::constant_value() const { return _value; }
coleenp@4037 121 ciObject* ArrayConstant::constant_value() const { return _value; }
coleenp@4037 122 ciObject* InstanceConstant::constant_value() const { return _value; }
coleenp@4037 123
duke@435 124 ValueType* as_ValueType(BasicType type) {
duke@435 125 switch (type) {
duke@435 126 case T_VOID : return voidType;
duke@435 127 case T_BYTE : // fall through
duke@435 128 case T_CHAR : // fall through
duke@435 129 case T_SHORT : // fall through
duke@435 130 case T_BOOLEAN: // fall through
duke@435 131 case T_INT : return intType;
duke@435 132 case T_LONG : return longType;
duke@435 133 case T_FLOAT : return floatType;
duke@435 134 case T_DOUBLE : return doubleType;
duke@435 135 case T_ARRAY : return arrayType;
duke@435 136 case T_OBJECT : return objectType;
duke@435 137 case T_ADDRESS: return addressType;
duke@435 138 case T_ILLEGAL: return illegalType;
duke@435 139 }
duke@435 140 ShouldNotReachHere();
duke@435 141 return illegalType;
duke@435 142 }
duke@435 143
duke@435 144
duke@435 145 ValueType* as_ValueType(ciConstant value) {
duke@435 146 switch (value.basic_type()) {
duke@435 147 case T_BYTE : // fall through
duke@435 148 case T_CHAR : // fall through
duke@435 149 case T_SHORT : // fall through
duke@435 150 case T_BOOLEAN: // fall through
duke@435 151 case T_INT : return new IntConstant (value.as_int ());
duke@435 152 case T_LONG : return new LongConstant (value.as_long ());
duke@435 153 case T_FLOAT : return new FloatConstant (value.as_float ());
duke@435 154 case T_DOUBLE : return new DoubleConstant(value.as_double());
duke@435 155 case T_ARRAY : // fall through (ciConstant doesn't have an array accessor)
duke@435 156 case T_OBJECT : return new ObjectConstant(value.as_object());
duke@435 157 }
duke@435 158 ShouldNotReachHere();
duke@435 159 return illegalType;
duke@435 160 }
duke@435 161
duke@435 162
duke@435 163 BasicType as_BasicType(ValueType* type) {
duke@435 164 switch (type->tag()) {
duke@435 165 case voidTag: return T_VOID;
duke@435 166 case intTag: return T_INT;
duke@435 167 case longTag: return T_LONG;
duke@435 168 case floatTag: return T_FLOAT;
duke@435 169 case doubleTag: return T_DOUBLE;
duke@435 170 case objectTag: return T_OBJECT;
roland@4051 171 case metaDataTag:return T_METADATA;
duke@435 172 case addressTag: return T_ADDRESS;
duke@435 173 case illegalTag: return T_ILLEGAL;
duke@435 174 }
duke@435 175 ShouldNotReachHere();
duke@435 176 return T_ILLEGAL;
duke@435 177 }

mercurial