src/share/vm/c1/c1_ValueType.hpp

Thu, 10 Oct 2013 15:44:12 +0200

author
anoll
date
Thu, 10 Oct 2013 15:44:12 +0200
changeset 5919
469216acdb28
parent 4037
da91efe96a93
child 6680
78bbf4d43a14
permissions
-rw-r--r--

8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
Summary: Ensure ensure correct initialization of compiler runtime
Reviewed-by: kvn, twisti

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 #ifndef SHARE_VM_C1_C1_VALUETYPE_HPP
stefank@2314 26 #define SHARE_VM_C1_C1_VALUETYPE_HPP
stefank@2314 27
stefank@2314 28 #include "c1/c1_Compilation.hpp"
stefank@2314 29 #include "ci/ciConstant.hpp"
coleenp@4037 30 #include "ci/ciMethodData.hpp"
stefank@2314 31
duke@435 32 // type hierarchy
duke@435 33 class ValueType;
duke@435 34 class VoidType;
duke@435 35 class IntType;
duke@435 36 class IntConstant;
duke@435 37 class IntInterval;
duke@435 38 class LongType;
duke@435 39 class LongConstant;
duke@435 40 class FloatType;
duke@435 41 class FloatConstant;
duke@435 42 class DoubleType;
duke@435 43 class DoubleConstant;
duke@435 44 class ObjectType;
duke@435 45 class ObjectConstant;
duke@435 46 class ArrayType;
duke@435 47 class ArrayConstant;
duke@435 48 class InstanceType;
duke@435 49 class InstanceConstant;
coleenp@4037 50 class MetadataType;
duke@435 51 class ClassType;
duke@435 52 class ClassConstant;
coleenp@4037 53 class MethodType;
coleenp@4037 54 class MethodConstant;
coleenp@4037 55 class MethodDataType;
coleenp@4037 56 class MethodDataConstant;
duke@435 57 class AddressType;
duke@435 58 class AddressConstant;
duke@435 59 class IllegalType;
duke@435 60
duke@435 61
duke@435 62 // predefined types
duke@435 63 extern VoidType* voidType;
duke@435 64 extern IntType* intType;
duke@435 65 extern LongType* longType;
duke@435 66 extern FloatType* floatType;
duke@435 67 extern DoubleType* doubleType;
duke@435 68 extern ObjectType* objectType;
duke@435 69 extern ArrayType* arrayType;
duke@435 70 extern InstanceType* instanceType;
duke@435 71 extern ClassType* classType;
duke@435 72 extern AddressType* addressType;
duke@435 73 extern IllegalType* illegalType;
duke@435 74
duke@435 75
duke@435 76 // predefined constants
duke@435 77 extern IntConstant* intZero;
duke@435 78 extern IntConstant* intOne;
duke@435 79 extern ObjectConstant* objectNull;
duke@435 80
duke@435 81
duke@435 82 // tags
duke@435 83 enum ValueTag {
duke@435 84 // all legal tags must come first
duke@435 85 intTag,
duke@435 86 longTag,
duke@435 87 floatTag,
duke@435 88 doubleTag,
duke@435 89 objectTag,
duke@435 90 addressTag,
coleenp@4037 91 metaDataTag,
duke@435 92 number_of_legal_tags,
duke@435 93 // all other tags must follow afterwards
duke@435 94 voidTag = number_of_legal_tags,
duke@435 95 illegalTag,
duke@435 96 number_of_tags
duke@435 97 };
duke@435 98
duke@435 99
duke@435 100 class ValueType: public CompilationResourceObj {
duke@435 101 private:
duke@435 102 const int _size;
duke@435 103 const ValueTag _tag;
duke@435 104 ValueType();
duke@435 105 protected:
duke@435 106 ValueType(ValueTag tag, int size): _tag(tag), _size(size) {}
duke@435 107
duke@435 108 public:
duke@435 109 // initialization
iveresov@1939 110 static void initialize(Arena* arena);
duke@435 111
duke@435 112 // accessors
duke@435 113 virtual ValueType* base() const = 0; // the 'canonical' type (e.g., intType for an IntConstant)
duke@435 114 ValueTag tag() const { return _tag; } // the 'canonical' tag (useful for type matching)
duke@435 115 int size() const { // the size of an object of the type in words
duke@435 116 assert(_size > -1, "shouldn't be asking for size");
duke@435 117 return _size;
duke@435 118 }
duke@435 119 virtual const char tchar() const = 0; // the type 'character' for printing
duke@435 120 virtual const char* name() const = 0; // the type name for printing
duke@435 121 virtual bool is_constant() const { return false; }
duke@435 122
duke@435 123 // testers
duke@435 124 bool is_void() { return tag() == voidTag; }
duke@435 125 bool is_int() { return tag() == intTag; }
duke@435 126 bool is_long() { return tag() == longTag; }
duke@435 127 bool is_float() { return tag() == floatTag; }
duke@435 128 bool is_double() { return tag() == doubleTag; }
duke@435 129 bool is_object() { return as_ObjectType() != NULL; }
duke@435 130 bool is_array() { return as_ArrayType() != NULL; }
duke@435 131 bool is_instance() { return as_InstanceType() != NULL; }
duke@435 132 bool is_class() { return as_ClassType() != NULL; }
coleenp@4037 133 bool is_method() { return as_MethodType() != NULL; }
coleenp@4037 134 bool is_method_data() { return as_MethodDataType() != NULL; }
duke@435 135 bool is_address() { return as_AddressType() != NULL; }
duke@435 136 bool is_illegal() { return tag() == illegalTag; }
duke@435 137
duke@435 138 bool is_int_kind() const { return tag() == intTag || tag() == longTag; }
duke@435 139 bool is_float_kind() const { return tag() == floatTag || tag() == doubleTag; }
duke@435 140 bool is_object_kind() const { return tag() == objectTag; }
duke@435 141
duke@435 142 bool is_single_word() const { return _size == 1; }
duke@435 143 bool is_double_word() const { return _size == 2; }
duke@435 144
duke@435 145 // casting
duke@435 146 virtual VoidType* as_VoidType() { return NULL; }
duke@435 147 virtual IntType* as_IntType() { return NULL; }
duke@435 148 virtual LongType* as_LongType() { return NULL; }
duke@435 149 virtual FloatType* as_FloatType() { return NULL; }
duke@435 150 virtual DoubleType* as_DoubleType() { return NULL; }
duke@435 151 virtual ObjectType* as_ObjectType() { return NULL; }
duke@435 152 virtual ArrayType* as_ArrayType() { return NULL; }
duke@435 153 virtual InstanceType* as_InstanceType() { return NULL; }
duke@435 154 virtual ClassType* as_ClassType() { return NULL; }
coleenp@4037 155 virtual MetadataType* as_MetadataType() { return NULL; }
coleenp@4037 156 virtual MethodType* as_MethodType() { return NULL; }
coleenp@4037 157 virtual MethodDataType* as_MethodDataType() { return NULL; }
duke@435 158 virtual AddressType* as_AddressType() { return NULL; }
duke@435 159 virtual IllegalType* as_IllegalType() { return NULL; }
duke@435 160
duke@435 161 virtual IntConstant* as_IntConstant() { return NULL; }
duke@435 162 virtual LongConstant* as_LongConstant() { return NULL; }
duke@435 163 virtual FloatConstant* as_FloatConstant() { return NULL; }
duke@435 164 virtual DoubleConstant* as_DoubleConstant() { return NULL; }
duke@435 165 virtual ObjectConstant* as_ObjectConstant() { return NULL; }
duke@435 166 virtual InstanceConstant* as_InstanceConstant(){ return NULL; }
duke@435 167 virtual ClassConstant* as_ClassConstant() { return NULL; }
coleenp@4037 168 virtual MethodConstant* as_MethodConstant() { return NULL; }
coleenp@4037 169 virtual MethodDataConstant* as_MethodDataConstant() { return NULL; }
duke@435 170 virtual ArrayConstant* as_ArrayConstant() { return NULL; }
duke@435 171 virtual AddressConstant* as_AddressConstant() { return NULL; }
duke@435 172
duke@435 173 // type operations
duke@435 174 ValueType* meet(ValueType* y) const;
duke@435 175 ValueType* join(ValueType* y) const;
duke@435 176
duke@435 177 // debugging
duke@435 178 void print(outputStream* s = tty) { s->print(name()); }
duke@435 179 };
duke@435 180
duke@435 181
duke@435 182 class VoidType: public ValueType {
duke@435 183 public:
duke@435 184 VoidType(): ValueType(voidTag, 0) {}
duke@435 185 virtual ValueType* base() const { return voidType; }
duke@435 186 virtual const char tchar() const { return 'v'; }
duke@435 187 virtual const char* name() const { return "void"; }
duke@435 188 virtual VoidType* as_VoidType() { return this; }
duke@435 189 };
duke@435 190
duke@435 191
duke@435 192 class IntType: public ValueType {
duke@435 193 public:
duke@435 194 IntType(): ValueType(intTag, 1) {}
duke@435 195 virtual ValueType* base() const { return intType; }
duke@435 196 virtual const char tchar() const { return 'i'; }
duke@435 197 virtual const char* name() const { return "int"; }
duke@435 198 virtual IntType* as_IntType() { return this; }
duke@435 199 };
duke@435 200
duke@435 201
duke@435 202 class IntConstant: public IntType {
duke@435 203 private:
duke@435 204 jint _value;
duke@435 205
duke@435 206 public:
duke@435 207 IntConstant(jint value) { _value = value; }
duke@435 208
duke@435 209 jint value() const { return _value; }
duke@435 210
duke@435 211 virtual bool is_constant() const { return true; }
duke@435 212 virtual IntConstant* as_IntConstant() { return this; }
duke@435 213 };
duke@435 214
duke@435 215
duke@435 216 class IntInterval: public IntType {
duke@435 217 private:
duke@435 218 jint _beg;
duke@435 219 jint _end;
duke@435 220
duke@435 221 public:
duke@435 222 IntInterval(jint beg, jint end) {
duke@435 223 assert(beg <= end, "illegal interval");
duke@435 224 _beg = beg;
duke@435 225 _end = end;
duke@435 226 }
duke@435 227
duke@435 228 jint beg() const { return _beg; }
duke@435 229 jint end() const { return _end; }
duke@435 230
duke@435 231 virtual bool is_interval() const { return true; }
duke@435 232 };
duke@435 233
duke@435 234
duke@435 235 class LongType: public ValueType {
duke@435 236 public:
duke@435 237 LongType(): ValueType(longTag, 2) {}
duke@435 238 virtual ValueType* base() const { return longType; }
duke@435 239 virtual const char tchar() const { return 'l'; }
duke@435 240 virtual const char* name() const { return "long"; }
duke@435 241 virtual LongType* as_LongType() { return this; }
duke@435 242 };
duke@435 243
duke@435 244
duke@435 245 class LongConstant: public LongType {
duke@435 246 private:
duke@435 247 jlong _value;
duke@435 248
duke@435 249 public:
duke@435 250 LongConstant(jlong value) { _value = value; }
duke@435 251
duke@435 252 jlong value() const { return _value; }
duke@435 253
duke@435 254 virtual bool is_constant() const { return true; }
duke@435 255 virtual LongConstant* as_LongConstant() { return this; }
duke@435 256 };
duke@435 257
duke@435 258
duke@435 259 class FloatType: public ValueType {
duke@435 260 public:
duke@435 261 FloatType(): ValueType(floatTag, 1) {}
duke@435 262 virtual ValueType* base() const { return floatType; }
duke@435 263 virtual const char tchar() const { return 'f'; }
duke@435 264 virtual const char* name() const { return "float"; }
duke@435 265 virtual FloatType* as_FloatType() { return this; }
duke@435 266 };
duke@435 267
duke@435 268
duke@435 269 class FloatConstant: public FloatType {
duke@435 270 private:
duke@435 271 jfloat _value;
duke@435 272
duke@435 273 public:
duke@435 274 FloatConstant(jfloat value) { _value = value; }
duke@435 275
duke@435 276 jfloat value() const { return _value; }
duke@435 277
duke@435 278 virtual bool is_constant() const { return true; }
duke@435 279 virtual FloatConstant* as_FloatConstant() { return this; }
duke@435 280 };
duke@435 281
duke@435 282
duke@435 283 class DoubleType: public ValueType {
duke@435 284 public:
duke@435 285 DoubleType(): ValueType(doubleTag, 2) {}
duke@435 286 virtual ValueType* base() const { return doubleType; }
duke@435 287 virtual const char tchar() const { return 'd'; }
duke@435 288 virtual const char* name() const { return "double"; }
duke@435 289 virtual DoubleType* as_DoubleType() { return this; }
duke@435 290 };
duke@435 291
duke@435 292
duke@435 293 class DoubleConstant: public DoubleType {
duke@435 294 private:
duke@435 295 jdouble _value;
duke@435 296
duke@435 297 public:
duke@435 298 DoubleConstant(jdouble value) { _value = value; }
duke@435 299
duke@435 300 jdouble value() const { return _value; }
duke@435 301
duke@435 302 virtual bool is_constant() const { return true; }
duke@435 303 virtual DoubleConstant* as_DoubleConstant() { return this; }
duke@435 304 };
duke@435 305
duke@435 306
duke@435 307 class ObjectType: public ValueType {
duke@435 308 public:
duke@435 309 ObjectType(): ValueType(objectTag, 1) {}
duke@435 310 virtual ValueType* base() const { return objectType; }
duke@435 311 virtual const char tchar() const { return 'a'; }
duke@435 312 virtual const char* name() const { return "object"; }
duke@435 313 virtual ObjectType* as_ObjectType() { return this; }
twisti@3969 314 virtual ciObject* constant_value() const { ShouldNotReachHere(); return NULL; }
twisti@3969 315 virtual ciType* exact_type() const { return NULL; }
duke@435 316 bool is_loaded() const;
duke@435 317 jobject encoding() const;
duke@435 318 };
duke@435 319
duke@435 320
duke@435 321 class ObjectConstant: public ObjectType {
duke@435 322 private:
duke@435 323 ciObject* _value;
duke@435 324
duke@435 325 public:
duke@435 326 ObjectConstant(ciObject* value) { _value = value; }
duke@435 327
duke@435 328 ciObject* value() const { return _value; }
duke@435 329
duke@435 330 virtual bool is_constant() const { return true; }
duke@435 331 virtual ObjectConstant* as_ObjectConstant() { return this; }
duke@435 332 virtual ciObject* constant_value() const;
twisti@3969 333 virtual ciType* exact_type() const;
duke@435 334 };
duke@435 335
duke@435 336
duke@435 337 class ArrayType: public ObjectType {
duke@435 338 public:
duke@435 339 virtual ArrayType* as_ArrayType() { return this; }
duke@435 340 };
duke@435 341
duke@435 342
duke@435 343 class ArrayConstant: public ArrayType {
duke@435 344 private:
duke@435 345 ciArray* _value;
duke@435 346
duke@435 347 public:
duke@435 348 ArrayConstant(ciArray* value) { _value = value; }
duke@435 349
duke@435 350 ciArray* value() const { return _value; }
duke@435 351
duke@435 352 virtual bool is_constant() const { return true; }
duke@435 353 virtual ArrayConstant* as_ArrayConstant() { return this; }
duke@435 354 virtual ciObject* constant_value() const;
twisti@3969 355 virtual ciType* exact_type() const;
duke@435 356 };
duke@435 357
duke@435 358
duke@435 359 class InstanceType: public ObjectType {
duke@435 360 public:
duke@435 361 virtual InstanceType* as_InstanceType() { return this; }
duke@435 362 };
duke@435 363
duke@435 364
duke@435 365 class InstanceConstant: public InstanceType {
duke@435 366 private:
duke@435 367 ciInstance* _value;
duke@435 368
duke@435 369 public:
duke@435 370 InstanceConstant(ciInstance* value) { _value = value; }
duke@435 371
duke@435 372 ciInstance* value() const { return _value; }
duke@435 373
duke@435 374 virtual bool is_constant() const { return true; }
duke@435 375 virtual InstanceConstant* as_InstanceConstant(){ return this; }
duke@435 376 virtual ciObject* constant_value() const;
twisti@3969 377 virtual ciType* exact_type() const;
duke@435 378 };
duke@435 379
duke@435 380
coleenp@4037 381 class MetadataType: public ValueType {
coleenp@4037 382 public:
coleenp@4037 383 MetadataType(): ValueType(metaDataTag, 1) {}
coleenp@4037 384 virtual ValueType* base() const { return objectType; }
coleenp@4037 385 virtual const char tchar() const { return 'a'; }
coleenp@4037 386 virtual const char* name() const { return "object"; }
coleenp@4037 387 virtual MetadataType* as_MetadataType() { return this; }
coleenp@4037 388 bool is_loaded() const;
coleenp@4037 389 jobject encoding() const;
coleenp@4037 390 virtual ciMetadata* constant_value() const { ShouldNotReachHere(); return NULL; }
coleenp@4037 391 };
coleenp@4037 392
coleenp@4037 393
coleenp@4037 394 class ClassType: public MetadataType {
duke@435 395 public:
duke@435 396 virtual ClassType* as_ClassType() { return this; }
duke@435 397 };
duke@435 398
duke@435 399
duke@435 400 class ClassConstant: public ClassType {
duke@435 401 private:
duke@435 402 ciInstanceKlass* _value;
duke@435 403
duke@435 404 public:
duke@435 405 ClassConstant(ciInstanceKlass* value) { _value = value; }
duke@435 406
duke@435 407 ciInstanceKlass* value() const { return _value; }
duke@435 408
duke@435 409 virtual bool is_constant() const { return true; }
duke@435 410 virtual ClassConstant* as_ClassConstant() { return this; }
coleenp@4037 411 virtual ciMetadata* constant_value() const { return _value; }
twisti@3969 412 virtual ciType* exact_type() const;
duke@435 413 };
duke@435 414
duke@435 415
coleenp@4037 416 class MethodType: public MetadataType {
coleenp@4037 417 public:
coleenp@4037 418 virtual MethodType* as_MethodType() { return this; }
coleenp@4037 419 };
coleenp@4037 420
coleenp@4037 421
coleenp@4037 422 class MethodConstant: public MethodType {
coleenp@4037 423 private:
coleenp@4037 424 ciMethod* _value;
coleenp@4037 425
coleenp@4037 426 public:
coleenp@4037 427 MethodConstant(ciMethod* value) { _value = value; }
coleenp@4037 428
coleenp@4037 429 ciMethod* value() const { return _value; }
coleenp@4037 430
coleenp@4037 431 virtual bool is_constant() const { return true; }
coleenp@4037 432
coleenp@4037 433 virtual MethodConstant* as_MethodConstant() { return this; }
coleenp@4037 434 virtual ciMetadata* constant_value() const { return _value; }
coleenp@4037 435 };
coleenp@4037 436
coleenp@4037 437
coleenp@4037 438 class MethodDataType: public MetadataType {
coleenp@4037 439 public:
coleenp@4037 440 virtual MethodDataType* as_MethodDataType() { return this; }
coleenp@4037 441 };
coleenp@4037 442
coleenp@4037 443
coleenp@4037 444 class MethodDataConstant: public MethodDataType {
coleenp@4037 445 private:
coleenp@4037 446 ciMethodData* _value;
coleenp@4037 447
coleenp@4037 448 public:
coleenp@4037 449 MethodDataConstant(ciMethodData* value) { _value = value; }
coleenp@4037 450
coleenp@4037 451 ciMethodData* value() const { return _value; }
coleenp@4037 452
coleenp@4037 453 virtual bool is_constant() const { return true; }
coleenp@4037 454
coleenp@4037 455 virtual MethodDataConstant* as_MethodDataConstant() { return this; }
coleenp@4037 456 virtual ciMetadata* constant_value() const { return _value; }
coleenp@4037 457 };
coleenp@4037 458
coleenp@4037 459
duke@435 460 class AddressType: public ValueType {
duke@435 461 public:
duke@435 462 AddressType(): ValueType(addressTag, 1) {}
duke@435 463 virtual ValueType* base() const { return addressType; }
duke@435 464 virtual const char tchar() const { return 'r'; }
duke@435 465 virtual const char* name() const { return "address"; }
duke@435 466 virtual AddressType* as_AddressType() { return this; }
duke@435 467 };
duke@435 468
duke@435 469
duke@435 470 class AddressConstant: public AddressType {
duke@435 471 private:
duke@435 472 jint _value;
duke@435 473
duke@435 474 public:
duke@435 475 AddressConstant(jint value) { _value = value; }
duke@435 476
duke@435 477 jint value() const { return _value; }
duke@435 478
duke@435 479 virtual bool is_constant() const { return true; }
duke@435 480
duke@435 481 virtual AddressConstant* as_AddressConstant() { return this; }
duke@435 482 };
duke@435 483
duke@435 484
duke@435 485 class IllegalType: public ValueType {
duke@435 486 public:
duke@435 487 IllegalType(): ValueType(illegalTag, -1) {}
duke@435 488 virtual ValueType* base() const { return illegalType; }
duke@435 489 virtual const char tchar() const { return ' '; }
duke@435 490 virtual const char* name() const { return "illegal"; }
duke@435 491 virtual IllegalType* as_IllegalType() { return this; }
duke@435 492 };
duke@435 493
duke@435 494
duke@435 495 // conversion between ValueTypes, BasicTypes, and ciConstants
duke@435 496 ValueType* as_ValueType(BasicType type);
duke@435 497 ValueType* as_ValueType(ciConstant value);
duke@435 498 BasicType as_BasicType(ValueType* type);
duke@435 499
duke@435 500 inline ValueType* as_ValueType(ciType* type) { return as_ValueType(type->basic_type()); }
stefank@2314 501
stefank@2314 502 #endif // SHARE_VM_C1_C1_VALUETYPE_HPP

mercurial