hotspot/src/share/vm/gc_implementation/shared/markSweep.cpp
author sla
Mon, 10 Jun 2013 11:30:51 +0200
changeset 18025 b7bcf7497f93
parent 17626 bc4e072add30
child 21916 4977554a0c5e
permissions -rw-r--r--
8005849: JEP 167: Event-Based JVM Tracing Reviewed-by: acorn, coleenp, sla Contributed-by: Karen Kinnear <karen.kinnear@oracle.com>, Bengt Rutisson <bengt.rutisson@oracle.com>, Calvin Cheung <calvin.cheung@oracle.com>, Erik Gahlin <erik.gahlin@oracle.com>, Erik Helin <erik.helin@oracle.com>, Jesper Wilhelmsson <jesper.wilhelmsson@oracle.com>, Keith McGuigan <keith.mcguigan@oracle.com>, Mattias Tobiasson <mattias.tobiasson@oracle.com>, Markus Gronlund <markus.gronlund@oracle.com>, Mikael Auno <mikael.auno@oracle.com>, Nils Eliasson <nils.eliasson@oracle.com>, Nils Loodin <nils.loodin@oracle.com>, Rickard Backman <rickard.backman@oracle.com>, Staffan Larsen <staffan.larsen@oracle.com>, Stefan Karlsson <stefan.karlsson@oracle.com>, Yekaterina Kantserova <yekaterina.kantserova@oracle.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
17370
59a0620561fa 8003557: NPG: Klass* const k should be const Klass* k.
minqi
parents: 17105
diff changeset
     2
 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. 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
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5080
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5080
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5080
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    26
#include "compiler/compileBroker.hpp"
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17626
diff changeset
    27
#include "gc_implementation/shared/gcTimer.hpp"
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17626
diff changeset
    28
#include "gc_implementation/shared/gcTrace.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    29
#include "gc_implementation/shared/markSweep.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    30
#include "gc_interface/collectedHeap.inline.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    31
#include "oops/methodData.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    32
#include "oops/objArrayKlass.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    33
#include "oops/oop.inline.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
17392
2f967c0e4246 6843347: Boundary values in some public GC options cause crashes
tschatzl
parents: 17105
diff changeset
    35
uint                    MarkSweep::_total_invocations = 0;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    36
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 8921
diff changeset
    37
Stack<oop, mtGC>              MarkSweep::_marking_stack;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 8921
diff changeset
    38
Stack<ObjArrayTask, mtGC>     MarkSweep::_objarray_stack;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 8921
diff changeset
    40
Stack<oop, mtGC>              MarkSweep::_preserved_oop_stack;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 8921
diff changeset
    41
Stack<markOop, mtGC>          MarkSweep::_preserved_mark_stack;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
size_t                  MarkSweep::_preserved_count = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
size_t                  MarkSweep::_preserved_count_max = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
PreservedMark*          MarkSweep::_preserved_marks = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
ReferenceProcessor*     MarkSweep::_ref_processor   = NULL;
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17626
diff changeset
    46
STWGCTimer*             MarkSweep::_gc_timer        = NULL;
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17626
diff changeset
    47
SerialOldTracer*        MarkSweep::_gc_tracer       = NULL;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    49
MarkSweep::FollowRootClosure  MarkSweep::follow_root_closure;
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 670
diff changeset
    50
