hotspot/src/share/vm/oops/instanceRefKlass.inline.hpp
author sjohanss
Wed, 26 Apr 2017 10:26:39 +0200
changeset 46415 7d5a286cdf89
parent 35498 392b50de06c6
child 46445 825b002e05ae
permissions -rw-r--r--
8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead Reviewed-by: kbarrett, stefank
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
     1
/*
46415
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
     2
 * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
     4
 *
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
     7
 * published by the Free Software Foundation.
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
     8
 *
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
    13
 * accompanied this code).
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
    14
 *
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
    18
 *
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
    21
 * questions.
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
    22
 *
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
    23
 */
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
    24
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
    25
#ifndef SHARE_VM_OOPS_INSTANCEREFKLASS_INLINE_HPP
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
    26
#define SHARE_VM_OOPS_INSTANCEREFKLASS_INLINE_HPP
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
    27
35498
392b50de06c6 8146401: Clean up oop.hpp: add inline directives and fix header files
goetz
parents: 35061
diff changeset
    28
#include "classfile/javaClasses.inline.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30558
diff changeset
    29
#include "gc/shared/referenceProcessor.hpp"
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33226
diff changeset
    30
#include "logging/log.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30558
diff changeset
    31
#include "oops/instanceKlass.inline.hpp"
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
    32
#include "oops/instanceRefKlass.hpp"
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
    33
#include "oops/oop.inline.hpp"
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
    34
#include "utilities/debug.hpp"
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
    35
#include "utilities/globalDefinitions.hpp"
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
    36
#include "utilities/macros.hpp"
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
    37
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
    38
