comparison src/share/vm/graal/graalEnv.cpp @ 7094:eec7173947a1

removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
author Doug Simon <doug.simon@oracle.com>
date Thu, 29 Nov 2012 17:13:13 +0100
parents af30115c9d0e
children 38076efb9062
comparison
equal deleted inserted replaced
7093:dff79b1f82f1 7094:eec7173947a1
43 #include "runtime/sharedRuntime.hpp" 43 #include "runtime/sharedRuntime.hpp"
44 #include "utilities/dtrace.hpp" 44 #include "utilities/dtrace.hpp"
45 #include "c1/c1_Runtime1.hpp" 45 #include "c1/c1_Runtime1.hpp"
46 46
47 // ------------------------------------------------------------------ 47 // ------------------------------------------------------------------
48 // ciEnv::check_klass_accessiblity
49 //
50 // Note: the logic of this method should mirror the logic of 48 // Note: the logic of this method should mirror the logic of
51 // constantPoolOopDesc::verify_constant_pool_resolve. 49 // constantPoolOopDesc::verify_constant_pool_resolve.
52 bool GraalEnv::check_klass_accessibility(KlassHandle accessing_klass, KlassHandle resolved_klass) { 50 bool GraalEnv::check_klass_accessibility(KlassHandle accessing_klass, KlassHandle resolved_klass) {
53 if (accessing_klass->oop_is_objArray()) { 51 if (accessing_klass->oop_is_objArray()) {
54 accessing_klass = ObjArrayKlass::cast(accessing_klass())->bottom_klass(); 52 accessing_klass = ObjArrayKlass::cast(accessing_klass())->bottom_klass();
66 } 64 }
67 return true; 65 return true;
68 } 66 }
69 67
70 // ------------------------------------------------------------------ 68 // ------------------------------------------------------------------
71 // ciEnv::get_klass_by_name_impl
72 KlassHandle GraalEnv::get_klass_by_name_impl(KlassHandle& accessing_klass, 69 KlassHandle GraalEnv::get_klass_by_name_impl(KlassHandle& accessing_klass,
73 constantPoolHandle& cpool, 70 constantPoolHandle& cpool,
74 Symbol* sym, 71 Symbol* sym,
75 bool require_local) { 72 bool require_local) {
76 EXCEPTION_CONTEXT; 73 EXCEPTION_CONTEXT;
118 // Build it on the fly if the element class exists. 115 // Build it on the fly if the element class exists.
119 TempNewSymbol elem_sym = SymbolTable::new_symbol(sym->as_utf8()+1, 116 TempNewSymbol elem_sym = SymbolTable::new_symbol(sym->as_utf8()+1,
120 sym->utf8_length()-1, 117 sym->utf8_length()-1,
121 CHECK_(KlassHandle())); 118 CHECK_(KlassHandle()));
122 119
123 // Get element ciKlass recursively. 120 // Get element Klass recursively.
124 KlassHandle elem_klass = 121 KlassHandle elem_klass =
125 get_klass_by_name_impl(accessing_klass, 122 get_klass_by_name_impl(accessing_klass,
126 cpool, 123 cpool,
127 elem_sym, 124 elem_sym,
128 require_local); 125 require_local);
146 143
147 return found_klass(); 144 return found_klass();
148 } 145 }
149 146
150 // ------------------------------------------------------------------ 147 // ------------------------------------------------------------------
151 // ciEnv::get_klass_by_name
152 KlassHandle GraalEnv::get_klass_by_name(KlassHandle& accessing_klass, 148 KlassHandle GraalEnv::get_klass_by_name(KlassHandle& accessing_klass,
153 Symbol* klass_name, 149 Symbol* klass_name,
154 bool require_local) { 150 bool require_local) {
155 ResourceMark rm; 151 ResourceMark rm;
156 constantPoolHandle cpool; 152 constantPoolHandle cpool;
159 klass_name, 155 klass_name,
160 require_local); 156 require_local);
161 } 157 }
162 158
163 // ------------------------------------------------------------------ 159 // ------------------------------------------------------------------
164 // ciEnv::get_klass_by_index_impl
165 //
166 // Implementation of get_klass_by_index. 160 // Implementation of get_klass_by_index.
167 KlassHandle GraalEnv::get_klass_by_index_impl(constantPoolHandle& cpool, 161 KlassHandle GraalEnv::get_klass_by_index_impl(constantPoolHandle& cpool,
168 int index, 162 int index,
169 bool& is_accessible, 163 bool& is_accessible,
170 KlassHandle& accessor) { 164 KlassHandle& accessor) {
220 is_accessible = true; 214 is_accessible = true;
221 return klass; 215 return klass;
222 } 216 }
223 217
224 // ------------------------------------------------------------------ 218 // ------------------------------------------------------------------
225 // ciEnv::get_klass_by_index
226 //
227 // Get a klass from the constant pool. 219 // Get a klass from the constant pool.
228 KlassHandle GraalEnv::get_klass_by_index(constantPoolHandle& cpool, 220 KlassHandle GraalEnv::get_klass_by_index(constantPoolHandle& cpool,
229 int index, 221 int index,
230 bool& is_accessible, 222 bool& is_accessible,
231 KlassHandle& accessor) { 223 KlassHandle& accessor) {
233 KlassHandle result = get_klass_by_index_impl(cpool, index, is_accessible, accessor); 225 KlassHandle result = get_klass_by_index_impl(cpool, index, is_accessible, accessor);
234 return result; 226 return result;
235 } 227 }
236 228
237 // ------------------------------------------------------------------ 229 // ------------------------------------------------------------------
238 // ciEnv::get_field_by_index_impl
239 //
240 // Implementation of get_field_by_index. 230 // Implementation of get_field_by_index.
241 // 231 //
242 // Implementation note: the results of field lookups are cached 232 // Implementation note: the results of field lookups are cached
243 // in the accessor klass. 233 // in the accessor klass.
244 void GraalEnv::get_field_by_index_impl(instanceKlassHandle& klass, fieldDescriptor& field_desc, 234 void GraalEnv::get_field_by_index_impl(instanceKlassHandle& klass, fieldDescriptor& field_desc,
255 int nt_index = cpool->name_and_type_ref_index_at(index); 245 int nt_index = cpool->name_and_type_ref_index_at(index);
256 int sig_index = cpool->signature_ref_index_at(nt_index); 246 int sig_index = cpool->signature_ref_index_at(nt_index);
257 Symbol* signature = cpool->symbol_at(sig_index); 247 Symbol* signature = cpool->symbol_at(sig_index);
258 248
259 // Get the field's declared holder. 249 // Get the field's declared holder.
260 //
261 // Note: we actually create a ciInstanceKlass for this klass,
262 // even though we may not need to.
263 int holder_index = cpool->klass_ref_index_at(index); 250 int holder_index = cpool->klass_ref_index_at(index);
264 bool holder_is_accessible; 251 bool holder_is_accessible;
265 KlassHandle declared_holder = get_klass_by_index(cpool, holder_index, 252 KlassHandle declared_holder = get_klass_by_index(cpool, holder_index,
266 holder_is_accessible, 253 holder_is_accessible,
267 klass); 254 klass);
282 269
283 assert(canonical_holder == field_desc.field_holder(), "just checking"); 270 assert(canonical_holder == field_desc.field_holder(), "just checking");
284 } 271 }
285 272
286 // ------------------------------------------------------------------ 273 // ------------------------------------------------------------------
287 // ciEnv::get_field_by_index
288 //
289 // Get a field by index from a klass's constant pool. 274 // Get a field by index from a klass's constant pool.
290 void GraalEnv::get_field_by_index(instanceKlassHandle& accessor, fieldDescriptor& fd, int index) { 275 void GraalEnv::get_field_by_index(instanceKlassHandle& accessor, fieldDescriptor& fd, int index) {
291 ResourceMark rm; 276 ResourceMark rm;
292 return get_field_by_index_impl(accessor, fd, index); 277 return get_field_by_index_impl(accessor, fd, index);
293 } 278 }
294 279
295 // ------------------------------------------------------------------ 280 // ------------------------------------------------------------------
296 // ciEnv::lookup_method
297 //
298 // Perform an appropriate method lookup based on accessor, holder, 281 // Perform an appropriate method lookup based on accessor, holder,
299 // name, signature, and bytecode. 282 // name, signature, and bytecode.
300 methodHandle GraalEnv::lookup_method(instanceKlassHandle& h_accessor, 283 methodHandle GraalEnv::lookup_method(instanceKlassHandle& h_accessor,
301 instanceKlassHandle& h_holder, 284 instanceKlassHandle& h_holder,
302 Symbol* name, 285 Symbol* name,
330 return dest_method; 313 return dest_method;
331 } 314 }
332 315
333 316
334 // ------------------------------------------------------------------ 317 // ------------------------------------------------------------------
335 // ciEnv::get_method_by_index_impl
336 methodHandle GraalEnv::get_method_by_index_impl(constantPoolHandle& cpool, 318 methodHandle GraalEnv::get_method_by_index_impl(constantPoolHandle& cpool,
337 int index, Bytecodes::Code bc, 319 int index, Bytecodes::Code bc,
338 instanceKlassHandle& accessor) { 320 instanceKlassHandle& accessor) {
339 int holder_index = cpool->klass_ref_index_at(index); 321 int holder_index = cpool->klass_ref_index_at(index);
340 bool holder_is_accessible; 322 bool holder_is_accessible;
358 return m; 340 return m;
359 } 341 }
360 } 342 }
361 343
362 // Either the declared holder was not loaded, or the method could 344 // Either the declared holder was not loaded, or the method could
363 // not be found. Create a dummy ciMethod to represent the failed 345 // not be found.
364 // lookup.
365 346
366 return NULL; 347 return NULL;
367 } 348 }
368 349
369 // ------------------------------------------------------------------ 350 // ------------------------------------------------------------------
370 // ciEnv::get_instance_klass_for_declared_method_holder
371 instanceKlassHandle GraalEnv::get_instance_klass_for_declared_method_holder(KlassHandle& method_holder) { 351 instanceKlassHandle GraalEnv::get_instance_klass_for_declared_method_holder(KlassHandle& method_holder) {
372 // For the case of <array>.clone(), the method holder can be a ciArrayKlass 352 // For the case of <array>.clone(), the method holder can be an ArrayKlass*
373 // instead of a ciInstanceKlass. For that case simply pretend that the 353 // instead of an InstanceKlass*. For that case simply pretend that the
374 // declared holder is Object.clone since that's where the call will bottom out. 354 // declared holder is Object.clone since that's where the call will bottom out.
375 // A more correct fix would trickle out through many interfaces in CI,
376 // requiring ciInstanceKlass* to become ciKlass* and many more places would
377 // require checks to make sure the expected type was found. Given that this
378 // only occurs for clone() the more extensive fix seems like overkill so
379 // instead we simply smear the array type into Object.
380 if (method_holder->oop_is_instance()) { 355 if (method_holder->oop_is_instance()) {
381 return instanceKlassHandle(method_holder()); 356 return instanceKlassHandle(method_holder());
382 } else if (method_holder->oop_is_array()) { 357 } else if (method_holder->oop_is_array()) {
383 return instanceKlassHandle(SystemDictionary::Object_klass()); 358 return instanceKlassHandle(SystemDictionary::Object_klass());
384 } else { 359 } else {
387 return NULL; 362 return NULL;
388 } 363 }
389 364
390 365
391 // ------------------------------------------------------------------ 366 // ------------------------------------------------------------------
392 // ciEnv::get_method_by_index
393 methodHandle GraalEnv::get_method_by_index(constantPoolHandle& cpool, 367 methodHandle GraalEnv::get_method_by_index(constantPoolHandle& cpool,
394 int index, Bytecodes::Code bc, 368 int index, Bytecodes::Code bc,
395 instanceKlassHandle& accessor) { 369 instanceKlassHandle& accessor) {
396 ResourceMark rm; 370 ResourceMark rm;
397 assert(bc != Bytecodes::_invokedynamic, "invokedynamic not yet supported"); 371 assert(bc != Bytecodes::_invokedynamic, "invokedynamic not yet supported");
398 return get_method_by_index_impl(cpool, index, bc, accessor); 372 return get_method_by_index_impl(cpool, index, bc, accessor);
399 } 373 }
400 374
401 // ------------------------------------------------------------------ 375 // ------------------------------------------------------------------
402 // ciEnv::check_for_system_dictionary_modification
403 // Check for changes to the system dictionary during compilation 376 // Check for changes to the system dictionary during compilation
404 // class loads, evolution, breakpoints 377 // class loads, evolution, breakpoints
405 bool GraalEnv::check_for_system_dictionary_modification(Dependencies* dependencies) { 378 bool GraalEnv::check_for_system_dictionary_modification(Dependencies* dependencies) {
406 // Dependencies must be checked when the system dictionary changes. 379 // Dependencies must be checked when the system dictionary changes.
407 // If logging is enabled all violated dependences will be recorded in 380 // If logging is enabled all violated dependences will be recorded in
425 398
426 return true; 399 return true;
427 } 400 }
428 401
429 // ------------------------------------------------------------------ 402 // ------------------------------------------------------------------
430 // ciEnv::register_method
431 GraalEnv::CodeInstallResult GraalEnv::register_method( 403 GraalEnv::CodeInstallResult GraalEnv::register_method(
432 methodHandle& method, 404 methodHandle& method,
433 nmethod*& nm, 405 nmethod*& nm,
434 int entry_bci, 406 int entry_bci,
435 CodeOffsets* offsets, 407 CodeOffsets* offsets,