Mercurial > hg > truffle
comparison src/share/vm/c1x/c1x_Compiler.hpp @ 1428:695451afc619
refactoring classes into separate files
author | Lukas Stadler <lukas.stadler@oracle.com> |
---|---|
date | Thu, 19 Aug 2010 14:34:52 -0700 |
parents | 149b1d2316de |
children | abc670a709dc |
comparison
equal
deleted
inserted
replaced
1427:149b1d2316de | 1428:695451afc619 |
---|---|
52 virtual void print_timers(); | 52 virtual void print_timers(); |
53 | 53 |
54 static oop get_RiType(ciType *klass, klassOop accessor, TRAPS); | 54 static oop get_RiType(ciType *klass, klassOop accessor, TRAPS); |
55 static oop get_RiField(ciField *ciField, TRAPS); | 55 static oop get_RiField(ciField *ciField, TRAPS); |
56 | 56 |
57 static void compute_offsets(); | |
58 | |
59 // this needs to correspond to HotSpotXirGenerator.java | |
60 enum MarkId { | |
61 MARK_VERIFIED_ENTRY = 1, | |
62 MARK_UNVERIFIED_ENTRY = 2, | |
63 MARK_OSR_ENTRY = 3, | |
64 MARK_STATIC_CALL_STUB = 1000, | |
65 MARK_INVOKE_INVALID = 2000, | |
66 MARK_INVOKEINTERFACE = 2001, | |
67 MARK_INVOKESTATIC = 2002, | |
68 MARK_INVOKESPECIAL = 2003, | |
69 MARK_INVOKEVIRTUAL = 2004 | |
70 }; | |
71 | |
72 /* | 57 /* |
73 static oop get_RiMethod(ciMethod *ciMethod, TRAPS); | 58 static oop get_RiMethod(ciMethod *ciMethod, TRAPS); |
74 static oop get_RiType(klassOop klass, TRAPS); | 59 static oop get_RiType(klassOop klass, TRAPS); |
75 static oop get_RiMethod(methodOop method, TRAPS); | 60 static oop get_RiMethod(methodOop method, TRAPS); |
76 static oop get_unresolved_RiType(oop klass, klassOop accessingType, TRAPS); | 61 static oop get_unresolved_RiType(oop klass, klassOop accessingType, TRAPS); |
77 static oop get_RiConstantPool(constantPoolOop cpOop, TRAPS); | 62 static oop get_RiConstantPool(constantPoolOop cpOop, TRAPS); |
78 */ | 63 */ |
79 }; | 64 }; |
80 | |
81 class C1XObjects : public AllStatic { | |
82 | |
83 private: | |
84 static GrowableArray<address>* _stubs; | |
85 static GrowableArray<jobject>* _localHandles; | |
86 | |
87 static oop getObject(jlong id); | |
88 | |
89 public: | |
90 // this enum needs to have the same values as the one in HotSpotProxy.java | |
91 enum CompilerObjectType { | |
92 STUB = 0x100000000000000l, | |
93 METHOD = 0x200000000000000l, | |
94 CLASS = 0x300000000000000l, | |
95 SYMBOL = 0x400000000000000l, | |
96 CONSTANT_POOL = 0x500000000000000l, | |
97 CONSTANT = 0x600000000000000l, | |
98 TYPE_MASK = 0xf00000000000000l, | |
99 DUMMY_CONSTANT = 0x6ffffffffffffffl | |
100 }; | |
101 | |
102 static void initializeObjects(); | |
103 static void cleanupLocalObjects(); | |
104 | |
105 static jlong addStub(address stub); | |
106 static jlong add(Handle obj, CompilerObjectType type); | |
107 template <typename T> static jlong add(T obj); | |
108 | |
109 static address getStub(jlong id); | |
110 template <typename T> static T get(jlong id); | |
111 | |
112 template <typename T> static T toString(symbolOop symbol, TRAPS); | |
113 static symbolOop toSymbol(jstring string); | |
114 }; | |
115 | |
116 template <> inline jlong C1XObjects::add<methodOop>(methodOop obj){ | |
117 assert(obj != NULL && obj->is_method(), "trying to add NULL or mistyped object"); | |
118 return add(Handle(obj), METHOD); | |
119 } | |
120 template <> inline jlong C1XObjects::add<klassOop>(klassOop obj) { | |
121 assert(obj != NULL && obj->is_klass(), "trying to add NULL or mistyped object"); | |
122 return add(Handle(obj), CLASS); | |
123 } | |
124 template <> inline jlong C1XObjects::add<symbolOop>(symbolOop obj) { | |
125 assert(obj != NULL && obj->is_symbol(), "trying to add NULL or mistyped object"); | |
126 return add(Handle(obj), SYMBOL); | |
127 } | |
128 template <> inline jlong C1XObjects::add<constantPoolOop>(constantPoolOop obj) { | |
129 assert(obj != NULL && obj->is_constantPool(), "trying to add NULL or mistyped object"); | |
130 return add(Handle(obj), CONSTANT_POOL); | |
131 } | |
132 template <> inline jlong C1XObjects::add<oop>(oop obj) { | |
133 assert(obj != NULL && obj->is_oop(), "trying to add NULL or mistyped object"); | |
134 return add(Handle(obj), CONSTANT); | |
135 } | |
136 | |
137 template <> inline methodOop C1XObjects::get<methodOop>(jlong id){ | |
138 assert((id & TYPE_MASK) == METHOD, "METHOD expected"); | |
139 assert(getObject(id)->is_method(), "methodOop expected"); | |
140 return (methodOop)getObject(id); | |
141 } | |
142 template <> inline klassOop C1XObjects::get<klassOop>(jlong id) { | |
143 assert((id & TYPE_MASK) == CLASS, "CLASS expected"); | |
144 assert(getObject(id)->is_klass(), "klassOop expected"); | |
145 return (klassOop)getObject(id); | |
146 } | |
147 template <> inline symbolOop C1XObjects::get<symbolOop>(jlong id) { | |
148 assert((id & TYPE_MASK) == SYMBOL, "SYMBOL expected"); | |
149 assert(getObject(id)->is_symbol(), "symbolOop expected"); | |
150 return (symbolOop)getObject(id); | |
151 } | |
152 template <> inline constantPoolOop C1XObjects::get<constantPoolOop>(jlong id) { | |
153 assert((id & TYPE_MASK) == CONSTANT_POOL, "CONSTANT_POOL expected"); | |
154 assert(getObject(id)->is_constantPool(), "constantPoolOop expected"); | |
155 return (constantPoolOop)getObject(id); | |
156 } | |
157 template <> inline oop C1XObjects::get<oop>(jlong id) { | |
158 assert((id & TYPE_MASK) == CONSTANT, "CONSTANT expected"); | |
159 assert(getObject(id)->is_oop(true), "oop expected"); | |
160 return (oop)getObject(id); | |
161 } | |
162 | |
163 template <> inline Handle C1XObjects::toString<Handle>(symbolOop symbol, TRAPS) { | |
164 return java_lang_String::create_from_symbol(symbol, THREAD); | |
165 } | |
166 template <> inline oop C1XObjects::toString<oop>(symbolOop symbol, TRAPS) { | |
167 return toString<Handle>(symbol, THREAD)(); | |
168 } | |
169 template <> inline jstring C1XObjects::toString<jstring>(symbolOop symbol, TRAPS) { | |
170 return (jstring)JNIHandles::make_local(toString<oop>(symbol, THREAD)); | |
171 } | |
172 template <> inline jobject C1XObjects::toString<jobject>(symbolOop symbol, TRAPS) { | |
173 return JNIHandles::make_local(toString<oop>(symbol, THREAD)); | |
174 } | |
175 | |
176 inline symbolOop C1XObjects::toSymbol(jstring string) { | |
177 return java_lang_String::as_symbol_or_null(JNIHandles::resolve(string)); | |
178 } | |
179 | 65 |
180 // Tracing macros | 66 // Tracing macros |
181 | 67 |
182 #define IF_TRACE_C1X_1 if (TraceC1X >= 1) | 68 #define IF_TRACE_C1X_1 if (TraceC1X >= 1) |
183 #define IF_TRACE_C1X_2 if (TraceC1X >= 2) | 69 #define IF_TRACE_C1X_2 if (TraceC1X >= 2) |
190 #define TRACE_C1X_3 if (TraceC1X >= 3) tty->print(" TraceC1X-3: "); if (TraceC1X >= 3) tty->print_cr | 76 #define TRACE_C1X_3 if (TraceC1X >= 3) tty->print(" TraceC1X-3: "); if (TraceC1X >= 3) tty->print_cr |
191 #define TRACE_C1X_4 if (TraceC1X >= 4) tty->print(" TraceC1X-4: "); if (TraceC1X >= 4) tty->print_cr | 77 #define TRACE_C1X_4 if (TraceC1X >= 4) tty->print(" TraceC1X-4: "); if (TraceC1X >= 4) tty->print_cr |
192 #define TRACE_C1X_5 if (TraceC1X >= 5) tty->print(" TraceC1X-5: "); if (TraceC1X >= 5) tty->print_cr | 78 #define TRACE_C1X_5 if (TraceC1X >= 5) tty->print(" TraceC1X-5: "); if (TraceC1X >= 5) tty->print_cr |
193 | 79 |
194 | 80 |
195 // defines the structure of the CiTargetMethod - classes | |
196 // this will generate classes with accessors similar to javaClasses.hpp | |
197 | 81 |
198 #define COMPILER_CLASSES_DO(start_class, end_class, char_field, int_field, long_field, oop_field, static_oop_field) \ | |
199 start_class(HotSpotTypeResolved) \ | |
200 long_field(HotSpotTypeResolved, vmId) \ | |
201 end_class \ | |
202 start_class(HotSpotMethod) \ | |
203 long_field(HotSpotMethod, vmId) \ | |
204 end_class \ | |
205 start_class(HotSpotTargetMethod) \ | |
206 oop_field(HotSpotTargetMethod, targetMethod, "Lcom/sun/cri/ci/CiTargetMethod;") \ | |
207 oop_field(HotSpotTargetMethod, method, "Lcom/sun/hotspot/c1x/HotSpotMethod;") \ | |
208 oop_field(HotSpotTargetMethod, name, "Ljava/lang/String;") \ | |
209 oop_field(HotSpotTargetMethod, sites, "[Lcom/sun/cri/ci/CiTargetMethod$Site;") \ | |
210 end_class \ | |
211 start_class(CiTargetMethod) \ | |
212 int_field(CiTargetMethod, frameSize) \ | |
213 oop_field(CiTargetMethod, targetCode, "[B") \ | |
214 int_field(CiTargetMethod, targetCodeSize) \ | |
215 int_field(CiTargetMethod, referenceRegisterCount) \ | |
216 end_class \ | |
217 start_class(CiTargetMethod_Site) \ | |
218 int_field(CiTargetMethod_Site, pcOffset) \ | |
219 end_class \ | |
220 start_class(CiTargetMethod_Call) \ | |
221 oop_field(CiTargetMethod_Call, runtimeCall, "Lcom/sun/cri/ci/CiRuntimeCall;") \ | |
222 oop_field(CiTargetMethod_Call, method, "Lcom/sun/cri/ri/RiMethod;") \ | |
223 oop_field(CiTargetMethod_Call, symbol, "Ljava/lang/String;") \ | |
224 oop_field(CiTargetMethod_Call, globalStubID, "Ljava/lang/Object;") \ | |
225 oop_field(CiTargetMethod_Call, debugInfo, "Lcom/sun/cri/ci/CiDebugInfo;") \ | |
226 oop_field(CiTargetMethod_Call, stackMap, "[B") \ | |
227 oop_field(CiTargetMethod_Call, registerMap, "[B") \ | |
228 end_class \ | |
229 start_class(CiTargetMethod_DataPatch) \ | |
230 oop_field(CiTargetMethod_DataPatch, constant, "Lcom/sun/cri/ci/CiConstant;") \ | |
231 end_class \ | |
232 start_class(CiTargetMethod_Safepoint) \ | |
233 oop_field(CiTargetMethod_Safepoint, debugInfo, "Lcom/sun/cri/ci/CiDebugInfo;") \ | |
234 end_class \ | |
235 start_class(CiTargetMethod_ExceptionHandler) \ | |
236 int_field(CiTargetMethod_ExceptionHandler, handlerPos) \ | |
237 oop_field(CiTargetMethod_ExceptionHandler, exceptionType, "Lcom/sun/cri/ri/RiType;")\ | |
238 end_class \ | |
239 start_class(CiTargetMethod_Mark) \ | |
240 oop_field(CiTargetMethod_Mark, id, "Ljava/lang/Object;") \ | |
241 oop_field(CiTargetMethod_Mark, references, "[Lcom/sun/cri/ci/CiTargetMethod$Mark;") \ | |
242 end_class \ | |
243 start_class(CiDebugInfo) \ | |
244 oop_field(CiDebugInfo, codePos, "Lcom/sun/cri/ci/CiCodePos;") \ | |
245 oop_field(CiDebugInfo, frame, "Lcom/sun/cri/ci/CiDebugInfo$Frame;") \ | |
246 oop_field(CiDebugInfo, registerRefMap, "[B") \ | |
247 oop_field(CiDebugInfo, frameRefMap, "[B") \ | |
248 end_class \ | |
249 start_class(CiDebugInfo_Frame) \ | |
250 oop_field(CiDebugInfo_Frame, caller, "Lcom/sun/cri/ci/CiDebugInfo$Frame;") \ | |
251 oop_field(CiDebugInfo_Frame, codePos, "Lcom/sun/cri/ci/CiCodePos;") \ | |
252 oop_field(CiDebugInfo_Frame, values, "[Lcom/sun/cri/ci/CiValue;") \ | |
253 int_field(CiDebugInfo_Frame, numLocals) \ | |
254 int_field(CiDebugInfo_Frame, numStack) \ | |
255 int_field(CiDebugInfo_Frame, numLocks) \ | |
256 end_class \ | |
257 start_class(CiCodePos) \ | |
258 oop_field(CiCodePos, caller, "Lcom/sun/cri/ci/CiCodePos;") \ | |
259 oop_field(CiCodePos, method, "Lcom/sun/cri/ri/RiMethod;") \ | |
260 int_field(CiCodePos, bci) \ | |
261 end_class \ | |
262 start_class(CiConstant) \ | |
263 oop_field(CiConstant, kind, "Lcom/sun/cri/ci/CiKind;") \ | |
264 oop_field(CiConstant, object, "Ljava/lang/Object;") \ | |
265 long_field(CiConstant, primitive) \ | |
266 end_class \ | |
267 start_class(CiKind) \ | |
268 char_field(CiKind, typeChar) \ | |
269 end_class \ | |
270 start_class(CiRuntimeCall) \ | |
271 static_oop_field(CiRuntimeCall, Debug, "Lcom/sun/cri/ci/CiRuntimeCall;"); \ | |
272 end_class \ | |
273 start_class(RiMethod) \ | |
274 end_class \ | |
275 start_class(CiRegisterValue) \ | |
276 end_class \ | |
277 start_class(CiStackSlot) \ | |
278 end_class \ | |
279 /* end*/ | |
280 | |
281 #define START_CLASS(name) \ | |
282 class name : AllStatic { \ | |
283 private: \ | |
284 friend class C1XCompiler; \ | |
285 static void check(oop obj) { assert(obj != NULL, "NULL field access"); assert(obj->is_a(SystemDictionary::name##_klass()), "wrong class, " #name " expected"); } \ | |
286 static void compute_offsets(); \ | |
287 public: \ | |
288 static klassOop klass() { return SystemDictionary::name##_klass(); } | |
289 | |
290 #define END_CLASS }; | |
291 | |
292 #define FIELD(name, type, accessor) \ | |
293 static int _##name##_offset; \ | |
294 static type name(oop obj) { check(obj); return obj->accessor(_##name##_offset); } \ | |
295 static type name(jobject obj) { check(JNIHandles::resolve(obj)); return JNIHandles::resolve(obj)->accessor(_##name##_offset); } \ | |
296 static void set_##name(oop obj, type x) { check(obj); obj->accessor##_put(_##name##_offset, x); } \ | |
297 static void set_##name(jobject obj, type x) { check(JNIHandles::resolve(obj)); JNIHandles::resolve(obj)->accessor##_put(_##name##_offset, x); } | |
298 | |
299 #define CHAR_FIELD(klass, name) FIELD(name, jchar, char_field) | |
300 #define INT_FIELD(klass, name) FIELD(name, jint, int_field) | |
301 #define LONG_FIELD(klass, name) FIELD(name, jlong, long_field) | |
302 #define OOP_FIELD(klass, name, signature) FIELD(name, oop, obj_field) | |
303 #define STATIC_OOP_FIELD(klassName, name, signature) \ | |
304 static int _##name##_offset; \ | |
305 static oop name() { return klassName::klass()->obj_field(_##name##_offset); } \ | |
306 static void set_##name(oop x) { klassName::klass()->obj_field_put(_##name##_offset, x); } | |
307 | |
308 COMPILER_CLASSES_DO(START_CLASS, END_CLASS, CHAR_FIELD, INT_FIELD, LONG_FIELD, OOP_FIELD, STATIC_OOP_FIELD) | |
309 #undef START_CLASS | |
310 #undef END_CLASS | |
311 #undef FIELD | |
312 #undef CHAR_FIELD | |
313 #undef INT_FIELD | |
314 #undef LONG_FIELD | |
315 #undef OOP_FIELD | |
316 #undef STATIC_OOP_FIELD | |
317 | |
318 |