hotspot/src/share/vm/oops/instanceRefKlass.cpp
author coleenp
Sat, 01 Sep 2012 13:25:18 -0400
changeset 13728 882756847a04
parent 12780 689210d5dd05
child 13738 d67be49a5beb
permissions -rw-r--r--
6964458: Reimplement class meta-data storage to use native memory Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
12379
2cf45b79ce3a 4988100: oop_verify_old_oop appears to be dead
brutisso
parents: 10537
diff changeset
     2
 * Copyright (c) 1997, 2012, 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: 4573
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4573
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: 4573
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: 6248
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    26
#include "classfile/javaClasses.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    27
#include "classfile/systemDictionary.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    28
#include "gc_implementation/shared/markSweep.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    29
#include "gc_interface/collectedHeap.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    30
#include "gc_interface/collectedHeap.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    31
#include "memory/genCollectedHeap.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    32
#include "memory/genOopClosures.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    33
#include "oops/instanceRefKlass.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    34
#include "oops/oop.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    35
#include "utilities/preserveException.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    36
#ifndef SERIALGC
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    37
#include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    38
#include "gc_implementation/g1/g1OopClosures.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    39
#include "gc_implementation/g1/g1RemSet.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    40
#include "gc_implementation/g1/heapRegionSeq.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    41
#include "gc_implementation/parNew/parOopClosures.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    42
#include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    43
#include "gc_implementation/parallelScavenge/psScavenge.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    44
#include "oops/oop.pcgc.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    45
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    47
template <class T>
10537
23539f11e110 7090259: Fix hotspot sources to build with old compilers
kvn
parents: 10526
diff changeset
    48
void specialized_oop_follow_contents(instanceRefKlass* ref, oop obj) {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    49
  T* referent_addr = (T*)java_lang_ref_Reference::referent_addr(obj);
3262
30d1c247fc25 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 1388
diff changeset
    50
  T heap_oop = oopDesc::load_heap_oop(referent_addr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  debug_only(
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
    if(TraceReferenceGC && PrintGCDetails) {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    53
      gclog_or_tty->print_cr("instanceRefKlass::oop_follow_contents " INTPTR_FORMAT, obj);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  )
3262
30d1c247fc25 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 1388
diff changeset
    56
  if (!oopDesc::is_null(heap_oop)) {
30d1c247fc25 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 1388
diff changeset
    57
    oop referent = oopDesc::decode_heap_oop_not_null(heap_oop);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
    if (!referent->is_gc_marked() &&
10526
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
    59
        MarkSweep::ref_processor()->discover_reference(obj, ref->reference_type())) {
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
    60
      // reference was discovered, referent will be traversed later
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12780
diff changeset
    61
      ref->InstanceKlass::oop_follow_contents(obj);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    62
      debug_only(
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    63
        if(TraceReferenceGC && PrintGCDetails) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    64
          gclog_or_tty->print_cr("       Non NULL enqueued " INTPTR_FORMAT, obj);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    65
        }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    66
      )
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    67
      return;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    68
    } else {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    69
      // treat referent as normal oop
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
      debug_only(
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
        if(TraceReferenceGC && PrintGCDetails) {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    72
          gclog_or_tty->print_cr("       Non NULL normal " INTPTR_FORMAT, obj);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    73
        }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    74
      )
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    75
      MarkSweep::mark_and_push(referent_addr);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    76
    }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    77
  }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    78
  T* next_addr = (T*)java_lang_ref_Reference::next_addr(obj);
10526
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
    79
  if (ReferenceProcessor::pending_list_uses_discovered_field()) {
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
    80
    // Treat discovered as normal oop, if ref is not "active",
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
    81
    // i.e. if next is non-NULL.
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
    82
    T  next_oop = oopDesc::load_heap_oop(next_addr);
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
    83
    if (!oopDesc::is_null(next_oop)) { // i.e. ref is not "active"
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
    84
      T* discovered_addr = (T*)java_lang_ref_Reference::discovered_addr(obj);
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
    85
      debug_only(
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
    86
        if(TraceReferenceGC && PrintGCDetails) {
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
    87
          gclog_or_tty->print_cr("   Process discovered as normal "
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
    88
                                 INTPTR_FORMAT, discovered_addr);
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
    89
        }
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
    90
      )
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
    91
      MarkSweep::mark_and_push(discovered_addr);
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
    92
    }
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
    93
  } else {
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
    94
#ifdef ASSERT
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
    95
    // In the case of older JDKs which do not use the discovered
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
    96
    // field for the pending list, an inactive ref (next != NULL)
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
    97
    // must always have a NULL discovered field.
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
    98
    oop next = oopDesc::load_decode_heap_oop(next_addr);
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
    99
    oop discovered = java_lang_ref_Reference::discovered(obj);
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   100
    assert(oopDesc::is_null(next) || oopDesc::is_null(discovered),
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   101
           err_msg("Found an inactive reference " PTR_FORMAT " with a non-NULL discovered field",
10537
23539f11e110 7090259: Fix hotspot sources to build with old compilers
kvn
parents: 10526
diff changeset
   102
                   (oopDesc*)obj));
10526
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   103
#endif
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   104
  }
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   105
  // treat next as normal oop.  next is a link in the reference queue.
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   106
  debug_only(
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   107
    if(TraceReferenceGC && PrintGCDetails) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   108
      gclog_or_tty->print_cr("   Process next as normal " INTPTR_FORMAT, next_addr);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   109
    }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   110
  )
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   111
  MarkSweep::mark_and_push(next_addr);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12780
diff changeset
   112
  ref->InstanceKlass::oop_follow_contents(obj);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   113
}
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   114
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   115
void instanceRefKlass::oop_follow_contents(oop obj) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   116
  if (UseCompressedOops) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   117
    specialized_oop_follow_contents<narrowOop>(this, obj);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   118
  } else {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   119
    specialized_oop_follow_contents<oop>(this, obj);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   120
  }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   121
}
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   122
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   123
#ifndef SERIALGC
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   124
template <class T>
4493
9204129f065e 6843629: Make current hotspot build part of jdk5 control build
phh
parents: 3795
diff changeset
   125
