src/hotspot/share/prims/jvmtiClassFileReconstituter.cpp
author coleenp
Wed, 21 Mar 2018 19:45:24 -0400
changeset 49480 d7df2dd501ce
parent 49449 ef5d5d343e2a
child 50735 2f2af62dfac7
permissions -rw-r--r--
8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files Summary: Remove frame.inline.hpp,etc from header files and adjust transitive includes. Reviewed-by: stefank, stuefe
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
49480
d7df2dd501ce 8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents: 49449
diff changeset
     2
 * Copyright (c) 2005, 2018, 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: 3261
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3261
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: 3261
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5702
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5702
diff changeset
    26
#include "classfile/symbolTable.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5702
diff changeset
    27
#include "interpreter/bytecodeStream.hpp"
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents: 8921
diff changeset
    28
#include "oops/fieldStreams.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5702
diff changeset
    29
#include "prims/jvmtiClassFileReconstituter.hpp"
49480
d7df2dd501ce 8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents: 49449
diff changeset
    30
#include "runtime/handles.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5702
diff changeset
    31
#include "runtime/signature.hpp"
25715
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 24322
diff changeset
    32
#include "utilities/bytes.hpp"
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 24322
diff changeset
    33
13863
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
    34
// FIXME: add Deprecated attribute
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
// FIXME: fix Synthetic attribute
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
    36
// FIXME: per Serguei, add error return handling for ConstantPool::copy_cpool_bytes()
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
49449
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 47216
diff changeset
    38
