hotspot/src/share/vm/memory/specialized_oop_closures.hpp
author brutisso
Mon, 01 Dec 2014 14:37:25 +0100
changeset 27904 d606512952cc
parent 25351 7c198a690050
child 29687 281ffb2398cd
permissions -rw-r--r--
8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration Reviewed-by: mgerdin, kbarrett
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
22234
da823d78ad65 8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents: 15482
diff changeset
     2
 * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1374
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1374
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: 1374
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#ifndef SHARE_VM_MEMORY_SPECIALIZED_OOP_CLOSURES_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_MEMORY_SPECIALIZED_OOP_CLOSURES_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13952
diff changeset
    28
#include "utilities/macros.hpp"
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13952
diff changeset
    29
#if INCLUDE_ALL_GCS
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "gc_implementation/g1/g1_specialized_oop_closures.hpp"
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13952
diff changeset
    31
#endif // INCLUDE_ALL_GCS
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    32
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
// The following OopClosure types get specialized versions of
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
// "oop_oop_iterate" that invoke the closures' do_oop methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
// non-virtually, using a mechanism defined in this file.  Extend these
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
// macros in the obvious way to add specializations for new closures.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
// Forward declarations.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
class OopClosure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
class OopsInGenClosure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
// DefNew
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
class ScanClosure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
class FastScanClosure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
class FilteringClosure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
// ParNew
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
class ParScanWithBarrierClosure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
class ParScanWithoutBarrierClosure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
// CMS
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
class MarkRefsIntoAndScanClosure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
class Par_MarkRefsIntoAndScanClosure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
class PushAndMarkClosure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
class Par_PushAndMarkClosure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
class PushOrMarkClosure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
class Par_PushOrMarkClosure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
class CMSKeepAliveClosure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
class CMSInnerParMarkAndPushClosure;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 7397
diff changeset
    57
// Misc
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 7397
diff changeset
    58
class NoHeaderExtendedOopClosure;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
// This macro applies an argument macro to all OopClosures for which we
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
// want specialized bodies of "oop_oop_iterate".  The arguments to "f" are:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
//   "f(closureType, non_virtual)"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
// where "closureType" is the name of the particular subclass of OopClosure,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
// and "non_virtual" will be the string "_nv" if the closure type should
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
// have its "do_oop" method invoked non-virtually, or else the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
// string "_v".  ("OopClosure" itself will be the only class in the latter
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
// category.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
// This is split into several because of a Visual C++ 6.0 compiler bug
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
// where very long macros cause the compiler to crash
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    72
// Some other heap might define further specialized closures.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    73
#ifndef FURTHER_SPECIALIZED_OOP_OOP_ITERATE_CLOSURES
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    74
#define FURTHER_SPECIALIZED_OOP_OOP_ITERATE_CLOSURES(f) \
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    75
        /* None */
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    76
#endif
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    77
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
#define SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_S(f)       \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  f(ScanClosure,_nv)                                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  f(FastScanClosure,_nv)                                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  f(FilteringClosure,_nv)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13952
diff changeset
    83
#if INCLUDE_ALL_GCS
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
#define SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_P(f)       \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  f(ParScanWithBarrierClosure,_nv)                      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  f(ParScanWithoutBarrierClosure,_nv)
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13952
diff changeset
    87
#else  // INCLUDE_ALL_GCS
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
#define SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_P(f)
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13952
diff changeset
    89
#endif // INCLUDE_ALL_GCS
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
#define SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_1(f)       \
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 7397
diff changeset
    92
  f(NoHeaderExtendedOopClosure,_nv)                     \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_S(f)             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_P(f)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13952
diff changeset
    96
#if INCLUDE_ALL_GCS
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    97
#define SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_2(f)       \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  f(MarkRefsIntoAndScanClosure,_nv)                     \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  f(Par_MarkRefsIntoAndScanClosure,_nv)                 \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  f(PushAndMarkClosure,_nv)                             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  f(Par_PushAndMarkClosure,_nv)                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  f(PushOrMarkClosure,_nv)                              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  f(Par_PushOrMarkClosure,_nv)                          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  f(CMSKeepAliveClosure,_nv)                            \
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   105
  f(CMSInnerParMarkAndPushClosure,_nv)                  \
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   106
  FURTHER_SPECIALIZED_OOP_OOP_ITERATE_CLOSURES(f)
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13952
diff changeset
   107
#else  // INCLUDE_ALL_GCS
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   108
#define SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_2(f)
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13952
diff changeset
   109
#endif // INCLUDE_ALL_GCS
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   111
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
// We separate these out, because sometime the general one has
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
// a different definition from the specialized ones, and sometimes it
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
// doesn't.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
#define ALL_OOP_OOP_ITERATE_CLOSURES_1(f)               \
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 7397
diff changeset
   117
  f(ExtendedOopClosure,_v)                              \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_1(f)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   120
#define ALL_OOP_OOP_ITERATE_CLOSURES_2(f)               \
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   121
  SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_2(f)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13952
diff changeset
   123
#if INCLUDE_ALL_GCS
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
// This macro applies an argument macro to all OopClosures for which we
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
// want specialized bodies of a family of methods related to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
// "par_oop_iterate".  The arguments to f are the same as above.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
// The "root_class" is the most general class to define; this may be
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
// "OopClosure" in some applications and "OopsInGenClosure" in others.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
#define SPECIALIZED_PAR_OOP_ITERATE_CLOSURES(f)        \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  f(MarkRefsIntoAndScanClosure,_nv)                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  f(PushAndMarkClosure,_nv)                            \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  f(Par_MarkRefsIntoAndScanClosure,_nv)                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  f(Par_PushAndMarkClosure,_nv)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
#define ALL_PAR_OOP_ITERATE_CLOSURES(f)                \
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 7397
diff changeset
   137
  f(ExtendedOopClosure,_v)                             \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  SPECIALIZED_PAR_OOP_ITERATE_CLOSURES(f)
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13952
diff changeset
   139
