< prev index next >

src/hotspot/share/aot/aotCodeHeap.cpp

Print this page
rev 56251 : imported patch 8226705-v1
rev 56252 : imported patch 8226705-v2


  21  * questions.
  22  */
  23 
  24 #include "precompiled.hpp"
  25 
  26 #include "aot/aotCodeHeap.hpp"
  27 #include "aot/aotLoader.hpp"
  28 #include "ci/ciUtilities.inline.hpp"
  29 #include "classfile/javaAssertions.hpp"
  30 #include "gc/shared/cardTable.hpp"
  31 #include "gc/shared/cardTableBarrierSet.hpp"
  32 #include "gc/shared/gcConfig.hpp"
  33 #include "gc/g1/heapRegion.hpp"
  34 #include "interpreter/abstractInterpreter.hpp"
  35 #include "jvmci/compilerRuntime.hpp"
  36 #include "jvmci/jvmciRuntime.hpp"
  37 #include "memory/allocation.inline.hpp"
  38 #include "memory/universe.hpp"
  39 #include "oops/compressedOops.hpp"
  40 #include "oops/method.inline.hpp"

  41 #include "runtime/handles.inline.hpp"
  42 #include "runtime/os.hpp"
  43 #include "runtime/safepointVerifiers.hpp"
  44 #include "runtime/sharedRuntime.hpp"
  45 #include "runtime/vmOperations.hpp"
  46 #include "utilities/sizes.hpp"
  47 
  48 bool AOTLib::_narrow_oop_shift_initialized = false;
  49 int  AOTLib::_narrow_oop_shift = 0;
  50 int  AOTLib::_narrow_klass_shift = 0;
  51 
  52 address AOTLib::load_symbol(const char *name) {
  53   address symbol = (address) os::dll_lookup(_dl_handle, name);
  54   if (symbol == NULL) {
  55     tty->print_cr("Shared file %s error: missing %s", _name, name);
  56     vm_exit(1);
  57   }
  58   return symbol;
  59 }
  60 


 334 #ifdef ASSERT
 335   if (_aot_id > CIStop || _aot_id < CIStart) {
 336     // Skip compilation
 337     return;
 338   }
 339 #endif
 340   // Check one more time.
 341   if (_code_to_aot[code_id]._state == invalid) {
 342     return;
 343   }
 344   AOTCompiledMethod *aot = new AOTCompiledMethod(code, mh(), meta, metadata_table, metadata_size, state_adr, this, name, code_id, _aot_id);
 345   assert(_code_to_aot[code_id]._aot == NULL, "should be not initialized");
 346   _code_to_aot[code_id]._aot = aot; // Should set this first
 347   if (Atomic::cmpxchg(in_use, &_code_to_aot[code_id]._state, not_set) != not_set) {
 348     _code_to_aot[code_id]._aot = NULL; // Clean
 349   } else { // success
 350     // Publish method
 351 #ifdef TIERED
 352     mh->set_aot_code(aot);
 353 #endif


 354     Method::set_code(mh, aot);

 355     if (PrintAOT || (PrintCompilation && PrintAOT)) {
 356       PauseNoSafepointVerifier pnsv(&nsv); // aot code is registered already
 357       aot->print_on(tty, NULL);
 358     }
 359     // Publish oop only after we are visible to CompiledMethodIterator
 360     aot->set_oop(mh()->method_holder()->klass_holder());
 361   }
 362 }
 363 
 364 void AOTCodeHeap::link_primitive_array_klasses() {
 365   ResourceMark rm;
 366   for (int i = T_BOOLEAN; i <= T_CONFLICT; i++) {
 367     BasicType t = (BasicType)i;
 368     if (is_java_primitive(t)) {
 369       const Klass* arr_klass = Universe::typeArrayKlassObj(t);
 370       AOTKlassData* klass_data = (AOTKlassData*) os::dll_lookup(_lib->dl_handle(), arr_klass->signature_name());
 371       if (klass_data != NULL) {
 372         // Set both GOT cells, resolved and initialized klass pointers.
 373         // _got_index points to second cell - resolved klass pointer.
 374         _klasses_got[klass_data->_got_index-1] = (Metadata*)arr_klass; // Initialized


 714   }
 715 }
 716 
 717 void AOTCodeHeap::sweep_dependent_methods(int* indexes, int methods_cnt) {
 718   int marked = 0;
 719   for (int i = 0; i < methods_cnt; ++i) {
 720     int code_id = indexes[i];
 721     // Invalidate aot code.
 722     if (Atomic::cmpxchg(invalid, &_code_to_aot[code_id]._state, not_set) != not_set) {
 723       if (_code_to_aot[code_id]._state == in_use) {
 724         AOTCompiledMethod* aot = _code_to_aot[code_id]._aot;
 725         assert(aot != NULL, "aot should be set");
 726         if (!aot->is_runtime_stub()) { // Something is wrong - should not invalidate stubs.
 727           aot->mark_for_deoptimization(false);
 728           marked++;
 729         }
 730       }
 731     }
 732   }
 733   if (marked > 0) {
 734     VM_Deoptimize op;
 735     VMThread::execute(&op);
 736   }
 737 }
 738 
 739 void AOTCodeHeap::sweep_dependent_methods(AOTKlassData* klass_data) {
 740   // Make dependent methods non_entrant forever.
 741   int methods_offset = klass_data->_dependent_methods_offset;
 742   if (methods_offset >= 0) {
 743     address methods_cnt_adr = _dependencies + methods_offset;
 744     int methods_cnt = *(int*)methods_cnt_adr;
 745     int* indexes = (int*)(methods_cnt_adr + 4);
 746     sweep_dependent_methods(indexes, methods_cnt);
 747   }
 748 }
 749 
 750 void AOTCodeHeap::sweep_dependent_methods(InstanceKlass* ik) {
 751   AOTKlassData* klass_data = find_klass(ik);
 752   vmassert(klass_data != NULL, "dependency data missing");
 753   sweep_dependent_methods(klass_data);
 754 }
 755 




  21  * questions.
  22  */
  23 
  24 #include "precompiled.hpp"
  25 
  26 #include "aot/aotCodeHeap.hpp"
  27 #include "aot/aotLoader.hpp"
  28 #include "ci/ciUtilities.inline.hpp"
  29 #include "classfile/javaAssertions.hpp"
  30 #include "gc/shared/cardTable.hpp"
  31 #include "gc/shared/cardTableBarrierSet.hpp"
  32 #include "gc/shared/gcConfig.hpp"
  33 #include "gc/g1/heapRegion.hpp"
  34 #include "interpreter/abstractInterpreter.hpp"
  35 #include "jvmci/compilerRuntime.hpp"
  36 #include "jvmci/jvmciRuntime.hpp"
  37 #include "memory/allocation.inline.hpp"
  38 #include "memory/universe.hpp"
  39 #include "oops/compressedOops.hpp"
  40 #include "oops/method.inline.hpp"
  41 #include "runtime/deoptimization.hpp"
  42 #include "runtime/handles.inline.hpp"
  43 #include "runtime/os.hpp"
  44 #include "runtime/safepointVerifiers.hpp"
  45 #include "runtime/sharedRuntime.hpp"
  46 #include "runtime/vmOperations.hpp"
  47 #include "utilities/sizes.hpp"
  48 
  49 bool AOTLib::_narrow_oop_shift_initialized = false;
  50 int  AOTLib::_narrow_oop_shift = 0;
  51 int  AOTLib::_narrow_klass_shift = 0;
  52 
  53 address AOTLib::load_symbol(const char *name) {
  54   address symbol = (address) os::dll_lookup(_dl_handle, name);
  55   if (symbol == NULL) {
  56     tty->print_cr("Shared file %s error: missing %s", _name, name);
  57     vm_exit(1);
  58   }
  59   return symbol;
  60 }
  61 


 335 #ifdef ASSERT
 336   if (_aot_id > CIStop || _aot_id < CIStart) {
 337     // Skip compilation
 338     return;
 339   }
 340 #endif
 341   // Check one more time.
 342   if (_code_to_aot[code_id]._state == invalid) {
 343     return;
 344   }
 345   AOTCompiledMethod *aot = new AOTCompiledMethod(code, mh(), meta, metadata_table, metadata_size, state_adr, this, name, code_id, _aot_id);
 346   assert(_code_to_aot[code_id]._aot == NULL, "should be not initialized");
 347   _code_to_aot[code_id]._aot = aot; // Should set this first
 348   if (Atomic::cmpxchg(in_use, &_code_to_aot[code_id]._state, not_set) != not_set) {
 349     _code_to_aot[code_id]._aot = NULL; // Clean
 350   } else { // success
 351     // Publish method
 352 #ifdef TIERED
 353     mh->set_aot_code(aot);
 354 #endif
 355     {
 356       MutexLocker pl(CompiledMethod_lock, Mutex::_no_safepoint_check_flag);
 357       Method::set_code(mh, aot);
 358     }
 359     if (PrintAOT || (PrintCompilation && PrintAOT)) {
 360       PauseNoSafepointVerifier pnsv(&nsv); // aot code is registered already
 361       aot->print_on(tty, NULL);
 362     }
 363     // Publish oop only after we are visible to CompiledMethodIterator
 364     aot->set_oop(mh()->method_holder()->klass_holder());
 365   }
 366 }
 367 
 368 void AOTCodeHeap::link_primitive_array_klasses() {
 369   ResourceMark rm;
 370   for (int i = T_BOOLEAN; i <= T_CONFLICT; i++) {
 371     BasicType t = (BasicType)i;
 372     if (is_java_primitive(t)) {
 373       const Klass* arr_klass = Universe::typeArrayKlassObj(t);
 374       AOTKlassData* klass_data = (AOTKlassData*) os::dll_lookup(_lib->dl_handle(), arr_klass->signature_name());
 375       if (klass_data != NULL) {
 376         // Set both GOT cells, resolved and initialized klass pointers.
 377         // _got_index points to second cell - resolved klass pointer.
 378         _klasses_got[klass_data->_got_index-1] = (Metadata*)arr_klass; // Initialized


 718   }
 719 }
 720 
 721 void AOTCodeHeap::sweep_dependent_methods(int* indexes, int methods_cnt) {
 722   int marked = 0;
 723   for (int i = 0; i < methods_cnt; ++i) {
 724     int code_id = indexes[i];
 725     // Invalidate aot code.
 726     if (Atomic::cmpxchg(invalid, &_code_to_aot[code_id]._state, not_set) != not_set) {
 727       if (_code_to_aot[code_id]._state == in_use) {
 728         AOTCompiledMethod* aot = _code_to_aot[code_id]._aot;
 729         assert(aot != NULL, "aot should be set");
 730         if (!aot->is_runtime_stub()) { // Something is wrong - should not invalidate stubs.
 731           aot->mark_for_deoptimization(false);
 732           marked++;
 733         }
 734       }
 735     }
 736   }
 737   if (marked > 0) {
 738     Deoptimization::deoptimize_all_marked();

 739   }
 740 }
 741 
 742 void AOTCodeHeap::sweep_dependent_methods(AOTKlassData* klass_data) {
 743   // Make dependent methods non_entrant forever.
 744   int methods_offset = klass_data->_dependent_methods_offset;
 745   if (methods_offset >= 0) {
 746     address methods_cnt_adr = _dependencies + methods_offset;
 747     int methods_cnt = *(int*)methods_cnt_adr;
 748     int* indexes = (int*)(methods_cnt_adr + 4);
 749     sweep_dependent_methods(indexes, methods_cnt);
 750   }
 751 }
 752 
 753 void AOTCodeHeap::sweep_dependent_methods(InstanceKlass* ik) {
 754   AOTKlassData* klass_data = find_klass(ik);
 755   vmassert(klass_data != NULL, "dependency data missing");
 756   sweep_dependent_methods(klass_data);
 757 }
 758 


< prev index next >