Mercurial > hg > graal-compiler
annotate src/share/vm/ci/ciConstant.hpp @ 1751:2528b5bd749c
6980262: Memory leak when exception is thrown in static initializer
Summary: Use resource memory instead of c-heap for the exception message
Reviewed-by: phh, jmasa
author | kamg |
---|---|
date | Fri, 27 Aug 2010 15:05:28 -0400 |
parents | c18cbe5936b8 |
children | f95d63e2154a |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
2 * Copyright (c) 1999, 2003, 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 | |
25 // ciConstant | |
26 // | |
27 // This class represents a constant value. | |
28 class ciConstant VALUE_OBJ_CLASS_SPEC { | |
29 private: | |
30 friend class ciEnv; | |
31 friend class ciField; | |
32 | |
33 BasicType _type; | |
34 union { | |
35 jint _int; | |
36 jlong _long; | |
37 jint _long_half[2]; | |
38 jfloat _float; | |
39 jdouble _double; | |
40 ciObject* _object; | |
41 } _value; | |
42 | |
43 // Implementation of the print method. | |
44 void print_impl(outputStream* st); | |
45 | |
46 public: | |
47 | |
48 ciConstant() { | |
49 _type = T_ILLEGAL; _value._long = -1; | |
50 } | |
51 ciConstant(BasicType type, jint value) { | |
52 assert(type != T_LONG && type != T_DOUBLE && type != T_FLOAT, | |
53 "using the wrong ciConstant constructor"); | |
54 _type = type; _value._int = value; | |
55 } | |
56 ciConstant(jlong value) { | |
57 _type = T_LONG; _value._long = value; | |
58 } | |
59 ciConstant(jfloat value) { | |
60 _type = T_FLOAT; _value._float = value; | |
61 } | |
62 ciConstant(jdouble value) { | |
63 _type = T_DOUBLE; _value._double = value; | |
64 } | |
65 ciConstant(BasicType type, ciObject* p) { | |
66 _type = type; _value._object = p; | |
67 } | |
68 | |
69 BasicType basic_type() const { return _type; } | |
70 | |
71 jboolean as_boolean() { | |
72 assert(basic_type() == T_BOOLEAN, "wrong type"); | |
73 return (jboolean)_value._int; | |
74 } | |
75 jchar as_char() { | |
76 assert(basic_type() == T_CHAR, "wrong type"); | |
77 return (jchar)_value._int; | |
78 } | |
79 jbyte as_byte() { | |
80 assert(basic_type() == T_BYTE, "wrong type"); | |
81 return (jbyte)_value._int; | |
82 } | |
83 jshort as_short() { | |
84 assert(basic_type() == T_SHORT, "wrong type"); | |
85 return (jshort)_value._int; | |
86 } | |
87 jint as_int() { | |
88 assert(basic_type() == T_BOOLEAN || basic_type() == T_CHAR || | |
89 basic_type() == T_BYTE || basic_type() == T_SHORT || | |
90 basic_type() == T_INT, "wrong type"); | |
91 return _value._int; | |
92 } | |
93 jlong as_long() { | |
94 assert(basic_type() == T_LONG, "wrong type"); | |
95 return _value._long; | |
96 } | |
97 jfloat as_float() { | |
98 assert(basic_type() == T_FLOAT, "wrong type"); | |
99 return _value._float; | |
100 } | |
101 jdouble as_double() { | |
102 assert(basic_type() == T_DOUBLE, "wrong type"); | |
103 return _value._double; | |
104 } | |
105 ciObject* as_object() const { | |
106 assert(basic_type() == T_OBJECT || basic_type() == T_ARRAY, "wrong type"); | |
107 return _value._object; | |
108 } | |
109 | |
110 // Debugging output | |
111 void print(); | |
112 }; |