Mercurial > hg > graal-jvmci-8
comparison src/share/vm/graal/graalEnv.cpp @ 6948:e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 12 Nov 2012 23:14:12 +0100 |
parents | 957c266d8bc5 |
children | 2afd99933ae6 |
comparison
equal
deleted
inserted
replaced
6711:ae13cc658b80 | 6948:e522a00b91aa |
---|---|
33 #include "compiler/compilerOracle.hpp" | 33 #include "compiler/compilerOracle.hpp" |
34 #include "interpreter/linkResolver.hpp" | 34 #include "interpreter/linkResolver.hpp" |
35 #include "memory/allocation.inline.hpp" | 35 #include "memory/allocation.inline.hpp" |
36 #include "memory/oopFactory.hpp" | 36 #include "memory/oopFactory.hpp" |
37 #include "memory/universe.inline.hpp" | 37 #include "memory/universe.inline.hpp" |
38 #include "oops/methodDataOop.hpp" | 38 #include "oops/methodData.hpp" |
39 #include "oops/objArrayKlass.hpp" | 39 #include "oops/objArrayKlass.hpp" |
40 #include "prims/jvmtiExport.hpp" | 40 #include "prims/jvmtiExport.hpp" |
41 #include "runtime/init.hpp" | 41 #include "runtime/init.hpp" |
42 #include "runtime/reflection.hpp" | 42 #include "runtime/reflection.hpp" |
43 #include "runtime/sharedRuntime.hpp" | 43 #include "runtime/sharedRuntime.hpp" |
49 // | 49 // |
50 // Note: the logic of this method should mirror the logic of | 50 // Note: the logic of this method should mirror the logic of |
51 // constantPoolOopDesc::verify_constant_pool_resolve. | 51 // constantPoolOopDesc::verify_constant_pool_resolve. |
52 bool GraalEnv::check_klass_accessibility(KlassHandle accessing_klass, KlassHandle resolved_klass) { | 52 bool GraalEnv::check_klass_accessibility(KlassHandle accessing_klass, KlassHandle resolved_klass) { |
53 if (accessing_klass->oop_is_objArray()) { | 53 if (accessing_klass->oop_is_objArray()) { |
54 accessing_klass = objArrayKlass::cast(accessing_klass())->bottom_klass(); | 54 accessing_klass = ObjArrayKlass::cast(accessing_klass())->bottom_klass(); |
55 } | 55 } |
56 if (!accessing_klass->oop_is_instance()) { | 56 if (!accessing_klass->oop_is_instance()) { |
57 return true; | 57 return true; |
58 } | 58 } |
59 | 59 |
60 if (resolved_klass->oop_is_objArray()) { | 60 if (resolved_klass->oop_is_objArray()) { |
61 // Find the element klass, if this is an array. | 61 // Find the element klass, if this is an array. |
62 resolved_klass = objArrayKlass::cast(resolved_klass())->bottom_klass(); | 62 resolved_klass = ObjArrayKlass::cast(resolved_klass())->bottom_klass(); |
63 } | 63 } |
64 if (resolved_klass->oop_is_instance()) { | 64 if (resolved_klass->oop_is_instance()) { |
65 return Reflection::verify_class_access(accessing_klass(), resolved_klass(), true); | 65 return Reflection::verify_class_access(accessing_klass(), resolved_klass(), true); |
66 } | 66 } |
67 return true; | 67 return true; |
95 | 95 |
96 KlassHandle found_klass; | 96 KlassHandle found_klass; |
97 { | 97 { |
98 ttyUnlocker ttyul; // release tty lock to avoid ordering problems | 98 ttyUnlocker ttyul; // release tty lock to avoid ordering problems |
99 MutexLocker ml(Compile_lock); | 99 MutexLocker ml(Compile_lock); |
100 klassOop kls; | 100 Klass* kls; |
101 if (!require_local) { | 101 if (!require_local) { |
102 kls = SystemDictionary::find_constrained_instance_or_array_klass(sym, loader, CHECK_(KlassHandle())); | 102 kls = SystemDictionary::find_constrained_instance_or_array_klass(sym, loader, CHECK_(KlassHandle())); |
103 } else { | 103 } else { |
104 kls = SystemDictionary::find_instance_or_array_klass(sym, loader, domain, CHECK_(KlassHandle())); | 104 kls = SystemDictionary::find_instance_or_array_klass(sym, loader, domain, CHECK_(KlassHandle())); |
105 } | 105 } |
134 | 134 |
135 if (found_klass.is_null() && !cpool.is_null() && cpool->has_preresolution()) { | 135 if (found_klass.is_null() && !cpool.is_null() && cpool->has_preresolution()) { |
136 // Look inside the constant pool for pre-resolved class entries. | 136 // Look inside the constant pool for pre-resolved class entries. |
137 for (int i = cpool->length() - 1; i >= 1; i--) { | 137 for (int i = cpool->length() - 1; i >= 1; i--) { |
138 if (cpool->tag_at(i).is_klass()) { | 138 if (cpool->tag_at(i).is_klass()) { |
139 klassOop kls = cpool->resolved_klass_at(i); | 139 Klass* kls = cpool->resolved_klass_at(i); |
140 if (Klass::cast(kls)->name() == sym) { | 140 if (Klass::cast(kls)->name() == sym) { |
141 return kls; | 141 return kls; |
142 } | 142 } |
143 } | 143 } |
144 } | 144 } |
167 KlassHandle GraalEnv::get_klass_by_index_impl(constantPoolHandle& cpool, | 167 KlassHandle GraalEnv::get_klass_by_index_impl(constantPoolHandle& cpool, |
168 int index, | 168 int index, |
169 bool& is_accessible, | 169 bool& is_accessible, |
170 KlassHandle& accessor) { | 170 KlassHandle& accessor) { |
171 EXCEPTION_CONTEXT; | 171 EXCEPTION_CONTEXT; |
172 KlassHandle klass (THREAD, constantPoolOopDesc::klass_at_if_loaded(cpool, index)); | 172 KlassHandle klass (THREAD, ConstantPool::klass_at_if_loaded(cpool, index)); |
173 Symbol* klass_name = NULL; | 173 Symbol* klass_name = NULL; |
174 if (klass.is_null()) { | 174 if (klass.is_null()) { |
175 // The klass has not been inserted into the constant pool. | 175 // The klass has not been inserted into the constant pool. |
176 // Try to look it up by name. | 176 // Try to look it up by name. |
177 { | 177 { |
178 // We have to lock the cpool to keep the oop from being resolved | 178 // We have to lock the cpool to keep the oop from being resolved |
179 // while we are accessing it. | 179 // while we are accessing it. |
180 ObjectLocker ol(cpool, THREAD); | 180 MutexLockerEx ml(cpool->lock(), THREAD); |
181 | 181 |
182 constantTag tag = cpool->tag_at(index); | 182 constantTag tag = cpool->tag_at(index); |
183 if (tag.is_klass()) { | 183 if (tag.is_klass()) { |
184 // The klass has been inserted into the constant pool | 184 // The klass has been inserted into the constant pool |
185 // very recently. | 185 // very recently. |
272 return; | 272 return; |
273 } | 273 } |
274 | 274 |
275 | 275 |
276 // Perform the field lookup. | 276 // Perform the field lookup. |
277 klassOop canonical_holder = | 277 Klass* canonical_holder = |
278 instanceKlass::cast(declared_holder())->find_field(name, signature, &field_desc); | 278 InstanceKlass::cast(declared_holder())->find_field(name, signature, &field_desc); |
279 if (canonical_holder == NULL) { | 279 if (canonical_holder == NULL) { |
280 return; | 280 return; |
281 } | 281 } |
282 | 282 |
283 assert(canonical_holder == field_desc.field_holder(), "just checking"); | 283 assert(canonical_holder == field_desc.field_holder(), "just checking"); |
285 | 285 |
286 // ------------------------------------------------------------------ | 286 // ------------------------------------------------------------------ |
287 // ciEnv::get_field_by_index | 287 // ciEnv::get_field_by_index |
288 // | 288 // |
289 // Get a field by index from a klass's constant pool. | 289 // Get a field by index from a klass's constant pool. |
290 void GraalEnv::get_field_by_index(instanceKlassHandle& accessor, fieldDescriptor& fd, | 290 void GraalEnv::get_field_by_index(instanceKlassHandle& accessor, fieldDescriptor& fd, int index) { |
291 int index) { | |
292 ResourceMark rm; | 291 ResourceMark rm; |
293 return get_field_by_index_impl(accessor, fd, index); | 292 return get_field_by_index_impl(accessor, fd, index); |
294 } | 293 } |
295 | 294 |
296 // ------------------------------------------------------------------ | 295 // ------------------------------------------------------------------ |
348 if (holder_is_accessible) { // Our declared holder is loaded. | 347 if (holder_is_accessible) { // Our declared holder is loaded. |
349 instanceKlassHandle lookup = get_instance_klass_for_declared_method_holder(holder); | 348 instanceKlassHandle lookup = get_instance_klass_for_declared_method_holder(holder); |
350 methodHandle m = lookup_method(accessor, lookup, name_sym, sig_sym, bc); | 349 methodHandle m = lookup_method(accessor, lookup, name_sym, sig_sym, bc); |
351 if (!m.is_null() && | 350 if (!m.is_null() && |
352 (bc == Bytecodes::_invokestatic | 351 (bc == Bytecodes::_invokestatic |
353 ? instanceKlass::cast(m->method_holder())->is_not_initialized() | 352 ? InstanceKlass::cast(m->method_holder())->is_not_initialized() |
354 : !instanceKlass::cast(m->method_holder())->is_loaded())) { | 353 : !InstanceKlass::cast(m->method_holder())->is_loaded())) { |
355 m = NULL; | 354 m = NULL; |
356 } | 355 } |
357 if (!m.is_null()) { | 356 if (!m.is_null()) { |
358 // We found the method. | 357 // We found the method. |
359 return m; | 358 return m; |
416 //bool test_deps = counter_changed; | 415 //bool test_deps = counter_changed; |
417 //DEBUG_ONLY(test_deps = true); | 416 //DEBUG_ONLY(test_deps = true); |
418 //if (!test_deps) return; | 417 //if (!test_deps) return; |
419 | 418 |
420 for (Dependencies::DepStream deps(dependencies); deps.next(); ) { | 419 for (Dependencies::DepStream deps(dependencies); deps.next(); ) { |
421 klassOop witness = deps.check_dependency(); | 420 Klass* witness = deps.check_dependency(); |
422 if (witness != NULL) { | 421 if (witness != NULL) { |
423 return false; | 422 return false; |
424 } | 423 } |
425 } | 424 } |
426 | 425 |
443 Dependencies* dependencies, | 442 Dependencies* dependencies, |
444 CompileTask* task, | 443 CompileTask* task, |
445 int compile_id, | 444 int compile_id, |
446 bool has_debug_info, | 445 bool has_debug_info, |
447 bool has_unsafe_access, | 446 bool has_unsafe_access, |
448 bool install_code) { | 447 bool bind_to_method) { |
449 EXCEPTION_CONTEXT; | 448 EXCEPTION_CONTEXT; |
450 NMethodSweeper::possibly_sweep(); | 449 NMethodSweeper::possibly_sweep(); |
451 nmethod* nm = NULL; | 450 nmethod* nm = NULL; |
452 int comp_level = CompLevel_simple; | 451 int comp_level = CompLevel_simple; |
453 { | 452 { |
462 dependencies->encode_content_bytes(); | 461 dependencies->encode_content_bytes(); |
463 | 462 |
464 // Check for {class loads, evolution, breakpoints} during compilation | 463 // Check for {class loads, evolution, breakpoints} during compilation |
465 if (!check_for_system_dictionary_modification(dependencies)) { | 464 if (!check_for_system_dictionary_modification(dependencies)) { |
466 // While not a true deoptimization, it is a preemptive decompile. | 465 // While not a true deoptimization, it is a preemptive decompile. |
467 methodDataOop mdo = method()->method_data(); | 466 MethodData* mdp = method()->method_data(); |
468 if (mdo != NULL) { | 467 if (mdp != NULL) { |
469 mdo->inc_decompile_count(); | 468 mdp->inc_decompile_count(); |
470 } | 469 } |
471 | 470 |
472 // All buffers in the CodeBuffer are allocated in the CodeCache. | 471 // All buffers in the CodeBuffer are allocated in the CodeCache. |
473 // If the code buffer is created on each compile attempt | 472 // If the code buffer is created on each compile attempt |
474 // as in C2, then it must be freed. | 473 // as in C2, then it must be freed. |
511 | 510 |
512 // Record successful registration. | 511 // Record successful registration. |
513 // (Put nm into the task handle *before* publishing to the Java heap.) | 512 // (Put nm into the task handle *before* publishing to the Java heap.) |
514 if (task != NULL) task->set_code(nm); | 513 if (task != NULL) task->set_code(nm); |
515 | 514 |
516 if (install_code) { | 515 if (bind_to_method) { |
517 if (entry_bci == InvocationEntryBci) { | 516 if (entry_bci == InvocationEntryBci) { |
518 if (TieredCompilation) { | 517 if (TieredCompilation) { |
519 // If there is an old version we're done with it | 518 // If there is an old version we're done with it |
520 nmethod* old = method->code(); | 519 nmethod* old = method->code(); |
521 if (TraceMethodReplacement && old != NULL) { | 520 if (TraceMethodReplacement && old != NULL) { |
545 tty->print_cr("Installing osr method (%d) %s @ %d", | 544 tty->print_cr("Installing osr method (%d) %s @ %d", |
546 comp_level, | 545 comp_level, |
547 method_name, | 546 method_name, |
548 entry_bci); | 547 entry_bci); |
549 } | 548 } |
550 instanceKlass::cast(method->method_holder())->add_osr_nmethod(nm); | 549 InstanceKlass::cast(method->method_holder())->add_osr_nmethod(nm); |
551 | 550 |
552 } | 551 } |
553 } | 552 } |
554 } | 553 } |
555 } | 554 } |