src/hotspot/share/code/dependencies.hpp
author vlivanov
Mon, 06 May 2019 12:15:49 -0700
changeset 54721 3661ad97da8f
parent 53244 9807daeb47c4
child 54734 e8f1b9fc82cc
permissions -rw-r--r--
8223171: Redundant nmethod dependencies for effectively final methods Reviewed-by: dlong
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 51333
diff changeset
     2
 * Copyright (c) 2005, 2019, 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: 4493
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4493
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: 4493
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
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 51333
diff changeset
    25
#ifndef SHARE_CODE_DEPENDENCIES_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 51333
diff changeset
    26
#define SHARE_CODE_DEPENDENCIES_HPP
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
10265
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
    28
#include "ci/ciCallSite.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "ci/ciKlass.hpp"
54721
3661ad97da8f 8223171: Redundant nmethod dependencies for effectively final methods
vlivanov
parents: 53244
diff changeset
    30
#include "ci/ciMethod.hpp"
10265
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
    31
#include "ci/ciMethodHandle.hpp"
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
    32
#include "classfile/systemDictionary.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    33
#include "code/compressedStream.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    34
#include "code/nmethod.hpp"
29201
fee2bbb2ec1d 8073389: Remove the include of resourceArea.hpp from classFileParser.hpp
stefank
parents: 28514
diff changeset
    35
#include "memory/resourceArea.hpp"
49594
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents: 49373
diff changeset
    36
#include "runtime/safepointVerifiers.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    37
#include "utilities/growableArray.hpp"
22921
ee35d5c0b1dc 8034839: jvm hangs with gc/gctests/LoadUnloadGC test
anoll
parents: 22506
diff changeset
    38
#include "utilities/hashtable.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    39
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
//** Dependencies represent assertions (approximate invariants) within
10265
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
    41
// the runtime system, e.g. class hierarchy changes.  An example is an
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
    42
// assertion that a given method is not overridden; another example is
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
    43
// that a type has only one concrete subtype.  Compiled code which
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
    44
// relies on such assertions must be discarded if they are overturned
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
    45
// by changes in the runtime system.  We can think of these assertions
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
    46
// as approximate invariants, because we expect them to be overturned
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
// very infrequently.  We are willing to perform expensive recovery
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
// operations when they are overturned.  The benefit, of course, is
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
// performing optimistic optimizations (!) on the object code.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
// Changes in the class hierarchy due to dynamic linking or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
// class evolution can violate dependencies.  There is enough
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
// indexing between classes and nmethods to make dependency
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
// checking reasonably efficient.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
class ciEnv;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
class nmethod;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
class OopRecorder;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
class xmlStream;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
class CompileLog;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
class DepChange;
10265
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
    62
class   KlassDepChange;
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
    63
class   CallSiteDepChange;
35492
c8c0273e6b91 8146690: Make all classes in GC follow the naming convention.
david
parents: 33611
diff changeset
    64
class NoSafepointVerifier;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
class Dependencies: public ResourceObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  // Note: In the comments on dependency types, most uses of the terms
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  // subtype and supertype are used in a "non-strict" or "inclusive"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  // sense, and are starred to remind the reader of this fact.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  // Strict uses of the terms use the word "proper".
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  // Specifically, every class is its own subtype* and supertype*.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  // (This trick is easier than continually saying things like "Y is a
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  // subtype of X or X itself".)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  // Sometimes we write X > Y to mean X is a proper supertype of Y.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  // The notation X > {Y, Z} means X has proper subtypes Y, Z.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  // The notation X.m > Y means that Y inherits m from X, while
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  // X.m > Y.m means Y overrides X.m.  A star denotes abstractness,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  // as *I > A, meaning (abstract) interface I is a super type of A,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  // or A.*m > B.m, meaning B.m implements abstract method A.m.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  // In this module, the terms "subtype" and "supertype" refer to
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  // Java-level reference type conversions, as detected by
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  // "instanceof" and performed by "checkcast" operations.  The method
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  // Klass::is_subtype_of tests these relations.  Note that "subtype"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  // is richer than "subclass" (as tested by Klass::is_subclass_of),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  // since it takes account of relations involving interface and array
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  // types.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  // To avoid needless complexity, dependencies involving array types
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  // are not accepted.  If you need to make an assertion about an
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  // array type, make the assertion about its corresponding element
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  // types.  Any assertion that might change about an array type can
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  // be converted to an assertion about its element type.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  // Most dependencies are evaluated over a "context type" CX, which
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  // stands for the set Subtypes(CX) of every Java type that is a subtype*
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  // of CX.  When the system loads a new class or interface N, it is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  // responsible for re-evaluating changed dependencies whose context
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  // type now includes N, that is, all super types of N.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  enum DepType {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
    end_marker = 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
    // An 'evol' dependency simply notes that the contents of the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
    // method were used.  If it evolves (is replaced), the nmethod
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
    // must be recompiled.  No other dependencies are implied.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
    evol_method,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
    FIRST_TYPE = evol_method,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
    // A context type CX is a leaf it if has no proper subtype.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
    leaf_type,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
    // An abstract class CX has exactly one concrete subtype CC.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
    abstract_with_unique_concrete_subtype,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
    // The type CX is purely abstract, with no concrete subtype* at all.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
    abstract_with_no_concrete_subtype,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
    // The concrete CX is free of concrete proper subtypes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
    concrete_with_no_concrete_subtype,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
    // Given a method M1 and a context class CX, the set MM(CX, M1) of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
    // "concrete matching methods" in CX of M1 is the set of every
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
    // concrete M2 for which it is possible to create an invokevirtual
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
    // or invokeinterface call site that can reach either M1 or M2.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
    // That is, M1 and M2 share a name, signature, and vtable index.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
    // We wish to notice when the set MM(CX, M1) is just {M1}, or
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
    // perhaps a set of two {M1,M2}, and issue dependencies on this.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
    // The set MM(CX, M1) can be computed by starting with any matching
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
    // concrete M2 that is inherited into CX, and then walking the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
    // subtypes* of CX looking for concrete definitions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
    // The parameters to this dependency are the method M1 and the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
    // context class CX.  M1 must be either inherited in CX or defined
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
    // in a subtype* of CX.  It asserts that MM(CX, M1) is no greater
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
    // than {M1}.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
    unique_concrete_method,       // one unique concrete method under CX
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
    // An "exclusive" assertion concerns two methods or subtypes, and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
    // declares that there are at most two (or perhaps later N>2)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
    // specific items that jointly satisfy the restriction.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
    // We list all items explicitly rather than just giving their
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
    // count, for robustness in the face of complex schema changes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
    // A context class CX (which may be either abstract or concrete)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
    // has two exclusive concrete subtypes* C1, C2 if every concrete
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
    // subtype* of CX is either C1 or C2.  Note that if neither C1 or C2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
    // are equal to CX, then CX itself must be abstract.  But it is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
    // also possible (for example) that C1 is CX (a concrete class)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
    // and C2 is a proper subtype of C1.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
    abstract_with_exclusive_concrete_subtypes_2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
    // This dependency asserts that MM(CX, M1) is no greater than {M1,M2}.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
    exclusive_concrete_methods_2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
    // This dependency asserts that no instances of class or it's
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
    // subclasses require finalization registration.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
    no_finalizable_subclasses,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