#endif // INCLUDE_ALL_GCS
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
// This macro applies an argument macro to all OopClosures for which we
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
// want specialized bodies of a family of methods related to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
// "oops_since_save_marks_do".  The arguments to f are the same as above.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
// The "root_class" is the most general class to define; this may be
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
// "OopClosure" in some applications and "OopsInGenClosure" in others.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   147
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   148
// Some other heap might define further specialized closures.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   149
#ifndef FURTHER_SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   150
#define FURTHER_SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES(f) \
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   151
        /* None */
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   152
#endif
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   153
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
#define SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES_YOUNG_S(f) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  f(ScanClosure,_nv)                                     \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  f(FastScanClosure,_nv)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13952
diff changeset
   158
#if INCLUDE_ALL_GCS
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
#define SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES_YOUNG_P(f) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  f(ParScanWithBarrierClosure,_nv)                       \
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   161
  f(ParScanWithoutBarrierClosure,_nv)                    \
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   162
  FURTHER_SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES(f)
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13952
diff changeset
   163
#else  // INCLUDE_ALL_GCS
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
#define SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES_YOUNG_P(f)
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13952
diff changeset
   165
#endif // INCLUDE_ALL_GCS
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
#define SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES_YOUNG(f)  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES_YOUNG_S(f)      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES_YOUNG_P(f)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
#define SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES(f)        \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES_YOUNG(f)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
// We separate these out, because sometime the general one has
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
// a different definition from the specialized ones, and sometimes it
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
// doesn't.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
// NOTE:   One of the valid criticisms of this
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
// specialize-oop_oop_iterate-for-specific-closures idiom is that it is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
// easy to have a silent performance bug: if you fail to de-virtualize,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
// things still work, just slower.  The "SpecializationStats" mode is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
// intended to at least make such a failure easy to detect.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
// *Not* using the ALL_SINCE_SAVE_MARKS_CLOSURES(f) macro defined
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
// below means that *only* closures for which oop_oop_iterate specializations
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
// exist above may be applied to "oops_since_save_marks".  That is,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
// this form of the performance bug is caught statically.  When you add
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
// a definition for the general type, this property goes away.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
// Make sure you test with SpecializationStats to find such bugs
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
// when introducing a new closure where you don't want virtual dispatch.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
#define ALL_SINCE_SAVE_MARKS_CLOSURES(f)                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  f(OopsInGenClosure,_v)                                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES(f)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
// For keeping stats on effectiveness.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
#define ENABLE_SPECIALIZATION_STATS 0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
class SpecializationStats {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  enum Kind {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 7397
diff changeset
   201
    ik,             // InstanceKlass
13738
d67be49a5beb 7195833: NPG: Rename instanceClassLoaderKlass, instanceRefKlass and instanceMirrorKlass
coleenp
parents: 13728
diff changeset
   202
    irk,            // InstanceRefKlass
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13738
diff changeset
   203
    oa,             // ObjArrayKlass
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
    NUM_Kinds
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
#if ENABLE_SPECIALIZATION_STATS
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
private:
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   209
  static bool _init;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   210
  static bool _wrapped;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   211
  static jint _numCallsAll;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   213
  static jint _numCallsTotal[NUM_Kinds];
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   214
  static jint _numCalls_nv[NUM_Kinds];
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   216
  static jint _numDoOopCallsTotal[NUM_Kinds];
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   217
  static jint _numDoOopCalls_nv[NUM_Kinds];
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
  static void clear()  PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  static inline void record_call()  PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
  static inline void record_iterate_call_v(Kind k)  PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  static inline void record_iterate_call_nv(Kind k)  PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
  static inline void record_do_oop_call_v(Kind k)  PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
  static inline void record_do_oop_call_nv(Kind k)  PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
  static void print() PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
#if ENABLE_SPECIALIZATION_STATS
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
inline void SpecializationStats::record_call() {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   235
  Atomic::inc(&_numCallsAll);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
inline void SpecializationStats::record_iterate_call_v(Kind k) {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   238
  Atomic::inc(&_numCallsTotal[k]);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
inline void SpecializationStats::record_iterate_call_nv(Kind k) {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   241
  Atomic::inc(&_numCallsTotal[k]);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   242
  Atomic::inc(&_numCalls_nv[k]);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
inline void SpecializationStats::record_do_oop_call_v(Kind k) {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   246
  Atomic::inc(&_numDoOopCallsTotal[k]);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
inline void SpecializationStats::record_do_oop_call_nv(Kind k) {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   249
  Atomic::inc(&_numDoOopCallsTotal[k]);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   250
  Atomic::inc(&_numDoOopCalls_nv[k]);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
#else   // !ENABLE_SPECIALIZATION_STATS
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
inline void SpecializationStats::record_call() {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
inline void SpecializationStats::record_iterate_call_v(Kind k) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
inline void SpecializationStats::record_iterate_call_nv(Kind k) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
inline void SpecializationStats::record_do_oop_call_v(Kind k) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
inline void SpecializationStats::record_do_oop_call_nv(Kind k) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
inline void SpecializationStats::clear() {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
inline void SpecializationStats::print() {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
#endif  // ENABLE_SPECIALIZATION_STATS
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
#endif  // !PRODUCT
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   265
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   266
#endif // SHARE_VM_MEMORY_SPECIALIZED_OOP_CLOSURES_HPP