src/hotspot/share/oops/constMethod.cpp
author coleenp
Wed, 24 Jul 2019 10:22:11 -0400
changeset 57511 00ae3b739184
parent 53584 f72661ff0294
child 59070 22ee476cc664
permissions -rw-r--r--
8228485: JVM crashes when bootstrap method for condy triggers loading of class whose static initializer throws exception Summary: Add case for JVM_CONSTANT_Dynamic in error_message function. Reviewed-by: dholmes, shade
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
53584
f72661ff0294 8212949: Remove ConstantPoolCache::is_constantPoolCache
coleenp
parents: 49594
diff changeset
     2
 * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
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: 1
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#include "precompiled.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    26
#include "interpreter/interpreter.hpp"
15437
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 15102
diff changeset
    27
#include "memory/heapInspection.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    28
#include "memory/metadataFactory.hpp"
46746
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46625
diff changeset
    29
#include "memory/metaspaceClosure.hpp"
37248
11a660dbbb8e 8132524: Missing includes to resourceArea.hpp
jprovino
parents: 35898
diff changeset
    30
#include "memory/resourceArea.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    31
#include "oops/constMethod.hpp"
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    32
#include "oops/method.hpp"
49594
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents: 47216
diff changeset
    33
#include "runtime/safepointVerifiers.hpp"
46625
edefffab74e2 8183552: Move align functions to align.hpp
stefank
parents: 46619
diff changeset
    34