CodeBlobToOopClosure MarkSweep::follow_code_root_closure(&MarkSweep::follow_root_closure, /*do_marking=*/ true);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    52
void MarkSweep::FollowRootClosure::do_oop(oop* p)       { follow_root(p); }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    53
void MarkSweep::FollowRootClosure::do_oop(narrowOop* p) { follow_root(p); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
MarkSweep::MarkAndPushClosure MarkSweep::mark_and_push_closure;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    56
MarkSweep::FollowKlassClosure MarkSweep::follow_klass_closure;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    57
MarkSweep::AdjustKlassClosure MarkSweep::adjust_klass_closure;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    59
void MarkSweep::MarkAndPushClosure::do_oop(oop* p)       { mark_and_push(p); }
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    60
void MarkSweep::MarkAndPushClosure::do_oop(narrowOop* p) { mark_and_push(p); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    62
void MarkSweep::FollowKlassClosure::do_klass(Klass* klass) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    63
  klass->oops_do(&MarkSweep::mark_and_push_closure);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    64
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    65
void MarkSweep::AdjustKlassClosure::do_klass(Klass* klass) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    66
  klass->oops_do(&MarkSweep::adjust_pointer_closure);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    67
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    68
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    69
void MarkSweep::follow_klass(Klass* klass) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    70
  ClassLoaderData* cld = klass->class_loader_data();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    71
  // The actual processing of the klass is done when we
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    72
  // traverse the list of Klasses in the class loader data.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    73
  MarkSweep::follow_class_loader(cld);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    74
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    75
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    76
void MarkSweep::adjust_klass(Klass* klass) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    77
  ClassLoaderData* cld = klass->class_loader_data();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    78
  // The actual processing of the klass is done when we
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    79
  // traverse the list of Klasses in the class loader data.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    80
  MarkSweep::adjust_class_loader(cld);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    81
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    82
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    83
void MarkSweep::follow_class_loader(ClassLoaderData* cld) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    84
  cld->oops_do(&MarkSweep::mark_and_push_closure, &MarkSweep::follow_klass_closure, true);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    85
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    86
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    87
void MarkSweep::adjust_class_loader(ClassLoaderData* cld) {
17105
25b392a7740d 8012687: Remove unused is_root checks and closures
stefank
parents: 15088
diff changeset
    88
  cld->oops_do(&MarkSweep::adjust_pointer_closure, &MarkSweep::adjust_klass_closure, true);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    89
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    90
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    91
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
void MarkSweep::follow_stack() {
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3919
diff changeset
    93
  do {
6762
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
    94
    while (!_marking_stack.is_empty()) {
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
    95
      oop obj = _marking_stack.pop();
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3919
diff changeset
    96
      assert (obj->is_gc_marked(), "p must be marked");
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3919
diff changeset
    97
      obj->follow_contents();
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3919
diff changeset
    98
    }
5080
eff0cc882603 6935839: excessive marking stack growth during full gcs
jcoomes
parents: 5076
diff changeset
    99
    // Process ObjArrays one at a time to avoid marking stack bloat.
6762
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
   100
    if (!_objarray_stack.is_empty()) {
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
   101
      ObjArrayTask task = _objarray_stack.pop();
17370
59a0620561fa 8003557: NPG: Klass* const k should be const Klass* k.
minqi
parents: 17105
diff changeset
   102
      ObjArrayKlass* k = (ObjArrayKlass*)task.obj()->klass();
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3919
diff changeset
   103
      k->oop_follow_contents(task.obj(), task.index());
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3919
diff changeset
   104
    }
6762
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
   105
  } while (!_marking_stack.is_empty() || !_objarray_stack.is_empty());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
MarkSweep::FollowStackClosure MarkSweep::follow_stack_closure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   110
void MarkSweep::FollowStackClosure::do_void() { follow_stack(); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
6762
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
   112
// We preserve the mark which should be replaced at the end and the location
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
   113
// that it will go.  Note that the object that this markOop belongs to isn't
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
   114
// currently at that address but it will be after phase4
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
void MarkSweep::preserve_mark(oop obj, markOop mark) {
6762
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
   116
  // We try to store preserved marks in the to space of the new generation since
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
   117
  // this is storage which should be available.  Most of the time this should be
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
   118
  // sufficient space for the marks we need to preserve but if it isn't we fall
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
   119
  // back to using Stacks to keep track of the overflow.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  if (_preserved_count < _preserved_count_max) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
    _preserved_marks[_preserved_count++].init(obj, mark);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  } else {
6762
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
   123
    _preserved_mark_stack.push(mark);
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
   124
    _preserved_oop_stack.push(obj);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
17105
25b392a7740d 8012687: Remove unused is_root checks and closures
stefank
parents: 15088
diff changeset
   128
MarkSweep::AdjustPointerClosure MarkSweep::adjust_pointer_closure;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
17105
25b392a7740d 8012687: Remove unused is_root checks and closures
stefank
parents: 15088
diff changeset
   130
void MarkSweep::AdjustPointerClosure::do_oop(oop* p)       { adjust_pointer(p); }
25b392a7740d 8012687: Remove unused is_root checks and closures
stefank
parents: 15088
diff changeset
   131
void MarkSweep::AdjustPointerClosure::do_oop(narrowOop* p) { adjust_pointer(p); }
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   132
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
void MarkSweep::adjust_marks() {
6762
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
   134
  assert( _preserved_oop_stack.size() == _preserved_mark_stack.size(),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
         "inconsistent preserved oop stacks");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  // adjust the oops we saved earlier
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  for (size_t i = 0; i < _preserved_count; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
    _preserved_marks[i].adjust_pointer();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  // deal with the overflow stack
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 8921
diff changeset
   143
  StackIterator<oop, mtGC> iter(_preserved_oop_stack);
6762
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
   144
  while (!iter.is_empty()) {
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
   145
    oop* p = iter.next_addr();
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
   146
    adjust_pointer(p);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
void MarkSweep::restore_marks() {
6762
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
   151
  assert(_preserved_oop_stack.size() == _preserved_mark_stack.size(),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
         "inconsistent preserved oop stacks");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  if (PrintGC && Verbose) {
6762
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
   154
    gclog_or_tty->print_cr("Restoring %d marks",
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
   155
                           _preserved_count + _preserved_oop_stack.size());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  // restore the marks we saved earlier
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  for (size_t i = 0; i < _preserved_count; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
    _preserved_marks[i].restore();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  // deal with the overflow
6762
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
   164
  while (!_preserved_oop_stack.is_empty()) {
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
   165
    oop obj       = _preserved_oop_stack.pop();
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
   166
    markOop mark  = _preserved_mark_stack.pop();
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
   167
    obj->set_mark(mark);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   171
MarkSweep::IsAliveClosure   MarkSweep::is_alive;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   173
bool MarkSweep::IsAliveClosure::do_object_b(oop p) { return p->is_gc_marked(); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
MarkSweep::KeepAliveClosure MarkSweep::keep_alive;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   177
void MarkSweep::KeepAliveClosure::do_oop(oop* p)       { MarkSweep::KeepAliveClosure::do_oop_work(p); }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   178
void MarkSweep::KeepAliveClosure::do_oop(narrowOop* p) { MarkSweep::KeepAliveClosure::do_oop_work(p); }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   179
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17626
diff changeset
   180
void marksweep_init() {
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17626
diff changeset
   181
  MarkSweep::_gc_timer = new (ResourceObj::C_HEAP, mtGC) STWGCTimer();
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17626
diff changeset
   182
  MarkSweep::_gc_tracer = new (ResourceObj::C_HEAP, mtGC) SerialOldTracer();
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17626
diff changeset
   183
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
void MarkSweep::trace(const char* msg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  if (TraceMarkSweep)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
    gclog_or_tty->print("%s", msg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
#endif