hotspot/src/share/vm/gc_implementation/parNew/parOopClosures.inline.hpp
author drchase
Fri, 09 May 2014 16:50:54 -0400
changeset 24424 2658d7834c6e
parent 20282 7f9cbdf89af2
child 27906 35c65cbbe92b
permissions -rw-r--r--
8037816: Fix for 8036122 breaks build with Xcode5/clang Summary: Repaired or selectively disabled offending formats; future-proofed with additional checking Reviewed-by: kvn, jrose, stefank
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 20282
diff changeset
     2
 * Copyright (c) 2007, 2014, 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: 360
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 360
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: 360
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: 5547
diff changeset
    25
#ifndef SHARE_VM_GC_IMPLEMENTATION_PARNEW_PAROOPCLOSURES_INLINE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_GC_IMPLEMENTATION_PARNEW_PAROOPCLOSURES_INLINE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "gc_implementation/parNew/parNewGeneration.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "gc_implementation/parNew/parOopClosures.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "memory/cardTableRS.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    32
template <class T> inline void ParScanWeakRefClosure::do_oop_work(T* p) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    33
  assert (!oopDesc::is_null(*p), "null weak reference?");
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    34
  oop obj = oopDesc::load_decode_heap_oop_not_null(p);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
  // weak references are sometimes scanned twice; must check
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
  // that to-space doesn't already contain this object
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
  if ((HeapWord*)obj < _boundary && !_g->to()->is_in_reserved(obj)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
    // we need to ensure that it is copied (see comment in
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
    // ParScanClosure::do_oop_work).
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9624
diff changeset
    40
    Klass* objK = obj->klass();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
    markOop m = obj->mark();
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    42
    oop new_obj;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
    if (m->is_marked()) { // Contains forwarding pointer.
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    44
      new_obj = ParNewGeneration::real_forwardee(obj);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
    } else {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9624
diff changeset
    46
      size_t obj_sz = obj->size_given_klass(objK);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    47
      new_obj = ((ParNewGeneration*)_g)->copy_to_survivor_space(_par_scan_state,
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    48
                                                                obj, obj_sz, m);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
    }
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    50
    oopDesc::encode_store_heap_oop_not_null(p, new_obj);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    54
inline void ParScanWeakRefClosure::do_oop_nv(oop* p)       { ParScanWeakRefClosure::do_oop_work(p); }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    55
inline void ParScanWeakRefClosure::do_oop_nv(narrowOop* p) { ParScanWeakRefClosure::do_oop_work(p); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    57
template <class T> inline void ParScanClosure::par_do_barrier(T* p) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  assert(generation()->is_in_reserved(p), "expected ref in generation");
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    59
  assert(!oopDesc::is_null(*p), "expected non-null object");
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    60
  oop obj = oopDesc::load_decode_heap_oop_not_null(p);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  // If p points to a younger generation, mark the card.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  if ((HeapWord*)obj < gen_boundary()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
    rs()->write_ref_field_gc_par(p, obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    67
template <class T>
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    68
inline void ParScanClosure::do_oop_work(T* p,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
                                        bool gc_barrier,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
                                        bool root_scan) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  assert((!Universe::heap()->is_in_reserved(p) ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
          generation()->is_in_reserved(p))
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
         && (generation()->level() == 0 || gc_barrier),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
         "The gen must be right, and we must be doing the barrier "
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
         "in older generations.");
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    76
  T heap_oop = oopDesc::load_heap_oop(p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    77
  if (!oopDesc::is_null(heap_oop)) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    78
    oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
    if ((HeapWord*)obj < _boundary) {
9624
c3657c3324ee 6883834: ParNew: assert(!_g->to()->is_in_reserved(obj),"Scanning field twice?") with LargeObjects tests
ysr
parents: 7397
diff changeset
    80
#ifndef PRODUCT
c3657c3324ee 6883834: ParNew: assert(!_g->to()->is_in_reserved(obj),"Scanning field twice?") with LargeObjects tests
ysr
parents: 7397
diff changeset
    81
      if (_g->to()->is_in_reserved(obj)) {
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 20282
diff changeset
    82
        tty->print_cr("Scanning field (" PTR_FORMAT ") twice?", p2i(p));
9624
c3657c3324ee 6883834: ParNew: assert(!_g->to()->is_in_reserved(obj),"Scanning field twice?") with LargeObjects tests
ysr
parents: 7397
diff changeset
    83
        GenCollectedHeap* gch =  (GenCollectedHeap*)Universe::heap();
c3657c3324ee 6883834: ParNew: assert(!_g->to()->is_in_reserved(obj),"Scanning field twice?") with LargeObjects tests
ysr
parents: 7397
diff changeset
    84
        Space* sp = gch->space_containing(p);
c3657c3324ee 6883834: ParNew: assert(!_g->to()->is_in_reserved(obj),"Scanning field twice?") with LargeObjects tests
ysr
parents: 7397
diff changeset
    85
        oop obj = oop(sp->block_start(p));
c3657c3324ee 6883834: ParNew: assert(!_g->to()->is_in_reserved(obj),"Scanning field twice?") with LargeObjects tests
ysr
parents: 7397
diff changeset
    86
        assert((HeapWord*)obj < (HeapWord*)p, "Error");
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 20282
diff changeset
    87
        tty->print_cr("Object: " PTR_FORMAT, p2i((void *)obj));
9624
c3657c3324ee 6883834: ParNew: assert(!_g->to()->is_in_reserved(obj),"Scanning field twice?") with LargeObjects tests
ysr
parents: 7397
diff changeset
    88
        tty->print_cr("-------");
c3657c3324ee 6883834: ParNew: assert(!_g->to()->is_in_reserved(obj),"Scanning field twice?") with LargeObjects tests
ysr
parents: 7397
diff changeset
    89
        obj->print();
c3657c3324ee 6883834: ParNew: assert(!_g->to()->is_in_reserved(obj),"Scanning field twice?") with LargeObjects tests
ysr
parents: 7397
diff changeset
    90
        tty->print_cr("-----");
c3657c3324ee 6883834: ParNew: assert(!_g->to()->is_in_reserved(obj),"Scanning field twice?") with LargeObjects tests
ysr
parents: 7397
diff changeset
    91
        tty->print_cr("Heap:");
c3657c3324ee 6883834: ParNew: assert(!_g->to()->is_in_reserved(obj),"Scanning field twice?") with LargeObjects tests
ysr
parents: 7397
diff changeset
    92
        tty->print_cr("-----");
c3657c3324ee 6883834: ParNew: assert(!_g->to()->is_in_reserved(obj),"Scanning field twice?") with LargeObjects tests
ysr
parents: 7397
diff changeset
    93
        gch->print();
c3657c3324ee 6883834: ParNew: assert(!_g->to()->is_in_reserved(obj),"Scanning field twice?") with LargeObjects tests
ysr
parents: 7397
diff changeset
    94
        ShouldNotReachHere();
c3657c3324ee 6883834: ParNew: assert(!_g->to()->is_in_reserved(obj),"Scanning field twice?") with LargeObjects tests
ysr
parents: 7397
diff changeset
    95
      }
c3657c3324ee 6883834: ParNew: assert(!_g->to()->is_in_reserved(obj),"Scanning field twice?") with LargeObjects tests
ysr
parents: 7397
diff changeset
    96
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
      // OK, we need to ensure that it is copied.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
      // We read the klass and mark in this order, so that we can reliably
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
      // get the size of the object: if the mark we read is not a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
      // forwarding pointer, then the klass is valid: the klass is only
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
      // overwritten with an overflow next pointer after the object is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
      // forwarded.
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9624
diff changeset
   103
      Klass* objK = obj->klass();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
      markOop m = obj->mark();
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   105
      oop new_obj;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
      if (m->is_marked()) { // Contains forwarding pointer.
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   107
        new_obj = ParNewGeneration::real_forwardee(obj);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   108
        oopDesc::encode_store_heap_oop_not_null(p, new_obj);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9624
diff changeset
   109
#ifndef PRODUCT
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9624
diff changeset
   110
        if (TraceScavenge) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9624
diff changeset
   111
          gclog_or_tty->print_cr("{%s %s ( " PTR_FORMAT " ) " PTR_FORMAT " -> " PTR_FORMAT " (%d)}",
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9624
diff changeset
   112
             "forwarded ",
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 20282
diff changeset
   113
             new_obj->klass()->internal_name(), p2i(p), p2i((void *)obj), p2i((void *)new_obj), new_obj->size());
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9624
diff changeset
   114
        }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9624
diff changeset
   115
#endif
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9624
diff changeset
   116
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
      } else {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9624
diff changeset
   118
        size_t obj_sz = obj->size_given_klass(objK);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   119
        new_obj = _g->copy_to_survivor_space(_par_scan_state, obj, obj_sz, m);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   120
        oopDesc::encode_store_heap_oop_not_null(p, new_obj);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
        if (root_scan) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
          // This may have pushed an object.  If we have a root
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
          // category with a lot of roots, can't let the queue get too
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
          // full:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
          (void)_par_scan_state->trim_queues(10 * ParallelGCThreads);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
      }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9624
diff changeset
   128
      if (is_scanning_a_klass()) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9624
diff changeset
   129
        do_klass_barrier();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9624
diff changeset
   130
      } else if (gc_barrier) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
        // Now call parent closure
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
        par_do_barrier(p);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
}
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   137
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   138
inline void ParScanWithBarrierClosure::do_oop_nv(oop* p)       { ParScanClosure::do_oop_work(p, true, false); }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   139
inline void ParScanWithBarrierClosure::do_oop_nv(narrowOop* p) { ParScanClosure::do_oop_work(p, true, false); }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   140
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   141
inline void ParScanWithoutBarrierClosure::do_oop_nv(oop* p)       { ParScanClosure::do_oop_work(p, false, false); }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   142
inline void ParScanWithoutBarrierClosure::do_oop_nv(narrowOop* p) { ParScanClosure::do_oop_work(p, false, false); }
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   143
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   144
#endif // SHARE_VM_GC_IMPLEMENTATION_PARNEW_PAROOPCLOSURES_INLINE_HPP