10265
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   164
    // This dependency asserts when the CallSite.target value changed.
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   165
    call_site_target_value,
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   166
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
    TYPE_LIMIT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  enum {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
    LG2_TYPE_LIMIT = 4,  // assert(TYPE_LIMIT <= (1<<LG2_TYPE_LIMIT))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
    // handy categorizations of dependency types:
39411
9b6627406019 8157758: JDK9 does not compile on Linux with GCC 6.1 because left-shifting a negative number has undefined behavior
kbarrett
parents: 36300
diff changeset
   173
    all_types           = ((1 << TYPE_LIMIT) - 1) & ((~0u) << FIRST_TYPE),
10503
04b74421bdea 7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents: 10265
diff changeset
   174
04b74421bdea 7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents: 10265
diff changeset
   175
    non_klass_types     = (1 << call_site_target_value),
04b74421bdea 7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents: 10265
diff changeset
   176
    klass_types         = all_types & ~non_klass_types,
04b74421bdea 7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents: 10265
diff changeset
   177
31037
01a5c5fa5681 8079205: CallSite dependency tracking is broken after sun.misc.Cleaner became automatically cleared
vlivanov
parents: 30296
diff changeset
   178
    non_ctxk_types      = (1 << evol_method) | (1 << call_site_target_value),
30296
95baefac8485 8057967: CallSite dependency tracking scales devastatingly poorly
vlivanov
parents: 29201
diff changeset
   179
    implicit_ctxk_types = 0,
10503
04b74421bdea 7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents: 10265
diff changeset
   180
    explicit_ctxk_types = all_types & ~(non_ctxk_types | implicit_ctxk_types),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
    max_arg_count = 3,   // current maximum number of arguments (incl. ctxk)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
    // A "context type" is a class or interface that
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
    // provides context for evaluating a dependency.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
    // When present, it is one of the arguments (dep_context_arg).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
    // If a dependency does not have a context type, there is a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
    // default context, depending on the type of the dependency.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
    // This bit signals that a default context has been compressed away.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
    default_context_type_bit = (1<<LG2_TYPE_LIMIT)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  static const char* dep_name(DepType dept);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  static int         dep_args(DepType dept);
10503
04b74421bdea 7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents: 10265
diff changeset
   196
04b74421bdea 7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents: 10265
diff changeset
   197
  static bool is_klass_type(           DepType dept) { return dept_in_mask(dept, klass_types        ); }
04b74421bdea 7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents: 10265
diff changeset
   198
04b74421bdea 7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents: 10265
diff changeset
   199
  static bool has_explicit_context_arg(DepType dept) { return dept_in_mask(dept, explicit_ctxk_types); }
04b74421bdea 7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents: 10265
diff changeset
   200
  static bool has_implicit_context_arg(DepType dept) { return dept_in_mask(dept, implicit_ctxk_types); }
04b74421bdea 7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents: 10265
diff changeset
   201
04b74421bdea 7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents: 10265
diff changeset
   202
  static int           dep_context_arg(DepType dept) { return has_explicit_context_arg(dept) ? 0 : -1; }
04b74421bdea 7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents: 10265
diff changeset
   203
  static int  dep_implicit_context_arg(DepType dept) { return has_implicit_context_arg(dept) ? 0 : -1; }
04b74421bdea 7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents: 10265
diff changeset
   204
10265
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   205
  static void check_valid_dependency_type(DepType dept);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   207
#if INCLUDE_JVMCI
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   208
  // A Metadata* or object value recorded in an OopRecorder
49373
47b5652f2928 8199283: Remove ValueObj class for allocation subclassing for compiler code
coleenp
parents: 48604
diff changeset
   209
  class DepValue {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   210
   private:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   211
    // Unique identifier of the value within the associated OopRecorder that
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   212
    // encodes both the category of the value (0: invalid, positive: metadata, negative: object)
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   213
    // and the index within a category specific array (metadata: index + 1, object: -(index + 1))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   214
    int _id;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   215
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   216
   public:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   217
    DepValue() : _id(0) {}
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   218
    DepValue(OopRecorder* rec, Metadata* metadata, DepValue* candidate = NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   219
      assert(candidate == NULL || candidate->is_metadata(), "oops");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   220
      if (candidate != NULL && candidate->as_metadata(rec) == metadata) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   221
        _id = candidate->_id;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   222
      } else {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   223
        _id = rec->find_index(metadata) + 1;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   224
      }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   225
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   226
    DepValue(OopRecorder* rec, jobject obj, DepValue* candidate = NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   227
      assert(candidate == NULL || candidate->is_object(), "oops");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   228
      if (candidate != NULL && candidate->as_object(rec) == obj) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   229
        _id = candidate->_id;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   230
      } else {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   231
        _id = -(rec->find_index(obj) + 1);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   232
      }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   233
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   234
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   235
    // Used to sort values in ascending order of index() with metadata values preceding object values
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   236
    int sort_key() const { return -_id; }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   237
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   238
    bool operator == (const DepValue& other) const   { return other._id == _id; }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   239
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   240
    bool is_valid() const             { return _id != 0; }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   241
    int  index() const                { assert(is_valid(), "oops"); return _id < 0 ? -(_id + 1) : _id - 1; }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   242
    bool is_metadata() const          { assert(is_valid(), "oops"); return _id > 0; }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   243
    bool is_object() const            { assert(is_valid(), "oops"); return _id < 0; }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   244
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   245
    Metadata*  as_metadata(OopRecorder* rec) const    { assert(is_metadata(), "oops"); return rec->metadata_at(index()); }
48604
37a5a1109b93 8194989: 2 Null pointer dereference defect groups caused by Dependencies::DepValue::as_klass()
dlong
parents: 48299
diff changeset
   246
    Klass*     as_klass(OopRecorder* rec) const {
37a5a1109b93 8194989: 2 Null pointer dereference defect groups caused by Dependencies::DepValue::as_klass()
dlong
parents: 48299
diff changeset
   247
      Metadata* m = as_metadata(rec);
37a5a1109b93 8194989: 2 Null pointer dereference defect groups caused by Dependencies::DepValue::as_klass()
dlong
parents: 48299
diff changeset
   248
      assert(m != NULL, "as_metadata returned NULL");
37a5a1109b93 8194989: 2 Null pointer dereference defect groups caused by Dependencies::DepValue::as_klass()
dlong
parents: 48299
diff changeset
   249
      assert(m->is_klass(), "oops");
37a5a1109b93 8194989: 2 Null pointer dereference defect groups caused by Dependencies::DepValue::as_klass()
dlong
parents: 48299
diff changeset
   250
      return (Klass*) m;
37a5a1109b93 8194989: 2 Null pointer dereference defect groups caused by Dependencies::DepValue::as_klass()
dlong
parents: 48299
diff changeset
   251
    }
37a5a1109b93 8194989: 2 Null pointer dereference defect groups caused by Dependencies::DepValue::as_klass()
dlong
parents: 48299
diff changeset
   252
    Method*    as_method(OopRecorder* rec) const {
37a5a1109b93 8194989: 2 Null pointer dereference defect groups caused by Dependencies::DepValue::as_klass()
dlong
parents: 48299
diff changeset
   253
      Metadata* m = as_metadata(rec);
37a5a1109b93 8194989: 2 Null pointer dereference defect groups caused by Dependencies::DepValue::as_klass()
dlong
parents: 48299
diff changeset
   254
      assert(m != NULL, "as_metadata returned NULL");
37a5a1109b93 8194989: 2 Null pointer dereference defect groups caused by Dependencies::DepValue::as_klass()
dlong
parents: 48299
diff changeset
   255
      assert(m->is_method(), "oops");
37a5a1109b93 8194989: 2 Null pointer dereference defect groups caused by Dependencies::DepValue::as_klass()
dlong
parents: 48299
diff changeset
   256
      return (Method*) m;
37a5a1109b93 8194989: 2 Null pointer dereference defect groups caused by Dependencies::DepValue::as_klass()
dlong
parents: 48299
diff changeset
   257
    }
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   258
    jobject    as_object(OopRecorder* rec) const      { assert(is_object(), "oops"); return rec->oop_at(index()); }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   259
  };
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   260
#endif // INCLUDE_JVMCI
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   261
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  // State for writing a new set of dependencies:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
  GrowableArray<int>*       _dep_seen;  // (seen[h->ident] & (1<<dept))
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   265
  GrowableArray<ciBaseObject*>*  _deps[TYPE_LIMIT];
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   266
#if INCLUDE_JVMCI
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   267
  bool _using_dep_values;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   268
  GrowableArray<DepValue>*  _dep_values[TYPE_LIMIT];
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   269
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
  static const char* _dep_name[TYPE_LIMIT];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
  static int         _dep_args[TYPE_LIMIT];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
  static bool dept_in_mask(DepType dept, int mask) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
    return (int)dept >= 0 && dept < TYPE_LIMIT && ((1<<dept) & mask) != 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   278
  bool note_dep_seen(int dept, ciBaseObject* x) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
    assert(dept < BitsPerInt, "oob");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
    int x_id = x->ident();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
    assert(_dep_seen != NULL, "deps must be writable");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
    int seen = _dep_seen->at_grow(x_id, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
    _dep_seen->at_put(x_id, seen | (1<<dept));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
    // return true if we've already seen dept/x
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
    return (seen & (1<<dept)) != 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   288
#if INCLUDE_JVMCI
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   289
  bool note_dep_seen(int dept, DepValue x) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   290
    assert(dept < BitsPerInt, "oops");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   291
    // place metadata deps at even indexes, object deps at odd indexes
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   292
    int x_id = x.is_metadata() ? x.index() * 2 : (x.index() * 2) + 1;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   293
    assert(_dep_seen != NULL, "deps must be writable");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   294
    int seen = _dep_seen->at_grow(x_id, 0);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   295
    _dep_seen->at_put(x_id, seen | (1<<dept));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   296
    // return true if we've already seen dept/x
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   297
    return (seen & (1<<dept)) != 0;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   298
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   299
#endif
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   300
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   301
  bool maybe_merge_ctxk(GrowableArray<ciBaseObject*>* deps,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
                        int ctxk_i, ciKlass* ctxk);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   303
#if INCLUDE_JVMCI
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   304
  bool maybe_merge_ctxk(GrowableArray<DepValue>* deps,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   305
                        int ctxk_i, DepValue ctxk);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   306
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
  void sort_all_deps();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
  size_t estimate_size_in_bytes();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
  // Initialize _deps, etc.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
  void initialize(ciEnv* env);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
  // State for making a new set of dependencies:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
  OopRecorder* _oop_recorder;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
  // Logging support
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
  CompileLog* _log;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
  address  _content_bytes;  // everything but the oop references, encoded
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
  size_t   _size_in_bytes;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
  // Make a new empty dependencies set.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
  Dependencies(ciEnv* env) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
    initialize(env);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
  }
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   328
#if INCLUDE_JVMCI
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   329
  Dependencies(Arena* arena, OopRecorder* oop_recorder, CompileLog* log);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   330
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
  // Check for a valid context type.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
  // Enforce the restriction against array types.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
  static void check_ctxk(ciKlass* ctxk) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
    assert(ctxk->is_instance_klass(), "java types only");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
  static void check_ctxk_concrete(ciKlass* ctxk) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
    assert(is_concrete_klass(ctxk->as_instance_klass()), "must be concrete");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
  static void check_ctxk_abstract(ciKlass* ctxk) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
    check_ctxk(ctxk);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
    assert(!is_concrete_klass(ctxk->as_instance_klass()), "must be abstract");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
  }