void specialized_oop_follow_contents(instanceRefKlass* ref,
9204129f065e 6843629: Make current hotspot build part of jdk5 control build
phh
parents: 3795
diff changeset
   126
                                     ParCompactionManager* cm,
9204129f065e 6843629: Make current hotspot build part of jdk5 control build
phh
parents: 3795
diff changeset
   127
                                     oop obj) {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   128
  T* referent_addr = (T*)java_lang_ref_Reference::referent_addr(obj);
3262
30d1c247fc25 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 1388
diff changeset
   129
  T heap_oop = oopDesc::load_heap_oop(referent_addr);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   130
  debug_only(
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   131
    if(TraceReferenceGC && PrintGCDetails) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   132
      gclog_or_tty->print_cr("instanceRefKlass::oop_follow_contents " INTPTR_FORMAT, obj);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   133
    }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   134
  )
3262
30d1c247fc25 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 1388
diff changeset
   135
  if (!oopDesc::is_null(heap_oop)) {
30d1c247fc25 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 1388
diff changeset
   136
    oop referent = oopDesc::decode_heap_oop_not_null(heap_oop);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   137
    if (PSParallelCompact::mark_bitmap()->is_unmarked(referent) &&
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   138
        PSParallelCompact::ref_processor()->
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   139
          discover_reference(obj, ref->reference_type())) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   140
      // reference already enqueued, referent will be traversed later
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12780
diff changeset
   141
      ref->InstanceKlass::oop_follow_contents(cm, obj);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   142
      debug_only(
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   143
        if(TraceReferenceGC && PrintGCDetails) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   144
          gclog_or_tty->print_cr("       Non NULL enqueued " INTPTR_FORMAT, obj);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
      )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
      return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
      // treat referent as normal oop
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
      debug_only(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
        if(TraceReferenceGC && PrintGCDetails) {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   152
          gclog_or_tty->print_cr("       Non NULL normal " INTPTR_FORMAT, obj);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
      )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
      PSParallelCompact::mark_and_push(cm, referent_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  }
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   158
  T* next_addr = (T*)java_lang_ref_Reference::next_addr(obj);
10526
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   159
  if (ReferenceProcessor::pending_list_uses_discovered_field()) {
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   160
    // Treat discovered as normal oop, if ref is not "active",
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   161
    // i.e. if next is non-NULL.
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   162
    T  next_oop = oopDesc::load_heap_oop(next_addr);
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   163
    if (!oopDesc::is_null(next_oop)) { // i.e. ref is not "active"
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   164
      T* discovered_addr = (T*)java_lang_ref_Reference::discovered_addr(obj);
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   165
      debug_only(
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   166
        if(TraceReferenceGC && PrintGCDetails) {
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   167
          gclog_or_tty->print_cr("   Process discovered as normal "
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   168
                                 INTPTR_FORMAT, discovered_addr);
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   169
        }
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   170
      )
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   171
      PSParallelCompact::mark_and_push(cm, discovered_addr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
    }
10526
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   173
  } else {
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   174
#ifdef ASSERT
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   175
    // In the case of older JDKs which do not use the discovered
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   176
    // field for the pending list, an inactive ref (next != NULL)
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   177
    // must always have a NULL discovered field.
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   178
    T next = oopDesc::load_heap_oop(next_addr);
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   179
    oop discovered = java_lang_ref_Reference::discovered(obj);
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   180
    assert(oopDesc::is_null(next) || oopDesc::is_null(discovered),
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   181
           err_msg("Found an inactive reference " PTR_FORMAT " with a non-NULL discovered field",
10537
23539f11e110 7090259: Fix hotspot sources to build with old compilers
kvn
parents: 10526
diff changeset
   182
                   (oopDesc*)obj));
10526
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   183
#endif
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   184
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  PSParallelCompact::mark_and_push(cm, next_addr);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12780
diff changeset
   186
  ref->InstanceKlass::oop_follow_contents(cm, obj);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   187
}
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   188
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   189
void instanceRefKlass::oop_follow_contents(ParCompactionManager* cm,
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   190
                                           oop obj) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   191
  if (UseCompressedOops) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   192
    specialized_oop_follow_contents<narrowOop>(this, cm, obj);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   193
  } else {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   194
    specialized_oop_follow_contents<oop>(this, cm, obj);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   195
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
#endif // SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   199
#ifdef ASSERT
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   200
template <class T> void trace_reference_gc(const char *s, oop obj,
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   201
                                           T* referent_addr,
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   202
                                           T* next_addr,
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   203
                                           T* discovered_addr) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   204
  if(TraceReferenceGC && PrintGCDetails) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   205
    gclog_or_tty->print_cr("%s obj " INTPTR_FORMAT, s, (address)obj);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   206
    gclog_or_tty->print_cr("     referent_addr/* " INTPTR_FORMAT " / "
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   207
         INTPTR_FORMAT, referent_addr,
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   208
         referent_addr ?
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   209
           (address)oopDesc::load_decode_heap_oop(referent_addr) : NULL);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   210
    gclog_or_tty->print_cr("     next_addr/* " INTPTR_FORMAT " / "
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   211
         INTPTR_FORMAT, next_addr,
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   212
         next_addr ? (address)oopDesc::load_decode_heap_oop(next_addr) : NULL);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   213
    gclog_or_tty->print_cr("     discovered_addr/* " INTPTR_FORMAT " / "
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   214
         INTPTR_FORMAT, discovered_addr,
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   215
         discovered_addr ?
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   216
           (address)oopDesc::load_decode_heap_oop(discovered_addr) : NULL);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   217
  }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   218
}
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   219
#endif
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   220
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   221
template <class T> void specialized_oop_adjust_pointers(instanceRefKlass *ref, oop obj) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   222
  T* referent_addr = (T*)java_lang_ref_Reference::referent_addr(obj);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   223
  MarkSweep::adjust_pointer(referent_addr);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   224
  T* next_addr = (T*)java_lang_ref_Reference::next_addr(obj);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   225
  MarkSweep::adjust_pointer(next_addr);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   226
  T* discovered_addr = (T*)java_lang_ref_Reference::discovered_addr(obj);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   227
  MarkSweep::adjust_pointer(discovered_addr);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   228
  debug_only(trace_reference_gc("instanceRefKlass::oop_adjust_pointers", obj,
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   229
                                referent_addr, next_addr, discovered_addr);)
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   230
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
int instanceRefKlass::oop_adjust_pointers(oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  int size = size_helper();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12780
diff changeset
   234
  InstanceKlass::oop_adjust_pointers(obj);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   236
  if (UseCompressedOops) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   237
    specialized_oop_adjust_pointers<narrowOop>(this, obj);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   238
  } else {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   239
    specialized_oop_adjust_pointers<oop>(this, obj);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  return size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   244
#define InstanceRefKlass_SPECIALIZED_OOP_ITERATE(T, nv_suffix, contains)        \
10526
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   245
  T* disc_addr = (T*)java_lang_ref_Reference::discovered_addr(obj);             \
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   246
  if (closure->apply_to_weak_ref_discovered_field()) {                          \
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   247
    closure->do_oop##nv_suffix(disc_addr);                                      \
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   248
  }                                                                             \
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   249
                                                                                \
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   250
  T* referent_addr = (T*)java_lang_ref_Reference::referent_addr(obj);           \
3262
30d1c247fc25 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 1388
diff changeset
   251
  T heap_oop = oopDesc::load_heap_oop(referent_addr);                           \
10526
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   252
  ReferenceProcessor* rp = closure->_ref_processor;                             \
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   253
  if (!oopDesc::is_null(heap_oop)) {                                            \
3262
30d1c247fc25 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 1388
diff changeset
   254
    oop referent = oopDesc::decode_heap_oop_not_null(heap_oop);                 \
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   255
    if (!referent->is_gc_marked() && (rp != NULL) &&                            \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   256
        rp->discover_reference(obj, reference_type())) {                        \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   257
      return size;                                                              \
10526
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   258
    } else if (contains(referent_addr)) {                                       \
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   259
      /* treat referent as normal oop */                                        \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   260
      SpecializationStats::record_do_oop_call##nv_suffix(SpecializationStats::irk);\
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   261
      closure->do_oop##nv_suffix(referent_addr);                                \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   262
    }                                                                           \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   263
  }                                                                             \
10526
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   264
  T* next_addr = (T*)java_lang_ref_Reference::next_addr(obj);                   \
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   265
  if (ReferenceProcessor::pending_list_uses_discovered_field()) {               \
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   266
    T next_oop  = oopDesc::load_heap_oop(next_addr);                            \
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   267
    /* Treat discovered as normal oop, if ref is not "active" (next non-NULL) */\
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   268
    if (!oopDesc::is_null(next_oop) && contains(disc_addr)) {                   \
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   269
        /* i.e. ref is not "active" */                                          \
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   270
      debug_only(                                                               \
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   271
        if(TraceReferenceGC && PrintGCDetails) {                                \
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   272
          gclog_or_tty->print_cr("   Process discovered as normal "             \
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   273
                                 INTPTR_FORMAT, disc_addr);                     \
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   274
        }                                                                       \
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   275
      )                                                                         \
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   276
      SpecializationStats::record_do_oop_call##nv_suffix(SpecializationStats::irk);\
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   277
      closure->do_oop##nv_suffix(disc_addr);                                    \
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   278
    }                                                                           \
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   279
  } else {                                                                      \
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   280
    /* In the case of older JDKs which do not use the discovered field for  */  \
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   281
    /* the pending list, an inactive ref (next != NULL) must always have a  */  \
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   282
    /* NULL discovered field. */                                                \
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   283
    debug_only(                                                                 \
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   284
      T next_oop = oopDesc::load_heap_oop(next_addr);                           \
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   285
      T disc_oop = oopDesc::load_heap_oop(disc_addr);                           \
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   286
      assert(oopDesc::is_null(next_oop) || oopDesc::is_null(disc_oop),          \
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   287
           err_msg("Found an inactive reference " PTR_FORMAT " with a non-NULL" \
10537
23539f11e110 7090259: Fix hotspot sources to build with old compilers
kvn
parents: 10526
diff changeset
   288
                   "discovered field", (oopDesc*)obj));                                   \
10526
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   289
    )                                                                           \
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   290
  }                                                                             \
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   291
  /* treat next as normal oop */                                                \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   292
  if (contains(next_addr)) {                                                    \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   293
    SpecializationStats::record_do_oop_call##nv_suffix(SpecializationStats::irk); \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   294
    closure->do_oop##nv_suffix(next_addr);                                      \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   295
  }                                                                             \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   296
  return size;                                                                  \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   297
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   298
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   299
template <class T> bool contains(T *t) { return true; }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   300
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   301
// Macro to define instanceRefKlass::oop_oop_iterate for virtual/nonvirtual for
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   302
// all closures.  Macros calling macros above for each oop size.
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   303
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
#define InstanceRefKlass_OOP_OOP_ITERATE_DEFN(OopClosureType, nv_suffix)        \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
                                                                                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
int instanceRefKlass::                                                          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
oop_oop_iterate##nv_suffix(oop obj, OopClosureType* closure) {                  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
  /* Get size before changing pointers */                                       \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
  SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk);\
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
                                                                                \
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12780
diff changeset
   311
  int size = InstanceKlass::oop_oop_iterate##nv_suffix(obj, closure);           \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
                                                                                \
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   313
  if (UseCompressedOops) {                                                      \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   314
    InstanceRefKlass_SPECIALIZED_OOP_ITERATE(narrowOop, nv_suffix, contains);   \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   315
  } else {                                                                      \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   316
    InstanceRefKlass_SPECIALIZED_OOP_ITERATE(oop, nv_suffix, contains);         \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
  }                                                                             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   320
#ifndef SERIALGC
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   321
#define InstanceRefKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN(OopClosureType, nv_suffix) \
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   322
                                                                                \
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   323
int instanceRefKlass::                                                          \
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   324
oop_oop_iterate_backwards##nv_suffix(oop obj, OopClosureType* closure) {        \
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   325
  /* Get size before changing pointers */                                       \
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   326
  SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk);\
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   327
                                                                                \
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12780
diff changeset
   328
  int size = InstanceKlass::oop_oop_iterate_backwards##nv_suffix(obj, closure); \
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   329
                                                                                \
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   330
  if (UseCompressedOops) {                                                      \
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   331
    InstanceRefKlass_SPECIALIZED_OOP_ITERATE(narrowOop, nv_suffix, contains);   \
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   332
  } else {                                                                      \
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   333
    InstanceRefKlass_SPECIALIZED_OOP_ITERATE(oop, nv_suffix, contains);         \
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   334
  }                                                                             \
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   335
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   336
#endif // !SERIALGC
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   337
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   338
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
#define InstanceRefKlass_OOP_OOP_ITERATE_DEFN_m(OopClosureType, nv_suffix)      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
                                                                                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