JvmtiConstantPoolReconstituter::JvmtiConstantPoolReconstituter(InstanceKlass* ik) {
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 47216
diff changeset
    39
  set_error(JVMTI_ERROR_NONE);
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 47216
diff changeset
    40
  _ik = ik;
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 47216
diff changeset
    41
  _cpool = constantPoolHandle(Thread::current(), ik->constants());
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 47216
diff changeset
    42
  _symmap = new SymbolHashMap();
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 47216
diff changeset
    43
  _classmap = new SymbolHashMap();
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 47216
diff changeset
    44
  _cpool_size = _cpool->hash_entries_to(_symmap, _classmap);
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 47216
diff changeset
    45
  if (_cpool_size == 0) {
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 47216
diff changeset
    46
    set_error(JVMTI_ERROR_OUT_OF_MEMORY);
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 47216
diff changeset
    47
  } else if (_cpool_size < 0) {
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 47216
diff changeset
    48
    set_error(JVMTI_ERROR_INTERNAL);
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 47216
diff changeset
    49
  }
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 47216
diff changeset
    50
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
// Write the field information portion of ClassFile structure
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
// JVMSpec|     u2 fields_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
// JVMSpec|     field_info fields[fields_count];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
void JvmtiClassFileReconstituter::write_field_infos() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  HandleMark hm(thread());
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 38031
diff changeset
    57
  Array<AnnotationArray*>* fields_anno = ik()->fields_annotations();
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 38031
diff changeset
    58
  Array<AnnotationArray*>* fields_type_anno = ik()->fields_type_annotations();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents: 8921
diff changeset
    60
  // Compute the real number of Java fields
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 38031
diff changeset
    61
  int java_fields = ik()->java_fields_count();
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents: 8921
diff changeset
    62
10552
4c615382f246 7090654: nightly failures after 7086585
never
parents: 10546
diff changeset
    63
  write_u2(java_fields);
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 38031
diff changeset
    64
  for (JavaFieldStream fs(ik()); !fs.done(); fs.next()) {
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents: 8921
diff changeset
    65
    AccessFlags access_flags = fs.access_flags();
e79347eebbc5 7086585: make Java field injection more flexible
never
parents: 8921
diff changeset
    66
    int name_index = fs.name_index();
e79347eebbc5 7086585: make Java field injection more flexible
never
parents: 8921
diff changeset
    67
    int signature_index = fs.signature_index();
e79347eebbc5 7086585: make Java field injection more flexible
never
parents: 8921
diff changeset
    68
    int initial_value_index = fs.initval_index();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
    guarantee(name_index != 0 && signature_index != 0, "bad constant pool index for field");
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 38031
diff changeset
    70
    // int offset = ik()->field_offset( index );
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents: 8921
diff changeset
    71
    int generic_signature_index = fs.generic_signature_index();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
    72
    AnnotationArray* anno = fields_anno == NULL ? NULL : fields_anno->at(fs.index());
27401
a4697c9502cb 8057043: Type annotations not retained during class redefine / retransform
aeriksso
parents: 25715
diff changeset
    73
    AnnotationArray* type_anno = fields_type_anno == NULL ? NULL : fields_type_anno->at(fs.index());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
    // JVMSpec|   field_info {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
    // JVMSpec|         u2 access_flags;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
    // JVMSpec|         u2 name_index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
    // JVMSpec|         u2 descriptor_index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
    // JVMSpec|         u2 attributes_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
    // JVMSpec|         attribute_info attributes[attributes_count];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
    // JVMSpec|   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents: 8921
diff changeset
    83
    write_u2(access_flags.as_int() & JVM_RECOGNIZED_FIELD_MODIFIERS);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
    write_u2(name_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
    write_u2(signature_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
    int attr_count = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
    if (initial_value_index != 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
      ++attr_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
    if (access_flags.is_synthetic()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
      // ++attr_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
    if (generic_signature_index != 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
      ++attr_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
    }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
    96
    if (anno != NULL) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
      ++attr_count;     // has RuntimeVisibleAnnotations attribute
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
    }
27401
a4697c9502cb 8057043: Type annotations not retained during class redefine / retransform
aeriksso
parents: 25715
diff changeset
    99
    if (type_anno != NULL) {
a4697c9502cb 8057043: Type annotations not retained during class redefine / retransform
aeriksso
parents: 25715
diff changeset
   100
      ++attr_count;     // has RuntimeVisibleTypeAnnotations attribute
a4697c9502cb 8057043: Type annotations not retained during class redefine / retransform
aeriksso
parents: 25715
diff changeset
   101
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
    write_u2(attr_count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
    if (initial_value_index != 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
      write_attribute_name_index("ConstantValue");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
      write_u4(2); //length always 2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
      write_u2(initial_value_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
    if (access_flags.is_synthetic()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
      // write_synthetic_attribute();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
    if (generic_signature_index != 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
      write_signature_attribute(generic_signature_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
    }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   116
    if (anno != NULL) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
      write_annotations_attribute("RuntimeVisibleAnnotations", anno);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
    }
27401
a4697c9502cb 8057043: Type annotations not retained during class redefine / retransform
aeriksso
parents: 25715
diff changeset
   119
    if (type_anno != NULL) {
a4697c9502cb 8057043: Type annotations not retained during class redefine / retransform
aeriksso
parents: 25715
diff changeset
   120
      write_annotations_attribute("RuntimeVisibleTypeAnnotations", type_anno);
a4697c9502cb 8057043: Type annotations not retained during class redefine / retransform
aeriksso
parents: 25715
diff changeset
   121
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
// Write Code attribute
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
// JVMSpec|   Code_attribute {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
// JVMSpec|     u2 attribute_name_index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
// JVMSpec|     u4 attribute_length;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
// JVMSpec|     u2 max_stack;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
// JVMSpec|     u2 max_locals;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
// JVMSpec|     u4 code_length;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
// JVMSpec|     u1 code[code_length];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
// JVMSpec|     u2 exception_table_length;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
// JVMSpec|     {       u2 start_pc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
// JVMSpec|             u2 end_pc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
// JVMSpec|             u2  handler_pc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
// JVMSpec|             u2  catch_type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
// JVMSpec|     }       exception_table[exception_table_length];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
// JVMSpec|     u2 attributes_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
// JVMSpec|     attribute_info attributes[attributes_count];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
// JVMSpec|   }
33593
60764a78fa5c 8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents: 27401
diff changeset
   142
void JvmtiClassFileReconstituter::write_code_attribute(const methodHandle& method) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   143
  ConstMethod* const_method = method->constMethod();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  u2 line_num_cnt = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  int stackmap_len = 0;
11257
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   146
  int local_variable_table_length = 0;
13863
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   147
  int local_variable_type_table_length = 0;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
11257
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   149
  // compute number and length of attributes
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  int attr_count = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  int attr_size = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  if (const_method->has_linenumber_table()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
    line_num_cnt = line_number_table_entries(method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
    if (line_num_cnt != 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
      ++attr_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
      // Compute the complete size of the line number table attribute:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
      //      LineNumberTable_attribute {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
      //        u2 attribute_name_index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
      //        u4 attribute_length;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
      //        u2 line_number_table_length;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
      //        {  u2 start_pc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
      //           u2 line_number;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
      //        } line_number_table[line_number_table_length];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
      //      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
      attr_size += 2 + 4 + 2 + line_num_cnt * (2 + 2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  if (method->has_stackmap_table()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
    stackmap_len = method->stackmap_data()->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
    if (stackmap_len != 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
      ++attr_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
      // Compute the  size of the stack map table attribute (VM stores raw):
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
      //      StackMapTable_attribute {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
      //        u2 attribute_name_index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
      //        u4 attribute_length;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
      //        u2 number_of_entries;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
      //        stack_map_frame_entries[number_of_entries];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
      //      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
      attr_size += 2 + 4 + stackmap_len;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  }
11257
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   182
  if (method->has_localvariable_table()) {
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   183
    local_variable_table_length = method->localvariable_table_length();
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   184
    if (local_variable_table_length != 0) {
13863
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   185
      ++attr_count;
11257
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   186
      // Compute the size of the local variable table attribute (VM stores raw):
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   187
      // LocalVariableTable_attribute {
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   188
      //   u2 attribute_name_index;
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   189
      //   u4 attribute_length;
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   190
      //   u2 local_variable_table_length;
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   191
      //   {
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   192
      //     u2 start_pc;
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   193
      //     u2 length;
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   194
      //     u2 name_index;
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   195
      //     u2 descriptor_index;
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   196
      //     u2 index;
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   197
      //   }
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   198
      attr_size += 2 + 4 + 2 + local_variable_table_length * (2 + 2 + 2 + 2 + 2);
13863
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   199
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   200
      // Local variables with generic signatures must have LVTT entries
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   201
      LocalVariableTableElement *elem = method->localvariable_table_start();
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   202
      for (int idx = 0; idx < local_variable_table_length; idx++) {
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   203
        if (elem[idx].signature_cp_index != 0) {
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   204
          local_variable_type_table_length++;
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   205
        }
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   206
      }
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   207
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   208
      if (local_variable_type_table_length != 0) {
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   209
        ++attr_count;
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   210
        // Compute the size of the local variable type table attribute (VM stores raw):
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   211
        // LocalVariableTypeTable_attribute {
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   212
        //   u2 attribute_name_index;
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   213
        //   u4 attribute_length;
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   214
        //   u2 local_variable_type_table_length;
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   215
        //   {
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   216
        //     u2 start_pc;
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   217
        //     u2 length;
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   218
        //     u2 name_index;
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   219
        //     u2 signature_index;
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   220
        //     u2 index;
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   221
        //   }
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   222
        attr_size += 2 + 4 + 2 + local_variable_type_table_length * (2 + 2 + 2 + 2 + 2);
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   223
      }
11257
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   224
    }
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   225
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12231
diff changeset
   227
  ExceptionTable exception_table(method());
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12231
diff changeset
   228
  int exception_table_length = exception_table.length();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
  int code_size = const_method->code_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
  int size =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
    2+2+4 +                                // max_stack, max_locals, code_length
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
    code_size +                            // code
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
    2 +                                    // exception_table_length
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12231
diff changeset
   234
    (2+2+2+2) * exception_table_length +   // exception_table
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
    2 +                                    // attributes_count
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
    attr_size;                             // attributes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  write_attribute_name_index("Code");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
  write_u4(size);
14480
06c1743f1285 7194607: VerifyLocalVariableTableOnRetransformTest.sh fails after JSR-292 merge
sspitsyn
parents: 13863
diff changeset
   240
  write_u2(method->verifier_max_stack());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  write_u2(method->max_locals());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  write_u4(code_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
  copy_bytecodes(method, (unsigned char*)writeable_address(code_size));
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12231
diff changeset
   244
  write_u2(exception_table_length);
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12231
diff changeset
   245
  for (int index = 0; index < exception_table_length; index++) {
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12231
diff changeset
   246
    write_u2(exception_table.start_pc(index));
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12231
diff changeset
   247
    write_u2(exception_table.end_pc(index));
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12231
diff changeset
   248
    write_u2(exception_table.handler_pc(index));
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12231
diff changeset
   249
    write_u2(exception_table.catch_type_index(index));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
  write_u2(attr_count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
  if (line_num_cnt != 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
    write_line_number_table_attribute(method, line_num_cnt);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  if (stackmap_len != 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
    write_stackmap_table_attribute(method, stackmap_len);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  }
11257
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   258
  if (local_variable_table_length != 0) {
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   259
    write_local_variable_table_attribute(method, local_variable_table_length);
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   260
  }
13863
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   261
  if (local_variable_type_table_length != 0) {
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   262
    write_local_variable_type_table_attribute(method, local_variable_type_table_length);
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   263
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
// Write Exceptions attribute
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
// JVMSpec|   Exceptions_attribute {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
// JVMSpec|     u2 attribute_name_index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
// JVMSpec|     u4 attribute_length;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
// JVMSpec|     u2 number_of_exceptions;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
// JVMSpec|     u2 exception_index_table[number_of_exceptions];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
// JVMSpec|   }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   273
void JvmtiClassFileReconstituter::write_exceptions_attribute(ConstMethod* const_method) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
  CheckedExceptionElement* checked_exceptions = const_method->checked_exceptions_start();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  int checked_exceptions_length = const_method->checked_exceptions_length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
  int size =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
    2 +                                    // number_of_exceptions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
    2 * checked_exceptions_length;         // exception_index_table
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
  write_attribute_name_index("Exceptions");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
  write_u4(size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
  write_u2(checked_exceptions_length);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
  for (int index = 0; index < checked_exceptions_length; index++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
    write_u2(checked_exceptions[index].class_cp_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
// Write SourceFile attribute
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
// JVMSpec|   SourceFile_attribute {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
// JVMSpec|     u2 attribute_name_index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
// JVMSpec|     u4 attribute_length;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
// JVMSpec|     u2 sourcefile_index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
// JVMSpec|   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
void JvmtiClassFileReconstituter::write_source_file_attribute() {
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 38031
diff changeset
   295
  assert(ik()->source_file_name() != NULL, "caller must check");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
  write_attribute_name_index("SourceFile");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  write_u4(2);  // always length 2
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 38031
diff changeset
   299
  write_u2(symbol_to_cpool_index(ik()->source_file_name()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
// Write SourceDebugExtension attribute
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
// JSR45|   SourceDebugExtension_attribute {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
// JSR45|       u2 attribute_name_index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
// JSR45|       u4 attribute_length;
13201
69f157caabcc 6294277: java -Xdebug crashes on SourceDebugExtension attribute larger than 64K
fparain
parents: 12231
diff changeset
   306
// JSR45|       u1 debug_extension[attribute_length];
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
// JSR45|   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
void JvmtiClassFileReconstituter::write_source_debug_extension_attribute() {
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 38031
diff changeset
   309
  assert(ik()->source_debug_extension() != NULL, "caller must check");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
  write_attribute_name_index("SourceDebugExtension");
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 38031
diff changeset
   312
  int len = (int)strlen(ik()->source_debug_extension());
13201
69f157caabcc 6294277: java -Xdebug crashes on SourceDebugExtension attribute larger than 64K
fparain
parents: 12231
diff changeset
   313
  write_u4(len);
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 38031
diff changeset
   314
  u1* ext = (u1*)ik()->source_debug_extension();
13201
69f157caabcc 6294277: java -Xdebug crashes on SourceDebugExtension attribute larger than 64K
fparain
parents: 12231
diff changeset
   315
  for (int i=0; i<len; i++) {
69f157caabcc 6294277: java -Xdebug crashes on SourceDebugExtension attribute larger than 64K
fparain
parents: 12231
diff changeset
   316
    write_u1(ext[i]);
69f157caabcc 6294277: java -Xdebug crashes on SourceDebugExtension attribute larger than 64K
fparain
parents: 12231
diff changeset
   317
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
// Write (generic) Signature attribute
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
// JVMSpec|   Signature_attribute {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
// JVMSpec|     u2 attribute_name_index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
// JVMSpec|     u4 attribute_length;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
// JVMSpec|     u2 signature_index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
// JVMSpec|   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
void JvmtiClassFileReconstituter::write_signature_attribute(u2 generic_signature_index) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
  write_attribute_name_index("Signature");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
  write_u4(2);  // always length 2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
  write_u2(generic_signature_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
// Compute the number of entries in the InnerClasses attribute
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
u2 JvmtiClassFileReconstituter::inner_classes_attribute_length() {
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 38031
diff changeset
   334
  InnerClassesIterator iter(ik());
12231
6a9cfc59a18a 7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents: 12102
diff changeset
   335
  return iter.length();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
// Write an annotation attribute.  The VM stores them in raw form, so all we need
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
// to do is add the attrubute name and fill in the length.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
// JSR202|   *Annotations_attribute {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
// JSR202|     u2 attribute_name_index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
// JSR202|     u4 attribute_length;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
// JSR202|     ...
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
// JSR202|   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
void JvmtiClassFileReconstituter::write_annotations_attribute(const char* attr_name,
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   346
                                                              AnnotationArray* annos) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
  u4 length = annos->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
  write_attribute_name_index(attr_name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
  write_u4(length);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   350
  memcpy(writeable_address(length), annos->adr_at(0), length);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
17307
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   353
//  BootstrapMethods_attribute {
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   354
//    u2 attribute_name_index;
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   355
//    u4 attribute_length;
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   356
//    u2 num_bootstrap_methods;
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   357
//    {   u2 bootstrap_method_ref;
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   358
//        u2 num_bootstrap_arguments;
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   359
//        u2 bootstrap_arguments[num_bootstrap_arguments];
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   360
//    } bootstrap_methods[num_bootstrap_methods];
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   361
//  }
17309
83ac929d332a 8014044: Spelling error in JDK-8009615: boostrapmethod
sla
parents: 17307
diff changeset
   362
void JvmtiClassFileReconstituter::write_bootstrapmethod_attribute() {
17307
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   363
  Array<u2>* operands = cpool()->operands();
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   364
  write_attribute_name_index("BootstrapMethods");
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   365
  int num_bootstrap_methods = ConstantPool::operand_array_length(operands);
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   366
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   367
  // calculate length of attribute
17309
83ac929d332a 8014044: Spelling error in JDK-8009615: boostrapmethod
sla
parents: 17307
diff changeset
   368
  int length = sizeof(u2); // num_bootstrap_methods
17307
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   369
  for (int n = 0; n < num_bootstrap_methods; n++) {
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   370
    u2 num_bootstrap_arguments = cpool()->operand_argument_count_at(n);
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   371
    length += sizeof(u2); // bootstrap_method_ref
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   372
    length += sizeof(u2); // num_bootstrap_arguments
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   373
    length += sizeof(u2) * num_bootstrap_arguments; // bootstrap_arguments[num_bootstrap_arguments]
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   374
  }
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   375
  write_u4(length);
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   376
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   377
  // write attribute
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   378
  write_u2(num_bootstrap_methods);
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   379
  for (int n = 0; n < num_bootstrap_methods; n++) {
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   380
    u2 bootstrap_method_ref = cpool()->operand_bootstrap_method_ref_index_at(n);
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   381
    u2 num_bootstrap_arguments = cpool()->operand_argument_count_at(n);
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   382
    write_u2(bootstrap_method_ref);
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   383
    write_u2(num_bootstrap_arguments);
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   384
    for (int arg = 0; arg < num_bootstrap_arguments; arg++) {
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   385
      u2 bootstrap_argument = cpool()->operand_argument_index_at(n, arg);
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   386
      write_u2(bootstrap_argument);
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   387
    }
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   388
  }
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   389
}
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   390
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
// Write InnerClasses attribute
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
// JVMSpec|   InnerClasses_attribute {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
// JVMSpec|     u2 attribute_name_index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
// JVMSpec|     u4 attribute_length;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
// JVMSpec|     u2 number_of_classes;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
// JVMSpec|     {  u2 inner_class_info_index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
// JVMSpec|        u2 outer_class_info_index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
// JVMSpec|        u2 inner_name_index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
// JVMSpec|        u2 inner_class_access_flags;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
// JVMSpec|     } classes[number_of_classes];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
// JVMSpec|   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
void JvmtiClassFileReconstituter::write_inner_classes_attribute(int length) {
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 38031
diff changeset
   404
  InnerClassesIterator iter(ik());
12231
6a9cfc59a18a 7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents: 12102
diff changeset
   405
  guarantee(iter.length() != 0 && iter.length() == length,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
            "caller must check");
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   407
  u2 entry_count = length / InstanceKlass::inner_class_next_offset;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
  u4 size = 2 + entry_count * (2+2+2+2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
  write_attribute_name_index("InnerClasses");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
  write_u4(size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
  write_u2(entry_count);
12231
6a9cfc59a18a 7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents: 12102
diff changeset
   413
  for (; !iter.done(); iter.next()) {
6a9cfc59a18a 7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents: 12102
diff changeset
   414
    write_u2(iter.inner_class_info_index());
6a9cfc59a18a 7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents: 12102
diff changeset
   415
    write_u2(iter.outer_class_info_index());
6a9cfc59a18a 7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents: 12102
diff changeset
   416
    write_u2(iter.inner_name_index());
6a9cfc59a18a 7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents: 12102
diff changeset
   417
    write_u2(iter.inner_access_flags());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
// Write Synthetic attribute
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
// JVMSpec|   Synthetic_attribute {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
// JVMSpec|     u2 attribute_name_index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
// JVMSpec|     u4 attribute_length;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
// JVMSpec|   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
void JvmtiClassFileReconstituter::write_synthetic_attribute() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
  write_attribute_name_index("Synthetic");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
  write_u4(0); //length always zero
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
// Compute size of LineNumberTable
33593
60764a78fa5c 8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents: 27401
diff changeset
   432
u2 JvmtiClassFileReconstituter::line_number_table_entries(const methodHandle& method) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
  // The line number table is compressed so we don't know how big it is until decompressed.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
  // Decompression is really fast so we just do it twice.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
  u2 num_entries = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
  CompressedLineNumberReadStream stream(method->compressed_linenumber_table());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
  while (stream.read_pair()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
    num_entries++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
  return num_entries;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
// Write LineNumberTable attribute
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
// JVMSpec|   LineNumberTable_attribute {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
// JVMSpec|     u2 attribute_name_index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
// JVMSpec|     u4 attribute_length;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
// JVMSpec|     u2 line_number_table_length;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
// JVMSpec|     {  u2 start_pc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
// JVMSpec|        u2 line_number;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
// JVMSpec|     } line_number_table[line_number_table_length];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
// JVMSpec|   }
33593
60764a78fa5c 8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents: 27401
diff changeset
   452
void JvmtiClassFileReconstituter::write_line_number_table_attribute(const methodHandle& method,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
                                                                    u2 num_entries) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
  write_attribute_name_index("LineNumberTable");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
  write_u4(2 + num_entries * (2 + 2));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
  write_u2(num_entries);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
  CompressedLineNumberReadStream stream(method->compressed_linenumber_table());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
  while (stream.read_pair()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
    write_u2(stream.bci());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
    write_u2(stream.line());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
13863
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   466
// Write LocalVariableTable attribute
11257
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   467
// JVMSpec|   LocalVariableTable_attribute {
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   468
// JVMSpec|     u2 attribute_name_index;
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   469
// JVMSpec|     u4 attribute_length;
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   470
// JVMSpec|     u2 local_variable_table_length;
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   471
// JVMSpec|     {  u2 start_pc;
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   472
// JVMSpec|       u2 length;
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   473
// JVMSpec|       u2 name_index;
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   474
// JVMSpec|       u2 descriptor_index;
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   475
// JVMSpec|       u2 index;
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   476
// JVMSpec|     } local_variable_table[local_variable_table_length];
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   477
// JVMSpec|   }
33593
60764a78fa5c 8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents: 27401
diff changeset
   478
void JvmtiClassFileReconstituter::write_local_variable_table_attribute(const methodHandle& method, u2 num_entries) {
11257
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   479
    write_attribute_name_index("LocalVariableTable");
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   480
    write_u4(2 + num_entries * (2 + 2 + 2 + 2 + 2));
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   481
    write_u2(num_entries);
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   482
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   483
    assert(method->localvariable_table_length() == num_entries, "just checking");
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   484
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   485
    LocalVariableTableElement *elem = method->localvariable_table_start();
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   486
    for (int j=0; j<method->localvariable_table_length(); j++) {
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   487
      write_u2(elem->start_bci);
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   488
      write_u2(elem->length);
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   489
      write_u2(elem->name_cp_index);
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   490
      write_u2(elem->descriptor_cp_index);
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   491
      write_u2(elem->slot);
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   492
      elem++;
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   493
    }
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   494
}
b98dfa12a8f7 7064927: retransformClasses() does not pass in LocalVariableTable of a method
coleenp
parents: 10552
diff changeset
   495
13863
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   496
// Write LocalVariableTypeTable attribute
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   497
// JVMSpec|   LocalVariableTypeTable_attribute {
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   498
// JVMSpec|     u2 attribute_name_index;
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   499
// JVMSpec|     u4 attribute_length;
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   500
// JVMSpec|     u2 local_variable_type_table_length;
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   501
// JVMSpec|     { u2 start_pc;
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   502
// JVMSpec|       u2 length;
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   503
// JVMSpec|       u2 name_index;
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   504
// JVMSpec|       u2 signature_index;
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   505
// JVMSpec|       u2 index;
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   506
// JVMSpec|     } local_variable_type_table[local_variable_type_table_length];
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   507
// JVMSpec|   }
33593
60764a78fa5c 8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents: 27401
diff changeset
   508
void JvmtiClassFileReconstituter::write_local_variable_type_table_attribute(const methodHandle& method, u2 num_entries) {
13863
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   509
    write_attribute_name_index("LocalVariableTypeTable");
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   510
    write_u4(2 + num_entries * (2 + 2 + 2 + 2 + 2));
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   511
    write_u2(num_entries);
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   512
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   513
    LocalVariableTableElement *elem = method->localvariable_table_start();
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   514
    for (int j=0; j<method->localvariable_table_length(); j++) {
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   515
      if (elem->signature_cp_index > 0) {
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   516
        // Local variable has a generic signature - write LVTT attribute entry
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   517
        write_u2(elem->start_bci);
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   518
        write_u2(elem->length);
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   519
        write_u2(elem->name_cp_index);
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   520
        write_u2(elem->signature_cp_index);
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   521
        write_u2(elem->slot);
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   522
        num_entries--;
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   523
      }
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   524
      elem++;
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   525
    }
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   526
    assert(num_entries == 0, "just checking");
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   527
}
3a6dfc8fdfd1 7191786: retransformClasses() does not pass in LocalVariableTypeTable of a method
minqi
parents: 13728
diff changeset
   528
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
// Write stack map table attribute
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
// JSR-202|   StackMapTable_attribute {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
// JSR-202|     u2 attribute_name_index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
// JSR-202|     u4 attribute_length;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
// JSR-202|     u2 number_of_entries;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
// JSR-202|     stack_map_frame_entries[number_of_entries];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
// JSR-202|   }
33593
60764a78fa5c 8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents: 27401
diff changeset
   536
void JvmtiClassFileReconstituter::write_stackmap_table_attribute(const methodHandle& method,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
                                                                 int stackmap_len) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
  write_attribute_name_index("StackMapTable");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
  write_u4(stackmap_len);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
  memcpy(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
    writeable_address(stackmap_len),
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   543
    (void*)(method->stackmap_data()->adr_at(0)),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
    stackmap_len);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
// Write one method_info structure
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
// JVMSpec|   method_info {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
// JVMSpec|     u2 access_flags;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
// JVMSpec|     u2 name_index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
// JVMSpec|     u2 descriptor_index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
// JVMSpec|     u2 attributes_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
// JVMSpec|     attribute_info attributes[attributes_count];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
// JVMSpec|   }
33593
60764a78fa5c 8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents: 27401
diff changeset
   555
void JvmtiClassFileReconstituter::write_method_info(const methodHandle& method) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
  AccessFlags access_flags = method->access_flags();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   557
  ConstMethod* const_method = method->constMethod();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
  u2 generic_signature_index = const_method->generic_signature_index();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   559
  AnnotationArray* anno = method->annotations();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   560
  AnnotationArray* param_anno = method->parameter_annotations();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   561
  AnnotationArray* default_anno = method->annotation_default();
27401
a4697c9502cb 8057043: Type annotations not retained during class redefine / retransform
aeriksso
parents: 25715
diff changeset
   562
  AnnotationArray* type_anno = method->type_annotations();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
17294
a1a03f4c1cab 8008453: JvmtiClassFileReconstituter does not recognize default methods
sla
parents: 14481
diff changeset
   564
  // skip generated default interface methods
a1a03f4c1cab 8008453: JvmtiClassFileReconstituter does not recognize default methods
sla
parents: 14481
diff changeset
   565
  if (method->is_overpass()) {
a1a03f4c1cab 8008453: JvmtiClassFileReconstituter does not recognize default methods
sla
parents: 14481
diff changeset
   566
    return;
a1a03f4c1cab 8008453: JvmtiClassFileReconstituter does not recognize default methods
sla
parents: 14481
diff changeset
   567
  }
a1a03f4c1cab 8008453: JvmtiClassFileReconstituter does not recognize default methods
sla
parents: 14481
diff changeset
   568
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
  write_u2(access_flags.get_flags() & JVM_RECOGNIZED_METHOD_MODIFIERS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
  write_u2(const_method->name_index());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
  write_u2(const_method->signature_index());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
  // write attributes in the same order javac does, so we can test with byte for
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
  // byte comparison
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
  int attr_count = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
  if (const_method->code_size() != 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
    ++attr_count;     // has Code attribute
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
  if (const_method->has_checked_exceptions()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
    ++attr_count;     // has Exceptions attribute
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
  }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   582
  if (default_anno != NULL) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
    ++attr_count;     // has AnnotationDefault attribute
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
  // Deprecated attribute would go here
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
  if (access_flags.is_synthetic()) { // FIXME
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
    // ++attr_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
  if (generic_signature_index != 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
    ++attr_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
  }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   592
  if (anno != NULL) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
    ++attr_count;     // has RuntimeVisibleAnnotations attribute
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
  }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   595
  if (param_anno != NULL) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
    ++attr_count;     // has RuntimeVisibleParameterAnnotations attribute
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
  }
27401
a4697c9502cb 8057043: Type annotations not retained during class redefine / retransform
aeriksso
parents: 25715
diff changeset
   598
  if (type_anno != NULL) {
a4697c9502cb 8057043: Type annotations not retained during class redefine / retransform
aeriksso
parents: 25715
diff changeset
   599
    ++attr_count;     // has RuntimeVisibleTypeAnnotations attribute
a4697c9502cb 8057043: Type annotations not retained during class redefine / retransform
aeriksso
parents: 25715
diff changeset
   600
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
  write_u2(attr_count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
  if (const_method->code_size() > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
    write_code_attribute(method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
  if (const_method->has_checked_exceptions()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
    write_exceptions_attribute(const_method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
  }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   609
  if (default_anno != NULL) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
    write_annotations_attribute("AnnotationDefault", default_anno);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
  // Deprecated attribute would go here
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
  if (access_flags.is_synthetic()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
    // write_synthetic_attribute();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
  if (generic_signature_index != 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
    write_signature_attribute(generic_signature_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
  }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   619
  if (anno != NULL) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
    write_annotations_attribute("RuntimeVisibleAnnotations", anno);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
  }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   622
  if (param_anno != NULL) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
    write_annotations_attribute("RuntimeVisibleParameterAnnotations", param_anno);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
  }
27401
a4697c9502cb 8057043: Type annotations not retained during class redefine / retransform
aeriksso
parents: 25715
diff changeset
   625
  if (type_anno != NULL) {
a4697c9502cb 8057043: Type annotations not retained during class redefine / retransform
aeriksso
parents: 25715
diff changeset
   626
    write_annotations_attribute("RuntimeVisibleTypeAnnotations", type_anno);
a4697c9502cb 8057043: Type annotations not retained during class redefine / retransform
aeriksso
parents: 25715
diff changeset
   627
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
489c9b5090e2 Initial load
duke
parents:
diff changeset
   630
// Write the class attributes portion of ClassFile structure
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
// JVMSpec|     u2 attributes_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
// JVMSpec|     attribute_info attributes[attributes_count];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
void JvmtiClassFileReconstituter::write_class_attributes() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
  u2 inner_classes_length = inner_classes_attribute_length();
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 38031
diff changeset
   635
  Symbol* generic_signature = ik()->generic_signature();
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 38031
diff changeset
   636
  AnnotationArray* anno = ik()->class_annotations();
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 38031
diff changeset
   637
  AnnotationArray* type_anno = ik()->class_type_annotations();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
489c9b5090e2 Initial load
duke
parents:
diff changeset
   639
  int attr_count = 0;
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   640
  if (generic_signature != NULL) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
    ++attr_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   642
  }
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 38031
diff changeset
   643
  if (ik()->source_file_name() != NULL) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   644
    ++attr_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   645
  }
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 38031
diff changeset
   646
  if (ik()->source_debug_extension() != NULL) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   647
    ++attr_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
  if (inner_classes_length > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
    ++attr_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
  }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   652
  if (anno != NULL) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   653
    ++attr_count;     // has RuntimeVisibleAnnotations attribute
489c9b5090e2 Initial load
duke
parents:
diff changeset
   654
  }
27401
a4697c9502cb 8057043: Type annotations not retained during class redefine / retransform
aeriksso
parents: 25715
diff changeset
   655
  if (type_anno != NULL) {
a4697c9502cb 8057043: Type annotations not retained during class redefine / retransform
aeriksso
parents: 25715
diff changeset
   656
    ++attr_count;     // has RuntimeVisibleTypeAnnotations attribute
a4697c9502cb 8057043: Type annotations not retained during class redefine / retransform
aeriksso
parents: 25715
diff changeset
   657
  }
17307
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   658
  if (cpool()->operands() != NULL) {
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   659
    ++attr_count;
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   660
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   661
489c9b5090e2 Initial load
duke
parents:
diff changeset
   662
  write_u2(attr_count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   663
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   664
  if (generic_signature != NULL) {
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   665
    write_signature_attribute(symbol_to_cpool_index(generic_signature));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   666
  }
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 38031
diff changeset
   667
  if (ik()->source_file_name() != NULL) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   668
    write_source_file_attribute();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   669
  }
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 38031
diff changeset
   670
  if (ik()->source_debug_extension() != NULL) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   671
    write_source_debug_extension_attribute();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   672
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   673
  if (inner_classes_length > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   674
    write_inner_classes_attribute(inner_classes_length);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   675
  }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   676
  if (anno != NULL) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   677
    write_annotations_attribute("RuntimeVisibleAnnotations", anno);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   678
  }
27401
a4697c9502cb 8057043: Type annotations not retained during class redefine / retransform
aeriksso
parents: 25715
diff changeset
   679
  if (type_anno != NULL) {
a4697c9502cb 8057043: Type annotations not retained during class redefine / retransform
aeriksso
parents: 25715
diff changeset
   680
    write_annotations_attribute("RuntimeVisibleTypeAnnotations", type_anno);
a4697c9502cb 8057043: Type annotations not retained during class redefine / retransform
aeriksso
parents: 25715
diff changeset
   681
  }
17307
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   682
  if (cpool()->operands() != NULL) {
17309
83ac929d332a 8014044: Spelling error in JDK-8009615: boostrapmethod
sla
parents: 17307
diff changeset
   683
    write_bootstrapmethod_attribute();
17307
74bb7db916df 8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
sla
parents: 17294
diff changeset
   684
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   685
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   686
489c9b5090e2 Initial load
duke
parents:
diff changeset
   687
// Write the method information portion of ClassFile structure
489c9b5090e2 Initial load
duke
parents:
diff changeset
   688
// JVMSpec|     u2 methods_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   689
// JVMSpec|     method_info methods[methods_count];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   690
void JvmtiClassFileReconstituter::write_method_infos() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   691
  HandleMark hm(thread());
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 38031
diff changeset
   692
  Array<Method*>* methods = ik()->methods();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   693
  int num_methods = methods->length();
17294
a1a03f4c1cab 8008453: JvmtiClassFileReconstituter does not recognize default methods
sla
parents: 14481
diff changeset
   694
  int num_overpass = 0;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   695
17294
a1a03f4c1cab 8008453: JvmtiClassFileReconstituter does not recognize default methods
sla
parents: 14481
diff changeset
   696
  // count the generated default interface methods
a1a03f4c1cab 8008453: JvmtiClassFileReconstituter does not recognize default methods
sla
parents: 14481
diff changeset
   697
  // these will not be re-created by write_method_info
a1a03f4c1cab 8008453: JvmtiClassFileReconstituter does not recognize default methods
sla
parents: 14481
diff changeset
   698
  // and should not be included in the total count
a1a03f4c1cab 8008453: JvmtiClassFileReconstituter does not recognize default methods
sla
parents: 14481
diff changeset
   699
  for (int index = 0; index < num_methods; index++) {
a1a03f4c1cab 8008453: JvmtiClassFileReconstituter does not recognize default methods
sla
parents: 14481
diff changeset
   700
    Method* method = methods->at(index);
a1a03f4c1cab 8008453: JvmtiClassFileReconstituter does not recognize default methods
sla
parents: 14481
diff changeset
   701
    if (method->is_overpass()) {
a1a03f4c1cab 8008453: JvmtiClassFileReconstituter does not recognize default methods
sla
parents: 14481
diff changeset
   702
      num_overpass++;
a1a03f4c1cab 8008453: JvmtiClassFileReconstituter does not recognize default methods
sla
parents: 14481
diff changeset
   703
    }
a1a03f4c1cab 8008453: JvmtiClassFileReconstituter does not recognize default methods
sla
parents: 14481
diff changeset
   704
  }
a1a03f4c1cab 8008453: JvmtiClassFileReconstituter does not recognize default methods
sla
parents: 14481
diff changeset
   705
a1a03f4c1cab 8008453: JvmtiClassFileReconstituter does not recognize default methods
sla
parents: 14481
diff changeset
   706
  write_u2(num_methods - num_overpass);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   707
  if (JvmtiExport::can_maintain_original_method_order()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   708
    int index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   709
    int original_index;
38031
e0b822facc03 8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents: 33593
diff changeset
   710
    intArray method_order(num_methods, num_methods, 0);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   711
489c9b5090e2 Initial load
duke
parents:
diff changeset
   712
    // invert the method order mapping
489c9b5090e2 Initial load
duke
parents:
diff changeset
   713
    for (index = 0; index < num_methods; index++) {
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 38031
diff changeset
   714
      original_index = ik()->method_ordering()->at(index);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   715
      assert(original_index >= 0 && original_index < num_methods,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   716
             "invalid original method index");
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   717
      method_order.at_put(original_index, index);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   718
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   719
489c9b5090e2 Initial load
duke
parents:
diff changeset
   720
    // write in original order
489c9b5090e2 Initial load
duke
parents:
diff changeset
   721
    for (original_index = 0; original_index < num_methods; original_index++) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   722
      index = method_order.at(original_index);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   723
      methodHandle method(thread(), methods->at(index));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   724
      write_method_info(method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   725
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   726
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   727
    // method order not preserved just dump the method infos
489c9b5090e2 Initial load
duke
parents:
diff changeset
   728
    for (int index = 0; index < num_methods; index++) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   729
      methodHandle method(thread(), methods->at(index));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   730
      write_method_info(method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   731
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   732
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   733
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   734
489c9b5090e2 Initial load
duke
parents:
diff changeset
   735
void JvmtiClassFileReconstituter::write_class_file_format() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   736
  ReallocMark();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   737
489c9b5090e2 Initial load
duke
parents:
diff changeset
   738
  // JVMSpec|   ClassFile {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   739
  // JVMSpec|           u4 magic;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   740
  write_u4(0xCAFEBABE);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   741
489c9b5090e2 Initial load
duke
parents:
diff changeset
   742
  // JVMSpec|           u2 minor_version;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   743
  // JVMSpec|           u2 major_version;
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 38031
diff changeset
   744
  write_u2(ik()->minor_version());
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 38031
diff changeset
   745
  u2 major = ik()->major_version();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   746
  write_u2(major);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   747
489c9b5090e2 Initial load
duke
parents:
diff changeset
   748
  // JVMSpec|           u2 constant_pool_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   749
  // JVMSpec|           cp_info constant_pool[constant_pool_count-1];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   750
  write_u2(cpool()->length());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   751
  copy_cpool_bytes(writeable_address(cpool_size()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   752
489c9b5090e2 Initial load
duke
parents:
diff changeset
   753
  // JVMSpec|           u2 access_flags;
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 38031
diff changeset
   754
  write_u2(ik()->access_flags().get_flags() & JVM_RECOGNIZED_CLASS_MODIFIERS);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   755
489c9b5090e2 Initial load
duke
parents:
diff changeset
   756
  // JVMSpec|           u2 this_class;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   757
  // JVMSpec|           u2 super_class;
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 38031
diff changeset
   758
  write_u2(class_symbol_to_cpool_index(ik()->name()));
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 38031
diff changeset
   759
  Klass* super_class = ik()->super();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   760
  write_u2(super_class == NULL? 0 :  // zero for java.lang.Object
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   761
                class_symbol_to_cpool_index(super_class->name()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   762
489c9b5090e2 Initial load
duke
parents:
diff changeset
   763
  // JVMSpec|           u2 interfaces_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   764
  // JVMSpec|           u2 interfaces[interfaces_count];
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 38031
diff changeset
   765
  Array<Klass*>* interfaces =  ik()->local_interfaces();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   766
  int num_interfaces = interfaces->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   767
  write_u2(num_interfaces);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   768
  for (int index = 0; index < num_interfaces; index++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   769
    HandleMark hm(thread());
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 38031
diff changeset
   770
    InstanceKlass* iik = InstanceKlass::cast(interfaces->at(index));
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 38031
diff changeset
   771
    write_u2(class_symbol_to_cpool_index(iik->name()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   772
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   773
489c9b5090e2 Initial load
duke
parents:
diff changeset
   774
  // JVMSpec|           u2 fields_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   775
  // JVMSpec|           field_info fields[fields_count];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   776
  write_field_infos();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   777
489c9b5090e2 Initial load
duke
parents:
diff changeset
   778
  // JVMSpec|           u2 methods_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   779
  // JVMSpec|           method_info methods[methods_count];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   780
  write_method_infos();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   781
489c9b5090e2 Initial load
duke
parents:
diff changeset
   782
  // JVMSpec|           u2 attributes_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   783
  // JVMSpec|           attribute_info attributes[attributes_count];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   784
  // JVMSpec|   } /* end ClassFile 8?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   785
  write_class_attributes();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   786
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   787
489c9b5090e2 Initial load
duke
parents:
diff changeset
   788
address JvmtiClassFileReconstituter::writeable_address(size_t size) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   789
  size_t used_size = _buffer_ptr - _buffer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   790
  if (size + used_size >= _buffer_size) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   791
    // compute the new buffer size: must be at least twice as big as before
489c9b5090e2 Initial load
duke
parents:
diff changeset
   792
    // plus whatever new is being used; then convert to nice clean block boundary
489c9b5090e2 Initial load
duke
parents:
diff changeset
   793
    size_t new_buffer_size = (size + _buffer_size*2 + 1) / initial_buffer_size
489c9b5090e2 Initial load
duke
parents:
diff changeset
   794
                                                         * initial_buffer_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   795
489c9b5090e2 Initial load
duke
parents:
diff changeset
   796
    // VM goes belly-up if the memory isn't available, so cannot do OOM processing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   797
    _buffer = REALLOC_RESOURCE_ARRAY(u1, _buffer, _buffer_size, new_buffer_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   798
    _buffer_size = new_buffer_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   799
    _buffer_ptr = _buffer + used_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   800
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   801
  u1* ret_ptr = _buffer_ptr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   802
  _buffer_ptr += size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   803
  return ret_ptr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   804
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   805
489c9b5090e2 Initial load
duke
parents:
diff changeset
   806
void JvmtiClassFileReconstituter::write_attribute_name_index(const char* name) {
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   807
  TempNewSymbol sym = SymbolTable::probe(name, (int)strlen(name));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   808
  assert(sym != NULL, "attribute name symbol not found");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   809
  u2 attr_name_index = symbol_to_cpool_index(sym);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   810
  assert(attr_name_index != 0, "attribute name symbol not in constant pool");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   811
  write_u2(attr_name_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   812
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   813
489c9b5090e2 Initial load
duke
parents:
diff changeset
   814
void JvmtiClassFileReconstituter::write_u1(u1 x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   815
  *writeable_address(1) = x;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   816
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   817
489c9b5090e2 Initial load
duke
parents:
diff changeset
   818
void JvmtiClassFileReconstituter::write_u2(u2 x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   819
  Bytes::put_Java_u2(writeable_address(2), x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   820
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   821
489c9b5090e2 Initial load
duke
parents:
diff changeset
   822
void JvmtiClassFileReconstituter::write_u4(u4 x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   823
  Bytes::put_Java_u4(writeable_address(4), x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   824
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   825
489c9b5090e2 Initial load
duke
parents:
diff changeset
   826
void JvmtiClassFileReconstituter::write_u8(u8 x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   827
  Bytes::put_Java_u8(writeable_address(8), x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   828
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   829
33593
60764a78fa5c 8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents: 27401
diff changeset
   830
void JvmtiClassFileReconstituter::copy_bytecodes(const methodHandle& mh,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   831
                                                 unsigned char* bytecodes) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   832
  // use a BytecodeStream to iterate over the bytecodes. JVM/fast bytecodes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   833
  // and the breakpoint bytecode are converted to their original bytecodes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   834
489c9b5090e2 Initial load
duke
parents:
diff changeset
   835
  BytecodeStream bs(mh);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   836
489c9b5090e2 Initial load
duke
parents:
diff changeset
   837
  unsigned char* p = bytecodes;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   838
  Bytecodes::Code code;
14391
df0a1573d5bd 8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents: 13863
diff changeset
   839
  bool is_rewritten = mh->method_holder()->is_rewritten();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   840
489c9b5090e2 Initial load
duke
parents:
diff changeset
   841
  while ((code = bs.next()) >= 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   842
    assert(Bytecodes::is_java_code(code), "sanity check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   843
    assert(code != Bytecodes::_breakpoint, "sanity check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   844
489c9b5090e2 Initial load
duke
parents:
diff changeset
   845
    // length of bytecode (mnemonic + operands)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   846
    address bcp = bs.bcp();
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 3261
diff changeset
   847
    int     len = bs.instruction_size();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   848
    assert(len > 0, "length must be > 0");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   849
489c9b5090e2 Initial load
duke
parents:
diff changeset
   850
    // copy the bytecodes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   851
    *p = (unsigned char) (bs.is_wide()? Bytecodes::_wide : code);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   852
    if (len > 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   853
      memcpy(p+1, bcp+1, len-1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   854
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   855
489c9b5090e2 Initial load
duke
parents:
diff changeset
   856
    // During linking the get/put and invoke instructions are rewritten
489c9b5090e2 Initial load
duke
parents:
diff changeset
   857
    // with an index into the constant pool cache. The original constant
489c9b5090e2 Initial load
duke
parents:
diff changeset
   858
    // pool index must be returned to caller.  Rewrite the index.
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   859
    if (is_rewritten && len > 1) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   860
      bool is_wide = false;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   861
      switch (code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   862
      case Bytecodes::_getstatic       :  // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   863
      case Bytecodes::_putstatic       :  // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   864
      case Bytecodes::_getfield        :  // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   865
      case Bytecodes::_putfield        :  // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   866
      case Bytecodes::_invokevirtual   :  // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   867
      case Bytecodes::_invokespecial   :  // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   868
      case Bytecodes::_invokestatic    :  // fall through
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   869
      case Bytecodes::_invokedynamic   :  // fall through
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   870
      case Bytecodes::_invokeinterface : {
12102
7a1c6c80bc23 7118280: The gbyc00102 JCK7 test causes an assert in JVM 7.0 fastdebug mode
dsamersoff
parents: 11257
diff changeset
   871
        assert(len == 3 ||
7a1c6c80bc23 7118280: The gbyc00102 JCK7 test causes an assert in JVM 7.0 fastdebug mode
dsamersoff
parents: 11257
diff changeset
   872
               (code == Bytecodes::_invokeinterface && len == 5) ||
7a1c6c80bc23 7118280: The gbyc00102 JCK7 test causes an assert in JVM 7.0 fastdebug mode
dsamersoff
parents: 11257
diff changeset
   873
               (code == Bytecodes::_invokedynamic   && len == 5),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   874
               "sanity check");
12102
7a1c6c80bc23 7118280: The gbyc00102 JCK7 test causes an assert in JVM 7.0 fastdebug mode
dsamersoff
parents: 11257
diff changeset
   875
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   876
        int cpci = Bytes::get_native_u2(bcp+1);
24322
c2978d1578e3 8036956: remove EnableInvokeDynamic flag
anoll
parents: 22234
diff changeset
   877
        bool is_invokedynamic = (code == Bytecodes::_invokedynamic);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   878
        ConstantPoolCacheEntry* entry;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   879
        if (is_invokedynamic) {
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   880
          cpci = Bytes::get_native_u4(bcp+1);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   881
          entry = mh->constants()->invokedynamic_cp_cache_entry_at(cpci);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   882
        } else {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   883
        // cache cannot be pre-fetched since some classes won't have it yet
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   884
          entry = mh->constants()->cache()->entry_at(cpci);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   885
        }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   886
        int i = entry->constant_pool_index();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   887
        assert(i < mh->constants()->length(), "sanity check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   888
        Bytes::put_Java_u2((address)(p+1), (u2)i);     // java byte ordering
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   889
        if (is_invokedynamic)  *(p+3) = *(p+4) = 0;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   890
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   891
      }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   892
      case Bytecodes::_ldc_w:
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   893
        is_wide = true; // fall through
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   894
      case Bytecodes::_ldc: {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   895
        if (bs.raw_code() == Bytecodes::_fast_aldc || bs.raw_code() == Bytecodes::_fast_aldc_w) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   896
          int cpci = is_wide ? Bytes::get_native_u2(bcp+1) : (u1)(*(bcp+1));
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   897
          int i = mh->constants()->object_to_cp_index(cpci);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   898
          assert(i < mh->constants()->length(), "sanity check");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   899
          if (is_wide) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   900
            Bytes::put_Java_u2((address)(p+1), (u2)i);     // java byte ordering
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   901
          } else {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   902
            *(p+1) = (u1)i;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   903
          }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   904
        }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   905
        break;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   906
        }
46630
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46329
diff changeset
   907
      default:
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46329
diff changeset
   908
        break;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13286
diff changeset
   909
      }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   910
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   911
489c9b5090e2 Initial load
duke
parents:
diff changeset
   912
    p += len;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   913
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   914
}