hotspot/src/share/vm/gc/serial/markSweep.cpp
author brutisso
Thu, 10 Dec 2015 14:57:55 +0100
changeset 35061 be6025ebffea
parent 32606 fdaa30d06ada
child 35498 392b50de06c6
permissions -rw-r--r--
8145092: Use Unified Logging for the GC logging Summary: JEP-271. VM changes contributed by brutisso, test changes contributed by david. Reviewed-by: sjohanss, david, brutisso Contributed-by: bengt.rutisson@oracle.com, david.lindholm@oralce.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
29701
f638fc81a3d0 8075803: Fix GC includes and forward declarations
stefank
parents: 25492
diff changeset
     2
 * Copyright (c) 1997, 2015, 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"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30558
diff changeset
    27
#include "gc/serial/markSweep.inline.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30558
diff changeset
    28
#include "gc/shared/collectedHeap.inline.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30558
diff changeset
    29
#include "gc/shared/gcTimer.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30558
diff changeset
    30
#include "gc/shared/gcTrace.hpp"
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
    31
#include "gc/shared/specialized_oop_closures.hpp"
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
    32
#include "memory/iterator.inline.hpp"
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
    33
#include "oops/instanceClassLoaderKlass.inline.hpp"
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
    34
#include "oops/instanceKlass.inline.hpp"
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
    35
#include "oops/instanceMirrorKlass.inline.hpp"
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
    36
#include "oops/instanceRefKlass.inline.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    37
#include "oops/methodData.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    38
#include "oops/objArrayKlass.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    39
#include "oops/oop.inline.hpp"
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
    40
#include "utilities/macros.hpp"
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
    41
#include "utilities/stack.inline.hpp"
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
    42
#if INCLUDE_ALL_GCS
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
    43
#include "gc/g1/g1StringDedup.hpp"
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
    44
#endif // INCLUDE_ALL_GCS
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
17392
2f967c0e4246 6843347: Boundary values in some public GC options cause crashes
tschatzl
parents: 17105
diff changeset
    46
uint                    MarkSweep::_total_invocations = 0;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    47
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 8921
diff changeset
    48
Stack<oop, mtGC>              MarkSweep::_marking_stack;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 8921
diff changeset
    49
Stack<ObjArrayTask, mtGC>     MarkSweep::_objarray_stack;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 8921
diff changeset
    51
Stack<oop, mtGC>              MarkSweep::_preserved_oop_stack;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 8921
diff changeset
    52
Stack<markOop, mtGC>          MarkSweep::_preserved_mark_stack;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
size_t                  MarkSweep::_preserved_count = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
size_t                  MarkSweep::_preserved_count_max = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
PreservedMark*          MarkSweep::_preserved_marks = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
ReferenceProcessor*     MarkSweep::_ref_processor   = NULL;
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17626
diff changeset
    57
STWGCTimer*             MarkSweep::_gc_timer        = NULL;
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17626
diff changeset
    58
SerialOldTracer*        MarkSweep::_gc_tracer       = NULL;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    60
MarkSweep::FollowRootClosure  MarkSweep::follow_root_closure;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
    62
MarkAndPushClosure            MarkSweep::mark_and_push_closure;
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
    63
CLDToOopClosure               MarkSweep::follow_cld_closure(&mark_and_push_closure);
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
    64
CLDToOopClosure               MarkSweep::adjust_cld_closure(&adjust_pointer_closure);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
    66
