< prev index next >

src/hotspot/share/cds/regeneratedClasses.cpp

Print this page

  1 /*
  2  * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *

 47   }
 48   _regenerated_mirrors->append(OopHandle(Universe::vm_global(), regen_klass->java_mirror()));
 49 
 50   if (_renegerated_objs == nullptr) {
 51     _renegerated_objs = new (mtClass)RegeneratedObjTable();
 52   }
 53 
 54   _renegerated_objs->put((address)orig_klass, (address)regen_klass);
 55   Array<Method*>* methods = orig_klass->methods();
 56   for (int i = 0; i < methods->length(); i++) {
 57     Method* orig_m = methods->at(i);
 58     Method* regen_m = regen_klass->find_method(orig_m->name(), orig_m->signature());
 59     if (regen_m == nullptr) {
 60       ResourceMark rm;
 61       log_warning(cds)("Method in original class is missing from regenerated class: " INTPTR_FORMAT " %s",
 62                        p2i(orig_m), orig_m->external_name());
 63     } else {
 64       _renegerated_objs->put((address)orig_m, (address)regen_m);
 65     }
 66   }






 67 }
 68 
 69 bool RegeneratedClasses::has_been_regenerated(address orig_obj) {
 70   if (_renegerated_objs == nullptr) {
 71     return false;
 72   } else {
 73     return _renegerated_objs->get(orig_obj) != nullptr;
 74   }
 75 }
 76 







 77 void RegeneratedClasses::record_regenerated_objects() {
 78   assert_locked_or_safepoint(DumpTimeTable_lock);
 79   if (_renegerated_objs != nullptr) {
 80     auto doit = [&] (address orig_obj, address regen_obj) {
 81       ArchiveBuilder::current()->record_regenerated_object(orig_obj, regen_obj);
 82     };
 83     _renegerated_objs->iterate_all(doit);
 84   }
 85 }
 86 
 87 void RegeneratedClasses::cleanup() {
 88   MutexLocker ml(DumpTimeTable_lock, Mutex::_no_safepoint_check_flag);
 89   if (_regenerated_mirrors != nullptr) {
 90     for (int i = 0; i < _regenerated_mirrors->length(); i++) {
 91       _regenerated_mirrors->at(i).release(Universe::vm_global());
 92     }
 93     delete _regenerated_mirrors;
 94     _regenerated_mirrors = nullptr;
 95   }
 96   if (_renegerated_objs != nullptr) {

  1 /*
  2  * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *

 47   }
 48   _regenerated_mirrors->append(OopHandle(Universe::vm_global(), regen_klass->java_mirror()));
 49 
 50   if (_renegerated_objs == nullptr) {
 51     _renegerated_objs = new (mtClass)RegeneratedObjTable();
 52   }
 53 
 54   _renegerated_objs->put((address)orig_klass, (address)regen_klass);
 55   Array<Method*>* methods = orig_klass->methods();
 56   for (int i = 0; i < methods->length(); i++) {
 57     Method* orig_m = methods->at(i);
 58     Method* regen_m = regen_klass->find_method(orig_m->name(), orig_m->signature());
 59     if (regen_m == nullptr) {
 60       ResourceMark rm;
 61       log_warning(cds)("Method in original class is missing from regenerated class: " INTPTR_FORMAT " %s",
 62                        p2i(orig_m), orig_m->external_name());
 63     } else {
 64       _renegerated_objs->put((address)orig_m, (address)regen_m);
 65     }
 66   }
 67 
 68   if (log_is_enabled(Info, cds)) {
 69     ResourceMark rm;
 70     log_info(cds)("Regenerated class %s: methods %d -> %d)", orig_klass->external_name(),
 71                   orig_klass->methods()->length(), regen_klass->methods()->length());
 72   }
 73 }
 74 
 75 bool RegeneratedClasses::has_been_regenerated(address orig_obj) {
 76   if (_renegerated_objs == nullptr) {
 77     return false;
 78   } else {
 79     return _renegerated_objs->get(orig_obj) != nullptr;
 80   }
 81 }
 82 
 83 address RegeneratedClasses::get_regenerated_object(address orig_obj) {
 84   assert(_renegerated_objs != nullptr, "must be");
 85   address* p =_renegerated_objs->get(orig_obj);
 86   assert(p != nullptr, "must be");
 87   return *p;
 88 }
 89 
 90 void RegeneratedClasses::record_regenerated_objects() {
 91   assert_locked_or_safepoint(DumpTimeTable_lock);
 92   if (_renegerated_objs != nullptr) {
 93     auto doit = [&] (address orig_obj, address regen_obj) {
 94       ArchiveBuilder::current()->record_regenerated_object(orig_obj, regen_obj);
 95     };
 96     _renegerated_objs->iterate_all(doit);
 97   }
 98 }
 99 
100 void RegeneratedClasses::cleanup() {
101   MutexLocker ml(DumpTimeTable_lock, Mutex::_no_safepoint_check_flag);
102   if (_regenerated_mirrors != nullptr) {
103     for (int i = 0; i < _regenerated_mirrors->length(); i++) {
104       _regenerated_mirrors->at(i).release(Universe::vm_global());
105     }
106     delete _regenerated_mirrors;
107     _regenerated_mirrors = nullptr;
108   }
109   if (_renegerated_objs != nullptr) {
< prev index next >