Print this page
rev 1026 : imported patch indy.compiler.inline.patch
Split |
Close |
Expand all |
Collapse all |
--- old/src/share/vm/ci/ciField.hpp
+++ new/src/share/vm/ci/ciField.hpp
1 1 /*
2 2 * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation.
8 8 *
9 9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 12 * version 2 for more details (a copy is included in the LICENSE file that
13 13 * accompanied this code).
14 14 *
15 15 * You should have received a copy of the GNU General Public License version
16 16 * 2 along with this work; if not, write to the Free Software Foundation,
17 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 18 *
19 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 21 * have any questions.
22 22 *
23 23 */
24 24
25 25 // ciField
26 26 //
27 27 // This class represents the result of a field lookup in the VM.
28 28 // The lookup may not succeed, in which case the information in
29 29 // the ciField will be incomplete.
30 30 class ciField : public ResourceObj {
31 31 CI_PACKAGE_ACCESS
32 32 friend class ciEnv;
33 33 friend class ciInstanceKlass;
34 34 friend class NonStaticFieldFiller;
35 35
36 36 private:
37 37 ciFlags _flags;
38 38 ciInstanceKlass* _holder;
39 39 ciSymbol* _name;
40 40 ciSymbol* _signature;
41 41 ciType* _type;
42 42 int _offset;
43 43 bool _is_constant;
44 44 ciInstanceKlass* _known_to_link_with;
45 45 ciConstant _constant_value;
46 46
47 47 // Used for will_link
48 48 int _cp_index;
49 49
50 50 ciType* compute_type();
51 51 ciType* compute_type_impl();
52 52
53 53 ciField(ciInstanceKlass* klass, int index);
54 54 ciField(fieldDescriptor* fd);
55 55
56 56 // shared constructor code
57 57 void initialize_from(fieldDescriptor* fd);
58 58
59 59 // The implementation of the print method.
60 60 void print_impl(outputStream* st);
61 61
62 62 public:
63 63 ciFlags flags() { return _flags; }
64 64
65 65 // Of which klass is this field a member?
66 66 //
67 67 // Usage note: the declared holder of a field is the class
68 68 // referenced by name in the bytecodes. The canonical holder
69 69 // is the most general class which holds the field. This
70 70 // method returns the canonical holder. The declared holder
71 71 // can be accessed via a method in ciBytecodeStream.
72 72 //
73 73 // Ex.
74 74 // class A {
75 75 // public int f = 7;
76 76 // }
77 77 // class B extends A {
78 78 // public void test() {
79 79 // System.out.println(f);
80 80 // }
81 81 // }
82 82 //
83 83 // A java compiler is permitted to compile the access to
84 84 // field f as:
85 85 //
86 86 // getfield B.f
87 87 //
88 88 // In that case the declared holder of f would be B and
89 89 // the canonical holder of f would be A.
90 90 ciInstanceKlass* holder() { return _holder; }
91 91
92 92 // Name of this field?
93 93 ciSymbol* name() { return _name; }
94 94
95 95 // Signature of this field?
96 96 ciSymbol* signature() { return _signature; }
97 97
98 98 // Of what type is this field?
99 99 ciType* type() { return (_type == NULL) ? compute_type() : _type; }
100 100
101 101 // How is this field actually stored in memory?
102 102 BasicType layout_type() { return type2field[(_type == NULL) ? T_OBJECT : _type->basic_type()]; }
103 103
104 104 // How big is this field in memory?
105 105 int size_in_bytes() { return type2aelembytes(layout_type()); }
106 106
107 107 // What is the offset of this field?
108 108 int offset() {
109 109 assert(_offset >= 1, "illegal call to offset()");
110 110 return _offset;
111 111 }
112 112
113 113 // Same question, explicit units. (Fields are aligned to the byte level.)
114 114 int offset_in_bytes() {
115 115 return offset();
116 116 }
117 117
118 118 // Is this field shared?
119 119 bool is_shared() {
120 120 // non-static fields of shared holders are cached
121 121 return _holder->is_shared() && !is_static();
122 122 }
123 123
124 124 // Is this field a constant?
125 125 //
126 126 // Clarification: A field is considered constant if:
127 127 // 1. The field is both static and final
128 128 // 2. The canonical holder of the field has undergone
129 129 // static initialization.
130 130 // 3. If the field is an object or array, then the oop
↓ open down ↓ |
130 lines elided |
↑ open up ↑ |
131 131 // in question is allocated in perm space.
132 132 // 4. The field is not one of the special static/final
133 133 // non-constant fields. These are java.lang.System.in
134 134 // and java.lang.System.out. Abomination.
135 135 //
136 136 // Note: the check for case 4 is not yet implemented.
137 137 bool is_constant() { return _is_constant; }
138 138
139 139 // Get the constant value of this field.
140 140 ciConstant constant_value() {
141 - assert(is_constant(), "illegal call to constant_value()");
141 + assert(is_static() && is_constant(), "illegal call to constant_value()");
142 142 return _constant_value;
143 143 }
144 144
145 + // Get the constant value of non-static final field in the given
146 + // object.
147 + ciConstant constant_value_of(ciObject* object) {
148 + assert(!is_static() && is_constant(), "only if field is non-static constant");
149 + assert(object->is_instance(), "must be instance");
150 + return object->as_instance()->field_value(this);
151 + }
152 +
145 153 // Check for link time errors. Accessing a field from a
146 154 // certain class via a certain bytecode may or may not be legal.
147 155 // This call checks to see if an exception may be raised by
148 156 // an access of this field.
149 157 //
150 158 // Usage note: if the same field is accessed multiple times
151 159 // in the same compilation, will_link will need to be checked
152 160 // at each point of access.
153 161 bool will_link(ciInstanceKlass* accessing_klass,
154 162 Bytecodes::Code bc);
155 163
156 164 // Java access flags
157 165 bool is_public () { return flags().is_public(); }
158 166 bool is_private () { return flags().is_private(); }
159 167 bool is_protected () { return flags().is_protected(); }
160 168 bool is_static () { return flags().is_static(); }
161 169 bool is_final () { return flags().is_final(); }
162 170 bool is_volatile () { return flags().is_volatile(); }
163 171 bool is_transient () { return flags().is_transient(); }
164 172
165 173 // Debugging output
166 174 void print();
167 175 void print_name_on(outputStream* st);
168 176 };
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX