src/hotspot/share/oops/instanceRefKlass.inline.hpp
author ihse
Mon, 26 Nov 2018 14:18:22 +0100
branchihse-manpages-branch
changeset 57043 23d7457ca4c6
parent 51708 469ab7c92a32
child 53244 9807daeb47c4
permissions -rw-r--r--
Clean up login in when running which kind of man page creation.
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
/*
49041
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 47216
diff changeset
     2
 * Copyright (c) 2015, 2018, 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"
49592
77fb0be7d19f 8199946: Move load/store and encode/decode out of oopDesc
stefank
parents: 49041
diff changeset
    31
#include "oops/access.inline.hpp"
77fb0be7d19f 8199946: Move load/store and encode/decode out of oopDesc
stefank
parents: 49041
diff changeset
    32
#include "oops/compressedOops.inline.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30558
diff changeset
    33
#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
    34
#include "oops/instanceRefKlass.hpp"
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
    35
#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
    36
#include "utilities/debug.hpp"
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
    37
#include "utilities/globalDefinitions.hpp"
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
    38
#include "utilities/macros.hpp"
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
    39
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50450
diff changeset
    40
template <typename T, class OopClosureType, class Contains>
46415
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    41
void InstanceRefKlass::do_referent(oop obj, OopClosureType* closure, Contains& contains) {
49041
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 47216
diff changeset
    42
  T* referent_addr = (T*)java_lang_ref_Reference::referent_addr_raw(obj);
46415
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    43
  if (contains(referent_addr)) {
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50450
diff changeset
    44
    Devirtualizer::do_oop(closure, referent_addr);
46415
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
}
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    47
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50450
diff changeset
    48
template <typename T, class OopClosureType, class Contains>
46415
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    49
void InstanceRefKlass::do_discovered(oop obj, OopClosureType* closure, Contains& contains) {
49041
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 47216
diff changeset
    50
  T* discovered_addr = (T*)java_lang_ref_Reference::discovered_addr_raw(obj);
46415
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    51
  if (contains(discovered_addr)) {
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50450
diff changeset
    52
    Devirtualizer::do_oop(closure, discovered_addr);
46415
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
}
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    55
50450
517f76115e5a 8204474: Have instanceRefKlass use HeapAccess when loading the referent
pliden
parents: 50277
diff changeset
    56
static inline oop load_referent(oop obj, ReferenceType type) {
517f76115e5a 8204474: Have instanceRefKlass use HeapAccess when loading the referent
pliden
parents: 50277
diff changeset
    57
  if (type == REF_PHANTOM) {
517f76115e5a 8204474: Have instanceRefKlass use HeapAccess when loading the referent
pliden
parents: 50277
diff changeset
    58
    return HeapAccess<ON_PHANTOM_OOP_REF | AS_NO_KEEPALIVE>::oop_load(java_lang_ref_Reference::referent_addr_raw(obj));
517f76115e5a 8204474: Have instanceRefKlass use HeapAccess when loading the referent
pliden
parents: 50277
diff changeset
    59
  } else {
517f76115e5a 8204474: Have instanceRefKlass use HeapAccess when loading the referent
pliden
parents: 50277
diff changeset
    60
    return HeapAccess<ON_WEAK_OOP_REF | AS_NO_KEEPALIVE>::oop_load(java_lang_ref_Reference::referent_addr_raw(obj));
517f76115e5a 8204474: Have instanceRefKlass use HeapAccess when loading the referent
pliden
parents: 50277
diff changeset
    61
  }
517f76115e5a 8204474: Have instanceRefKlass use HeapAccess when loading the referent
pliden
parents: 50277
diff changeset
    62
}
517f76115e5a 8204474: Have instanceRefKlass use HeapAccess when loading the referent
pliden
parents: 50277
diff changeset
    63
46415
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    64
template <typename T, class OopClosureType>
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    65
bool InstanceRefKlass::try_discover(oop obj, ReferenceType type, OopClosureType* closure) {
49827
a4672513d6e3 8201646: Introduce ReferenceDiscoverer interface
pliden
parents: 49592
diff changeset
    66
  ReferenceDiscoverer* rd = closure->ref_discoverer();
a4672513d6e3 8201646: Introduce ReferenceDiscoverer interface
pliden
parents: 49592
diff changeset
    67
  if (rd != NULL) {
50450
517f76115e5a 8204474: Have instanceRefKlass use HeapAccess when loading the referent
pliden
parents: 50277
diff changeset
    68
    oop referent = load_referent(obj, type);
517f76115e5a 8204474: Have instanceRefKlass use HeapAccess when loading the referent
pliden
parents: 50277
diff changeset
    69
    if (referent != NULL) {
46415
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    70
      if (!referent->is_gc_marked()) {
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    71
        // Only try to discover if not yet marked.
49827
a4672513d6e3 8201646: Introduce ReferenceDiscoverer interface
pliden
parents: 49592
diff changeset
    72
        return rd->discover_reference(obj, type);
46415
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
  }
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    76
  return false;
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
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50450
diff changeset
    79
template <typename T, class OopClosureType, class Contains>
46415
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    80
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
    81
  // 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
    82
  if (try_discover<T>(obj, type, closure)) {
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    83
    return;
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    84
  }
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    85
50277
f84ae8aa5d88 8203028: Simplify reference processing in light of JDK-8175797
kbarrett
parents: 49982
diff changeset
    86
  // Treat referent and discovered as normal oops.
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50450
diff changeset
    87
  do_referent<T>(obj, closure, contains);
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50450
diff changeset
    88
  do_discovered<T>(obj, closure, contains);
46415
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    89
}
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
    90
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50450
diff changeset
    91
template <typename T, class OopClosureType, class Contains>
50870
830b05ca7f58 8205923: ZGC: Verification applies load barrier before verification
stefank
parents: 50752
diff changeset
    92
void InstanceRefKlass::oop_oop_iterate_discovered_and_discovery(oop obj, ReferenceType type, OopClosureType* closure, Contains& contains) {
830b05ca7f58 8205923: ZGC: Verification applies load barrier before verification
stefank
parents: 50752
diff changeset
    93
  // Explicitly apply closure to the discovered field.
830b05ca7f58 8205923: ZGC: Verification applies load barrier before verification
stefank
parents: 50752
diff changeset
    94
  do_discovered<T>(obj, closure, contains);
830b05ca7f58 8205923: ZGC: Verification applies load barrier before verification
stefank
parents: 50752
diff changeset
    95
  // Then do normal reference processing with discovery.
830b05ca7f58 8205923: ZGC: Verification applies load barrier before verification
stefank
parents: 50752
diff changeset
    96
  oop_oop_iterate_discovery<T>(obj, type, closure, contains);
830b05ca7f58 8205923: ZGC: Verification applies load barrier before verification
stefank
parents: 50752
diff changeset
    97
}
830b05ca7f58 8205923: ZGC: Verification applies load barrier before verification
stefank
parents: 50752
diff changeset
    98
830b05ca7f58 8205923: ZGC: Verification applies load barrier before verification
stefank
parents: 50752
diff changeset
    99
template <typename T, class OopClosureType, class Contains>
46415
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   100
void InstanceRefKlass::oop_oop_iterate_fields(oop obj, OopClosureType* closure, Contains& contains) {
51708
469ab7c92a32 8209843: Optimize oop scan closure closures wrt to reference processing in G1
tschatzl
parents: 51516
diff changeset
   101
  assert(closure->ref_discoverer() == NULL, "ReferenceDiscoverer should not be set");
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50450
diff changeset
   102
  do_referent<T>(obj, closure, contains);
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50450
diff changeset
   103
  do_discovered<T>(obj, closure, contains);
46415
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
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50450
diff changeset
   106
template <typename T, class OopClosureType, class Contains>
50870
830b05ca7f58 8205923: ZGC: Verification applies load barrier before verification
stefank
parents: 50752
diff changeset
   107
void InstanceRefKlass::oop_oop_iterate_fields_except_referent(oop obj, OopClosureType* closure, Contains& contains) {
51708
469ab7c92a32 8209843: Optimize oop scan closure closures wrt to reference processing in G1
tschatzl
parents: 51516
diff changeset
   108
  assert(closure->ref_discoverer() == NULL, "ReferenceDiscoverer should not be set");
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50450
diff changeset
   109
  do_discovered<T>(obj, closure, contains);
46445
825b002e05ae 8138888: Remove ExtendedOopClosure::apply_to_weak_ref_discovered_field
sjohanss
parents: 46415
diff changeset
   110
}
825b002e05ae 8138888: Remove ExtendedOopClosure::apply_to_weak_ref_discovered_field
sjohanss
parents: 46415
diff changeset
   111
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50450
diff changeset
   112
template <typename T, class OopClosureType, class Contains>
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50450
diff changeset
   113
void InstanceRefKlass::oop_oop_iterate_ref_processing(oop obj, OopClosureType* closure, Contains& contains) {
46415
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   114
  switch (closure->reference_iteration_mode()) {
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50450
diff changeset
   115
    case OopIterateClosure::DO_DISCOVERY:
46446
ababb65abf24 8179550: Unify trace logging for InstanceRefKlass
sjohanss
parents: 46445
diff changeset
   116
      trace_reference_gc<T>("do_discovery", obj);
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50450
diff changeset
   117
      oop_oop_iterate_discovery<T>(obj, reference_type(), closure, contains);
46415
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   118
      break;
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50450
diff changeset
   119
    case OopIterateClosure::DO_DISCOVERED_AND_DISCOVERY:
46446
ababb65abf24 8179550: Unify trace logging for InstanceRefKlass
sjohanss
parents: 46445
diff changeset
   120
      trace_reference_gc<T>("do_discovered_and_discovery", obj);
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50450
diff changeset
   121
      oop_oop_iterate_discovered_and_discovery<T>(obj, reference_type(), closure, contains);
46445
825b002e05ae 8138888: Remove ExtendedOopClosure::apply_to_weak_ref_discovered_field
sjohanss
parents: 46415
diff changeset
   122
      break;
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50450
diff changeset
   123
    case OopIterateClosure::DO_FIELDS:
46446
ababb65abf24 8179550: Unify trace logging for InstanceRefKlass
sjohanss
parents: 46445
diff changeset
   124
      trace_reference_gc<T>("do_fields", obj);
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50450
diff changeset
   125
      oop_oop_iterate_fields<T>(obj, closure, contains);
46415
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   126
      break;
50870
830b05ca7f58 8205923: ZGC: Verification applies load barrier before verification
stefank
parents: 50752
diff changeset
   127
    case OopIterateClosure::DO_FIELDS_EXCEPT_REFERENT:
830b05ca7f58 8205923: ZGC: Verification applies load barrier before verification
stefank
parents: 50752
diff changeset
   128
      trace_reference_gc<T>("do_fields_except_referent", obj);
830b05ca7f58 8205923: ZGC: Verification applies load barrier before verification
stefank
parents: 50752
diff changeset
   129
      oop_oop_iterate_fields_except_referent<T>(obj, closure, contains);
830b05ca7f58 8205923: ZGC: Verification applies load barrier before verification
stefank
parents: 50752
diff changeset
   130
      break;
46415
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   131
    default:
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   132
      ShouldNotReachHere();
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   133
  }
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   134
}
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
class AlwaysContains {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   137
 public:
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   138
  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
   139
};
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   140
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50450
diff changeset
   141
template <typename T, class OopClosureType>
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   142
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
   143
  AlwaysContains always_contains;
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50450
diff changeset
   144
  oop_oop_iterate_ref_processing<T>(obj, closure, always_contains);
30150
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
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50450
diff changeset
   154
template <typename T, class OopClosureType>
30150
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);
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50450
diff changeset
   157
  oop_oop_iterate_ref_processing<T>(obj, closure, contains);
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50450
diff changeset
   158
}
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50450
diff changeset
   159
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50450
diff changeset
   160
template <typename T, class OopClosureType>
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50450
diff changeset
   161
void InstanceRefKlass::oop_oop_iterate(oop obj, OopClosureType* closure) {
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50450
diff changeset
   162
  InstanceKlass::oop_oop_iterate<T>(obj, closure);
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50450
diff changeset
   163
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50450
diff changeset
   164
  oop_oop_iterate_ref_processing<T>(obj, closure);
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   165
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   166
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50450
diff changeset
   167
template <typename T, class OopClosureType>
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50450
diff changeset
   168
void InstanceRefKlass::oop_oop_iterate_reverse(oop obj, OopClosureType* closure) {
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50450
diff changeset
   169
  InstanceKlass::oop_oop_iterate_reverse<T>(obj, closure);
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   170
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50450
diff changeset
   171
  oop_oop_iterate_ref_processing<T>(obj, closure);
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   172
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   173
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50450
diff changeset
   174
template <typename T, class OopClosureType>
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50450
diff changeset
   175
void InstanceRefKlass::oop_oop_iterate_bounded(oop obj, OopClosureType* closure, MemRegion mr) {
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50450
diff changeset
   176
  InstanceKlass::oop_oop_iterate_bounded<T>(obj, closure, mr);
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   177
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50450
diff changeset
   178
  oop_oop_iterate_ref_processing_bounded<T>(obj, closure, mr);
30150
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
46415
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   181
#ifdef ASSERT
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   182
template <typename T>
46446
ababb65abf24 8179550: Unify trace logging for InstanceRefKlass
sjohanss
parents: 46445
diff changeset
   183
void InstanceRefKlass::trace_reference_gc(const char *s, oop obj) {
49041
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 47216
diff changeset
   184
  T* referent_addr   = (T*) java_lang_ref_Reference::referent_addr_raw(obj);
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 47216
diff changeset
   185
  T* discovered_addr = (T*) java_lang_ref_Reference::discovered_addr_raw(obj);
46446
ababb65abf24 8179550: Unify trace logging for InstanceRefKlass
sjohanss
parents: 46445
diff changeset
   186
ababb65abf24 8179550: Unify trace logging for InstanceRefKlass
sjohanss
parents: 46445
diff changeset
   187
  log_develop_trace(gc, ref)("InstanceRefKlass %s for obj " PTR_FORMAT, s, p2i(obj));
51516
7c3891b9f1e0 8206457: Code paths from oop_iterate() must use barrier-free access
rkennke
parents: 50870
diff changeset
   188
  if (java_lang_ref_Reference::is_phantom(obj)) {
7c3891b9f1e0 8206457: Code paths from oop_iterate() must use barrier-free access
rkennke
parents: 50870
diff changeset
   189
    log_develop_trace(gc, ref)("     referent_addr/* " PTR_FORMAT " / " PTR_FORMAT,
7c3891b9f1e0 8206457: Code paths from oop_iterate() must use barrier-free access
rkennke
parents: 50870
diff changeset
   190
                               p2i(referent_addr), p2i((oop)HeapAccess<ON_PHANTOM_OOP_REF | AS_NO_KEEPALIVE>::oop_load(referent_addr)));
7c3891b9f1e0 8206457: Code paths from oop_iterate() must use barrier-free access
rkennke
parents: 50870
diff changeset
   191
  } else {
7c3891b9f1e0 8206457: Code paths from oop_iterate() must use barrier-free access
rkennke
parents: 50870
diff changeset
   192
    log_develop_trace(gc, ref)("     referent_addr/* " PTR_FORMAT " / " PTR_FORMAT,
7c3891b9f1e0 8206457: Code paths from oop_iterate() must use barrier-free access
rkennke
parents: 50870
diff changeset
   193
                               p2i(referent_addr), p2i((oop)HeapAccess<ON_WEAK_OOP_REF | AS_NO_KEEPALIVE>::oop_load(referent_addr)));
7c3891b9f1e0 8206457: Code paths from oop_iterate() must use barrier-free access
rkennke
parents: 50870
diff changeset
   194
  }
46415
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   195
  log_develop_trace(gc, ref)("     discovered_addr/* " PTR_FORMAT " / " PTR_FORMAT,
50450
517f76115e5a 8204474: Have instanceRefKlass use HeapAccess when loading the referent
pliden
parents: 50277
diff changeset
   196
      p2i(discovered_addr), p2i((oop)HeapAccess<AS_NO_KEEPALIVE>::oop_load(discovered_addr)));
46415
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   197
}
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   198
#endif
7d5a286cdf89 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents: 35498
diff changeset
   199
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff changeset
   200
#endif // SHARE_VM_OOPS_INSTANCEREFKLASS_INLINE_HPP