inline void MarkSweep::mark_object(oop obj) {
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
    67
#if INCLUDE_ALL_GCS
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
    68
  if (G1StringDedup::is_enabled()) {
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
    69
    // We must enqueue the object before it is marked
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
    70
    // as we otherwise can't read the object's age.
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
    71
    G1StringDedup::enqueue_from_mark(obj);
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
    72
  }
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
    73
#endif
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
    74
  // some marks may contain information we need to preserve so we store them away
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
    75
  // and overwrite the mark.  We'll restore it at the end of markSweep.
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
    76
  markOop mark = obj->mark();
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
    77
  obj->set_mark(markOopDesc::prototype()->set_marked());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
    79
  if (mark->must_be_preserved(obj)) {
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
    80
    preserve_mark(obj, mark);
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
    81
  }
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
    82
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
    83
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
    84
template <class T> inline void MarkSweep::mark_and_push(T* p) {
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
    85
  T heap_oop = oopDesc::load_heap_oop(p);
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
    86
  if (!oopDesc::is_null(heap_oop)) {
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
    87
    oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
    88
    if (!obj->mark()->is_marked() &&
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
    89
        !is_archive_object(obj)) {
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
    90
      mark_object(obj);
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
    91
      _marking_stack.push(obj);
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
    92
    }
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
    93
  }
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
    94
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
    95
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
    96
inline void MarkSweep::follow_klass(Klass* klass) {
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
    97
  oop op = klass->klass_holder();
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
    98
  MarkSweep::mark_and_push(&op);
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
    99
}
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   100
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   101
inline void MarkSweep::follow_cld(ClassLoaderData* cld) {
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   102
  MarkSweep::follow_cld_closure.do_cld(cld);
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   103
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   104
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   105
template <typename T>
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   106
inline void MarkAndPushClosure::do_oop_nv(T* p)                 { MarkSweep::mark_and_push(p); }
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   107
void MarkAndPushClosure::do_oop(oop* p)                         { do_oop_nv(p); }
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   108
void MarkAndPushClosure::do_oop(narrowOop* p)                   { do_oop_nv(p); }
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   109
inline bool MarkAndPushClosure::do_metadata_nv()                { return true; }
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   110
bool MarkAndPushClosure::do_metadata()                          { return do_metadata_nv(); }
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   111
inline void MarkAndPushClosure::do_klass_nv(Klass* k)           { MarkSweep::follow_klass(k); }
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   112
void MarkAndPushClosure::do_klass(Klass* k)                     { do_klass_nv(k); }
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   113
inline void MarkAndPushClosure::do_cld_nv(ClassLoaderData* cld) { MarkSweep::follow_cld(cld); }
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   114
void MarkAndPushClosure::do_cld(ClassLoaderData* cld)           { do_cld_nv(cld); }
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   115
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   116
template <class T> inline void MarkSweep::KeepAliveClosure::do_oop_work(T* p) {
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   117
  mark_and_push(p);
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   118
}
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   119
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   120
void MarkSweep::push_objarray(oop obj, size_t index) {
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   121
  ObjArrayTask task(obj, index);
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   122
  assert(task.is_valid(), "bad ObjArrayTask");
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   123
  _objarray_stack.push(task);
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   124
}
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   125
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   126
inline void MarkSweep::follow_array(objArrayOop array) {
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   127
  MarkSweep::follow_klass(array->klass());
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   128
  // Don't push empty arrays to avoid unnecessary work.
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   129
  if (array->length() > 0) {
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   130
    MarkSweep::push_objarray(array, 0);
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   131
  }
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   132
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   133
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   134
inline void MarkSweep::follow_object(oop obj) {
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   135
  assert(obj->is_gc_marked(), "should be marked");
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   136
  if (obj->is_objArray()) {
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   137
    // Handle object arrays explicitly to allow them to
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   138
    // be split into chunks if needed.
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   139
    MarkSweep::follow_array((objArrayOop)obj);
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   140
  } else {
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   141
    obj->oop_iterate(&mark_and_push_closure);
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   142
  }
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   143
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   144
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   145
void MarkSweep::follow_array_chunk(objArrayOop array, int index) {
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   146
  const int len = array->length();
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   147
  const int beg_index = index;
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   148
  assert(beg_index < len || len == 0, "index too large");
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   149
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   150
  const int stride = MIN2(len - beg_index, (int) ObjArrayMarkingStride);
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   151
  const int end_index = beg_index + stride;
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   152
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   153
  array->oop_iterate_range(&mark_and_push_closure, beg_index, end_index);
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   154
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   155
  if (end_index < len) {
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   156
    MarkSweep::push_objarray(array, end_index); // Push the continuation.
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   157
  }
29792
8c6fa07f0869 8075957: Reduce calls to the GC specific object visitors in oopDesc
stefank
parents: 29701
diff changeset
   158
}
8c6fa07f0869 8075957: Reduce calls to the GC specific object visitors in oopDesc
stefank
parents: 29701
diff changeset
   159
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
void MarkSweep::follow_stack() {
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3919
diff changeset
   161
  do {
6762
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
   162
    while (!_marking_stack.is_empty()) {
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
   163
      oop obj = _marking_stack.pop();
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3919
diff changeset
   164
      assert (obj->is_gc_marked(), "p must be marked");
29792
8c6fa07f0869 8075957: Reduce calls to the GC specific object visitors in oopDesc
stefank
parents: 29701
diff changeset
   165
      follow_object(obj);
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3919
diff changeset
   166
    }
5080
eff0cc882603 6935839: excessive marking stack growth during full gcs
jcoomes
parents: 5076
diff changeset
   167
    // 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
   168
    if (!_objarray_stack.is_empty()) {
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
   169
      ObjArrayTask task = _objarray_stack.pop();
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   170
      follow_array_chunk(objArrayOop(task.obj()), task.index());
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3919
diff changeset
   171
    }
6762
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
   172
  } while (!_marking_stack.is_empty() || !_objarray_stack.is_empty());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
MarkSweep::FollowStackClosure MarkSweep::follow_stack_closure;
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::FollowStackClosure::do_void() { follow_stack(); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   179
template <class T> inline void MarkSweep::follow_root(T* p) {
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   180
  assert(!Universe::heap()->is_in_reserved(p),
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   181
         "roots shouldn't be things within the heap");
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   182
  T heap_oop = oopDesc::load_heap_oop(p);
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   183
  if (!oopDesc::is_null(heap_oop)) {
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   184
    oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   185
    if (!obj->mark()->is_marked() &&
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   186
        !is_archive_object(obj)) {
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   187
      mark_object(obj);
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   188
      follow_object(obj);
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   189
    }
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   190
  }
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   191
  follow_stack();
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   192
}
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   193
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   194
void MarkSweep::FollowRootClosure::do_oop(oop* p)       { follow_root(p); }
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   195
void MarkSweep::FollowRootClosure::do_oop(narrowOop* p) { follow_root(p); }
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   196
29701
f638fc81a3d0 8075803: Fix GC includes and forward declarations
stefank
parents: 25492
diff changeset
   197
void PreservedMark::adjust_pointer() {
f638fc81a3d0 8075803: Fix GC includes and forward declarations
stefank
parents: 25492
diff changeset
   198
  MarkSweep::adjust_pointer(&_obj);
f638fc81a3d0 8075803: Fix GC includes and forward declarations
stefank
parents: 25492
diff changeset
   199
}
f638fc81a3d0 8075803: Fix GC includes and forward declarations
stefank
parents: 25492
diff changeset
   200
f638fc81a3d0 8075803: Fix GC includes and forward declarations
stefank
parents: 25492
diff changeset
   201
void PreservedMark::restore() {
f638fc81a3d0 8075803: Fix GC includes and forward declarations
stefank
parents: 25492
diff changeset
   202
  _obj->set_mark(_mark);
f638fc81a3d0 8075803: Fix GC includes and forward declarations
stefank
parents: 25492
diff changeset
   203
}
f638fc81a3d0 8075803: Fix GC includes and forward declarations
stefank
parents: 25492
diff changeset
   204
6762
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
   205
// 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
   206
// 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
   207
// currently at that address but it will be after phase4
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
void MarkSweep::preserve_mark(oop obj, markOop mark) {
6762
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
   209
  // 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
   210
  // 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
   211
  // 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
   212
  // back to using Stacks to keep track of the overflow.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  if (_preserved_count < _preserved_count_max) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
    _preserved_marks[_preserved_count++].init(obj, mark);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  } else {
6762
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
   216
    _preserved_mark_stack.push(mark);
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
   217
    _preserved_oop_stack.push(obj);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   221
void MarkSweep::set_ref_processor(ReferenceProcessor* rp) {
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   222
  _ref_processor = rp;
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   223
  mark_and_push_closure.set_ref_processor(_ref_processor);
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   224
}
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   225
17105
25b392a7740d 8012687: Remove unused is_root checks and closures
stefank
parents: 15088
diff changeset
   226
MarkSweep::AdjustPointerClosure MarkSweep::adjust_pointer_closure;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   228
template <typename T>
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   229
void MarkSweep::AdjustPointerClosure::do_oop_nv(T* p)      { adjust_pointer(p); }
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   230
void MarkSweep::AdjustPointerClosure::do_oop(oop* p)       { do_oop_nv(p); }
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   231
void MarkSweep::AdjustPointerClosure::do_oop(narrowOop* p) { do_oop_nv(p); }
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   232
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
void MarkSweep::adjust_marks() {
6762
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
   234
  assert( _preserved_oop_stack.size() == _preserved_mark_stack.size(),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
         "inconsistent preserved oop stacks");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  // adjust the oops we saved earlier
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  for (size_t i = 0; i < _preserved_count; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
    _preserved_marks[i].adjust_pointer();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  // deal with the overflow stack
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 8921
diff changeset
   243
  StackIterator<oop, mtGC> iter(_preserved_oop_stack);
6762
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
   244
  while (!iter.is_empty()) {
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
   245
    oop* p = iter.next_addr();
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
   246
    adjust_pointer(p);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
void MarkSweep::restore_marks() {
6762
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
   251
  assert(_preserved_oop_stack.size() == _preserved_mark_stack.size(),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
         "inconsistent preserved oop stacks");
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 32606
diff changeset
   253
  log_trace(gc)("Restoring " SIZE_FORMAT " marks", _preserved_count + _preserved_oop_stack.size());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  // restore the marks we saved earlier
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  for (size_t i = 0; i < _preserved_count; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
    _preserved_marks[i].restore();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  // deal with the overflow
6762
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
   261
  while (!_preserved_oop_stack.is_empty()) {
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
   262
    oop obj       = _preserved_oop_stack.pop();
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
   263
    markOop mark  = _preserved_mark_stack.pop();
f8d1b560700e 6423256: GC stacks should use a better data structure
jcoomes
parents: 5547
diff changeset
   264
    obj->set_mark(mark);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   268
MarkSweep::IsAliveClosure   MarkSweep::is_alive;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
31346
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   270
bool MarkSweep::IsAliveClosure::do_object_b(oop p) { return p->is_gc_marked() || is_archive_object(p); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
MarkSweep::KeepAliveClosure MarkSweep::keep_alive;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   274
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
   275
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
   276
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17626
diff changeset
   277
void marksweep_init() {
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17626
diff changeset
   278
  MarkSweep::_gc_timer = new (ResourceObj::C_HEAP, mtGC) STWGCTimer();
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17626
diff changeset
   279
  MarkSweep::_gc_tracer = new (ResourceObj::C_HEAP, mtGC) SerialOldTracer();
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17626
diff changeset
   280
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   282
int InstanceKlass::oop_ms_adjust_pointers(oop obj) {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   283
  int size = size_helper();
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   284
  oop_oop_iterate_oop_maps<true>(obj, &MarkSweep::adjust_pointer_closure);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   285
  return size;
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   286
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   287
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   288
int InstanceMirrorKlass::oop_ms_adjust_pointers(oop obj) {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   289
  int size = oop_size(obj);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   290
  InstanceKlass::oop_ms_adjust_pointers(obj);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   291
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   292
  oop_oop_iterate_statics<true>(obj, &MarkSweep::adjust_pointer_closure);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   293
  return size;
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   294
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   295
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   296
int InstanceClassLoaderKlass::oop_ms_adjust_pointers(oop obj) {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   297
  return InstanceKlass::oop_ms_adjust_pointers(obj);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   298
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   299
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   300
#ifdef ASSERT
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   301
template <class T> static void trace_reference_gc(const char *s, oop obj,
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   302
                                                  T* referent_addr,
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   303
                                                  T* next_addr,
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   304
                                                  T* discovered_addr) {
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 32606
diff changeset
   305
  log_develop_trace(gc, ref)("%s obj " PTR_FORMAT, s, p2i(obj));
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 32606
diff changeset
   306
  log_develop_trace(gc, ref)("     referent_addr/* " PTR_FORMAT " / " PTR_FORMAT,
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 32606
diff changeset
   307
                             p2i(referent_addr), p2i(referent_addr ? (address)oopDesc::load_decode_heap_oop(referent_addr) : NULL));
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 32606
diff changeset
   308
  log_develop_trace(gc, ref)("     next_addr/* " PTR_FORMAT " / " PTR_FORMAT,
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 32606
diff changeset
   309
                             p2i(next_addr), p2i(next_addr ? (address)oopDesc::load_decode_heap_oop(next_addr) : NULL));
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 32606
diff changeset
   310
  log_develop_trace(gc, ref)("     discovered_addr/* " PTR_FORMAT " / " PTR_FORMAT,
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 32606
diff changeset
   311
                             p2i(discovered_addr), p2i(discovered_addr ? (address)oopDesc::load_decode_heap_oop(discovered_addr) : NULL));
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   312
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   313
#endif
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   314
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   315
template <class T> void static adjust_object_specialized(oop obj) {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   316
  T* referent_addr = (T*)java_lang_ref_Reference::referent_addr(obj);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   317
  MarkSweep::adjust_pointer(referent_addr);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   318
  T* next_addr = (T*)java_lang_ref_Reference::next_addr(obj);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   319
  MarkSweep::adjust_pointer(next_addr);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   320
  T* discovered_addr = (T*)java_lang_ref_Reference::discovered_addr(obj);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   321
  MarkSweep::adjust_pointer(discovered_addr);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   322
  debug_only(trace_reference_gc("InstanceRefKlass::oop_ms_adjust_pointers", obj,
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   323
                                referent_addr, next_addr, discovered_addr);)
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   324
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   325
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   326
int InstanceRefKlass::oop_ms_adjust_pointers(oop obj) {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   327
  int size = size_helper();
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   328
  InstanceKlass::oop_ms_adjust_pointers(obj);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   329
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   330
  if (UseCompressedOops) {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   331
    adjust_object_specialized<narrowOop>(obj);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   332
  } else {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   333
    adjust_object_specialized<oop>(obj);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   334
  }
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   335
  return size;
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   336
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   337
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   338
int ObjArrayKlass::oop_ms_adjust_pointers(oop obj) {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   339
  assert(obj->is_objArray(), "obj must be obj array");
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   340
  objArrayOop a = objArrayOop(obj);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   341
  // Get size before changing pointers.
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   342
  // Don't call size() or oop_size() since that is a virtual call.
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   343
  int size = a->object_size();
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   344
  oop_oop_iterate_elements<true>(a, &MarkSweep::adjust_pointer_closure);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   345
  return size;
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   346
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   347
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   348
int TypeArrayKlass::oop_ms_adjust_pointers(oop obj) {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   349
  assert(obj->is_typeArray(), "must be a type array");
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   350
  typeArrayOop t = typeArrayOop(obj);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   351
  // Performance tweak: We skip iterating over the klass pointer since we
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   352
  // know that Universe::TypeArrayKlass never moves.
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   353
  return t->object_size();
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29800
diff changeset
   354
}
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   355
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   356
// Generate MS specialized oop_oop_iterate functions.
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
   357
SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_MS(ALL_KLASS_OOP_OOP_ITERATE_DEFN)