#include "utilities/align.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
// Static initialization
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    37
const u2 ConstMethod::MAX_IDNUM   = 0xFFFE;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    38
const u2 ConstMethod::UNSET_IDNUM = 0xFFFF;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    39
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    40
ConstMethod* ConstMethod::allocate(ClassLoaderData* loader_data,
14385
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents: 13728
diff changeset
    41
                                   int byte_code_size,
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
    42
                                   InlineTableSizes* sizes,
14385
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents: 13728
diff changeset
    43
                                   MethodType method_type,
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents: 13728
diff changeset
    44
                                   TRAPS) {
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
    45
  int size = ConstMethod::size(byte_code_size, sizes);
46746
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46625
diff changeset
    46
  return new (loader_data, size, MetaspaceObj::ConstMethodType, THREAD) ConstMethod(
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
    47
      byte_code_size, sizes, method_type, size);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    48
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    49
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    50
ConstMethod::ConstMethod(int byte_code_size,
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
    51
                         InlineTableSizes* sizes,
14385
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents: 13728
diff changeset
    52
                         MethodType method_type,
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents: 13728
diff changeset
    53
                         int size) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    54
35492
c8c0273e6b91 8146690: Make all classes in GC follow the naming convention.
david
parents: 30764
diff changeset
    55
  NoSafepointVerifier no_safepoint;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    56
  init_fingerprint();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    57
  set_constants(NULL);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    58
  set_stackmap_data(NULL);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    59
  set_code_size(byte_code_size);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    60
  set_constMethod_size(size);
15931
c4fc378a132b 8009836: nsk/regression/b4222717 fails with empty stack trace
coleenp
parents: 15928
diff changeset
    61
  set_inlined_tables_length(sizes); // sets _flags
14385
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents: 13728
diff changeset
    62
  set_method_type(method_type);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    63
  assert(this->size() == size, "wrong size for object");
15928
f9d5c6e4107f 8003553: NPG: metaspace objects should be zeroed in constructors
coleenp
parents: 15601
diff changeset
    64
  set_name_index(0);
f9d5c6e4107f 8003553: NPG: metaspace objects should be zeroed in constructors
coleenp
parents: 15601
diff changeset
    65
  set_signature_index(0);
f9d5c6e4107f 8003553: NPG: metaspace objects should be zeroed in constructors
coleenp
parents: 15601
diff changeset
    66
  set_constants(NULL);
f9d5c6e4107f 8003553: NPG: metaspace objects should be zeroed in constructors
coleenp
parents: 15601
diff changeset
    67
  set_max_stack(0);
f9d5c6e4107f 8003553: NPG: metaspace objects should be zeroed in constructors
coleenp
parents: 15601
diff changeset
    68
  set_max_locals(0);
f9d5c6e4107f 8003553: NPG: metaspace objects should be zeroed in constructors
coleenp
parents: 15601
diff changeset
    69
  set_method_idnum(0);
15931
c4fc378a132b 8009836: nsk/regression/b4222717 fails with empty stack trace
coleenp
parents: 15928
diff changeset
    70
  set_size_of_parameters(0);
37480
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 37248
diff changeset
    71
  set_result_type(T_VOID);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    72
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    73
15935
50da9e5eb858 8003419: NPG: Clean up metadata created during class loading if failure
coleenp
parents: 15931
diff changeset
    74
// Accessor that copies to metadata.
50da9e5eb858 8003419: NPG: Clean up metadata created during class loading if failure
coleenp
parents: 15931
diff changeset
    75
void ConstMethod::copy_stackmap_data(ClassLoaderData* loader_data,
50da9e5eb858 8003419: NPG: Clean up metadata created during class loading if failure
coleenp
parents: 15931
diff changeset
    76
                                     u1* sd, int length, TRAPS) {
50da9e5eb858 8003419: NPG: Clean up metadata created during class loading if failure
coleenp
parents: 15931
diff changeset
    77
  _stackmap_data = MetadataFactory::new_array<u1>(loader_data, length, CHECK);
50da9e5eb858 8003419: NPG: Clean up metadata created during class loading if failure
coleenp
parents: 15931
diff changeset
    78
  memcpy((void*)_stackmap_data->adr_at(0), (void*)sd, length);
50da9e5eb858 8003419: NPG: Clean up metadata created during class loading if failure
coleenp
parents: 15931
diff changeset
    79
}
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    80
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    81
// Deallocate metadata fields associated with ConstMethod*
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    82
void ConstMethod::deallocate_contents(ClassLoaderData* loader_data) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    83
  if (stackmap_data() != NULL) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    84
    MetadataFactory::free_array<u1>(loader_data, stackmap_data());
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    85
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    86
  set_stackmap_data(NULL);
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
    87
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
    88
  // deallocate annotation arrays
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
    89
  if (has_method_annotations())
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
    90
    MetadataFactory::free_array<u1>(loader_data, method_annotations());
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
    91
  if (has_parameter_annotations())
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
    92
    MetadataFactory::free_array<u1>(loader_data, parameter_annotations());
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
    93
  if (has_type_annotations())
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
    94
    MetadataFactory::free_array<u1>(loader_data, type_annotations());
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
    95
  if (has_default_annotations())
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
    96
    MetadataFactory::free_array<u1>(loader_data, default_annotations());
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    97
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
// How big must this constMethodObject be?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   101
int ConstMethod::size(int code_size,
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   102
                      InlineTableSizes* sizes) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  int extra_bytes = code_size;
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   104
  if (sizes->compressed_linenumber_size() > 0) {
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   105
    extra_bytes += sizes->compressed_linenumber_size();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  }
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   107
  if (sizes->checked_exceptions_length() > 0) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
    extra_bytes += sizeof(u2);
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   109
    extra_bytes += sizes->checked_exceptions_length() * sizeof(CheckedExceptionElement);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  }
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   111
  if (sizes->localvariable_table_length() > 0) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
    extra_bytes += sizeof(u2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
    extra_bytes +=
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   114
              sizes->localvariable_table_length() * sizeof(LocalVariableTableElement);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  }
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   116
  if (sizes->exception_table_length() > 0) {
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   117
    extra_bytes += sizeof(u2);
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   118
    extra_bytes += sizes->exception_table_length() * sizeof(ExceptionTableElement);
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   119
  }
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   120
  if (sizes->generic_signature_index() != 0) {
14586
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 14391
diff changeset
   121
    extra_bytes += sizeof(u2);
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 14391
diff changeset
   122
  }
27612
7201412afbd0 8058313: Mismatch of method descriptor and MethodParameters.parameters_count should cause MalformedParameterException
emc
parents: 24424
diff changeset
   123
  // This has to be a less-than-or-equal check, because we might be
7201412afbd0 8058313: Mismatch of method descriptor and MethodParameters.parameters_count should cause MalformedParameterException
emc
parents: 24424
diff changeset
   124
  // storing information from a zero-length MethodParameters
7201412afbd0 8058313: Mismatch of method descriptor and MethodParameters.parameters_count should cause MalformedParameterException
emc
parents: 24424
diff changeset
   125
  // attribute.  We have to store these, because in some cases, they
7201412afbd0 8058313: Mismatch of method descriptor and MethodParameters.parameters_count should cause MalformedParameterException
emc
parents: 24424
diff changeset
   126
  // cause the reflection API to throw a MalformedParametersException.
7201412afbd0 8058313: Mismatch of method descriptor and MethodParameters.parameters_count should cause MalformedParameterException
emc
parents: 24424
diff changeset
   127
  if (sizes->method_parameters_length() >= 0) {
15102
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   128
    extra_bytes += sizeof(u2);
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   129
    extra_bytes += sizes->method_parameters_length() * sizeof(MethodParametersElement);
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   130
  }
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   131
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   132
  // Align sizes up to a word.
46619
a3919f5e8d2b 8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents: 45240
diff changeset
   133
  extra_bytes = align_up(extra_bytes, BytesPerWord);
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   134
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   135
  // One pointer per annotation array
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   136
  if (sizes->method_annotations_length() > 0) {
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   137
    extra_bytes += sizeof(AnnotationArray*);
15102
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   138
  }
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   139
  if (sizes->parameter_annotations_length() > 0) {
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   140
    extra_bytes += sizeof(AnnotationArray*);
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   141
  }
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   142
  if (sizes->type_annotations_length() > 0) {
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   143
    extra_bytes += sizeof(AnnotationArray*);
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   144
  }
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   145
  if (sizes->default_annotations_length() > 0) {
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   146
    extra_bytes += sizeof(AnnotationArray*);
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   147
  }
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   148
46619
a3919f5e8d2b 8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents: 45240
diff changeset
   149
  int extra_words = align_up(extra_bytes, BytesPerWord) / BytesPerWord;
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   150
  assert(extra_words == extra_bytes/BytesPerWord, "should already be aligned");
35898
ddc274f0052f 8145628: hotspot metadata classes shouldn't use HeapWordSize or heap related macros like align_object_size
coleenp
parents: 35492
diff changeset
   151
  return align_metadata_size(header_size() + extra_words);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   154
