hotspot/src/share/vm/memory/compactingPermGenGen.cpp
author ysr
Thu, 03 Dec 2009 15:01:57 -0800
changeset 4461 c17c526d36ef
parent 4106 30919106db1d
child 5547 f4b087cbb361
permissions -rw-r--r--
6906727: UseCompressedOops: some card-marking fixes related to object arrays Summary: Introduced a new write_ref_array(HeapWords* start, size_t count) method that does the requisite MemRegion range calculation so (some of the) clients of the erstwhile write_ref_array(MemRegion mr) do not need to worry. This removed all external uses of array_size(), which was also simplified and made private. Asserts were added to catch other possible issues. Further, less essential, fixes stemming from this investigation are deferred to CR 6904516 (to follow shortly in hs17). Reviewed-by: kvn, coleenp, jmasa
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
670
ddf3e9583f2f 6719955: Update copyright year
xdono
parents: 360
diff changeset
     2
 * Copyright 2003-2008 Sun Microsystems, Inc.  All Rights Reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
#include "incls/_precompiled.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
#include "incls/_compactingPermGenGen.cpp.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
220
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
    29
// An ObjectClosure helper: Recursively adjust all pointers in an object
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
    30
// and all objects by referenced it. Clear marks on objects in order to
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
    31
// prevent visiting any object twice. This helper is used when the
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
    32
// RedefineClasses() API has been called.
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
    33
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
    34
class AdjustSharedObjectClosure : public ObjectClosure {
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
    35
public:
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
    36
  void do_object(oop obj) {
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
    37
    if (obj->is_shared_readwrite()) {
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
    38
      if (obj->mark()->is_marked()) {
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
    39
        obj->init_mark();         // Don't revisit this object.
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
    40
        obj->adjust_pointers();   // Adjust this object's references.
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
    41
      }
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
    42
    }
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
    43
  }
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
    44
};
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
    45
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
    46
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
    47
// An OopClosure helper: Recursively adjust all pointers in an object
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
    48
// and all objects by referenced it. Clear marks on objects in order
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
    49