int instanceRefKlass::                                                          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
oop_oop_iterate##nv_suffix##_m(oop obj,                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
                               OopClosureType* closure,                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
                               MemRegion mr) {                                  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
  SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk);\
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
                                                                                \
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12780
diff changeset
   347
  int size = InstanceKlass::oop_oop_iterate##nv_suffix##_m(obj, closure, mr);   \
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   348
  if (UseCompressedOops) {                                                      \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   349
    InstanceRefKlass_SPECIALIZED_OOP_ITERATE(narrowOop, nv_suffix, mr.contains); \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   350
  } else {                                                                      \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   351
    InstanceRefKlass_SPECIALIZED_OOP_ITERATE(oop, nv_suffix, mr.contains);      \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
  }                                                                             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceRefKlass_OOP_OOP_ITERATE_DEFN)
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   356
ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceRefKlass_OOP_OOP_ITERATE_DEFN)
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   357
#ifndef SERIALGC
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   358
ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceRefKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN)
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   359
ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceRefKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN)
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   360
#endif // SERIALGC
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceRefKlass_OOP_OOP_ITERATE_DEFN_m)
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   362
ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceRefKlass_OOP_OOP_ITERATE_DEFN_m)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
#ifndef SERIALGC
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   365
template <class T>
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   366
void specialized_oop_push_contents(instanceRefKlass *ref,
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   367
                                   PSPromotionManager* pm, oop obj) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   368
  T* referent_addr = (T*)java_lang_ref_Reference::referent_addr(obj);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   369
  if (PSScavenge::should_scavenge(referent_addr)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
    ReferenceProcessor* rp = PSScavenge::reference_processor();
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   371
    if (rp->discover_reference(obj, ref->reference_type())) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
      // reference already enqueued, referent and next will be traversed later
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12780
diff changeset
   373
      ref->InstanceKlass::oop_push_contents(pm, obj);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
      return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
      // treat referent as normal oop
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
      pm->claim_or_forward_depth(referent_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
  }
10526
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   380
  // Treat discovered as normal oop, if ref is not "active",
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   381
  // i.e. if next is non-NULL.
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   382
  T* next_addr = (T*)java_lang_ref_Reference::next_addr(obj);
10526
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   383
  if (ReferenceProcessor::pending_list_uses_discovered_field()) {
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   384
    T  next_oop = oopDesc::load_heap_oop(next_addr);
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   385
    if (!oopDesc::is_null(next_oop)) { // i.e. ref is not "active"
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   386
      T* discovered_addr = (T*)java_lang_ref_Reference::discovered_addr(obj);
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   387
      debug_only(
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   388
        if(TraceReferenceGC && PrintGCDetails) {
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   389
          gclog_or_tty->print_cr("   Process discovered as normal "
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   390
                                 INTPTR_FORMAT, discovered_addr);
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   391
        }
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   392
      )
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   393
      if (PSScavenge::should_scavenge(discovered_addr)) {
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   394
        pm->claim_or_forward_depth(discovered_addr);
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   395
      }
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   396
    }
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   397
  } else {
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   398
#ifdef ASSERT
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   399
    // In the case of older JDKs which do not use the discovered
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   400
    // field for the pending list, an inactive ref (next != NULL)
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   401
    // must always have a NULL discovered field.
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   402
    oop next = oopDesc::load_decode_heap_oop(next_addr);
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   403
    oop discovered = java_lang_ref_Reference::discovered(obj);
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   404
    assert(oopDesc::is_null(next) || oopDesc::is_null(discovered),
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   405
           err_msg("Found an inactive reference " PTR_FORMAT " with a non-NULL discovered field",
10537
23539f11e110 7090259: Fix hotspot sources to build with old compilers
kvn
parents: 10526
diff changeset
   406
                   (oopDesc*)obj));
10526
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   407
#endif
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   408
  }
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   409
3e92f211533f 4965777: GC changes to support use of discovered field for pending references
ysr
parents: 9935
diff changeset
   410
  // Treat next as normal oop;  next is a link in the reference queue.
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   411
  if (PSScavenge::should_scavenge(next_addr)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
    pm->claim_or_forward_depth(next_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
  }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12780
diff changeset
   414
  ref->InstanceKlass::oop_push_contents(pm, obj);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   415
}
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   416
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   417
void instanceRefKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   418
  if (UseCompressedOops) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   419
    specialized_oop_push_contents<narrowOop>(this, pm, obj);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   420
  } else {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   421
    specialized_oop_push_contents<oop>(this, pm, obj);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   422
  }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   423
}
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   424
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   425
template <class T>
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   426
void specialized_oop_update_pointers(instanceRefKlass *ref,
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   427
                                    ParCompactionManager* cm, oop obj) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   428
  T* referent_addr = (T*)java_lang_ref_Reference::referent_addr(obj);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   429
  PSParallelCompact::adjust_pointer(referent_addr);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   430
  T* next_addr = (T*)java_lang_ref_Reference::next_addr(obj);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   431
  PSParallelCompact::adjust_pointer(next_addr);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   432
  T* discovered_addr = (T*)java_lang_ref_Reference::discovered_addr(obj);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   433
  PSParallelCompact::adjust_pointer(discovered_addr);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   434
  debug_only(trace_reference_gc("instanceRefKlass::oop_update_ptrs", obj,
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   435
                                referent_addr, next_addr, discovered_addr);)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
int instanceRefKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12780
diff changeset
   439
  InstanceKlass::oop_update_pointers(cm, obj);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   440
  if (UseCompressedOops) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   441
    specialized_oop_update_pointers<narrowOop>(this, cm, obj);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   442
  } else {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   443
    specialized_oop_update_pointers<oop>(this, cm, obj);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   444
  }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   445
  return size_helper();
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   446
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
#endif // SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12780
diff changeset
   449
void instanceRefKlass::update_nonstatic_oop_maps(Klass* k) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
  // Clear the nonstatic oop-map entries corresponding to referent
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
  // and nextPending field.  They are treated specially by the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
  // garbage collector.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
  // The discovered field is used only by the garbage collector
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
  // and is also treated specially.
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12780
diff changeset
   455
  InstanceKlass* ik = InstanceKlass::cast(k);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
  // Check that we have the right class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
  debug_only(static bool first_time = true);
4571
80b553bddc26 6914300: ciEnv should export all well known classes
never
parents: 3795
diff changeset
   459
  assert(k == SystemDictionary::Reference_klass() && first_time,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
         "Invalid update of maps");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
  debug_only(first_time = false);
3693
af387bf37e8d 6861660: OopMapBlock count/size confusion
jcoomes
parents: 3262
diff changeset
   462
  assert(ik->nonstatic_oop_map_count() == 1, "just checking");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
  OopMapBlock* map = ik->start_of_nonstatic_oop_maps();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
  // Check that the current map is (2,4) - currently points at field with
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
  // offset 2 (words) and has 4 map entries.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
  debug_only(int offset = java_lang_ref_Reference::referent_offset);