Method* ConstMethod::method() const {
14391
df0a1573d5bd 8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents: 14385
diff changeset
   155
    return _constants->pool_holder()->method_with_idnum(_method_idnum);
12937
0032fb2caff6 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 7397
diff changeset
   156
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
// linenumber table - note that length is unknown until decompression,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
// see class CompressedLineNumberReadStream.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   161
u_char* ConstMethod::compressed_linenumber_table() const {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  // Located immediately following the bytecodes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  assert(has_linenumber_table(), "called only if table is present");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  return code_end();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   167
// Last short in ConstMethod* before annotations
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   168
u2* ConstMethod::last_u2_element() const {
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   169
  int offset = 0;
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   170
  if (has_method_annotations()) offset++;
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   171
  if (has_parameter_annotations()) offset++;
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   172
  if (has_type_annotations()) offset++;
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   173
  if (has_default_annotations()) offset++;
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   174
  return (u2*)((AnnotationArray**)constMethod_end() - offset) - 1;
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   175
}
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   176
14586
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 14391
diff changeset
   177
u2* ConstMethod::generic_signature_index_addr() const {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  // Located at the end of the constMethod.
14586
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 14391
diff changeset
   179
  assert(has_generic_signature(), "called only if generic signature exists");
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 14391
diff changeset
   180
  return last_u2_element();
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 14391
diff changeset
   181
}
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 14391
diff changeset
   182
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   183
u2* ConstMethod::method_parameters_length_addr() const {
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   184
  assert(has_method_parameters(), "called only if table is present");
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   185
  return has_generic_signature() ? (last_u2_element() - 1) :
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   186
                                    last_u2_element();
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   187
}
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   188
14586
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 14391
diff changeset
   189
u2* ConstMethod::checked_exceptions_length_addr() const {
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 14391
diff changeset
   190
  // Located immediately before the generic signature index.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  assert(has_checked_exceptions(), "called only if table is present");
15102
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   192
  if(has_method_parameters()) {
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   193
    // If method parameters present, locate immediately before them.
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   194
    return (u2*)method_parameters_start() - 1;
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   195
  } else {
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   196
    // Else, the exception table is at the end of the constMethod.
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   197
    return has_generic_signature() ? (last_u2_element() - 1) :
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   198
                                     last_u2_element();
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   199
  }
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   200
}
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   201
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   202
u2* ConstMethod::exception_table_length_addr() const {
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   203
  assert(has_exception_handler(), "called only if table is present");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  if (has_checked_exceptions()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
    // If checked_exception present, locate immediately before them.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
    return (u2*) checked_exceptions_start() - 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  } else {
15102
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   208
    if(has_method_parameters()) {
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   209
      // If method parameters present, locate immediately before them.
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   210
      return (u2*)method_parameters_start() - 1;
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   211
    } else {
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   212
      // Else, the exception table is at the end of the constMethod.
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   213
      return has_generic_signature() ? (last_u2_element() - 1) :
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   214
                                        last_u2_element();
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   215
    }
15102
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   216
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   219
u2* ConstMethod::localvariable_table_length_addr() const {
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   220
  assert(has_localvariable_table(), "called only if table is present");
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   221
  if (has_exception_handler()) {
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   222
    // If exception_table present, locate immediately before them.
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   223
    return (u2*) exception_table_start() - 1;
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   224
  } else {
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   225
    if (has_checked_exceptions()) {
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   226
      // If checked_exception present, locate immediately before them.
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   227
      return (u2*) checked_exceptions_start() - 1;
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   228
    } else {
15102
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   229
      if(has_method_parameters()) {
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   230
        // If method parameters present, locate immediately before them.
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   231
        return (u2*)method_parameters_start() - 1;
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   232
      } else {
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   233
        // Else, the exception table is at the end of the constMethod.
14586
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 14391
diff changeset
   234
      return has_generic_signature() ? (last_u2_element() - 1) :
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 14391
diff changeset
   235
                                        last_u2_element();
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   236
      }
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   237
    }
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   238
  }
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   239
}
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   240
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
// Update the flags to indicate the presence of these optional fields.
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   242
void ConstMethod::set_inlined_tables_length(InlineTableSizes* sizes) {
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   243
  _flags = 0;
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   244
  if (sizes->compressed_linenumber_size() > 0)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
    _flags |= _has_linenumber_table;
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   246
  if (sizes->generic_signature_index() != 0)
14586
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 14391
diff changeset
   247
    _flags |= _has_generic_signature;
27612
7201412afbd0 8058313: Mismatch of method descriptor and MethodParameters.parameters_count should cause MalformedParameterException
emc
parents: 24424
diff changeset
   248
  if (sizes->method_parameters_length() >= 0)
15102
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   249
    _flags |= _has_method_parameters;
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   250
  if (sizes->checked_exceptions_length() > 0)
15102
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   251
    _flags |= _has_checked_exceptions;
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   252
  if (sizes->exception_table_length() > 0)
15102
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   253
    _flags |= _has_exception_table;
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   254
  if (sizes->localvariable_table_length() > 0)
15102
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   255
    _flags |= _has_localvariable_table;
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   256
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   257
  // annotations, they are all pointer sized embedded objects so don't have
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   258
  // a length embedded also.
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   259
  if (sizes->method_annotations_length() > 0)
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   260
    _flags |= _has_method_annotations;
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   261
  if (sizes->parameter_annotations_length() > 0)
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   262
    _flags |= _has_parameter_annotations;
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   263
  if (sizes->type_annotations_length() > 0)
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   264
    _flags |= _has_type_annotations;
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   265
  if (sizes->default_annotations_length() > 0)
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   266
    _flags |= _has_default_annotations;
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   267
15102
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   268
  // This code is extremely brittle and should possibly be revised.
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   269
  // The *_length_addr functions walk backwards through the
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   270
  // constMethod data, using each of the length indexes ahead of them,
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   271
  // as well as the flags variable.  Therefore, the indexes must be
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   272
  // initialized in reverse order, or else they will compute the wrong
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   273
  // offsets.  Moving the initialization of _flags into a separate
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   274
  // block solves *half* of the problem, but the following part will
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   275
  // still break if the order is not exactly right.
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   276
  //
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   277
  // Also, the servicability agent needs to be informed anytime
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   278
  // anything is added here.  It might be advisable to have some sort
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   279
  // of indication of this inline.
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   280
  if (sizes->generic_signature_index() != 0)
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   281
    *(generic_signature_index_addr()) = sizes->generic_signature_index();
15102
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   282
  // New data should probably go here.
27612
7201412afbd0 8058313: Mismatch of method descriptor and MethodParameters.parameters_count should cause MalformedParameterException
emc
parents: 24424
diff changeset
   283
  if (sizes->method_parameters_length() >= 0)
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   284
    *(method_parameters_length_addr()) = sizes->method_parameters_length();
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   285
  if (sizes->checked_exceptions_length() > 0)
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   286
    *(checked_exceptions_length_addr()) = sizes->checked_exceptions_length();
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   287
  if (sizes->exception_table_length() > 0)
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   288
    *(exception_table_length_addr()) = sizes->exception_table_length();
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   289
  if (sizes->localvariable_table_length() > 0)
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   290
    *(localvariable_table_length_addr()) = sizes->localvariable_table_length();
15102
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   291
}
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   292
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   293
int ConstMethod::method_parameters_length() const {
27612
7201412afbd0 8058313: Mismatch of method descriptor and MethodParameters.parameters_count should cause MalformedParameterException
emc
parents: 24424
diff changeset
   294
  return has_method_parameters() ? *(method_parameters_length_addr()) : -1;
15102
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   295
}
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   296
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   297
MethodParametersElement* ConstMethod::method_parameters_start() const {
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   298
  u2* addr = method_parameters_length_addr();
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   299
  u2 length = *addr;
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   300
  addr -= length * sizeof(MethodParametersElement) / sizeof(u2);
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   301
  return (MethodParametersElement*) addr;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   305
int ConstMethod::checked_exceptions_length() const {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
  return has_checked_exceptions() ? *(checked_exceptions_length_addr()) : 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   310
CheckedExceptionElement* ConstMethod::checked_exceptions_start() const {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
  u2* addr = checked_exceptions_length_addr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
  u2 length = *addr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
  assert(length > 0, "should only be called if table is present");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
  addr -= length * sizeof(CheckedExceptionElement) / sizeof(u2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
  return (CheckedExceptionElement*) addr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   319
int ConstMethod::localvariable_table_length() const {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
  return has_localvariable_table() ? *(localvariable_table_length_addr()) : 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   324
LocalVariableTableElement* ConstMethod::localvariable_table_start() const {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
  u2* addr = localvariable_table_length_addr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
  u2 length = *addr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
  assert(length > 0, "should only be called if table is present");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
  addr -= length * sizeof(LocalVariableTableElement) / sizeof(u2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
  return (LocalVariableTableElement*) addr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
}
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   331
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   332
int ConstMethod::exception_table_length() const {
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   333
  return has_exception_handler() ? *(exception_table_length_addr()) : 0;
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   334
}
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   335
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   336
ExceptionTableElement* ConstMethod::exception_table_start() const {
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   337
  u2* addr = exception_table_length_addr();
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   338
  u2 length = *addr;
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   339
  assert(length > 0, "should only be called if table is present");
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   340
  addr -= length * sizeof(ExceptionTableElement) / sizeof(u2);
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   341
  return (ExceptionTableElement*)addr;
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   342
}
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   343
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   344
AnnotationArray** ConstMethod::method_annotations_addr() const {
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   345
  assert(has_method_annotations(), "should only be called if method annotations are present");
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   346
  return (AnnotationArray**)constMethod_end() - 1;
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   347
}
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   348
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   349
AnnotationArray** ConstMethod::parameter_annotations_addr() const {
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   350
  assert(has_parameter_annotations(), "should only be called if method parameter annotations are present");
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   351
  int offset = 1;
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   352
  if (has_method_annotations()) offset++;
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   353
  return (AnnotationArray**)constMethod_end() - offset;
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   354
}
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   355
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   356
AnnotationArray** ConstMethod::type_annotations_addr() const {
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   357
  assert(has_type_annotations(), "should only be called if method type annotations are present");
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   358
  int offset = 1;
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   359
  if (has_method_annotations()) offset++;
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   360
  if (has_parameter_annotations()) offset++;
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   361
  return (AnnotationArray**)constMethod_end() - offset;
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   362
}
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   363
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   364
AnnotationArray** ConstMethod::default_annotations_addr() const {
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   365
  assert(has_default_annotations(), "should only be called if method default annotations are present");
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   366
  int offset = 1;
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   367
  if (has_method_annotations()) offset++;
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   368
  if (has_parameter_annotations()) offset++;
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   369
  if (has_type_annotations()) offset++;
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   370
  return (AnnotationArray**)constMethod_end() - offset;
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   371
}
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   372
41727
f1658e76a682 8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents: 37480
diff changeset
   373
Array<u1>* copy_annotations(ClassLoaderData* loader_data, AnnotationArray* from, TRAPS) {
f1658e76a682 8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents: 37480
diff changeset
   374
  int length = from->length();
f1658e76a682 8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents: 37480
diff changeset
   375
  Array<u1>* a = MetadataFactory::new_array<u1>(loader_data, length, 0, CHECK_NULL);
f1658e76a682 8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents: 37480
diff changeset
   376
  memcpy((void*)a->adr_at(0), (void*)from->adr_at(0), length);
f1658e76a682 8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents: 37480
diff changeset
   377
  return a;
f1658e76a682 8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents: 37480
diff changeset
   378
}
f1658e76a682 8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents: 37480
diff changeset
   379
16588
7e90e795813e 8009531: Crash when redefining class with annotated method
coleenp
parents: 15935
diff changeset
   380
// copy annotations from 'cm' to 'this'
41727
f1658e76a682 8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents: 37480
diff changeset
   381
// Must make copy because these are deallocated with their constMethod, if redefined.
f1658e76a682 8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents: 37480
diff changeset
   382
void ConstMethod::copy_annotations_from(ClassLoaderData* loader_data, ConstMethod* cm, TRAPS) {
f1658e76a682 8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents: 37480
diff changeset
   383
  Array<u1>* a;
16588
7e90e795813e 8009531: Crash when redefining class with annotated method
coleenp
parents: 15935
diff changeset
   384
  if (cm->has_method_annotations()) {
7e90e795813e 8009531: Crash when redefining class with annotated method
coleenp
parents: 15935
diff changeset
   385
    assert(has_method_annotations(), "should be allocated already");
41727
f1658e76a682 8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents: 37480
diff changeset
   386
    a = copy_annotations(loader_data, cm->method_annotations(), CHECK);
f1658e76a682 8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents: 37480
diff changeset
   387
    set_method_annotations(a);
16588
7e90e795813e 8009531: Crash when redefining class with annotated method
coleenp
parents: 15935
diff changeset
   388
  }
7e90e795813e 8009531: Crash when redefining class with annotated method
coleenp
parents: 15935
diff changeset
   389
  if (cm->has_parameter_annotations()) {
7e90e795813e 8009531: Crash when redefining class with annotated method
coleenp
parents: 15935
diff changeset
   390
    assert(has_parameter_annotations(), "should be allocated already");
41727
f1658e76a682 8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents: 37480
diff changeset
   391
    a = copy_annotations(loader_data, cm->parameter_annotations(), CHECK);
f1658e76a682 8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents: 37480
diff changeset
   392
    set_parameter_annotations(a);
16588
7e90e795813e 8009531: Crash when redefining class with annotated method
coleenp
parents: 15935
diff changeset
   393
  }
7e90e795813e 8009531: Crash when redefining class with annotated method
coleenp
parents: 15935
diff changeset
   394
  if (cm->has_type_annotations()) {
7e90e795813e 8009531: Crash when redefining class with annotated method
coleenp
parents: 15935
diff changeset
   395
    assert(has_type_annotations(), "should be allocated already");
41727
f1658e76a682 8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents: 37480
diff changeset
   396
    a = copy_annotations(loader_data, cm->type_annotations(), CHECK);
f1658e76a682 8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents: 37480
diff changeset
   397
    set_type_annotations(a);
16588
7e90e795813e 8009531: Crash when redefining class with annotated method
coleenp
parents: 15935
diff changeset
   398
  }
7e90e795813e 8009531: Crash when redefining class with annotated method
coleenp
parents: 15935
diff changeset
   399
  if (cm->has_default_annotations()) {
7e90e795813e 8009531: Crash when redefining class with annotated method
coleenp
parents: 15935
diff changeset
   400
    assert(has_default_annotations(), "should be allocated already");
41727
f1658e76a682 8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents: 37480
diff changeset
   401
    a = copy_annotations(loader_data, cm->default_annotations(), CHECK);
f1658e76a682 8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents: 37480
diff changeset
   402
    set_default_annotations(a);
16588
7e90e795813e 8009531: Crash when redefining class with annotated method
coleenp
parents: 15935
diff changeset
   403
  }
7e90e795813e 8009531: Crash when redefining class with annotated method
coleenp
parents: 15935
diff changeset
   404
}
7e90e795813e 8009531: Crash when redefining class with annotated method
coleenp
parents: 15935
diff changeset
   405
46746
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46625
diff changeset
   406
void ConstMethod::metaspace_pointers_do(MetaspaceClosure* it) {
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46625
diff changeset
   407
  log_trace(cds)("Iter(ConstMethod): %p", this);
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46625
diff changeset
   408
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46625
diff changeset
   409
  it->push(&_constants);
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46625
diff changeset
   410
  it->push(&_stackmap_data);
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46625
diff changeset
   411
  if (has_method_annotations()) {
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46625
diff changeset
   412
    it->push(method_annotations_addr());
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46625
diff changeset
   413
  }
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46625
diff changeset
   414
  if (has_parameter_annotations()) {
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46625
diff changeset
   415
      it->push(parameter_annotations_addr());
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46625
diff changeset
   416
  }
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46625
diff changeset
   417
  if (has_type_annotations()) {
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46625
diff changeset
   418
      it->push(type_annotations_addr());
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46625
diff changeset
   419
  }
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46625
diff changeset
   420
  if (has_default_annotations()) {
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46625
diff changeset
   421
      it->push(default_annotations_addr());
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46625
diff changeset
   422
  }
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46625
diff changeset
   423
}
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46625
diff changeset
   424
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   425
// Printing
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   426
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   427
void ConstMethod::print_on(outputStream* st) const {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   428
  ResourceMark rm;
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 18439
diff changeset
   429
  st->print_cr("%s", internal_name());
45240
e804b9d60859 8180565: Null pointer dereferences of ConstMethod::method()
thartmann
parents: 41727
diff changeset
   430
  Method* m = method();
e804b9d60859 8180565: Null pointer dereferences of ConstMethod::method()
thartmann
parents: 41727
diff changeset
   431
  st->print(" - method:       " INTPTR_FORMAT " ", p2i((address)m));
e804b9d60859 8180565: Null pointer dereferences of ConstMethod::method()
thartmann
parents: 41727
diff changeset
   432
  if (m != NULL) {
e804b9d60859 8180565: Null pointer dereferences of ConstMethod::method()
thartmann
parents: 41727
diff changeset
   433
    m->print_value_on(st);
e804b9d60859 8180565: Null pointer dereferences of ConstMethod::method()
thartmann
parents: 41727
diff changeset
   434
  }
e804b9d60859 8180565: Null pointer dereferences of ConstMethod::method()
thartmann
parents: 41727
diff changeset
   435
  st->cr();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   436
  if (has_stackmap_table()) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   437
    st->print(" - stackmap data:       ");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   438
    stackmap_data()->print_value_on(st);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   439
    st->cr();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   440
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   441
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   442
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   443
// Short version of printing ConstMethod* - just print the name of the
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   444
// method it belongs to.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   445
void ConstMethod::print_value_on(outputStream* st) const {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   446
  st->print(" const part of method " );
45240
e804b9d60859 8180565: Null pointer dereferences of ConstMethod::method()
thartmann
parents: 41727
diff changeset
   447
  Method* m = method();
e804b9d60859 8180565: Null pointer dereferences of ConstMethod::method()
thartmann
parents: 41727
diff changeset
   448
  if (m != NULL) {
e804b9d60859 8180565: Null pointer dereferences of ConstMethod::method()
thartmann
parents: 41727
diff changeset
   449
    m->print_value_on(st);
e804b9d60859 8180565: Null pointer dereferences of ConstMethod::method()
thartmann
parents: 41727
diff changeset
   450
  } else {
e804b9d60859 8180565: Null pointer dereferences of ConstMethod::method()
thartmann
parents: 41727
diff changeset
   451
    st->print("NULL");
e804b9d60859 8180565: Null pointer dereferences of ConstMethod::method()
thartmann
parents: 41727
diff changeset
   452
  }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   453
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   454
15437
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 15102
diff changeset
   455
#if INCLUDE_SERVICES
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 15102
diff changeset
   456
// Size Statistics
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 15102
diff changeset
   457
void ConstMethod::collect_statistics(KlassSizeStats *sz) const {
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 15102
diff changeset
   458
  int n1, n2, n3;
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 15102
diff changeset
   459
  sz->_const_method_bytes += (n1 = sz->count(this));
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 15102
diff changeset
   460
  sz->_bytecode_bytes     += (n2 = code_size());
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 15102
diff changeset
   461
  sz->_stackmap_bytes     += (n3 = sz->count_array(stackmap_data()));
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 15102
diff changeset
   462
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   463
  // Count method annotations
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   464
  int a1 = 0, a2 = 0, a3 = 0, a4 = 0;
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   465
  if (has_method_annotations()) {
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   466
    sz->_methods_annotations_bytes += (a1 = sz->count_array(method_annotations()));
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   467
  }
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   468
  if (has_parameter_annotations()) {
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   469
    sz->_methods_parameter_annotations_bytes += (a2 = sz->count_array(parameter_annotations()));
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   470
  }
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   471
  if (has_type_annotations()) {
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   472
    sz->_methods_type_annotations_bytes += (a3 = sz->count_array(type_annotations()));
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   473
  }
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   474
  if (has_default_annotations()) {
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   475
    sz->_methods_default_annotations_bytes += (a4 = sz->count_array(default_annotations()));
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   476
  }
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   477
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   478
  int size_annotations = a1 + a2 + a3 + a4;
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   479
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   480
  sz->_method_all_bytes += n1 + n3 + size_annotations; // note: n2 is part of n3
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   481
  sz->_ro_bytes += n1 + n3 + size_annotations;
15437
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 15102
diff changeset
   482
}
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 15102
diff changeset
   483
#endif // INCLUDE_SERVICES
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   484
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   485
// Verification
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   486
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   487
void ConstMethod::verify_on(outputStream* st) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   488
  // Verification can occur during oop construction before the method or
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   489
  // other fields have been initialized.
45240
e804b9d60859 8180565: Null pointer dereferences of ConstMethod::method()
thartmann
parents: 41727
diff changeset
   490
  guarantee(method() != NULL && method()->is_method(), "should be method");
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   491
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
   492
  address m_end = (address)((intptr_t) this + size());
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   493
  address compressed_table_start = code_end();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   494
  guarantee(compressed_table_start <= m_end, "invalid method layout");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   495
  address compressed_table_end = compressed_table_start;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   496
  // Verify line number table
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   497
  if (has_linenumber_table()) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   498
    CompressedLineNumberReadStream stream(compressed_linenumber_table());
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   499
    while (stream.read_pair()) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   500
      guarantee(stream.bci() >= 0 && stream.bci() <= code_size(), "invalid bci in line number table");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   501
    }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   502
    compressed_table_end += stream.position();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   503
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   504
  guarantee(compressed_table_end <= m_end, "invalid method layout");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   505
  // Verify checked exceptions, exception table and local variable tables
15102
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   506
  if (has_method_parameters()) {
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   507
    u2* addr = method_parameters_length_addr();
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   508
    guarantee(*addr > 0 && (address) addr >= compressed_table_end && (address) addr < m_end, "invalid method layout");
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   509
  }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   510
  if (has_checked_exceptions()) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   511
    u2* addr = checked_exceptions_length_addr();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   512
    guarantee(*addr > 0 && (address) addr >= compressed_table_end && (address) addr < m_end, "invalid method layout");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   513
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   514
  if (has_exception_handler()) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   515
    u2* addr = exception_table_length_addr();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   516
     guarantee(*addr > 0 && (address) addr >= compressed_table_end && (address) addr < m_end, "invalid method layout");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   517
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   518
  if (has_localvariable_table()) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   519
    u2* addr = localvariable_table_length_addr();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   520
    guarantee(*addr > 0 && (address) addr >= compressed_table_end && (address) addr < m_end, "invalid method layout");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   521
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   522
  // Check compressed_table_end relative to uncompressed_table_start
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   523
  u2* uncompressed_table_start;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   524
  if (has_localvariable_table()) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   525
    uncompressed_table_start = (u2*) localvariable_table_start();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   526
  } else if (has_exception_handler()) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   527
    uncompressed_table_start = (u2*) exception_table_start();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   528
  } else if (has_checked_exceptions()) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   529
      uncompressed_table_start = (u2*) checked_exceptions_start();
15102
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   530
  } else if (has_method_parameters()) {
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   531
      uncompressed_table_start = (u2*) method_parameters_start();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   532
  } else {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   533
      uncompressed_table_start = (u2*) m_end;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   534
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   535
  int gap = (intptr_t) uncompressed_table_start - (intptr_t) compressed_table_end;
35898
ddc274f0052f 8145628: hotspot metadata classes shouldn't use HeapWordSize or heap related macros like align_object_size
coleenp
parents: 35492
diff changeset
   536
  int max_gap = align_metadata_size(1)*BytesPerWord;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   537
  guarantee(gap >= 0 && gap < max_gap, "invalid method layout");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   538
}