< prev index next >

src/hotspot/share/cds/heapShared.cpp

Print this page

   1 /*
   2  * Copyright (c) 2018, 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  *

1588 }
1589 
1590 void HeapShared::archive_object_subgraphs(ArchivableStaticFieldInfo fields[],
1591                                           bool is_full_module_graph) {
1592   _num_total_subgraph_recordings = 0;
1593   _num_total_walked_objs = 0;
1594   _num_total_archived_objs = 0;
1595   _num_total_recorded_klasses = 0;
1596   _num_total_verifications = 0;
1597 
1598   // For each class X that has one or more archived fields:
1599   // [1] Dump the subgraph of each archived field
1600   // [2] Create a list of all the class of the objects that can be reached
1601   //     by any of these static fields.
1602   //     At runtime, these classes are initialized before X's archived fields
1603   //     are restored by HeapShared::initialize_from_archived_subgraph().
1604   int i;
1605   for (int i = 0; fields[i].valid(); ) {
1606     ArchivableStaticFieldInfo* info = &fields[i];
1607     const char* klass_name = info->klass_name;







1608     start_recording_subgraph(info->klass, klass_name, is_full_module_graph);
1609 
1610     // If you have specified consecutive fields of the same klass in
1611     // fields[], these will be archived in the same
1612     // {start_recording_subgraph ... done_recording_subgraph} pass to
1613     // save time.
1614     for (; fields[i].valid(); i++) {
1615       ArchivableStaticFieldInfo* f = &fields[i];
1616       if (f->klass_name != klass_name) {
1617         break;
1618       }
1619 
1620       archive_reachable_objects_from_static_field(f->klass, f->klass_name,
1621                                                   f->offset, f->field_name);
1622     }
1623     done_recording_subgraph(info->klass, klass_name);
1624   }
1625 
1626   log_info(cds, heap)("Archived subgraph records = %d",
1627                       _num_total_subgraph_recordings);

   1 /*
   2  * Copyright (c) 2018, 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  *

1588 }
1589 
1590 void HeapShared::archive_object_subgraphs(ArchivableStaticFieldInfo fields[],
1591                                           bool is_full_module_graph) {
1592   _num_total_subgraph_recordings = 0;
1593   _num_total_walked_objs = 0;
1594   _num_total_archived_objs = 0;
1595   _num_total_recorded_klasses = 0;
1596   _num_total_verifications = 0;
1597 
1598   // For each class X that has one or more archived fields:
1599   // [1] Dump the subgraph of each archived field
1600   // [2] Create a list of all the class of the objects that can be reached
1601   //     by any of these static fields.
1602   //     At runtime, these classes are initialized before X's archived fields
1603   //     are restored by HeapShared::initialize_from_archived_subgraph().
1604   int i;
1605   for (int i = 0; fields[i].valid(); ) {
1606     ArchivableStaticFieldInfo* info = &fields[i];
1607     const char* klass_name = info->klass_name;
1608 
1609     if (CDSConfig::is_valhalla_preview() && strcmp(klass_name, "jdk/internal/module/ArchivedModuleGraph") == 0) {
1610       // FIXME -- ArchivedModuleGraph doesn't work when java.base is patched with valhalla classes.
1611       i++;
1612       continue;
1613     }
1614 
1615     start_recording_subgraph(info->klass, klass_name, is_full_module_graph);
1616 
1617     // If you have specified consecutive fields of the same klass in
1618     // fields[], these will be archived in the same
1619     // {start_recording_subgraph ... done_recording_subgraph} pass to
1620     // save time.
1621     for (; fields[i].valid(); i++) {
1622       ArchivableStaticFieldInfo* f = &fields[i];
1623       if (f->klass_name != klass_name) {
1624         break;
1625       }
1626 
1627       archive_reachable_objects_from_static_field(f->klass, f->klass_name,
1628                                                   f->offset, f->field_name);
1629     }
1630     done_recording_subgraph(info->klass, klass_name);
1631   }
1632 
1633   log_info(cds, heap)("Archived subgraph records = %d",
1634                       _num_total_subgraph_recordings);
< prev index next >