< prev index next >

src/share/vm/aot/aotCodeHeap.cpp

Print this page
rev 13198 : 8183573: Refactor CodeHeap and AOTCodeHeap to devirtualize hot methods
Reviewed-by: rbackman


 241   _oop_got      = (oop*) _lib->load_symbol("JVM.oop.got");
 242   _oop_got_size = _lib->header()->_oop_got_size;
 243 
 244   // Collect stubs info
 245   _stubs_offsets = (int*) _lib->load_symbol("JVM.stubs.offsets");
 246 
 247   // code segments table
 248   _code_segments = (address) _lib->load_symbol("JVM.code.segments");
 249 
 250   // method state
 251   _method_state = (jlong*) _lib->load_symbol("JVM.meth.state");
 252 
 253   // Create a table for mapping classes
 254   _classes = NEW_C_HEAP_ARRAY(AOTClass, _class_count, mtCode);
 255   memset(_classes, 0, _class_count * sizeof(AOTClass));
 256 
 257   // Create table for searching AOTCompiledMethod based on pc.
 258   _code_to_aot = NEW_C_HEAP_ARRAY(CodeToAMethod, _method_count, mtCode);
 259   memset(_code_to_aot, 0, _method_count * sizeof(CodeToAMethod));
 260 
 261   _low_boundary = _code_space;
 262   _memory.set_low_boundary((char *)_code_space);
 263   _memory.set_high_boundary((char *)_code_space);
 264   _memory.set_low((char *)_code_space);
 265   _memory.set_high((char *)_code_space);
 266 
 267   _segmap.set_low_boundary((char *)_code_segments);
 268   _segmap.set_low((char *)_code_segments);
 269 
 270   _log2_segment_size = exact_log2(_lib->config()->_codeSegmentSize);
 271 
 272   // Register aot stubs
 273   register_stubs();
 274 
 275   if (PrintAOT || (PrintCompilation && PrintAOT)) {
 276     tty->print("%7d ", (int) tty->time_stamp().milliseconds());
 277     tty->print_cr("%4d     loaded    %s  aot library", _lib->id(), _lib->name());
 278   }
 279 }
 280 
 281 void AOTCodeHeap::publish_aot(const methodHandle& mh, AOTMethodData* method_data, int code_id) {


 783 void* AOTCodeHeap::find_start(void* p) const {
 784   if (!contains(p)) {
 785     return NULL;
 786   }
 787   size_t offset = pointer_delta(p, low_boundary(), 1);
 788   // Use segments table
 789   size_t seg_idx = offset / _lib->config()->_codeSegmentSize;
 790   if ((int)(_code_segments[seg_idx]) == 0xff) {
 791     return NULL;
 792   }
 793   while (_code_segments[seg_idx] > 0) {
 794     seg_idx -= (int)_code_segments[seg_idx];
 795   }
 796   int code_offset = (int)seg_idx * _lib->config()->_codeSegmentSize;
 797   int aot_index = *(int*)(_code_space + code_offset);
 798   AOTCompiledMethod* aot = _code_to_aot[aot_index]._aot;
 799   assert(aot != NULL, "should find registered aot method");
 800   return aot;
 801 }
 802 




 803 AOTCompiledMethod* AOTCodeHeap::find_aot(address p) const {
 804   assert(contains(p), "should be here");
 805   return (AOTCompiledMethod *)find_start(p);
 806 }
 807 
 808 CodeBlob* AOTCodeHeap::find_blob_unsafe(void* start) const {
 809   return (CodeBlob*)AOTCodeHeap::find_start(start);
 810 }
 811 
 812 void AOTCodeHeap::oops_do(OopClosure* f) {
 813   for (int i = 0; i < _oop_got_size; i++) {
 814     oop* p = &_oop_got[i];
 815     if (*p == NULL)  continue;  // skip non-oops
 816     f->do_oop(p);
 817   }
 818   for (int index = 0; index < _method_count; index++) {
 819     if (_code_to_aot[index]._state != in_use) {
 820       continue; // Skip uninitialized entries.
 821     }
 822     AOTCompiledMethod* aot = _code_to_aot[index]._aot;
 823     aot->do_oops(f);
 824   }
 825 }
 826 
 827 // Scan only metaspace_got cells which should have only Klass*,
 828 // metadata_got cells are scanned only for alive AOT methods
 829 // by AOTCompiledMethod::metadata_do().




 241   _oop_got      = (oop*) _lib->load_symbol("JVM.oop.got");
 242   _oop_got_size = _lib->header()->_oop_got_size;
 243 
 244   // Collect stubs info
 245   _stubs_offsets = (int*) _lib->load_symbol("JVM.stubs.offsets");
 246 
 247   // code segments table
 248   _code_segments = (address) _lib->load_symbol("JVM.code.segments");
 249 
 250   // method state
 251   _method_state = (jlong*) _lib->load_symbol("JVM.meth.state");
 252 
 253   // Create a table for mapping classes
 254   _classes = NEW_C_HEAP_ARRAY(AOTClass, _class_count, mtCode);
 255   memset(_classes, 0, _class_count * sizeof(AOTClass));
 256 
 257   // Create table for searching AOTCompiledMethod based on pc.
 258   _code_to_aot = NEW_C_HEAP_ARRAY(CodeToAMethod, _method_count, mtCode);
 259   memset(_code_to_aot, 0, _method_count * sizeof(CodeToAMethod));
 260 

 261   _memory.set_low_boundary((char *)_code_space);
 262   _memory.set_high_boundary((char *)_code_space);
 263   _memory.set_low((char *)_code_space);
 264   _memory.set_high((char *)_code_space);
 265 
 266   _segmap.set_low_boundary((char *)_code_segments);
 267   _segmap.set_low((char *)_code_segments);
 268 
 269   _log2_segment_size = exact_log2(_lib->config()->_codeSegmentSize);
 270 
 271   // Register aot stubs
 272   register_stubs();
 273 
 274   if (PrintAOT || (PrintCompilation && PrintAOT)) {
 275     tty->print("%7d ", (int) tty->time_stamp().milliseconds());
 276     tty->print_cr("%4d     loaded    %s  aot library", _lib->id(), _lib->name());
 277   }
 278 }
 279 
 280 void AOTCodeHeap::publish_aot(const methodHandle& mh, AOTMethodData* method_data, int code_id) {


 782 void* AOTCodeHeap::find_start(void* p) const {
 783   if (!contains(p)) {
 784     return NULL;
 785   }
 786   size_t offset = pointer_delta(p, low_boundary(), 1);
 787   // Use segments table
 788   size_t seg_idx = offset / _lib->config()->_codeSegmentSize;
 789   if ((int)(_code_segments[seg_idx]) == 0xff) {
 790     return NULL;
 791   }
 792   while (_code_segments[seg_idx] > 0) {
 793     seg_idx -= (int)_code_segments[seg_idx];
 794   }
 795   int code_offset = (int)seg_idx * _lib->config()->_codeSegmentSize;
 796   int aot_index = *(int*)(_code_space + code_offset);
 797   AOTCompiledMethod* aot = _code_to_aot[aot_index]._aot;
 798   assert(aot != NULL, "should find registered aot method");
 799   return aot;
 800 }
 801 
 802 CodeBlob* AOTCodeHeap::find_blob_unsafe(void* start) const {
 803   return (CodeBlob*)AOTCodeHeap::find_start(start);
 804 }
 805 
 806 AOTCompiledMethod* AOTCodeHeap::find_aot(address p) const {
 807   assert(contains(p), "should be here");
 808   return (AOTCompiledMethod *)find_start(p);




 809 }
 810 
 811 void AOTCodeHeap::oops_do(OopClosure* f) {
 812   for (int i = 0; i < _oop_got_size; i++) {
 813     oop* p = &_oop_got[i];
 814     if (*p == NULL)  continue;  // skip non-oops
 815     f->do_oop(p);
 816   }
 817   for (int index = 0; index < _method_count; index++) {
 818     if (_code_to_aot[index]._state != in_use) {
 819       continue; // Skip uninitialized entries.
 820     }
 821     AOTCompiledMethod* aot = _code_to_aot[index]._aot;
 822     aot->do_oops(f);
 823   }
 824 }
 825 
 826 // Scan only metaspace_got cells which should have only Klass*,
 827 // metadata_got cells are scanned only for alive AOT methods
 828 // by AOTCompiledMethod::metadata_do().


< prev index next >