// to prevent visiting any object twice.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
class RecursiveAdjustSharedObjectClosure : public OopClosure {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 220
diff changeset
    52
 protected:
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 220
diff changeset
    53
  template <class T> inline void do_oop_work(T* p) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 220
diff changeset
    54
    oop obj = oopDesc::load_decode_heap_oop_not_null(p);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
    if (obj->is_shared_readwrite()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
      if (obj->mark()->is_marked()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
        obj->init_mark();         // Don't revisit this object.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
        obj->oop_iterate(this);   // Recurse - adjust objects referenced.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
        obj->adjust_pointers();   // Adjust this object's references.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
        // Special case: if a class has a read-only constant pool,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
        // then the read-write objects referenced by the pool must
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
        // have their marks reset.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
        if (obj->klass() == Universe::instanceKlassKlassObj()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
          instanceKlass* ik = instanceKlass::cast((klassOop)obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
          constantPoolOop cp = ik->constants();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
          if (cp->is_shared_readonly()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
            cp->oop_iterate(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
    }
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 220
diff changeset
    74
  }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 220
diff changeset
    75
 public:
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 220
diff changeset
    76
  virtual void do_oop(oop* p)       { RecursiveAdjustSharedObjectClosure::do_oop_work(p); }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 220
diff changeset
    77
  virtual void do_oop(narrowOop* p) { RecursiveAdjustSharedObjectClosure::do_oop_work(p); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
// We need to go through all placeholders in the system dictionary and
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
// try to resolve them into shared classes. Other threads might be in
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
// the process of loading a shared class and have strong roots on
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
// their stack to the class without having added the class to the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
// dictionary yet. This means the class will be marked during phase 1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
// but will not be unmarked during the application of the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
// RecursiveAdjustSharedObjectClosure to the SystemDictionary. Note
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
// that we must not call find_shared_class with non-read-only symbols
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
// as doing so can cause hash codes to be computed, destroying
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
// forwarding pointers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
class TraversePlaceholdersClosure : public OopClosure {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 220
diff changeset
    92
 protected:
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 220
diff changeset
    93
  template <class T> inline void do_oop_work(T* p) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 220
diff changeset
    94
    oop obj = oopDesc::load_decode_heap_oop_not_null(p);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
    if (obj->klass() == Universe::symbolKlassObj() &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
        obj->is_shared_readonly()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
      symbolHandle sym((symbolOop) obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
      oop k = SystemDictionary::find_shared_class(sym);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
      if (k != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
        RecursiveAdjustSharedObjectClosure clo;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
        clo.do_oop(&k);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  }
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 220
diff changeset
   105
 public:
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 220
diff changeset
   106
  virtual void do_oop(oop* p)       { TraversePlaceholdersClosure::do_oop_work(p); }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 220
diff changeset
   107
  virtual void do_oop(narrowOop* p) { TraversePlaceholdersClosure::do_oop_work(p); }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 220
diff changeset
   108
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
void CompactingPermGenGen::initialize_performance_counters() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  const char* gen_name = "perm";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  // Generation Counters - generation 2, 1 subspace
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  _gen_counters = new GenerationCounters(gen_name, 2, 1, &_virtual_space);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  _space_counters = new CSpaceCounters(gen_name, 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
                                       _virtual_space.reserved_size(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
                                      _the_space, _gen_counters);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
void CompactingPermGenGen::update_counters() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  if (UsePerfData) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
    _space_counters->update_all();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
    _gen_counters->update_all();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
CompactingPermGenGen::CompactingPermGenGen(ReservedSpace rs,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
                                           ReservedSpace shared_rs,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
                                           size_t initial_byte_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
                                           int level, GenRemSet* remset,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
                                           ContiguousSpace* space,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
                                           PermanentGenerationSpec* spec_) :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  OneContigSpaceCardGeneration(rs, initial_byte_size, MinPermHeapExpansion,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
                               level, remset, space) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  set_spec(spec_);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  if (!UseSharedSpaces && !DumpSharedSpaces) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
    spec()->disable_sharing();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  // Break virtual space into address ranges for all spaces.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  if (spec()->enable_shared_spaces()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
    shared_end = (HeapWord*)(shared_rs.base() + shared_rs.size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
      misccode_end = shared_end;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
      misccode_bottom = misccode_end - heap_word_size(spec()->misc_code_size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
      miscdata_end = misccode_bottom;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
      miscdata_bottom = miscdata_end - heap_word_size(spec()->misc_data_size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
      readwrite_end = miscdata_bottom;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
      readwrite_bottom =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
        readwrite_end - heap_word_size(spec()->read_write_size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
      readonly_end = readwrite_bottom;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
      readonly_bottom =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
        readonly_end - heap_word_size(spec()->read_only_size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
    shared_bottom = readonly_bottom;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
    unshared_end = shared_bottom;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
    assert((char*)shared_bottom == shared_rs.base(), "shared space mismatch");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
    shared_end = (HeapWord*)(rs.base() + rs.size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
      misccode_end = shared_end;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
      misccode_bottom = shared_end;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
      miscdata_end = shared_end;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
      miscdata_bottom = shared_end;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
      readwrite_end = shared_end;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
      readwrite_bottom = shared_end;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
      readonly_end = shared_end;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
      readonly_bottom = shared_end;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
    shared_bottom = shared_end;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
    unshared_end = shared_bottom;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  unshared_bottom = (HeapWord*) rs.base();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  // Verify shared and unshared spaces adjacent.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  assert((char*)shared_bottom == rs.base()+rs.size(), "shared space mismatch");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  assert(unshared_end > unshared_bottom, "shared space mismatch");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  // Split reserved memory into pieces.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  ReservedSpace ro_rs   = shared_rs.first_part(spec()->read_only_size(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
                                              UseSharedSpaces);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  ReservedSpace tmp_rs1 = shared_rs.last_part(spec()->read_only_size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  ReservedSpace rw_rs   = tmp_rs1.first_part(spec()->read_write_size(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
                                             UseSharedSpaces);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  ReservedSpace tmp_rs2 = tmp_rs1.last_part(spec()->read_write_size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  ReservedSpace md_rs   = tmp_rs2.first_part(spec()->misc_data_size(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
                                             UseSharedSpaces);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  ReservedSpace mc_rs   = tmp_rs2.last_part(spec()->misc_data_size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  _shared_space_size = spec()->read_only_size()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
                     + spec()->read_write_size()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
                     + spec()->misc_data_size()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
                     + spec()->misc_code_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  // Allocate the unshared (default) space.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  _the_space = new ContigPermSpace(_bts,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
               MemRegion(unshared_bottom, heap_word_size(initial_byte_size)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  if (_the_space == NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
    vm_exit_during_initialization("Could not allocate an unshared"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
                                  " CompactingPermGen Space");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  // Allocate shared spaces
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  if (spec()->enable_shared_spaces()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
    // If mapping a shared file, the space is not committed, don't
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
    // mangle.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
    NOT_PRODUCT(bool old_ZapUnusedHeapArea = ZapUnusedHeapArea;)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
    NOT_PRODUCT(if (UseSharedSpaces) ZapUnusedHeapArea = false;)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
    // Commit the memory behind the shared spaces if dumping (not
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
    // mapping).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
    if (DumpSharedSpaces) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
      _ro_vs.initialize(ro_rs, spec()->read_only_size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
      _rw_vs.initialize(rw_rs, spec()->read_write_size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
      _md_vs.initialize(md_rs, spec()->misc_data_size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
      _mc_vs.initialize(mc_rs, spec()->misc_code_size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
    // Allocate the shared spaces.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
    _ro_bts = new BlockOffsetSharedArray(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
                  MemRegion(readonly_bottom,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
                            heap_word_size(spec()->read_only_size())),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
                  heap_word_size(spec()->read_only_size()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
    _ro_space = new OffsetTableContigSpace(_ro_bts,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
                  MemRegion(readonly_bottom, readonly_end));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
    _rw_bts = new BlockOffsetSharedArray(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
                  MemRegion(readwrite_bottom,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
                            heap_word_size(spec()->read_write_size())),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
                  heap_word_size(spec()->read_write_size()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
    _rw_space = new OffsetTableContigSpace(_rw_bts,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
                  MemRegion(readwrite_bottom, readwrite_end));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
    // Restore mangling flag.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
    NOT_PRODUCT(ZapUnusedHeapArea = old_ZapUnusedHeapArea;)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
    if (_ro_space == NULL || _rw_space == NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
      vm_exit_during_initialization("Could not allocate a shared space");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
    // Cover both shared spaces entirely with cards.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
    _rs->resize_covered_region(MemRegion(readonly_bottom, readwrite_end));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
    if (UseSharedSpaces) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
      // Map in the regions in the shared file.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
      FileMapInfo* mapinfo = FileMapInfo::current_info();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
      size_t image_alignment = mapinfo->alignment();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
      CollectedHeap* ch = Universe::heap();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
      if ((!mapinfo->map_space(ro, ro_rs, _ro_space)) ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
          (!mapinfo->map_space(rw, rw_rs, _rw_space)) ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
          (!mapinfo->map_space(md, md_rs, NULL))      ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
          (!mapinfo->map_space(mc, mc_rs, NULL))      ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
          // check the alignment constraints
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
          (ch == NULL || ch->kind() != CollectedHeap::GenCollectedHeap ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
           image_alignment !=
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
           ((GenCollectedHeap*)ch)->gen_policy()->max_alignment())) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
        // Base addresses didn't match; skip sharing, but continue
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
        shared_rs.release();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
        spec()->disable_sharing();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
        // If -Xshare:on is specified, print out the error message and exit VM,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
        // otherwise, set UseSharedSpaces to false and continue.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
        if (RequireSharedSpaces) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
          vm_exit_during_initialization("Unable to use shared archive.", NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
          FLAG_SET_DEFAULT(UseSharedSpaces, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
        // Note: freeing the block offset array objects does not
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
        // currently free up the underlying storage.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
        delete _ro_bts;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
        _ro_bts = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
        delete _ro_space;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
        _ro_space = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
        delete _rw_bts;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
        _rw_bts = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
        delete _rw_space;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
        _rw_space = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
        shared_end = (HeapWord*)(rs.base() + rs.size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
        _rs->resize_covered_region(MemRegion(shared_bottom, shared_bottom));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
    // Reserved region includes shared spaces for oop.is_in_reserved().
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
    _reserved.set_end(shared_end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
    _ro_space = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
    _rw_space = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
// Do a complete scan of the shared read write space to catch all
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
// objects which contain references to any younger generation.  Forward
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
// the pointers.  Avoid space_iterate, as actually visiting all the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
// objects in the space will page in more objects than we need.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
// Instead, use the system dictionary as strong roots into the read
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
// write space.
220
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
   302
//
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
   303
// If a RedefineClasses() call has been made, then we have to iterate
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
   304
// over the entire shared read-write space in order to find all the
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
   305
// objects that need to be forwarded. For example, it is possible for
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
   306
// an nmethod to be found and marked in GC phase-1 only for the nmethod
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
   307
// to be freed by the time we reach GC phase-3. The underlying method
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
   308
// is still marked, but we can't (easily) find it in GC phase-3 so we
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
   309
// blow up in GC phase-4. With RedefineClasses() we want replaced code
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
   310
// (EMCP or obsolete) to go away (i.e., be collectible) once it is no
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
   311
// longer being executed by any thread so we keep minimal attachments
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
   312
// to the replaced code. However, we can't guarantee when those EMCP
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
   313
// or obsolete methods will be collected so they may still be out there
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
   314
// even after we've severed our minimal attachments.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
void CompactingPermGenGen::pre_adjust_pointers() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
  if (spec()->enable_shared_spaces()) {
220
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
   318
    if (JvmtiExport::has_redefined_a_class()) {
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
   319
      // RedefineClasses() requires a brute force approach
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
   320
      AdjustSharedObjectClosure blk;
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
   321
      rw_space()->object_iterate(&blk);
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
   322
    } else {
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
   323
      RecursiveAdjustSharedObjectClosure blk;
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
   324
      Universe::oops_do(&blk);
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
   325
      StringTable::oops_do(&blk);
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
   326
      SystemDictionary::always_strong_classes_do(&blk);
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
   327
      TraversePlaceholdersClosure tpc;
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
   328
      SystemDictionary::placeholders_do(&tpc);
e6ef4818c49d 6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents: 1
diff changeset
   329
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
class VerifyMarksClearedClosure : public ObjectClosure {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
  void do_object(oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
    assert(SharedSkipVerify || !obj->mark()->is_marked(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
           "Shared oop still marked?");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
void CompactingPermGenGen::post_compact() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
  if (!SharedSkipVerify && spec()->enable_shared_spaces()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
    VerifyMarksClearedClosure blk;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
    rw_space()->object_iterate(&blk);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
4106
30919106db1d 6801625: CDS: HeapDump tests crash with internal error in compactingPermGenGen.cpp
ysr
parents: 999
diff changeset
   355
// Do not use in time-critical operations due to the possibility of paging
30919106db1d 6801625: CDS: HeapDump tests crash with internal error in compactingPermGenGen.cpp
ysr
parents: 999
diff changeset
   356
// in otherwise untouched or previously unread portions of the perm gen,
30919106db1d 6801625: CDS: HeapDump tests crash with internal error in compactingPermGenGen.cpp
ysr
parents: 999
diff changeset
   357
// for instance, the shared spaces. NOTE: Because CompactingPermGenGen
30919106db1d 6801625: CDS: HeapDump tests crash with internal error in compactingPermGenGen.cpp
ysr
parents: 999
diff changeset
   358
// derives from OneContigSpaceCardGeneration which is supposed to have a
30919106db1d 6801625: CDS: HeapDump tests crash with internal error in compactingPermGenGen.cpp
ysr
parents: 999
diff changeset
   359
// single space, and does not override its object_iterate() method,
30919106db1d 6801625: CDS: HeapDump tests crash with internal error in compactingPermGenGen.cpp
ysr
parents: 999
diff changeset
   360
// object iteration via that interface does not look at the objects in
30919106db1d 6801625: CDS: HeapDump tests crash with internal error in compactingPermGenGen.cpp
ysr
parents: 999
diff changeset
   361
// the shared spaces when using CDS. This should be fixed; see CR 6897798.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
void CompactingPermGenGen::space_iterate(SpaceClosure* blk, bool usedOnly) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
  OneContigSpaceCardGeneration::space_iterate(blk, usedOnly);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
  if (spec()->enable_shared_spaces()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
    // Making the rw_space walkable will page in the entire space, and
4106
30919106db1d 6801625: CDS: HeapDump tests crash with internal error in compactingPermGenGen.cpp
ysr
parents: 999
diff changeset
   366
    // is to be avoided in the case of time-critical operations.
30919106db1d 6801625: CDS: HeapDump tests crash with internal error in compactingPermGenGen.cpp
ysr
parents: 999
diff changeset
   367
    // However, this is required for Verify and heap dump operations.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
    blk->do_space(ro_space());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
    blk->do_space(rw_space());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
void CompactingPermGenGen::print_on(outputStream* st) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
  OneContigSpaceCardGeneration::print_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
  if (spec()->enable_shared_spaces()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
    st->print("    ro");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
    ro_space()->print_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
    st->print("    rw");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
    rw_space()->print_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
    st->print_cr("No shared spaces configured.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
// References from the perm gen to the younger generation objects may
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
// occur in static fields in Java classes or in constant pool references
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
// to String objects.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
void CompactingPermGenGen::younger_refs_iterate(OopsInGenClosure* blk) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
  OneContigSpaceCardGeneration::younger_refs_iterate(blk);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
  if (spec()->enable_shared_spaces()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
    blk->set_generation(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
    // ro_space has no younger gen refs.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
    _rs->younger_refs_in_space_iterate(rw_space(), blk);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
    blk->reset_generation();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
// Shared spaces are addressed in pre_adjust_pointers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
void CompactingPermGenGen::adjust_pointers() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
  the_space()->adjust_pointers();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
void CompactingPermGenGen::compact() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
  the_space()->compact();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
size_t CompactingPermGenGen::contiguous_available() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
  // Don't include shared spaces.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
  return OneContigSpaceCardGeneration::contiguous_available()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
         - _shared_space_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
size_t CompactingPermGenGen::max_capacity() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
  // Don't include shared spaces.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
  assert(UseSharedSpaces || (_shared_space_size == 0),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
    "If not used, the size of shared spaces should be 0");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
  return OneContigSpaceCardGeneration::max_capacity()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
          - _shared_space_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
// No young generation references, clear this generation's main space's
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
// card table entries.  Do NOT clear the card table entries for the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
// read-only space (always clear) or the read-write space (valuable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
// information).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
void CompactingPermGenGen::clear_remembered_set() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
  _rs->clear(MemRegion(the_space()->bottom(), the_space()->end()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
// Objects in this generation's main space may have moved, invalidate
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
// that space's cards.  Do NOT invalidate the card table entries for the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
// read-only or read-write spaces, as those objects never move.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
void CompactingPermGenGen::invalidate_remembered_set() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
  _rs->invalidate(used_region());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
void CompactingPermGenGen::verify(bool allow_dirty) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
  the_space()->verify(allow_dirty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
  if (!SharedSkipVerify && spec()->enable_shared_spaces()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
    ro_space()->verify(allow_dirty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
    rw_space()->verify(allow_dirty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
HeapWord* CompactingPermGenGen::unshared_bottom;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
HeapWord* CompactingPermGenGen::unshared_end;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
HeapWord* CompactingPermGenGen::shared_bottom;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
HeapWord* CompactingPermGenGen::shared_end;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
HeapWord* CompactingPermGenGen::readonly_bottom;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
HeapWord* CompactingPermGenGen::readonly_end;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
HeapWord* CompactingPermGenGen::readwrite_bottom;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
HeapWord* CompactingPermGenGen::readwrite_end;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
HeapWord* CompactingPermGenGen::miscdata_bottom;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
HeapWord* CompactingPermGenGen::miscdata_end;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
HeapWord* CompactingPermGenGen::misccode_bottom;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
HeapWord* CompactingPermGenGen::misccode_end;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
// JVM/TI RedefineClasses() support:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
bool CompactingPermGenGen::remap_shared_readonly_as_readwrite() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
  assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
  if (UseSharedSpaces) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
    // remap the shared readonly space to shared readwrite, private
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
    FileMapInfo* mapinfo = FileMapInfo::current_info();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
    if (!mapinfo->remap_shared_readonly_as_readwrite()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
      return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
  return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
void** CompactingPermGenGen::_vtbl_list;