src/hotspot/share/gc/serial/markSweep.inline.hpp
author chegar
Thu, 17 Oct 2019 20:54:25 +0100
branchdatagramsocketimpl-branch
changeset 58679 9c3209ff7550
parent 58678 9cf78a70fa4f
parent 58229 722a19a45994
permissions -rw-r--r--
datagramsocketimpl-branch: merge with default
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52907
diff changeset
     2
 * Copyright (c) 2000, 2019, 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: 5076
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5076
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: 5076
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
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52907
diff changeset
    25
#ifndef SHARE_GC_SERIAL_MARKSWEEP_INLINE_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52907
diff changeset
    26
#define SHARE_GC_SERIAL_MARKSWEEP_INLINE_HPP
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    27
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
    28
#include "classfile/classLoaderData.inline.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30150
diff changeset
    29
#include "gc/serial/markSweep.hpp"
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
    30
#include "memory/universe.hpp"
57811
947252a54b98 8229838: Rename markOop files to markWord
stefank
parents: 57777
diff changeset
    31
#include "oops/markWord.inline.hpp"
49592
77fb0be7d19f 8199946: Move load/store and encode/decode out of oopDesc
stefank
parents: 47897
diff changeset
    32
#include "oops/access.inline.hpp"
77fb0be7d19f 8199946: Move load/store and encode/decode out of oopDesc
stefank
parents: 47897
diff changeset
    33
#include "oops/compressedOops.inline.hpp"
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 31346
diff changeset
    34
#include "oops/oop.inline.hpp"
58229
722a19a45994 8231113: Remove CollectedHeap::check_oop_location()
pliden
parents: 58015
diff changeset
    35
#include "utilities/align.hpp"
50772
c1b82eee939f 8205632: Include stack.inline.hpp in markSweep.inline.hpp
stefank
parents: 50752
diff changeset
    36
#include "utilities/stack.inline.hpp"
31346
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
    37
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
    38
inline void MarkSweep::mark_object(oop obj) {
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
    39
  // some marks may contain information we need to preserve so we store them away
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
    40
  // and overwrite the mark.  We'll restore it at the end of markSweep.
57777
90ead0febf56 8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents: 53244
diff changeset
    41
  markWord mark = obj->mark_raw();
90ead0febf56 8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents: 53244
diff changeset
    42
  obj->set_mark_raw(markWord::prototype().set_marked());
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
    43
57812
9bb28ccc6106 8229839: Break circular dependency between oop.inline.hpp and markWord.inline.hpp
stefank
parents: 57811
diff changeset
    44
  if (obj->mark_must_be_preserved(mark)) {
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
    45
    preserve_mark(obj, mark);
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
    46
  }
29792
8c6fa07f0869 8075957: Reduce calls to the GC specific object visitors in oopDesc
stefank
parents: 27624
diff changeset
    47
}
8c6fa07f0869 8075957: Reduce calls to the GC specific object visitors in oopDesc
stefank
parents: 27624
diff changeset
    48
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
    49
template <class T> inline void MarkSweep::mark_and_push(T* p) {
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
    50
  T heap_oop = RawAccess<>::oop_load(p);
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
    51
  if (!CompressedOops::is_null(heap_oop)) {
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
    52
    oop obj = CompressedOops::decode_not_null(heap_oop);
57777
90ead0febf56 8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents: 53244
diff changeset
    53
    if (!obj->mark_raw().is_marked()) {
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
    54
      mark_object(obj);
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
    55
      _marking_stack.push(obj);
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
    56
    }
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
    57
  }
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
    58
}
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
    59
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
    60
inline void MarkSweep::follow_klass(Klass* klass) {
52907
7cc17c043ce0 8214972: Uses of klass_holder() except GC need to apply GC barriers
coleenp
parents: 51796
diff changeset
    61
  oop op = klass->class_loader_data()->holder_no_keepalive();
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
    62
  MarkSweep::mark_and_push(&op);
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
    63
}
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
    64
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
    65
inline void MarkSweep::follow_cld(ClassLoaderData* cld) {
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
    66
  MarkSweep::follow_cld_closure.do_cld(cld);
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
    67
}
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
    68
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
    69
template <typename T>
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
    70
inline void MarkAndPushClosure::do_oop_work(T* p)            { MarkSweep::mark_and_push(p); }
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
    71
inline void MarkAndPushClosure::do_oop(oop* p)               { do_oop_work(p); }
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
    72
inline void MarkAndPushClosure::do_oop(narrowOop* p)         { do_oop_work(p); }
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
    73
inline void MarkAndPushClosure::do_klass(Klass* k)           { MarkSweep::follow_klass(k); }
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
    74
inline void MarkAndPushClosure::do_cld(ClassLoaderData* cld) { MarkSweep::follow_cld(cld); }
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
    75
17105
25b392a7740d 8012687: Remove unused is_root checks and closures
stefank
parents: 15482
diff changeset
    76
template <class T> inline void MarkSweep::adjust_pointer(T* p) {
49592
77fb0be7d19f 8199946: Move load/store and encode/decode out of oopDesc
stefank
parents: 47897
diff changeset
    77
  T heap_oop = RawAccess<>::oop_load(p);
77fb0be7d19f 8199946: Move load/store and encode/decode out of oopDesc
stefank
parents: 47897
diff changeset
    78
  if (!CompressedOops::is_null(heap_oop)) {
77fb0be7d19f 8199946: Move load/store and encode/decode out of oopDesc
stefank
parents: 47897
diff changeset
    79
    oop obj = CompressedOops::decode_not_null(heap_oop);
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29792
diff changeset
    80
    assert(Universe::heap()->is_in(obj), "should be in heap");
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29792
diff changeset
    81
57777
90ead0febf56 8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents: 53244
diff changeset
    82
    oop new_obj = oop(obj->mark_raw().decode_pointer());
46810
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46415
diff changeset
    83
57777
90ead0febf56 8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents: 53244
diff changeset
    84
    assert(new_obj != NULL ||                          // is forwarding ptr?
90ead0febf56 8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents: 53244
diff changeset
    85
           obj->mark_raw() == markWord::prototype() || // not gc marked?
90ead0febf56 8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents: 53244
diff changeset
    86
           (UseBiasedLocking && obj->mark_raw().has_bias_pattern()),
31346
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
    87
           // not gc marked?
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    88
           "should be forwarded");
46810
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46415
diff changeset
    89
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    90
    if (new_obj != NULL) {
58229
722a19a45994 8231113: Remove CollectedHeap::check_oop_location()
pliden
parents: 58015
diff changeset
    91
      assert(is_object_aligned(new_obj), "oop must be aligned");
50728
9375184cec98 8205459: Rename Access API flag decorators
kbarrett
parents: 49722
diff changeset
    92
      RawAccess<IS_NOT_NULL>::oop_store(p, new_obj);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    93
    }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    94
  }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    95
}
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    96
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
    97
template <typename T>
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
    98
void AdjustPointerClosure::do_oop_work(T* p)           { MarkSweep::adjust_pointer(p); }
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
    99
inline void AdjustPointerClosure::do_oop(oop* p)       { do_oop_work(p); }
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
   100
inline void AdjustPointerClosure::do_oop(narrowOop* p) { do_oop_work(p); }
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
   101
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
   102
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
   103
inline int MarkSweep::adjust_pointers(oop obj) {
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
   104
  return obj->oop_iterate_size(&MarkSweep::adjust_pointer_closure);
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
   105
}
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50728
diff changeset
   106
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52907
diff changeset
   107
#endif // SHARE_GC_SERIAL_MARKSWEEP_INLINE_HPP