< prev index next >

src/hotspot/share/memory/dynamicArchive.cpp

Print this page




 739   FileMapInfo* base_info = FileMapInfo::current_info();
 740   int* crc = _header->_base_archive_crc;
 741   *crc++ = base_info->crc(); // base archive header crc
 742   for (int i = 0; i < MetaspaceShared::n_regions; i++) {
 743     *crc++ = base_info->space_crc(i);
 744   }
 745   _header->populate(base_info, os::vm_allocation_granularity());
 746 }
 747 
 748 size_t DynamicArchiveBuilder::estimate_trampoline_size() {
 749   size_t total = 0;
 750   size_t each_method_bytes =
 751     align_up(SharedRuntime::trampoline_size(), BytesPerWord) +
 752     align_up(sizeof(AdapterHandlerEntry*), BytesPerWord);
 753 
 754   for (int i = 0; i < _klasses->length(); i++) {
 755     InstanceKlass* ik = _klasses->at(i);
 756     Array<Method*>* methods = ik->methods();
 757     total += each_method_bytes * methods->length();
 758   }
 759   if (total == 0) {
 760     // We have nothing to archive, but let's avoid having an empty region.
 761     total = SharedRuntime::trampoline_size();
 762   }
 763   return total;
 764 }
 765 
 766 void DynamicArchiveBuilder::make_trampolines() {
 767   for (int i = 0; i < _klasses->length(); i++) {
 768     InstanceKlass* ik = _klasses->at(i);
 769     Array<Method*>* methods = ik->methods();
 770     for (int j = 0; j < methods->length(); j++) {
 771       Method* m = methods->at(j);
 772       address c2i_entry_trampoline =
 773         (address)MetaspaceShared::misc_code_space_alloc(SharedRuntime::trampoline_size());
 774       m->set_from_compiled_entry(to_target(c2i_entry_trampoline));
 775       AdapterHandlerEntry** adapter_trampoline =
 776         (AdapterHandlerEntry**)MetaspaceShared::misc_code_space_alloc(sizeof(AdapterHandlerEntry*));
 777       *adapter_trampoline = NULL;
 778       m->set_adapter_trampoline(to_target(adapter_trampoline));
 779     }
 780   }
 781 
 782   if (MetaspaceShared::misc_code_dump_space()->used() == 0) {
 783     // We have nothing to archive, but let's avoid having an empty region.
 784     MetaspaceShared::misc_code_space_alloc(SharedRuntime::trampoline_size());
 785   }
 786 }
 787 
 788 void DynamicArchiveBuilder::make_klasses_shareable() {
 789   int i, count = _klasses->length();
 790 
 791   for (i = 0; i < count; i++) {
 792     InstanceKlass* ik = _klasses->at(i);
 793     sort_methods(ik);
 794   }
 795 
 796   for (i = 0; i < count; i++) {
 797     InstanceKlass* ik = _klasses->at(i);
 798     ClassLoaderData *cld = ik->class_loader_data();
 799     if (cld->is_boot_class_loader_data()) {
 800       ik->set_class_loader_type(ClassLoader::BOOT_LOADER);
 801     }
 802     else if (cld->is_platform_class_loader_data()) {
 803       ik->set_class_loader_type(ClassLoader::PLATFORM_LOADER);
 804     }




 739   FileMapInfo* base_info = FileMapInfo::current_info();
 740   int* crc = _header->_base_archive_crc;
 741   *crc++ = base_info->crc(); // base archive header crc
 742   for (int i = 0; i < MetaspaceShared::n_regions; i++) {
 743     *crc++ = base_info->space_crc(i);
 744   }
 745   _header->populate(base_info, os::vm_allocation_granularity());
 746 }
 747 
 748 size_t DynamicArchiveBuilder::estimate_trampoline_size() {
 749   size_t total = 0;
 750   size_t each_method_bytes =
 751     align_up(SharedRuntime::trampoline_size(), BytesPerWord) +
 752     align_up(sizeof(AdapterHandlerEntry*), BytesPerWord);
 753 
 754   for (int i = 0; i < _klasses->length(); i++) {
 755     InstanceKlass* ik = _klasses->at(i);
 756     Array<Method*>* methods = ik->methods();
 757     total += each_method_bytes * methods->length();
 758   }




 759   return total;
 760 }
 761 
 762 void DynamicArchiveBuilder::make_trampolines() {
 763   for (int i = 0; i < _klasses->length(); i++) {
 764     InstanceKlass* ik = _klasses->at(i);
 765     Array<Method*>* methods = ik->methods();
 766     for (int j = 0; j < methods->length(); j++) {
 767       Method* m = methods->at(j);
 768       address c2i_entry_trampoline =
 769         (address)MetaspaceShared::misc_code_space_alloc(SharedRuntime::trampoline_size());
 770       m->set_from_compiled_entry(to_target(c2i_entry_trampoline));
 771       AdapterHandlerEntry** adapter_trampoline =
 772         (AdapterHandlerEntry**)MetaspaceShared::misc_code_space_alloc(sizeof(AdapterHandlerEntry*));
 773       *adapter_trampoline = NULL;
 774       m->set_adapter_trampoline(to_target(adapter_trampoline));
 775     }





 776   }
 777 }
 778 
 779 void DynamicArchiveBuilder::make_klasses_shareable() {
 780   int i, count = _klasses->length();
 781 
 782   for (i = 0; i < count; i++) {
 783     InstanceKlass* ik = _klasses->at(i);
 784     sort_methods(ik);
 785   }
 786 
 787   for (i = 0; i < count; i++) {
 788     InstanceKlass* ik = _klasses->at(i);
 789     ClassLoaderData *cld = ik->class_loader_data();
 790     if (cld->is_boot_class_loader_data()) {
 791       ik->set_class_loader_type(ClassLoader::BOOT_LOADER);
 792     }
 793     else if (cld->is_platform_class_loader_data()) {
 794       ik->set_class_loader_type(ClassLoader::PLATFORM_LOADER);
 795     }


< prev index next >