Mercurial > hg > graal-compiler
annotate src/share/vm/ci/ciConstant.hpp @ 3650:0e8a2a629afb
Pass-by compilation broker.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Wed, 16 Nov 2011 21:27:28 +0100 |
parents | f95d63e2154a |
children | c124e2e7463e |
rev | line source |
---|---|
0 | 1 /* |
1972 | 2 * Copyright (c) 1999, 2010, 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 { | |
35 private: | |
36 friend class ciEnv; | |
37 friend class ciField; | |
38 | |
39 BasicType _type; | |
40 union { | |
41 jint _int; | |
42 jlong _long; | |
43 jint _long_half[2]; | |
44 jfloat _float; | |
45 jdouble _double; | |
46 ciObject* _object; | |
47 } _value; | |
48 | |
49 // Implementation of the print method. | |
50 void print_impl(outputStream* st); | |
51 | |
52 public: | |
53 | |
54 ciConstant() { | |
55 _type = T_ILLEGAL; _value._long = -1; | |
56 } | |
57 ciConstant(BasicType type, jint value) { | |
58 assert(type != T_LONG && type != T_DOUBLE && type != T_FLOAT, | |
59 "using the wrong ciConstant constructor"); | |
60 _type = type; _value._int = value; | |
61 } | |
62 ciConstant(jlong value) { | |
63 _type = T_LONG; _value._long = value; | |
64 } | |
65 ciConstant(jfloat value) { | |
66 _type = T_FLOAT; _value._float = value; | |
67 } | |
68 ciConstant(jdouble value) { | |
69 _type = T_DOUBLE; _value._double = value; | |
70 } | |
71 ciConstant(BasicType type, ciObject* p) { | |
72 _type = type; _value._object = p; | |
73 } | |
74 | |
75 BasicType basic_type() const { return _type; } | |
76 | |
77 jboolean as_boolean() { | |
78 assert(basic_type() == T_BOOLEAN, "wrong type"); | |
79 return (jboolean)_value._int; | |
80 } | |
81 jchar as_char() { | |
82 assert(basic_type() == T_CHAR, "wrong type"); | |
83 return (jchar)_value._int; | |
84 } | |
85 jbyte as_byte() { | |
86 assert(basic_type() == T_BYTE, "wrong type"); | |
87 return (jbyte)_value._int; | |
88 } | |
89 jshort as_short() { | |
90 assert(basic_type() == T_SHORT, "wrong type"); | |
91 return (jshort)_value._int; | |
92 } | |
93 jint as_int() { | |
94 assert(basic_type() == T_BOOLEAN || basic_type() == T_CHAR || | |
95 basic_type() == T_BYTE || basic_type() == T_SHORT || | |
96 basic_type() == T_INT, "wrong type"); | |
97 return _value._int; | |
98 } | |
99 jlong as_long() { | |
100 assert(basic_type() == T_LONG, "wrong type"); | |
101 return _value._long; | |
102 } | |
103 jfloat as_float() { | |
104 assert(basic_type() == T_FLOAT, "wrong type"); | |
105 return _value._float; | |
106 } | |
107 jdouble as_double() { | |
108 assert(basic_type() == T_DOUBLE, "wrong type"); | |
109 return _value._double; | |
110 } | |
111 ciObject* as_object() const { | |
112 assert(basic_type() == T_OBJECT || basic_type() == T_ARRAY, "wrong type"); | |
113 return _value._object; | |
114 } | |
115 | |
116 // Debugging output | |
117 void print(); | |
118 }; | |
1972 | 119 |
120 #endif // SHARE_VM_CI_CICONSTANT_HPP |