template <bool nv, typename T, class OopClosureType, class Contains>
46415
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    39
void InstanceRefKlass::do_referent(oop obj, OopClosureType* closure, Contains& contains) {
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    40
  T* referent_addr = (T*)java_lang_ref_Reference::referent_addr(obj);
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    41
  if (contains(referent_addr)) {
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    42
    Devirtualizer<nv>::do_oop(closure, referent_addr);
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    43
  }
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    44
}
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    45
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    46
template <bool nv, typename T, class OopClosureType, class Contains>
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    47
void InstanceRefKlass::do_next(oop obj, OopClosureType* closure, Contains& contains) {
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    48
  T* next_addr = (T*)java_lang_ref_Reference::next_addr(obj);
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    49
  if (contains(next_addr)) {
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    50
    Devirtualizer<nv>::do_oop(closure, next_addr);
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    51
  }
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    52
}
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    53
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    54
template <bool nv, typename T, class OopClosureType, class Contains>
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    55
void InstanceRefKlass::do_discovered(oop obj, OopClosureType* closure, Contains& contains) {
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    56
  T* discovered_addr = (T*)java_lang_ref_Reference::discovered_addr(obj);
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    57
  if (contains(discovered_addr)) {
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    58
    Devirtualizer<nv>::do_oop(closure, discovered_addr);
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    59
  }
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    60
}
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    61
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    62
template <typename T, class OopClosureType>
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    63
bool InstanceRefKlass::try_discover(oop obj, ReferenceType type, OopClosureType* closure) {
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    64
  ReferenceProcessor* rp = closure->ref_processor();
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    65
  if (rp != NULL) {
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    66
    T referent_oop = oopDesc::load_heap_oop((T*)java_lang_ref_Reference::referent_addr(obj));
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    67
    if (!oopDesc::is_null(referent_oop)) {
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    68
      oop referent = oopDesc::decode_heap_oop_not_null(referent_oop);
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    69
      if (!referent->is_gc_marked()) {
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    70
        // Only try to discover if not yet marked.
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    71
        return rp->discover_reference(obj, type);
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    72
      }
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    73
    }
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    74
  }
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    75
  return false;
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    76
}
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    77
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    78
template <bool nv, typename T, class OopClosureType, class Contains>
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    79
void InstanceRefKlass::oop_oop_iterate_discovery(oop obj, ReferenceType type, OopClosureType* closure, Contains& contains) {
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    80
  log_develop_trace(gc, ref)("Process reference with discovery " PTR_FORMAT, p2i(obj));
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    81
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    82
  // Special case for some closures.
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
    83
  if (closure->apply_to_weak_ref_discovered_field()) {
46415
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    84
    do_discovered<nv, T>(obj, closure, contains);
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
    85
  }
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
    86
46415
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    87
  // Try to discover reference and return if it succeeds.
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    88
  if (try_discover<T>(obj, type, closure)) {
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    89
    return;
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    90
  }
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    91
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    92
  // Treat referent as normal oop.
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    93
  do_referent<nv, T>(obj, closure, contains);
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    94
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    95
  // Treat discovered as normal oop, if ref is not "active" (next non-NULL).
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    96
  T next_oop  = oopDesc::load_heap_oop((T*)java_lang_ref_Reference::next_addr(obj));
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    97
  if (!oopDesc::is_null(next_oop)) {
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    98
    do_discovered<nv, T>(obj, closure, contains);
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
    99
  }
46415
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   100
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   101
  // Treat next as normal oop.
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   102
  do_next<nv, T>(obj, closure, contains);
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   103
}
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   104
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   105
template <bool nv, typename T, class OopClosureType, class Contains>
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   106
void InstanceRefKlass::oop_oop_iterate_fields(oop obj, OopClosureType* closure, Contains& contains) {
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   107
  do_referent<nv, T>(obj, closure, contains);
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   108
  do_discovered<nv, T>(obj, closure, contains);
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   109
  do_next<nv, T>(obj, closure, contains);
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   110
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   111
  trace_reference_gc("InstanceRefKlass::oop_oop_iterate_fields()",
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   112
                     obj,
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   113
                     (T*)java_lang_ref_Reference::referent_addr(obj),
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   114
                     (T*)java_lang_ref_Reference::next_addr(obj),
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   115
                     (T*)java_lang_ref_Reference::discovered_addr(obj));
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   116
}
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   117
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   118
template <bool nv, typename T, class OopClosureType, class Contains>
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   119
void InstanceRefKlass::oop_oop_iterate_ref_processing_specialized(oop obj, OopClosureType* closure, Contains& contains) {
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   120
  switch (closure->reference_iteration_mode()) {
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   121
    case ExtendedOopClosure::DO_DISCOVERY:
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   122
      oop_oop_iterate_discovery<nv, T>(obj, reference_type(), closure, contains);
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   123
      break;
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   124
    case ExtendedOopClosure::DO_FIELDS:
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   125
      oop_oop_iterate_fields<nv, T>(obj, closure, contains);
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   126
      break;
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   127
    default:
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   128
      ShouldNotReachHere();
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   129
  }
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   130
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   131
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   132
class AlwaysContains {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   133
 public:
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   134
  template <typename T> bool operator()(T* p) const { return true; }
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   135
};
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   136
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   137
template <bool nv, class OopClosureType>
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   138
void InstanceRefKlass::oop_oop_iterate_ref_processing(oop obj, OopClosureType* closure) {
30161
73469ec877cd 8077315: Build failure on OSX after compiler upgrade
jwilhelm
parents: 30160
diff changeset
   139
  AlwaysContains always_contains;
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   140
  if (UseCompressedOops) {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   141
    oop_oop_iterate_ref_processing_specialized<nv, narrowOop>(obj, closure, always_contains);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   142
  } else {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   143
    oop_oop_iterate_ref_processing_specialized<nv, oop>(obj, closure, always_contains);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   144
  }
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   145
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   146
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   147
class MrContains {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   148
  const MemRegion _mr;
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   149
 public:
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   150
  MrContains(MemRegion mr) : _mr(mr) {}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   151
  template <typename T> bool operator()(T* p) const { return _mr.contains(p); }
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   152
};
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   153
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   154
template <bool nv, class OopClosureType>
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   155
void InstanceRefKlass::oop_oop_iterate_ref_processing_bounded(oop obj, OopClosureType* closure, MemRegion mr) {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   156
  const MrContains contains(mr);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   157
  if (UseCompressedOops) {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   158
    oop_oop_iterate_ref_processing_specialized<nv, narrowOop>(obj, closure, contains);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   159
  } else {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   160
    oop_oop_iterate_ref_processing_specialized<nv, oop>(obj, closure, contains);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   161
  }
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   162
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   163
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   164
template <bool nv, class OopClosureType>
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30880
diff changeset
   165
void InstanceRefKlass::oop_oop_iterate(oop obj, OopClosureType* closure) {
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30880
diff changeset
   166
  InstanceKlass::oop_oop_iterate<nv>(obj, closure);
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   167
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   168
  oop_oop_iterate_ref_processing<nv>(obj, closure);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   169
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   170
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   171
#if INCLUDE_ALL_GCS
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   172
template <bool nv, class OopClosureType>
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30880
diff changeset
   173
void InstanceRefKlass::oop_oop_iterate_reverse(oop obj, OopClosureType* closure) {
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30880
diff changeset
   174
  InstanceKlass::oop_oop_iterate_reverse<nv>(obj, closure);
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   175
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   176
  oop_oop_iterate_ref_processing<nv>(obj, closure);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   177
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   178
#endif // INCLUDE_ALL_GCS
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   179
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   180
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   181
template <bool nv, class OopClosureType>
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30880
diff changeset
   182
void InstanceRefKlass::oop_oop_iterate_bounded(oop obj, OopClosureType* closure, MemRegion mr) {
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30880
diff changeset
   183
  InstanceKlass::oop_oop_iterate_bounded<nv>(obj, closure, mr);
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   184
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   185
  oop_oop_iterate_ref_processing_bounded<nv>(obj, closure, mr);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   186
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   187
46415
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   188
#ifdef ASSERT
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   189
template <typename T>
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   190
void InstanceRefKlass::trace_reference_gc(const char *s, oop obj, T* referent_addr, T* next_addr, T* discovered_addr) {
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   191
  log_develop_trace(gc, ref)("%s obj " PTR_FORMAT, s, p2i(obj));
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   192
  log_develop_trace(gc, ref)("     referent_addr/* " PTR_FORMAT " / " PTR_FORMAT,
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   193
      p2i(referent_addr), p2i(referent_addr ? (address)oopDesc::load_decode_heap_oop(referent_addr) : NULL));
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   194
  log_develop_trace(gc, ref)("     next_addr/* " PTR_FORMAT " / " PTR_FORMAT,
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   195
      p2i(next_addr), p2i(next_addr ? (address)oopDesc::load_decode_heap_oop(next_addr) : NULL));
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   196
  log_develop_trace(gc, ref)("     discovered_addr/* " PTR_FORMAT " / " PTR_FORMAT,
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   197
      p2i(discovered_addr), p2i(discovered_addr ? (address)oopDesc::load_decode_heap_oop(discovered_addr) : NULL));
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   198
}
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   199
#endif
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   200
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   201
// Macro to define InstanceRefKlass::oop_oop_iterate for virtual/nonvirtual for
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   202
// all closures.  Macros calling macros above for each oop size.
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   203
#define ALL_INSTANCE_REF_KLASS_OOP_OOP_ITERATE_DEFN(OopClosureType, nv_suffix)  \
30880
efe35e08179f 8080746: Refactor oop iteration macros to be more general
sjohanss
parents: 30764
diff changeset
   204
  OOP_OOP_ITERATE_DEFN(          InstanceRefKlass, OopClosureType, nv_suffix)   \
efe35e08179f 8080746: Refactor oop iteration macros to be more general
sjohanss
parents: 30764
diff changeset
   205
  OOP_OOP_ITERATE_DEFN_BOUNDED(  InstanceRefKlass, OopClosureType, nv_suffix)   \
efe35e08179f 8080746: Refactor oop iteration macros to be more general
sjohanss
parents: 30764
diff changeset
   206
  OOP_OOP_ITERATE_DEFN_BACKWARDS(InstanceRefKlass, OopClosureType, nv_suffix)
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   207
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   208
#endif // SHARE_VM_OOPS_INSTANCEREFKLASS_INLINE_HPP