Mercurial > hg > truffle
annotate src/share/vm/ci/ciConstant.hpp @ 13046:613e6a6fc328
Merge
author | iveresov |
---|---|
date | Tue, 05 Nov 2013 02:29:41 -0800 |
parents | edb5ab0f3fe5 |
children | de6a9e811145 |
rev | line source |
---|---|
0 | 1 /* |
3939 | 2 * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_CI_CICONSTANT_HPP |
26 #define SHARE_VM_CI_CICONSTANT_HPP | |
27 | |
28 #include "ci/ciClassList.hpp" | |
29 #include "ci/ciNullObject.hpp" | |
30 | |
0 | 31 // ciConstant |
32 // | |
33 // This class represents a constant value. | |
34 class ciConstant VALUE_OBJ_CLASS_SPEC { | |
3939 | 35 friend class VMStructs; |
0 | 36 private: |
37 friend class ciEnv; | |
38 friend class ciField; | |
39 | |
40 BasicType _type; | |
41 union { | |
42 jint _int; | |
43 jlong _long; | |
44 jfloat _float; | |
45 jdouble _double; | |
46 ciObject* _object; | |
47 } _value; | |
48 | |
49 public: | |
50 | |
51 ciConstant() { | |
52 _type = T_ILLEGAL; _value._long = -1; | |
53 } | |
54 ciConstant(BasicType type, jint value) { | |
55 assert(type != T_LONG && type != T_DOUBLE && type != T_FLOAT, | |
56 "using the wrong ciConstant constructor"); | |
57 _type = type; _value._int = value; | |
58 } | |
59 ciConstant(jlong value) { | |
60 _type = T_LONG; _value._long = value; | |
61 } | |
62 ciConstant(jfloat value) { | |
63 _type = T_FLOAT; _value._float = value; | |
64 } | |
65 ciConstant(jdouble value) { | |
66 _type = T_DOUBLE; _value._double = value; | |
67 } | |
68 ciConstant(BasicType type, ciObject* p) { | |
69 _type = type; _value._object = p; | |
70 } | |
71 | |
72 BasicType basic_type() const { return _type; } | |
73 | |
74 jboolean as_boolean() { | |
75 assert(basic_type() == T_BOOLEAN, "wrong type"); | |
76 return (jboolean)_value._int; | |
77 } | |
78 jchar as_char() { | |
79 assert(basic_type() == T_CHAR, "wrong type"); | |
80 return (jchar)_value._int; | |
81 } | |
82 jbyte as_byte() { | |
83 assert(basic_type() == T_BYTE, "wrong type"); | |
84 return (jbyte)_value._int; | |
85 } | |
86 jshort as_short() { | |
87 assert(basic_type() == T_SHORT, "wrong type"); | |
88 return (jshort)_value._int; | |
89 } | |
90 jint as_int() { | |
91 assert(basic_type() == T_BOOLEAN || basic_type() == T_CHAR || | |
92 basic_type() == T_BYTE || basic_type() == T_SHORT || | |
93 basic_type() == T_INT, "wrong type"); | |
94 return _value._int; | |
95 } | |
96 jlong as_long() { | |
97 assert(basic_type() == T_LONG, "wrong type"); | |
98 return _value._long; | |
99 } | |
100 jfloat as_float() { | |
101 assert(basic_type() == T_FLOAT, "wrong type"); | |
102 return _value._float; | |
103 } | |
104 jdouble as_double() { | |
105 assert(basic_type() == T_DOUBLE, "wrong type"); | |
106 return _value._double; | |
107 } | |
108 ciObject* as_object() const { | |
109 assert(basic_type() == T_OBJECT || basic_type() == T_ARRAY, "wrong type"); | |
110 return _value._object; | |
111 } | |
112 | |
12190
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
3939
diff
changeset
|
113 bool is_null_or_zero() const { |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
3939
diff
changeset
|
114 if (!is_java_primitive(basic_type())) { |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
3939
diff
changeset
|
115 return as_object()->is_null_object(); |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
3939
diff
changeset
|
116 } else if (type2size[basic_type()] == 1) { |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
3939
diff
changeset
|
117 // treat float bits as int, to avoid comparison with -0 and NaN |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
3939
diff
changeset
|
118 return (_value._int == 0); |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
3939
diff
changeset
|
119 } else if (type2size[basic_type()] == 2) { |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
3939
diff
changeset
|
120 // treat double bits as long, to avoid comparison with -0 and NaN |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
3939
diff
changeset
|
121 return (_value._long == 0); |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
3939
diff
changeset
|
122 } else { |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
3939
diff
changeset
|
123 return false; |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
3939
diff
changeset
|
124 } |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
3939
diff
changeset
|
125 } |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
3939
diff
changeset
|
126 |
0 | 127 // Debugging output |
128 void print(); | |
129 }; | |
1972 | 130 |
131 #endif // SHARE_VM_CI_CICONSTANT_HPP |