3694
942b7bc7f28c 6845368: large objects cause a crash or unexpected exception
jcoomes
parents: 3693
diff changeset
   469
  debug_only(unsigned int count = ((java_lang_ref_Reference::discovered_offset -
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   470
    java_lang_ref_Reference::referent_offset)/heapOopSize) + 1);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
  if (UseSharedSpaces) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
    assert(map->offset() == java_lang_ref_Reference::queue_offset &&
3693
af387bf37e8d 6861660: OopMapBlock count/size confusion
jcoomes
parents: 3262
diff changeset
   474
           map->count() == 1, "just checking");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
  } else {
3693
af387bf37e8d 6861660: OopMapBlock count/size confusion
jcoomes
parents: 3262
diff changeset
   476
    assert(map->offset() == offset && map->count() == count,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
           "just checking");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
    // Update map to (3,1) - point to offset of 3 (words) with 1 map entry.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
    map->set_offset(java_lang_ref_Reference::queue_offset);
3693
af387bf37e8d 6861660: OopMapBlock count/size confusion
jcoomes
parents: 3262
diff changeset
   481
    map->set_count(1);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
// Verification
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
void instanceRefKlass::oop_verify_on(oop obj, outputStream* st) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12780
diff changeset
   489
  InstanceKlass::oop_verify_on(obj, st);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
  // Verify referent field
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
  oop referent = java_lang_ref_Reference::referent(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
  // We should make this general to all heaps
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
  GenCollectedHeap* gch = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
  if (Universe::heap()->kind() == CollectedHeap::GenCollectedHeap)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
    gch = GenCollectedHeap::heap();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
  if (referent != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
    guarantee(referent->is_oop(), "referent field heap failed");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
  // Verify next field
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
  oop next = java_lang_ref_Reference::next(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
  if (next != NULL) {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   504
    guarantee(next->is_oop(), "next field verify failed");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
    guarantee(next->is_instanceRef(), "next field verify failed");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
7446
9193aa209467 6988439: Parallel Class Loading test deadlock involving MethodData_lock and Pending List Lock
coleenp
parents: 7397
diff changeset
   509
bool instanceRefKlass::owns_pending_list_lock(JavaThread* thread) {
7450
e44c68293be8 7006471: fix for 6988439 crashes when pending list lock is null
coleenp
parents: 7446
diff changeset
   510
  if (java_lang_ref_Reference::pending_list_lock() == NULL) return false;
7446
9193aa209467 6988439: Parallel Class Loading test deadlock involving MethodData_lock and Pending List Lock
coleenp
parents: 7397
diff changeset
   511
  Handle h_lock(thread, java_lang_ref_Reference::pending_list_lock());
9193aa209467 6988439: Parallel Class Loading test deadlock involving MethodData_lock and Pending List Lock
coleenp
parents: 7397
diff changeset
   512
  return ObjectSynchronizer::current_thread_holds_lock(thread, h_lock);
9193aa209467 6988439: Parallel Class Loading test deadlock involving MethodData_lock and Pending List Lock
coleenp
parents: 7397
diff changeset
   513
}
9193aa209467 6988439: Parallel Class Loading test deadlock involving MethodData_lock and Pending List Lock
coleenp
parents: 7397
diff changeset
   514
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
void instanceRefKlass::acquire_pending_list_lock(BasicLock *pending_list_basic_lock) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
  // we may enter this with pending exception set
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
  PRESERVE_EXCEPTION_MARK;  // exceptions are never thrown, needed for TRAPS argument
12780
689210d5dd05 7158682: G1: Handle leak when running nsk.sysdict tests
johnc
parents: 12379
diff changeset
   518
689210d5dd05 7158682: G1: Handle leak when running nsk.sysdict tests
johnc
parents: 12379
diff changeset
   519
  // Create a HandleMark in case we retry a GC multiple times.
689210d5dd05 7158682: G1: Handle leak when running nsk.sysdict tests
johnc
parents: 12379
diff changeset
   520
  // Each time we attempt the GC, we allocate the handle below
689210d5dd05 7158682: G1: Handle leak when running nsk.sysdict tests
johnc
parents: 12379
diff changeset
   521
  // to hold the pending list lock. We want to free this handle.
689210d5dd05 7158682: G1: Handle leak when running nsk.sysdict tests
johnc
parents: 12379
diff changeset
   522
  HandleMark hm;
689210d5dd05 7158682: G1: Handle leak when running nsk.sysdict tests
johnc
parents: 12379
diff changeset
   523
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
  Handle h_lock(THREAD, java_lang_ref_Reference::pending_list_lock());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
  ObjectSynchronizer::fast_enter(h_lock, pending_list_basic_lock, false, THREAD);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
  assert(ObjectSynchronizer::current_thread_holds_lock(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
           JavaThread::current(), h_lock),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
         "Locking should have succeeded");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
  if (HAS_PENDING_EXCEPTION) CLEAR_PENDING_EXCEPTION;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
void instanceRefKlass::release_and_notify_pending_list_lock(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
  BasicLock *pending_list_basic_lock) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
  // we may enter this with pending exception set
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
  PRESERVE_EXCEPTION_MARK;  // exceptions are never thrown, needed for TRAPS argument
12780
689210d5dd05 7158682: G1: Handle leak when running nsk.sysdict tests
johnc
parents: 12379
diff changeset
   536
689210d5dd05 7158682: G1: Handle leak when running nsk.sysdict tests
johnc
parents: 12379
diff changeset
   537
  // Create a HandleMark in case we retry a GC multiple times.
689210d5dd05 7158682: G1: Handle leak when running nsk.sysdict tests
johnc
parents: 12379
diff changeset
   538
  // Each time we attempt the GC, we allocate the handle below
689210d5dd05 7158682: G1: Handle leak when running nsk.sysdict tests
johnc
parents: 12379
diff changeset
   539
  // to hold the pending list lock. We want to free this handle.
689210d5dd05 7158682: G1: Handle leak when running nsk.sysdict tests
johnc
parents: 12379
diff changeset
   540
  HandleMark hm;
689210d5dd05 7158682: G1: Handle leak when running nsk.sysdict tests
johnc
parents: 12379
diff changeset
   541
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
  Handle h_lock(THREAD, java_lang_ref_Reference::pending_list_lock());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
  assert(ObjectSynchronizer::current_thread_holds_lock(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
           JavaThread::current(), h_lock),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
         "Lock should be held");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
  // Notify waiters on pending lists lock if there is any reference.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
  if (java_lang_ref_Reference::pending_list() != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
    ObjectSynchronizer::notifyall(h_lock, THREAD);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
  ObjectSynchronizer::fast_exit(h_lock(), pending_list_basic_lock, THREAD);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
  if (HAS_PENDING_EXCEPTION) CLEAR_PENDING_EXCEPTION;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
}