hotspot/src/share/vm/prims/jvmtiRedefineClasses.hpp
author ysr
Fri, 30 Jan 2009 14:17:52 -0800
changeset 2005 42075507972b
parent 1 489c9b5090e2
child 5547 f4b087cbb361
permissions -rw-r--r--
6787254: Work queue capacity can be increased substantially on some platforms Summary: Increased the default and maximum size of the CMS marking stack and the size of the parallel workers' work queues in 64-bit mode. The latter was accomplished by an increase in the width of the Taskqueue's Age struct and its Tag field in 64-bit mode. Reviewed-by: jmasa, tonyp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2003-2006 Sun Microsystems, Inc.  All Rights Reserved.
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
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
// Introduction:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
// The RedefineClasses() API is used to change the definition of one or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
// more classes. While the API supports redefining more than one class
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
// in a single call, in general, the API is discussed in the context of
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
// changing the definition of a single current class to a single new
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
// class. For clarity, the current class is will always be called
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
// "the_class" and the new class will always be called "scratch_class".
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
// The name "the_class" is used because there is only one structure
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
// that represents a specific class; redefinition does not replace the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
// structure, but instead replaces parts of the structure. The name
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
// "scratch_class" is used because the structure that represents the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
// new definition of a specific class is simply used to carry around
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
// the parts of the new definition until they are used to replace the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
// appropriate parts in the_class. Once redefinition of a class is
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
// complete, scratch_class is thrown away.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
// Implementation Overview:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
// The RedefineClasses() API is mostly a wrapper around the VM op that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
// does the real work. The work is split in varying degrees between
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
// doit_prologue(), doit() and doit_epilogue().
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
// 1) doit_prologue() is called by the JavaThread on the way to a
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
//    safepoint. It does parameter verification and loads scratch_class
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
//    which involves:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
//    - parsing the incoming class definition using the_class' class
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
//      loader and security context
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
//    - linking scratch_class
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
//    - merging constant pools and rewriting bytecodes as needed
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
//      for the merged constant pool
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
//    - verifying the bytecodes in scratch_class
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
//    - setting up the constant pool cache and rewriting bytecodes
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
//      as needed to use the cache
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
//    - finally, scratch_class is compared to the_class to verify
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
//      that it is a valid replacement class
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
//    - if everything is good, then scratch_class is saved in an
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
//      instance field in the VM operation for the doit() call
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
//    Note: A JavaThread must do the above work.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
// 2) doit() is called by the VMThread during a safepoint. It installs
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
//    the new class definition(s) which involves:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
//    - retrieving the scratch_class from the instance field in the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
//      VM operation
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
//    - house keeping (flushing breakpoints and caches, deoptimizing
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
//      dependent compiled code)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
//    - replacing parts in the_class with parts from scratch_class
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
//    - adding weak reference(s) to track the obsolete but interesting
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
//      parts of the_class
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
//    - adjusting constant pool caches and vtables in other classes
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
//      that refer to methods in the_class. These adjustments use the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
//      SystemDictionary::classes_do() facility which only allows
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
//      a helper method to be specified. The interesting parameters
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
//      that we would like to pass to the helper method are saved in
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
//      static global fields in the VM operation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
//    - telling the SystemDictionary to notice our changes
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
//    Note: the above work must be done by the VMThread to be safe.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
// 3) doit_epilogue() is called by the JavaThread after the VM op
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
//    is finished and the safepoint is done. It simply cleans up
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
//    memory allocated in doit_prologue() and used in doit().
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
// Constant Pool Details:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
// When the_class is redefined, we cannot just replace the constant
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
// pool in the_class with the constant pool from scratch_class because
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
// that could confuse obsolete methods that may still be running.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
// Instead, the constant pool from the_class, old_cp, is merged with
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
// the constant pool from scratch_class, scratch_cp. The resulting
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
// constant pool, merge_cp, replaces old_cp in the_class.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
// The key part of any merging algorithm is the entry comparison
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
// function so we have to know the types of entries in a constant pool
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
// in order to merge two of them together. Constant pools can contain
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
// up to 12 different kinds of entries; the JVM_CONSTANT_Unicode entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
// is not presently used so we only have to worry about the other 11
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
// entry types. For the purposes of constant pool merging, it is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
// helpful to know that the 11 entry types fall into 3 different
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
// subtypes: "direct", "indirect" and "double-indirect".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
// Direct CP entries contain data and do not contain references to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
// other CP entries. The following are direct CP entries:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
//     JVM_CONSTANT_{Double,Float,Integer,Long,Utf8}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
// Indirect CP entries contain 1 or 2 references to a direct CP entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
// and no other data. The following are indirect CP entries:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
//     JVM_CONSTANT_{Class,NameAndType,String}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
// Double-indirect CP entries contain two references to indirect CP
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
// entries and no other data. The following are double-indirect CP
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
// entries:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
//     JVM_CONSTANT_{Fieldref,InterfaceMethodref,Methodref}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
// When comparing entries between two constant pools, the entry types
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
// are compared first and if they match, then further comparisons are
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
// made depending on the entry subtype. Comparing direct CP entries is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
// simply a matter of comparing the data associated with each entry.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
// Comparing both indirect and double-indirect CP entries requires
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
// recursion.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
// Fortunately, the recursive combinations are limited because indirect
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
// CP entries can only refer to direct CP entries and double-indirect
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
// CP entries can only refer to indirect CP entries. The following is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
// an example illustration of the deepest set of indirections needed to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
// access the data associated with a JVM_CONSTANT_Fieldref entry:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
//     JVM_CONSTANT_Fieldref {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
//         class_index => JVM_CONSTANT_Class {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
//             name_index => JVM_CONSTANT_Utf8 {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
//                 <data-1>
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
//             }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
//         }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
//         name_and_type_index => JVM_CONSTANT_NameAndType {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
//             name_index => JVM_CONSTANT_Utf8 {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
//                 <data-2>
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
//             }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
//             descriptor_index => JVM_CONSTANT_Utf8 {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
//                 <data-3>
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
//             }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
//         }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
//     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
// The above illustration is not a data structure definition for any
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
// computer language. The curly braces ('{' and '}') are meant to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
// delimit the context of the "fields" in the CP entry types shown.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
// Each indirection from the JVM_CONSTANT_Fieldref entry is shown via
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
// "=>", e.g., the class_index is used to indirectly reference a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
// JVM_CONSTANT_Class entry where the name_index is used to indirectly
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
// reference a JVM_CONSTANT_Utf8 entry which contains the interesting
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
// <data-1>. In order to understand a JVM_CONSTANT_Fieldref entry, we
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
// have to do a total of 5 indirections just to get to the CP entries
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
// that contain the interesting pieces of data and then we have to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
// fetch the three pieces of data. This means we have to do a total of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
// (5 + 3) * 2 == 16 dereferences to compare two JVM_CONSTANT_Fieldref
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
// entries.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
// Here is the indirection, data and dereference count for each entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
// type:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
//    JVM_CONSTANT_Class               1 indir, 1 data, 2 derefs
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
//    JVM_CONSTANT_Double              0 indir, 1 data, 1 deref
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
//    JVM_CONSTANT_Fieldref            2 indir, 3 data, 8 derefs
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
//    JVM_CONSTANT_Float               0 indir, 1 data, 1 deref
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
//    JVM_CONSTANT_Integer             0 indir, 1 data, 1 deref
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
//    JVM_CONSTANT_InterfaceMethodref  2 indir, 3 data, 8 derefs
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
//    JVM_CONSTANT_Long                0 indir, 1 data, 1 deref
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
//    JVM_CONSTANT_Methodref           2 indir, 3 data, 8 derefs
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
//    JVM_CONSTANT_NameAndType         1 indir, 2 data, 4 derefs
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
//    JVM_CONSTANT_String              1 indir, 1 data, 2 derefs
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
//    JVM_CONSTANT_Utf8                0 indir, 1 data, 1 deref
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
// So different subtypes of CP entries require different amounts of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
// work for a proper comparison.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
// Now that we've talked about the different entry types and how to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
// compare them we need to get back to merging. This is not a merge in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
// the "sort -u" sense or even in the "sort" sense. When we merge two
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
// constant pools, we copy all the entries from old_cp to merge_cp,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
// preserving entry order. Next we append all the unique entries from
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
// scratch_cp to merge_cp and we track the index changes from the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
// location in scratch_cp to the possibly new location in merge_cp.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
// When we are done, any obsolete code that is still running that
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
// uses old_cp should not be able to observe any difference if it
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
// were to use merge_cp. As for the new code in scratch_class, it is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
// modified to use the appropriate index values in merge_cp before it
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
// is used to replace the code in the_class.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
// There is one small complication in copying the entries from old_cp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
// to merge_cp. Two of the CP entry types are special in that they are
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
// lazily resolved. Before explaining the copying complication, we need
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
// to digress into CP entry resolution.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
// JVM_CONSTANT_Class and JVM_CONSTANT_String entries are present in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
// the class file, but are not stored in memory as such until they are
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
// resolved. The entries are not resolved unless they are used because
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
// resolution is expensive. During class file parsing the entries are
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
// initially stored in memory as JVM_CONSTANT_ClassIndex and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
// JVM_CONSTANT_StringIndex entries. These special CP entry types
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
// indicate that the JVM_CONSTANT_Class and JVM_CONSTANT_String entries
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
// have been parsed, but the index values in the entries have not been
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
// validated. After the entire constant pool has been parsed, the index
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
// values can be validated and then the entries are converted into
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
// JVM_CONSTANT_UnresolvedClass and JVM_CONSTANT_UnresolvedString
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
// entries. During this conversion process, the UTF8 values that are
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
// indirectly referenced by the JVM_CONSTANT_ClassIndex and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
// JVM_CONSTANT_StringIndex entries are changed into symbolOops and the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
// entries are modified to refer to the symbolOops. This optimization
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
// eliminates one level of indirection for those two CP entry types and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
// gets the entries ready for verification. During class file parsing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
// it is also possible for JVM_CONSTANT_UnresolvedString entries to be
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
// resolved into JVM_CONSTANT_String entries. Verification expects to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
// find JVM_CONSTANT_UnresolvedClass and either JVM_CONSTANT_String or
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
// JVM_CONSTANT_UnresolvedString entries and not JVM_CONSTANT_Class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
// entries.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
// Now we can get back to the copying complication. When we copy
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
// entries from old_cp to merge_cp, we have to revert any
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
// JVM_CONSTANT_Class entries to JVM_CONSTANT_UnresolvedClass entries
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
// or verification will fail.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
// It is important to explicitly state that the merging algorithm
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
// effectively unresolves JVM_CONSTANT_Class entries that were in the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
// old_cp when they are changed into JVM_CONSTANT_UnresolvedClass
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
// entries in the merge_cp. This is done both to make verification
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
// happy and to avoid adding more brittleness between RedefineClasses
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
// and the constant pool cache. By allowing the constant pool cache
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
// implementation to (re)resolve JVM_CONSTANT_UnresolvedClass entries
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
// into JVM_CONSTANT_Class entries, we avoid having to embed knowledge
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
// about those algorithms in RedefineClasses.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
// Appending unique entries from scratch_cp to merge_cp is straight
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
// forward for direct CP entries and most indirect CP entries. For the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
// indirect CP entry type JVM_CONSTANT_NameAndType and for the double-
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
// indirect CP entry types, the presence of more than one piece of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
// interesting data makes appending the entries more complicated.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
// For the JVM_CONSTANT_{Double,Float,Integer,Long,Utf8} entry types,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
// the entry is simply copied from scratch_cp to the end of merge_cp.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
// If the index in scratch_cp is different than the destination index
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
// in merge_cp, then the change in index value is tracked.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
// Note: the above discussion for the direct CP entries also applies
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
// to the JVM_CONSTANT_Unresolved{Class,String} entry types.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
// For the JVM_CONSTANT_{Class,String} entry types, since there is only
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
// one data element at the end of the recursion, we know that we have
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
// either one or two unique entries. If the JVM_CONSTANT_Utf8 entry is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
// unique then it is appended to merge_cp before the current entry.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
// If the JVM_CONSTANT_Utf8 entry is not unique, then the current entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
// is updated to refer to the duplicate entry in merge_cp before it is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
// appended to merge_cp. Again, any changes in index values are tracked
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
// as needed.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
// Note: the above discussion for JVM_CONSTANT_{Class,String} entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
// types is theoretical. Since those entry types have already been
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
// optimized into JVM_CONSTANT_Unresolved{Class,String} entry types,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
// they are handled as direct CP entries.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
// For the JVM_CONSTANT_NameAndType entry type, since there are two
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
// data elements at the end of the recursions, we know that we have
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
// between one and three unique entries. Any unique JVM_CONSTANT_Utf8
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
// entries are appended to merge_cp before the current entry. For any
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
// JVM_CONSTANT_Utf8 entries that are not unique, the current entry is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
// updated to refer to the duplicate entry in merge_cp before it is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
// appended to merge_cp. Again, any changes in index values are tracked
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
// as needed.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
// For the JVM_CONSTANT_{Fieldref,InterfaceMethodref,Methodref} entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
// types, since there are two indirect CP entries and three data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
// elements at the end of the recursions, we know that we have between
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
// one and six unique entries. See the JVM_CONSTANT_Fieldref diagram
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
// above for an example of all six entries. The uniqueness algorithm
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
// for the JVM_CONSTANT_Class and JVM_CONSTANT_NameAndType entries is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
// covered above. Any unique entries are appended to merge_cp before
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
// the current entry. For any entries that are not unique, the current
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
// entry is updated to refer to the duplicate entry in merge_cp before
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
// it is appended to merge_cp. Again, any changes in index values are
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
// tracked as needed.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
// Other Details:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
// Details for other parts of RedefineClasses need to be written.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
// This is a placeholder section.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
// Open Issues (in no particular order):
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
// - How do we serialize the RedefineClasses() API without deadlocking?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
// - SystemDictionary::parse_stream() was called with a NULL protection
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
//   domain since the initial version. This has been changed to pass
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
//   the_class->protection_domain(). This change has been tested with
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
//   all NSK tests and nothing broke, but what will adding it now break
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
//   in ways that we don't test?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
// - GenerateOopMap::rewrite_load_or_store() has a comment in its
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
//   (indirect) use of the Relocator class that the max instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
//   size is 4 bytes. goto_w and jsr_w are 5 bytes and wide/iinc is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
//   6 bytes. Perhaps Relocator only needs a 4 byte buffer to do
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
//   what it does to the bytecodes. More investigation is needed.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
// - java.lang.Object methods can be called on arrays. This is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
//   implemented via the arrayKlassOop vtable which we don't
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
//   update. For example, if we redefine java.lang.Object.toString(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
//   then the new version of the method will not be called for array
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
//   objects.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
// - How do we know if redefine_single_class() and the guts of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
//   instanceKlass are out of sync? I don't think this can be
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
//   automated, but we should probably order the work in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
//   redefine_single_class() to match the order of field
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
//   definitions in instanceKlass. We also need to add some
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
//   comments about keeping things in sync.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
// - set_new_constant_pool() is huge and we should consider refactoring
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
//   it into smaller chunks of work.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
// - The exception table update code in set_new_constant_pool() defines
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
//   const values that are also defined in a local context elsewhere.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
//   The same literal values are also used in elsewhere. We need to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
//   coordinate a cleanup of these constants with Runtime.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
class VM_RedefineClasses: public VM_Operation {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
  // These static fields are needed by SystemDictionary::classes_do()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
  // facility and the adjust_cpool_cache_and_vtable() helper:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
  static objArrayOop     _old_methods;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
  static objArrayOop     _new_methods;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
  static methodOop*      _matching_old_methods;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
  static methodOop*      _matching_new_methods;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
  static methodOop*      _deleted_methods;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
  static methodOop*      _added_methods;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
  static int             _matching_methods_length;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
  static int             _deleted_methods_length;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
  static int             _added_methods_length;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
  static klassOop        _the_class_oop;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
  // The instance fields are used to pass information from
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
  // doit_prologue() to doit() and doit_epilogue().
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
  jint                        _class_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
  const jvmtiClassDefinition *_class_defs;  // ptr to _class_count defs
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
  // This operation is used by both RedefineClasses and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
  // RetransformClasses.  Indicate which.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
  JvmtiClassLoadKind          _class_load_kind;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
  // _index_map_count is just an optimization for knowing if
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
  // _index_map_p contains any entries.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
  int                         _index_map_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
  intArray *                  _index_map_p;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
  // ptr to _class_count scratch_classes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
  instanceKlassHandle *       _scratch_classes;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
  jvmtiError                  _res;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
  // Performance measurement support. These timers do not cover all
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
  // the work done for JVM/TI RedefineClasses() but they do cover
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
  // the heavy lifting.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
  elapsedTimer  _timer_rsc_phase1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
  elapsedTimer  _timer_rsc_phase2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
  elapsedTimer  _timer_vm_op_prologue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
  // These routines are roughly in call order unless otherwise noted.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
  // Load the caller's new class definition(s) into _scratch_classes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
  // Constant pool merging work is done here as needed. Also calls
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
  // compare_and_normalize_class_versions() to verify the class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
  // definition(s).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
  jvmtiError load_new_class_versions(TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
  // Verify that the caller provided class definition(s) that meet
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
  // the restrictions of RedefineClasses. Normalize the order of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
  // overloaded methods as needed.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
  jvmtiError compare_and_normalize_class_versions(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
    instanceKlassHandle the_class, instanceKlassHandle scratch_class);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
  // Swap annotations[i] with annotations[j]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
  // Used by compare_and_normalize_class_versions() when normalizing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
  // overloaded methods or changing idnum as when adding or deleting methods.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
  void swap_all_method_annotations(int i, int j, instanceKlassHandle scratch_class);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
  // Figure out which new methods match old methods in name and signature,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
  // which methods have been added, and which are no longer present
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
  void compute_added_deleted_matching_methods();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
  // Change jmethodIDs to point to the new methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
  void update_jmethod_ids();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
  // In addition to marking methods as obsolete, this routine
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
  // records which methods are EMCP (Equivalent Module Constant
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
  // Pool) in the emcp_methods BitMap and returns the number of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
  // EMCP methods via emcp_method_count_p. This information is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
  // used when information about the previous version of the_class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
  // is squirreled away.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
  void check_methods_and_mark_as_obsolete(BitMap *emcp_methods,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
         int * emcp_method_count_p);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
  void transfer_old_native_function_registrations(instanceKlassHandle the_class);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
  // Unevolving classes may point to methods of the_class directly
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
  // from their constant pool caches, itables, and/or vtables. We
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
  // use the SystemDictionary::classes_do() facility and this helper
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
  // to fix up these pointers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
  static void adjust_cpool_cache_and_vtable(klassOop k_oop, oop loader, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
  // Install the redefinition of a class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
  void redefine_single_class(jclass the_jclass,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
    instanceKlassHandle scratch_class, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
  // Increment the classRedefinedCount field in the specific instanceKlass
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
  // and in all direct and indirect subclasses.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
  void increment_class_counter(instanceKlass *ik, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
  // Support for constant pool merging (these routines are in alpha
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
  // order):
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
  void append_entry(constantPoolHandle scratch_cp, int scratch_i,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
    constantPoolHandle *merge_cp_p, int *merge_cp_length_p, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
  int find_new_index(int old_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
  bool is_unresolved_class_mismatch(constantPoolHandle cp1, int index1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
    constantPoolHandle cp2, int index2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
  bool is_unresolved_string_mismatch(constantPoolHandle cp1, int index1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
    constantPoolHandle cp2, int index2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
  void map_index(constantPoolHandle scratch_cp, int old_index, int new_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
  bool merge_constant_pools(constantPoolHandle old_cp,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
    constantPoolHandle scratch_cp, constantPoolHandle *merge_cp_p,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
    int *merge_cp_length_p, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
  jvmtiError merge_cp_and_rewrite(instanceKlassHandle the_class,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
    instanceKlassHandle scratch_class, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
  u2 rewrite_cp_ref_in_annotation_data(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
    typeArrayHandle annotations_typeArray, int &byte_i_ref,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
    const char * trace_mesg, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
  bool rewrite_cp_refs(instanceKlassHandle scratch_class, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
  bool rewrite_cp_refs_in_annotation_struct(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
    typeArrayHandle class_annotations, int &byte_i_ref, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
  bool rewrite_cp_refs_in_annotations_typeArray(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
    typeArrayHandle annotations_typeArray, int &byte_i_ref, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
  bool rewrite_cp_refs_in_class_annotations(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
    instanceKlassHandle scratch_class, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
  bool rewrite_cp_refs_in_element_value(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
    typeArrayHandle class_annotations, int &byte_i_ref, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
  bool rewrite_cp_refs_in_fields_annotations(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
    instanceKlassHandle scratch_class, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
  void rewrite_cp_refs_in_method(methodHandle method,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
    methodHandle * new_method_p, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
  bool rewrite_cp_refs_in_methods(instanceKlassHandle scratch_class, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
  bool rewrite_cp_refs_in_methods_annotations(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
    instanceKlassHandle scratch_class, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
  bool rewrite_cp_refs_in_methods_default_annotations(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
    instanceKlassHandle scratch_class, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
  bool rewrite_cp_refs_in_methods_parameter_annotations(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
    instanceKlassHandle scratch_class, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
  void rewrite_cp_refs_in_stack_map_table(methodHandle method, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
  void rewrite_cp_refs_in_verification_type_info(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
         address& stackmap_addr_ref, address stackmap_end, u2 frame_i,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
         u1 frame_size, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
  void set_new_constant_pool(instanceKlassHandle scratch_class,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
    constantPoolHandle scratch_cp, int scratch_cp_length, bool shrink, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
  void flush_dependent_code(instanceKlassHandle k_h, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
  static void check_class(klassOop k_oop, oop initiating_loader, TRAPS) PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
  static void dump_methods()   PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
  VM_RedefineClasses(jint class_count,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
                     const jvmtiClassDefinition *class_defs,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
                     JvmtiClassLoadKind class_load_kind);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
  VMOp_Type type() const { return VMOp_RedefineClasses; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
  bool doit_prologue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
  void doit();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
  void doit_epilogue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
  bool allow_nested_vm_operations() const        { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
  jvmtiError check_error()                       { return _res; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
  // Modifiable test must be shared between IsModifiableClass query
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
  // and redefine implementation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
  static bool is_modifiable_class(oop klass_mirror);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
};