src/share/vm/ci/ciConstant.hpp

Wed, 23 Oct 2013 12:40:23 +0200

author
roland
date
Wed, 23 Oct 2013 12:40:23 +0200
changeset 5991
b2ee5dc63353
parent 5658
edb5ab0f3fe5
child 6198
55fb97c4c58d
permissions
-rw-r--r--

8024070: C2 needs some form of type speculation
Summary: record unused type profile information with type system, propagate and use it.
Reviewed-by: kvn, twisti

duke@435 1 /*
never@3138 2 * Copyright (c) 1999, 2011, 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_CI_CICONSTANT_HPP
stefank@2314 26 #define SHARE_VM_CI_CICONSTANT_HPP
stefank@2314 27
stefank@2314 28 #include "ci/ciClassList.hpp"
stefank@2314 29 #include "ci/ciNullObject.hpp"
stefank@2314 30
duke@435 31 // ciConstant
duke@435 32 //
duke@435 33 // This class represents a constant value.
duke@435 34 class ciConstant VALUE_OBJ_CLASS_SPEC {
never@3138 35 friend class VMStructs;
duke@435 36 private:
duke@435 37 friend class ciEnv;
duke@435 38 friend class ciField;
duke@435 39
duke@435 40 BasicType _type;
duke@435 41 union {
duke@435 42 jint _int;
duke@435 43 jlong _long;
duke@435 44 jfloat _float;
duke@435 45 jdouble _double;
duke@435 46 ciObject* _object;
duke@435 47 } _value;
duke@435 48
duke@435 49 public:
duke@435 50
duke@435 51 ciConstant() {
duke@435 52 _type = T_ILLEGAL; _value._long = -1;
duke@435 53 }
duke@435 54 ciConstant(BasicType type, jint value) {
duke@435 55 assert(type != T_LONG && type != T_DOUBLE && type != T_FLOAT,
duke@435 56 "using the wrong ciConstant constructor");
duke@435 57 _type = type; _value._int = value;
duke@435 58 }
duke@435 59 ciConstant(jlong value) {
duke@435 60 _type = T_LONG; _value._long = value;
duke@435 61 }
duke@435 62 ciConstant(jfloat value) {
duke@435 63 _type = T_FLOAT; _value._float = value;
duke@435 64 }
duke@435 65 ciConstant(jdouble value) {
duke@435 66 _type = T_DOUBLE; _value._double = value;
duke@435 67 }
duke@435 68 ciConstant(BasicType type, ciObject* p) {
duke@435 69 _type = type; _value._object = p;
duke@435 70 }
duke@435 71
duke@435 72 BasicType basic_type() const { return _type; }
duke@435 73
duke@435 74 jboolean as_boolean() {
duke@435 75 assert(basic_type() == T_BOOLEAN, "wrong type");
duke@435 76 return (jboolean)_value._int;
duke@435 77 }
duke@435 78 jchar as_char() {
duke@435 79 assert(basic_type() == T_CHAR, "wrong type");
duke@435 80 return (jchar)_value._int;
duke@435 81 }
duke@435 82 jbyte as_byte() {
duke@435 83 assert(basic_type() == T_BYTE, "wrong type");
duke@435 84 return (jbyte)_value._int;
duke@435 85 }
duke@435 86 jshort as_short() {
duke@435 87 assert(basic_type() == T_SHORT, "wrong type");
duke@435 88 return (jshort)_value._int;
duke@435 89 }
duke@435 90 jint as_int() {
duke@435 91 assert(basic_type() == T_BOOLEAN || basic_type() == T_CHAR ||
duke@435 92 basic_type() == T_BYTE || basic_type() == T_SHORT ||
duke@435 93 basic_type() == T_INT, "wrong type");
duke@435 94 return _value._int;
duke@435 95 }
duke@435 96 jlong as_long() {
duke@435 97 assert(basic_type() == T_LONG, "wrong type");
duke@435 98 return _value._long;
duke@435 99 }
duke@435 100 jfloat as_float() {
duke@435 101 assert(basic_type() == T_FLOAT, "wrong type");
duke@435 102 return _value._float;
duke@435 103 }
duke@435 104 jdouble as_double() {
duke@435 105 assert(basic_type() == T_DOUBLE, "wrong type");
duke@435 106 return _value._double;
duke@435 107 }
duke@435 108 ciObject* as_object() const {
duke@435 109 assert(basic_type() == T_OBJECT || basic_type() == T_ARRAY, "wrong type");
duke@435 110 return _value._object;
duke@435 111 }
duke@435 112
vlivanov@5658 113 bool is_null_or_zero() const {
vlivanov@5658 114 if (!is_java_primitive(basic_type())) {
vlivanov@5658 115 return as_object()->is_null_object();
vlivanov@5658 116 } else if (type2size[basic_type()] == 1) {
vlivanov@5658 117 // treat float bits as int, to avoid comparison with -0 and NaN
vlivanov@5658 118 return (_value._int == 0);
vlivanov@5658 119 } else if (type2size[basic_type()] == 2) {
vlivanov@5658 120 // treat double bits as long, to avoid comparison with -0 and NaN
vlivanov@5658 121 return (_value._long == 0);
vlivanov@5658 122 } else {
vlivanov@5658 123 return false;
vlivanov@5658 124 }
vlivanov@5658 125 }
vlivanov@5658 126
duke@435 127 // Debugging output
duke@435 128 void print();
duke@435 129 };
stefank@2314 130
stefank@2314 131 #endif // SHARE_VM_CI_CICONSTANT_HPP

mercurial