54721
3661ad97da8f 8223171: Redundant nmethod dependencies for effectively final methods
vlivanov
parents: 53244
diff changeset
   345
  static void check_unique_method(ciKlass* ctxk, ciMethod* m) {
3661ad97da8f 8223171: Redundant nmethod dependencies for effectively final methods
vlivanov
parents: 53244
diff changeset
   346
    assert(!m->can_be_statically_bound(ctxk->as_instance_klass()), "redundant");
3661ad97da8f 8223171: Redundant nmethod dependencies for effectively final methods
vlivanov
parents: 53244
diff changeset
   347
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   349
  void assert_common_1(DepType dept, ciBaseObject* x);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   350
  void assert_common_2(DepType dept, ciBaseObject* x0, ciBaseObject* x1);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   351
  void assert_common_3(DepType dept, ciKlass* ctxk, ciBaseObject* x1, ciBaseObject* x2);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
  // Adding assertions to a new dependency set at compile time:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
  void assert_evol_method(ciMethod* m);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
  void assert_leaf_type(ciKlass* ctxk);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
  void assert_abstract_with_unique_concrete_subtype(ciKlass* ctxk, ciKlass* conck);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
  void assert_abstract_with_no_concrete_subtype(ciKlass* ctxk);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
  void assert_concrete_with_no_concrete_subtype(ciKlass* ctxk);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
  void assert_unique_concrete_method(ciKlass* ctxk, ciMethod* uniqm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
  void assert_abstract_with_exclusive_concrete_subtypes(ciKlass* ctxk, ciKlass* k1, ciKlass* k2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
  void assert_exclusive_concrete_methods(ciKlass* ctxk, ciMethod* m1, ciMethod* m2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
  void assert_has_no_finalizable_subclasses(ciKlass* ctxk);
10503
04b74421bdea 7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents: 10265
diff changeset
   364
  void assert_call_site_target_value(ciCallSite* call_site, ciMethodHandle* method_handle);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   366
#if INCLUDE_JVMCI
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   367
 private:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   368
  static void check_ctxk(Klass* ctxk) {
33611
9abd65805e19 8139203: Consistent naming for klass type predicates
coleenp
parents: 33160
diff changeset
   369
    assert(ctxk->is_instance_klass(), "java types only");
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   370
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   371
  static void check_ctxk_abstract(Klass* ctxk) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   372
    check_ctxk(ctxk);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   373
    assert(ctxk->is_abstract(), "must be abstract");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   374
  }
54721
3661ad97da8f 8223171: Redundant nmethod dependencies for effectively final methods
vlivanov
parents: 53244
diff changeset
   375
  static void check_unique_method(Klass* ctxk, Method* m) {
3661ad97da8f 8223171: Redundant nmethod dependencies for effectively final methods
vlivanov
parents: 53244
diff changeset
   376
    assert(!m->can_be_statically_bound(InstanceKlass::cast(ctxk)), "redundant");
3661ad97da8f 8223171: Redundant nmethod dependencies for effectively final methods
vlivanov
parents: 53244
diff changeset
   377
  }
3661ad97da8f 8223171: Redundant nmethod dependencies for effectively final methods
vlivanov
parents: 53244
diff changeset
   378
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   379
  void assert_common_1(DepType dept, DepValue x);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   380
  void assert_common_2(DepType dept, DepValue x0, DepValue x1);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   381
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   382
 public:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   383
  void assert_evol_method(Method* m);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   384
  void assert_has_no_finalizable_subclasses(Klass* ctxk);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   385
  void assert_leaf_type(Klass* ctxk);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   386
  void assert_unique_concrete_method(Klass* ctxk, Method* uniqm);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   387
  void assert_abstract_with_unique_concrete_subtype(Klass* ctxk, Klass* conck);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   388
  void assert_call_site_target_value(oop callSite, oop methodHandle);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   389
#endif // INCLUDE_JVMCI
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   390
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
  // Define whether a given method or type is concrete.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
  // These methods define the term "concrete" as used in this module.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
  // For this module, an "abstract" class is one which is non-concrete.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
  // Future optimizations may allow some classes to remain
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
  // non-concrete until their first instantiation, and allow some
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
  // methods to remain non-concrete until their first invocation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
  // In that case, there would be a middle ground between concrete
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
  // and abstract (as defined by the Java language and VM).
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   400
  static bool is_concrete_klass(Klass* k);    // k is instantiable
28514
da53c1ffc837 8064524: Compiler code generation improvements
drchase
parents: 25936
diff changeset
   401
  static bool is_concrete_method(Method* m, Klass* k);  // m is invocable
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
  static Klass* find_finalizable_subclass(Klass* k);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
  // These versions of the concreteness queries work through the CI.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
  // The CI versions are allowed to skew sometimes from the VM
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
  // (oop-based) versions.  The cost of such a difference is a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
  // (safely) aborted compilation, or a deoptimization, or a missed
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
  // optimization opportunity.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
  // In order to prevent spurious assertions, query results must
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
  // remain stable within any single ciEnv instance.  (I.e., they must
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
  // not go back into the VM to get their value; they must cache the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
  // bit in the CI, either eagerly or lazily.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
  static bool is_concrete_klass(ciInstanceKlass* k); // k appears instantiable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
  static bool has_finalizable_subclass(ciInstanceKlass* k);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
  // As a general rule, it is OK to compile under the assumption that
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
  // a given type or method is concrete, even if it at some future
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
  // point becomes abstract.  So dependency checking is one-sided, in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
  // that it permits supposedly concrete classes or methods to turn up
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
  // as really abstract.  (This shouldn't happen, except during class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
  // evolution, but that's the logic of the checking.)  However, if a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
  // supposedly abstract class or method suddenly becomes concrete, a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
  // dependency on it must fail.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
  // Checking old assertions at run-time (in the VM only):
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   427
  static Klass* check_evol_method(Method* m);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   428
  static Klass* check_leaf_type(Klass* ctxk);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   429
  static Klass* check_abstract_with_unique_concrete_subtype(Klass* ctxk, Klass* conck,
10265
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   430
                                                              KlassDepChange* changes = NULL);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   431
  static Klass* check_abstract_with_no_concrete_subtype(Klass* ctxk,
10265
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   432
                                                          KlassDepChange* changes = NULL);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   433
  static Klass* check_concrete_with_no_concrete_subtype(Klass* ctxk,
10265
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   434
                                                          KlassDepChange* changes = NULL);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   435
  static Klass* check_unique_concrete_method(Klass* ctxk, Method* uniqm,
10265
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   436
                                               KlassDepChange* changes = NULL);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   437
  static Klass* check_abstract_with_exclusive_concrete_subtypes(Klass* ctxk, Klass* k1, Klass* k2,
10265
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   438
                                                                  KlassDepChange* changes = NULL);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   439
  static Klass* check_exclusive_concrete_methods(Klass* ctxk, Method* m1, Method* m2,
10265
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   440
                                                   KlassDepChange* changes = NULL);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   441
  static Klass* check_has_no_finalizable_subclasses(Klass* ctxk, KlassDepChange* changes = NULL);
31037
01a5c5fa5681 8079205: CallSite dependency tracking is broken after sun.misc.Cleaner became automatically cleared
vlivanov
parents: 30296
diff changeset
   442
  static Klass* check_call_site_target_value(oop call_site, oop method_handle, CallSiteDepChange* changes = NULL);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   443
  // A returned Klass* is NULL if the dependency assertion is still
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   444
  // valid.  A non-NULL Klass* is a 'witness' to the assertion
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
  // failure, a point in the class hierarchy where the assertion has
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
  // been proven false.  For example, if check_leaf_type returns
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
  // non-NULL, the value is a subtype of the supposed leaf type.  This
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
  // witness value may be useful for logging the dependency failure.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
  // Note that, when a dependency fails, there may be several possible
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
  // witnesses to the failure.  The value returned from the check_foo
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
  // method is chosen arbitrarily.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
  // The 'changes' value, if non-null, requests a limited spot-check
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
  // near the indicated recent changes in the class hierarchy.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
  // It is used by DepStream::spot_check_dependency_at.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
  // Detecting possible new assertions:
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   458
  static Klass*    find_unique_concrete_subtype(Klass* ctxk);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   459
  static Method*   find_unique_concrete_method(Klass* ctxk, Method* m);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   460
  static int       find_exclusive_concrete_subtypes(Klass* ctxk, int klen, Klass* k[]);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
  // Create the encoding which will be stored in an nmethod.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
  void encode_content_bytes();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
  address content_bytes() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
    assert(_content_bytes != NULL, "encode it first");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
    return _content_bytes;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
  size_t size_in_bytes() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
    assert(_content_bytes != NULL, "encode it first");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
    return _size_in_bytes;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
  OopRecorder* oop_recorder() { return _oop_recorder; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
  CompileLog*  log()          { return _log; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
  void copy_to(nmethod* nm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
48299
e8f5fc8f5f67 8191052: [Graal] java/lang/invoke/CallSiteTest.java intermittently fails with "Failed dependency of type call_site_target_value" when running with Graal as JIT
never
parents: 47216
diff changeset
   479
  DepType validate_dependencies(CompileTask* task, bool counter_changed, char** failure_detail = NULL);
e8f5fc8f5f67 8191052: [Graal] java/lang/invoke/CallSiteTest.java intermittently fails with "Failed dependency of type call_site_target_value" when running with Graal as JIT
never
parents: 47216
diff changeset
   480
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
  void log_all_dependencies();
25936
9b693ed74c13 8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents: 23187
diff changeset
   482
9b693ed74c13 8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents: 23187
diff changeset
   483
  void log_dependency(DepType dept, GrowableArray<ciBaseObject*>* args) {
9b693ed74c13 8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents: 23187
diff changeset
   484
    ResourceMark rm;
9b693ed74c13 8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents: 23187
diff changeset
   485
    int argslen = args->length();
9b693ed74c13 8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents: 23187
diff changeset
   486
    write_dependency_to(log(), dept, args);
9b693ed74c13 8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents: 23187
diff changeset
   487
    guarantee(argslen == args->length(),
9b693ed74c13 8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents: 23187
diff changeset
   488
              "args array cannot grow inside nested ResoureMark scope");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
  }
25936
9b693ed74c13 8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents: 23187
diff changeset
   490
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
  void log_dependency(DepType dept,
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   492
                      ciBaseObject* x0,
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   493
                      ciBaseObject* x1 = NULL,
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   494
                      ciBaseObject* x2 = NULL) {
25936
9b693ed74c13 8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents: 23187
diff changeset
   495
    if (log() == NULL) {
9b693ed74c13 8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents: 23187
diff changeset
   496
      return;
9b693ed74c13 8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents: 23187
diff changeset
   497
    }
9b693ed74c13 8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents: 23187
diff changeset
   498
    ResourceMark rm;
9b693ed74c13 8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents: 23187
diff changeset
   499
    GrowableArray<ciBaseObject*>* ciargs =
9b693ed74c13 8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents: 23187
diff changeset
   500
                new GrowableArray<ciBaseObject*>(dep_args(dept));
9b693ed74c13 8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents: 23187
diff changeset
   501
    assert (x0 != NULL, "no log x0");
9b693ed74c13 8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents: 23187
diff changeset
   502
    ciargs->push(x0);
9b693ed74c13 8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents: 23187
diff changeset
   503
9b693ed74c13 8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents: 23187
diff changeset
   504
    if (x1 != NULL) {
9b693ed74c13 8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents: 23187
diff changeset
   505
      ciargs->push(x1);
9b693ed74c13 8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents: 23187
diff changeset
   506
    }
9b693ed74c13 8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents: 23187
diff changeset
   507
    if (x2 != NULL) {
9b693ed74c13 8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents: 23187
diff changeset
   508
      ciargs->push(x2);
9b693ed74c13 8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents: 23187
diff changeset
   509
    }
9b693ed74c13 8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents: 23187
diff changeset
   510
    assert(ciargs->length() == dep_args(dept), "");
9b693ed74c13 8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents: 23187
diff changeset
   511
    log_dependency(dept, ciargs);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   514
  class DepArgument : public ResourceObj {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   515
   private:
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   516
    bool  _is_oop;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   517
    bool  _valid;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   518
    void* _value;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   519
   public:
51333
f6641fcf7b7e 8208670: Compiler changes to allow enabling -Wreorder
tschatzl
parents: 51329
diff changeset
   520
    DepArgument() : _is_oop(false), _valid(false), _value(NULL) {}
f6641fcf7b7e 8208670: Compiler changes to allow enabling -Wreorder
tschatzl
parents: 51329
diff changeset
   521
    DepArgument(oop v): _is_oop(true), _valid(true), _value(v) {}
f6641fcf7b7e 8208670: Compiler changes to allow enabling -Wreorder
tschatzl
parents: 51329
diff changeset
   522
    DepArgument(Metadata* v): _is_oop(false), _valid(true), _value(v) {}
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   523
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   524
    bool is_null() const               { return _value == NULL; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   525
    bool is_oop() const                { return _is_oop; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   526
    bool is_metadata() const           { return !_is_oop; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   527
    bool is_klass() const              { return is_metadata() && metadata_value()->is_klass(); }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   528
    bool is_method() const              { return is_metadata() && metadata_value()->is_method(); }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   529
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   530
    oop oop_value() const              { assert(_is_oop && _valid, "must be"); return (oop) _value; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   531
    Metadata* metadata_value() const { assert(!_is_oop && _valid, "must be"); return (Metadata*) _value; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   532
  };
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   533
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
  static void print_dependency(DepType dept,
25936
9b693ed74c13 8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents: 23187
diff changeset
   535
                               GrowableArray<DepArgument>* args,
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   536
                               Klass* witness = NULL, outputStream* st = tty);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
  // helper for encoding common context types as zero:
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   540
  static ciKlass* ctxk_encoded_as_null(DepType dept, ciBaseObject* x);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   542
  static Klass* ctxk_encoded_as_null(DepType dept, Metadata* x);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
25936
9b693ed74c13 8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents: 23187
diff changeset
   544
  static void write_dependency_to(CompileLog* log,
9b693ed74c13 8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents: 23187
diff changeset
   545
                                  DepType dept,
9b693ed74c13 8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents: 23187
diff changeset
   546
                                  GrowableArray<ciBaseObject*>* args,
9b693ed74c13 8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents: 23187
diff changeset
   547
                                  Klass* witness = NULL);
9b693ed74c13 8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents: 23187
diff changeset
   548
  static void write_dependency_to(CompileLog* log,
9b693ed74c13 8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents: 23187
diff changeset
   549
                                  DepType dept,
9b693ed74c13 8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents: 23187
diff changeset
   550
                                  GrowableArray<DepArgument>* args,
9b693ed74c13 8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents: 23187
diff changeset
   551
                                  Klass* witness = NULL);
9b693ed74c13 8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents: 23187
diff changeset
   552
  static void write_dependency_to(xmlStream* xtty,
9b693ed74c13 8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents: 23187
diff changeset
   553
                                  DepType dept,
9b693ed74c13 8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents: 23187
diff changeset
   554
                                  GrowableArray<DepArgument>* args,
9b693ed74c13 8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents: 23187
diff changeset
   555
                                  Klass* witness = NULL);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
  // Use this to iterate over an nmethod's dependency set.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
  // Works on new and old dependency sets.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
  // Usage:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
  // ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
  // Dependencies::DepType dept;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
  // for (Dependencies::DepStream deps(nm); deps.next(); ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
  //   ...
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
  // }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
  // The caller must be in the VM, since oops are not wrapped in handles.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
  class DepStream {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
  private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
    nmethod*              _code;   // null if in a compiler thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
    Dependencies*         _deps;   // null if not in a compiler thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
    CompressedReadStream  _bytes;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
    size_t                _byte_limit;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
    // iteration variables:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
    DepType               _type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
    int                   _xi[max_arg_count+1];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
    void initial_asserts(size_t byte_limit) NOT_DEBUG({});
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   583
    inline Metadata* recorded_metadata_at(int i);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
    inline oop recorded_oop_at(int i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   586
    Klass* check_klass_dependency(KlassDepChange* changes);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   587
    Klass* check_call_site_dependency(CallSiteDepChange* changes);
10265
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   588
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   589
    void trace_and_log_witness(Klass* witness);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
  public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
    DepStream(Dependencies* deps)
51333
f6641fcf7b7e 8208670: Compiler changes to allow enabling -Wreorder
tschatzl
parents: 51329
diff changeset
   593
      : _code(NULL),
f6641fcf7b7e 8208670: Compiler changes to allow enabling -Wreorder
tschatzl
parents: 51329
diff changeset
   594
        _deps(deps),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
        _bytes(deps->content_bytes())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
      initial_asserts(deps->size_in_bytes());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
    DepStream(nmethod* code)
51333
f6641fcf7b7e 8208670: Compiler changes to allow enabling -Wreorder
tschatzl
parents: 51329
diff changeset
   600
      : _code(code),
f6641fcf7b7e 8208670: Compiler changes to allow enabling -Wreorder
tschatzl
parents: 51329
diff changeset
   601
        _deps(NULL),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
        _bytes(code->dependencies_begin())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
      initial_asserts(code->dependencies_size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
    bool next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
    DepType type()               { return _type; }
31037
01a5c5fa5681 8079205: CallSite dependency tracking is broken after sun.misc.Cleaner became automatically cleared
vlivanov
parents: 30296
diff changeset
   610
    bool is_oop_argument(int i)  { return type() == call_site_target_value; }
22506
0759c126204d 7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents: 13728
diff changeset
   611
    uintptr_t get_identifier(int i);
0759c126204d 7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents: 13728
diff changeset
   612
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
    int argument_count()         { return dep_args(type()); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
    int argument_index(int i)    { assert(0 <= i && i < argument_count(), "oob");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
                                   return _xi[i]; }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   616
    Metadata* argument(int i);     // => recorded_oop_at(argument_index(i))
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   617
    oop argument_oop(int i);         // => recorded_oop_at(argument_index(i))
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   618
    Klass* context_type();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
10503
04b74421bdea 7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents: 10265
diff changeset
   620
    bool is_klass_type()         { return Dependencies::is_klass_type(type()); }
04b74421bdea 7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents: 10265
diff changeset
   621
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   622
    Method* method_argument(int i) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   623
      Metadata* x = argument(i);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
      assert(x->is_method(), "type");
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   625
      return (Method*) x;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
    }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   627
    Klass* type_argument(int i) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   628
      Metadata* x = argument(i);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
      assert(x->is_klass(), "type");
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   630
      return (Klass*) x;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
10265
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   633
    // The point of the whole exercise:  Is this dep still OK?
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   634
    Klass* check_dependency() {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   635
      Klass* result = check_klass_dependency(NULL);
10265
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   636
      if (result != NULL)  return result;
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   637
      return check_call_site_dependency(NULL);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
    }
10265
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   639
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   640
    // A lighter version:  Checks only around recent changes in a class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
    // hierarchy.  (See Universe::flush_dependents_on.)
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   642
    Klass* spot_check_dependency_at(DepChange& changes);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   643
489c9b5090e2 Initial load
duke
parents:
diff changeset
   644
    // Log the current dependency to xtty or compilation log.
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   645
    void log_dependency(Klass* witness = NULL);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   646
489c9b5090e2 Initial load
duke
parents:
diff changeset
   647
    // Print the current dependency to tty.
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31037
diff changeset
   648
    void print_dependency(Klass* witness = NULL, bool verbose = false, outputStream* st = tty);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
  friend class Dependencies::DepStream;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652
  static void print_statistics() PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   653
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   654
10265
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   655
23187
0f438571f278 8035946: Use ResourceHashtable for dependency checking
anoll
parents: 22921
diff changeset
   656
class DependencySignature : public ResourceObj {
22506
0759c126204d 7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents: 13728
diff changeset
   657
 private:
0759c126204d 7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents: 13728
diff changeset
   658
  int                   _args_count;
0759c126204d 7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents: 13728
diff changeset
   659
  uintptr_t             _argument_hash[Dependencies::max_arg_count];
0759c126204d 7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents: 13728
diff changeset
   660
  Dependencies::DepType _type;
0759c126204d 7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents: 13728
diff changeset
   661
0759c126204d 7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents: 13728
diff changeset
   662
 public:
0759c126204d 7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents: 13728
diff changeset
   663
  DependencySignature(Dependencies::DepStream& dep) {
0759c126204d 7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents: 13728
diff changeset
   664
    _args_count = dep.argument_count();
0759c126204d 7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents: 13728
diff changeset
   665
    _type = dep.type();
0759c126204d 7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents: 13728
diff changeset
   666
    for (int i = 0; i < _args_count; i++) {
0759c126204d 7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents: 13728
diff changeset
   667
      _argument_hash[i] = dep.get_identifier(i);
0759c126204d 7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents: 13728
diff changeset
   668
    }
0759c126204d 7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents: 13728
diff changeset
   669
  }
0759c126204d 7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents: 13728
diff changeset
   670
23187
0f438571f278 8035946: Use ResourceHashtable for dependency checking
anoll
parents: 22921
diff changeset
   671
  static bool     equals(DependencySignature const& s1, DependencySignature const& s2);
0f438571f278 8035946: Use ResourceHashtable for dependency checking
anoll
parents: 22921
diff changeset
   672
  static unsigned hash  (DependencySignature const& s1) { return s1.arg(0) >> 2; }
22506
0759c126204d 7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents: 13728
diff changeset
   673
0759c126204d 7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents: 13728
diff changeset
   674
  int args_count()             const { return _args_count; }
0759c126204d 7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents: 13728
diff changeset
   675
  uintptr_t arg(int idx)       const { return _argument_hash[idx]; }
0759c126204d 7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents: 13728
diff changeset
   676
  Dependencies::DepType type() const { return _type; }
23187
0f438571f278 8035946: Use ResourceHashtable for dependency checking
anoll
parents: 22921
diff changeset
   677
22506
0759c126204d 7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents: 13728
diff changeset
   678
};
0759c126204d 7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents: 13728
diff changeset
   679
0759c126204d 7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents: 13728
diff changeset
   680
10265
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   681
// Every particular DepChange is a sub-class of this class.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   682
class DepChange : public StackObj {
4493
9204129f065e 6843629: Make current hotspot build part of jdk5 control build
phh
parents: 1
diff changeset
   683
 public:
10265
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   684
  // What kind of DepChange is this?
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   685
  virtual bool is_klass_change()     const { return false; }
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   686
  virtual bool is_call_site_change() const { return false; }
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   687
36300
5b47f168b948 7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents: 35499
diff changeset
   688
  virtual void mark_for_deoptimization(nmethod* nm) = 0;
5b47f168b948 7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents: 35499
diff changeset
   689
10265
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   690
  // Subclass casting with assertions.
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   691
  KlassDepChange*    as_klass_change() {
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   692
    assert(is_klass_change(), "bad cast");
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   693
    return (KlassDepChange*) this;
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   694
  }
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   695
  CallSiteDepChange* as_call_site_change() {
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   696
    assert(is_call_site_change(), "bad cast");
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   697
    return (CallSiteDepChange*) this;
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   698
  }
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   699
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   700
  void print();
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   701
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   702
 public:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   703
  enum ChangeType {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   704
    NO_CHANGE = 0,              // an uninvolved klass
489c9b5090e2 Initial load
duke
parents:
diff changeset
   705
    Change_new_type,            // a newly loaded type
489c9b5090e2 Initial load
duke
parents:
diff changeset
   706
    Change_new_sub,             // a super with a new subtype
489c9b5090e2 Initial load
duke
parents:
diff changeset
   707
    Change_new_impl,            // an interface with a new implementation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   708
    CHANGE_LIMIT,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   709
    Start_Klass = CHANGE_LIMIT  // internal indicator for ContextStream
489c9b5090e2 Initial load
duke
parents:
diff changeset
   710
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   711
489c9b5090e2 Initial load
duke
parents:
diff changeset
   712
  // Usage:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   713
  // for (DepChange::ContextStream str(changes); str.next(); ) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   714
  //   Klass* k = str.klass();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   715
  //   switch (str.change_type()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   716
  //     ...
489c9b5090e2 Initial load
duke
parents:
diff changeset
   717
  //   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   718
  // }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   719
  class ContextStream : public StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   720
   private:
4493
9204129f065e 6843629: Make current hotspot build part of jdk5 control build
phh
parents: 1
diff changeset
   721
    DepChange&  _changes;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   722
    friend class DepChange;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   723
489c9b5090e2 Initial load
duke
parents:
diff changeset
   724
    // iteration variables:
4493
9204129f065e 6843629: Make current hotspot build part of jdk5 control build
phh
parents: 1
diff changeset
   725
    ChangeType  _change_type;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   726
    Klass*      _klass;
51329
9c68699bebe5 8208999: Some use of Klass* should be replaced by InstanceKlass*
iklam
parents: 49594
diff changeset
   727
    Array<InstanceKlass*>* _ti_base;    // i.e., transitive_interfaces
4493
9204129f065e 6843629: Make current hotspot build part of jdk5 control build
phh
parents: 1
diff changeset
   728
    int         _ti_index;
9204129f065e 6843629: Make current hotspot build part of jdk5 control build
phh
parents: 1
diff changeset
   729
    int         _ti_limit;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   730
489c9b5090e2 Initial load
duke
parents:
diff changeset
   731
    // start at the beginning:
10265
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   732
    void start();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   733
4493
9204129f065e 6843629: Make current hotspot build part of jdk5 control build
phh
parents: 1
diff changeset
   734
   public:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   735
    ContextStream(DepChange& changes)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   736
      : _changes(changes)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   737
    { start(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   738
35492
c8c0273e6b91 8146690: Make all classes in GC follow the naming convention.
david
parents: 33611
diff changeset
   739
    ContextStream(DepChange& changes, NoSafepointVerifier& nsv)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   740
      : _changes(changes)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   741
      // the nsv argument makes it safe to hold oops like _klass
489c9b5090e2 Initial load
duke
parents:
diff changeset
   742
    { start(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   743
489c9b5090e2 Initial load
duke
parents:
diff changeset
   744
    bool next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   745
4493
9204129f065e 6843629: Make current hotspot build part of jdk5 control build
phh
parents: 1
diff changeset
   746
    ChangeType change_type()     { return _change_type; }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   747
    Klass*     klass()           { return _klass; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   748
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   749
  friend class DepChange::ContextStream;
10265
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   750
};
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   751
10265
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   752
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   753
// A class hierarchy change coming through the VM (under the Compile_lock).
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   754
// The change is structured as a single new type with any number of supers
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   755
// and implemented interface types.  Other than the new type, any of the
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   756
// super types can be context types for a relevant dependency, which the
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   757
// new type could invalidate.
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   758
class KlassDepChange : public DepChange {
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   759
 private:
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   760
  // each change set is rooted in exactly one new type (at present):
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 39411
diff changeset
   761
  Klass* _new_type;
10265
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   762
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   763
  void initialize();
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   764
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   765
 public:
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   766
  // notes the new type, marks it and all its super-types
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 39411
diff changeset
   767
  KlassDepChange(Klass* new_type)
10265
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   768
    : _new_type(new_type)
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   769
  {
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   770
    initialize();
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   771
  }
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   772
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   773
  // cleans up the marks
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   774
  ~KlassDepChange();
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   775
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   776
  // What kind of DepChange is this?
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   777
  virtual bool is_klass_change() const { return true; }
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   778
36300
5b47f168b948 7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents: 35499
diff changeset
   779
  virtual void mark_for_deoptimization(nmethod* nm) {
5b47f168b948 7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents: 35499
diff changeset
   780
    nm->mark_for_deoptimization(/*inc_recompile_counts=*/true);
5b47f168b948 7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents: 35499
diff changeset
   781
  }
5b47f168b948 7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents: 35499
diff changeset
   782
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 39411
diff changeset
   783
  Klass* new_type() { return _new_type; }
10265
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   784
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   785
  // involves_context(k) is true if k is new_type or any of the super types
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10503
diff changeset
   786
  bool involves_context(Klass* k);
10265
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   787
};
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   788
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   789
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   790
// A CallSite has changed its target.
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   791
class CallSiteDepChange : public DepChange {
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   792
 private:
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   793
  Handle _call_site;
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   794
  Handle _method_handle;
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   795
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   796
 public:
35498
392b50de06c6 8146401: Clean up oop.hpp: add inline directives and fix header files
goetz
parents: 33611
diff changeset
   797
  CallSiteDepChange(Handle call_site, Handle method_handle);
10265
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   798
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   799
  // What kind of DepChange is this?
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   800
  virtual bool is_call_site_change() const { return true; }
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   801
36300
5b47f168b948 7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents: 35499
diff changeset
   802
  virtual void mark_for_deoptimization(nmethod* nm) {
5b47f168b948 7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents: 35499
diff changeset
   803
    nm->mark_for_deoptimization(/*inc_recompile_counts=*/false);
5b47f168b948 7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents: 35499
diff changeset
   804
  }
5b47f168b948 7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents: 35499
diff changeset
   805
10265
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   806
  oop call_site()     const { return _call_site();     }
4c869854aebd 7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents: 7397
diff changeset
   807
  oop method_handle() const { return _method_handle(); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   808
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   809
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 51333
diff changeset
   810
#endif // SHARE_CODE_DEPENDENCIES_HPP