src/hotspot/share/oops/objArrayKlass.inline.hpp
author ccheung
Wed, 02 Oct 2019 16:55:08 -0700
changeset 58447 319173c62caa
parent 53244 9807daeb47c4
permissions -rw-r--r--
8231606: _method_ordering is not set during CDS dynamic dump time Summary: Add the missing DynamicDumpSharedSpaces check in sort_methods(); replace the (DumpSharedSpaces || DynamicDumpSharedSpaces) with the Arguments::is_dumping_archive() function call. Reviewed-by: iklam, coleenp, jiangli
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 50752
diff changeset
     2
 * Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
diff changeset
     4
 *
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
diff changeset
     7
 * published by the Free Software Foundation.
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
diff changeset
     8
 *
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
diff changeset
    13
 * accompanied this code).
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
diff changeset
    14
 *
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5076
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5076
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5076
diff changeset
    21
 * questions.
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
diff changeset
    22
 *
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
diff changeset
    23
 */
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
diff changeset
    24
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 50752
diff changeset
    25
#ifndef SHARE_OOPS_OBJARRAYKLASS_INLINE_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 50752
diff changeset
    26
#define SHARE_OOPS_OBJARRAYKLASS_INLINE_HPP
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    28
#include "memory/memRegion.hpp"
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49404
diff changeset
    29
#include "memory/iterator.hpp"
49041
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 47216
diff changeset
    30
#include "oops/arrayOop.inline.hpp"
30880
efe35e08179f 8080746: Refactor oop iteration macros to be more general
sjohanss
parents: 30150
diff changeset
    31
#include "oops/arrayKlass.hpp"
efe35e08179f 8080746: Refactor oop iteration macros to be more general
sjohanss
parents: 30150
diff changeset
    32
#include "oops/klass.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    33
#include "oops/objArrayKlass.hpp"
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    34
#include "oops/objArrayOop.inline.hpp"
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    35
#include "oops/oop.inline.hpp"
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13952
diff changeset
    36
#include "utilities/macros.hpp"
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    37
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49404
diff changeset
    38
template <typename T, class OopClosureType>
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49404
diff changeset
    39
void ObjArrayKlass::oop_oop_iterate_elements(objArrayOop a, OopClosureType* closure) {
49404
911e32d49f76 8199559: objArrayKlass::oop_iterate() and friends must use base_raw() instead of base()
rkennke
parents: 49041
diff changeset
    40
  T* p         = (T*)a->base_raw();
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    41
  T* const end = p + a->length();
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    42
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    43
  for (;p < end; p++) {
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49404
diff changeset
    44
    Devirtualizer::do_oop(closure, p);
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    45
  }
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    46
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    47
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49404
diff changeset
    48
template <typename T, class OopClosureType>
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49404
diff changeset
    49
void ObjArrayKlass::oop_oop_iterate_elements_bounded(
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    50
    objArrayOop a, OopClosureType* closure, void* low, void* high) {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    51
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    52
  T* const l = (T*)low;
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    53
  T* const h = (T*)high;
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    54
49404
911e32d49f76 8199559: objArrayKlass::oop_iterate() and friends must use base_raw() instead of base()
rkennke
parents: 49041
diff changeset
    55
  T* p   = (T*)a->base_raw();
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    56
  T* end = p + a->length();
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    57
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    58
  if (p < l) {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    59
    p = l;
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    60
  }
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    61
  if (end > h) {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    62
    end = h;
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    63
  }
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    64
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    65
  for (;p < end; ++p) {
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49404
diff changeset
    66
    Devirtualizer::do_oop(closure, p);
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    67
  }
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    68
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    69
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49404
diff changeset
    70
template <typename T, typename OopClosureType>
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30880
diff changeset
    71
void ObjArrayKlass::oop_oop_iterate(oop obj, OopClosureType* closure) {
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    72
  assert (obj->is_array(), "obj must be array");
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
diff changeset
    73
  objArrayOop a = objArrayOop(obj);
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    74
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49404
diff changeset
    75
  if (Devirtualizer::do_metadata(closure)) {
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49404
diff changeset
    76
    Devirtualizer::do_klass(closure, obj->klass());
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    77
  }
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    78
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49404
diff changeset
    79
  oop_oop_iterate_elements<T>(a, closure);
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    80
}
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
diff changeset
    81
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49404
diff changeset
    82
template <typename T, typename OopClosureType>
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49404
diff changeset
    83
void ObjArrayKlass::oop_oop_iterate_reverse(oop obj, OopClosureType* closure) {
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49404
diff changeset
    84
  // No reverse implementation ATM.
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49404
diff changeset
    85
  oop_oop_iterate<T>(obj, closure);
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49404
diff changeset
    86
}
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49404
diff changeset
    87
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49404
diff changeset
    88
template <typename T, typename OopClosureType>
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30880
diff changeset
    89
void ObjArrayKlass::oop_oop_iterate_bounded(oop obj, OopClosureType* closure, MemRegion mr) {
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    90
  assert(obj->is_array(), "obj must be array");
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    91
  objArrayOop a  = objArrayOop(obj);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    92
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49404
diff changeset
    93
  if (Devirtualizer::do_metadata(closure)) {
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49404
diff changeset
    94
    Devirtualizer::do_klass(closure, a->klass());
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
diff changeset
    95
  }
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
diff changeset
    96
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49404
diff changeset
    97
  oop_oop_iterate_elements_bounded<T>(a, closure, mr.start(), mr.end());
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    98
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
    99
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
   100
// Like oop_oop_iterate but only iterates over a specified range and only used
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
   101
// for objArrayOops.
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49404
diff changeset
   102
template <typename T, class OopClosureType>
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49404
diff changeset
   103
void ObjArrayKlass::oop_oop_iterate_range(objArrayOop a, OopClosureType* closure, int start, int end) {
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49404
diff changeset
   104
  T* low = start == 0 ? cast_from_oop<T*>(a) : a->obj_at_addr_raw<T>(start);
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49404
diff changeset
   105
  T* high = (T*)a->base_raw() + end;
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49404
diff changeset
   106
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49404
diff changeset
   107
  oop_oop_iterate_elements_bounded<T>(a, closure, low, high);
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49404
diff changeset
   108
}
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
   109
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49404
diff changeset
   110
// Placed here to resolve include cycle between objArrayKlass.inline.hpp and objArrayOop.inline.hpp
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49404
diff changeset
   111
template <typename OopClosureType>
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49404
diff changeset
   112
void objArrayOopDesc::oop_iterate_range(OopClosureType* blk, int start, int end) {
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
   113
  if (UseCompressedOops) {
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49404
diff changeset
   114
    ((ObjArrayKlass*)klass())->oop_oop_iterate_range<narrowOop>(this, blk, start, end);
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
   115
  } else {
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49404
diff changeset
   116
    ((ObjArrayKlass*)klass())->oop_oop_iterate_range<oop>(this, blk, start, end);
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
   117
  }
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
   118
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 22234
diff changeset
   119
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 50752
diff changeset
   120
#endif // SHARE_OOPS_OBJARRAYKLASS_INLINE_HPP