hotspot/src/share/vm/oops/constMethod.cpp
author coleenp
Mon, 14 Jan 2013 11:01:39 -0500
changeset 15194 a35093d73168
parent 15102 0a86564e5f61
child 15437 eabd4555d072
permissions -rw-r--r--
8006005: Fix constant pool index validation and alignment trap for method parameter reflection Summary: This patch addresses an alignment trap due to the storage format of method parameters data in constMethod. It also adds code to validate constant pool indexes for method parameters data. Reviewed-by: jrose, dholmes Contributed-by: eric.mccorkle@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
12937
0032fb2caff6 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 7397
diff changeset
     2
 * Copyright (c) 2003, 2012, 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"
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    27
#include "memory/gcLocker.hpp"
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    28
#include "memory/metadataFactory.hpp"
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    29
#include "oops/constMethod.hpp"
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    30
#include "oops/method.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
// Static initialization
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    33
const u2 ConstMethod::MAX_IDNUM   = 0xFFFE;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    34
const u2 ConstMethod::UNSET_IDNUM = 0xFFFF;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    35
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    36
ConstMethod* ConstMethod::allocate(ClassLoaderData* loader_data,
14385
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents: 13728
diff changeset
    37
                                   int byte_code_size,
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents: 13728
diff changeset
    38
                                   int compressed_line_number_size,
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents: 13728
diff changeset
    39
                                   int localvariable_table_length,
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents: 13728
diff changeset
    40
                                   int exception_table_length,
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents: 13728
diff changeset
    41
                                   int checked_exceptions_length,
15102
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
    42
                                   int method_parameters_length,
14586
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 14391
diff changeset
    43
                                   u2  generic_signature_index,
14385
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents: 13728
diff changeset
    44
                                   MethodType method_type,
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents: 13728
diff changeset
    45
                                   TRAPS) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    46
  int size = ConstMethod::size(byte_code_size,
15102
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
    47
                               compressed_line_number_size,
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
    48
                               localvariable_table_length,
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
    49
                               exception_table_length,
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
    50
                               checked_exceptions_length,
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
    51
                               method_parameters_length,
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
    52
                               generic_signature_index);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    53
  return new (loader_data, size, true, THREAD) ConstMethod(
14385
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents: 13728
diff changeset
    54
      byte_code_size, compressed_line_number_size, localvariable_table_length,
15102
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
    55
      exception_table_length, checked_exceptions_length,
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
    56
      method_parameters_length, generic_signature_index,
14586
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 14391
diff changeset
    57
      method_type, size);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    58
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    59
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    60
ConstMethod::ConstMethod(int byte_code_size,
14385
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents: 13728
diff changeset
    61
                         int compressed_line_number_size,
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents: 13728
diff changeset
    62
                         int localvariable_table_length,
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents: 13728
diff changeset
    63
                         int exception_table_length,
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents: 13728
diff changeset
    64
                         int checked_exceptions_length,
15102
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
    65
                         int method_parameters_length,
14586
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 14391
diff changeset
    66
                         u2  generic_signature_index,
14385
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents: 13728
diff changeset
    67
                         MethodType method_type,
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents: 13728
diff changeset
    68
                         int size) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    69
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    70
  No_Safepoint_Verifier no_safepoint;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    71
  set_interpreter_kind(Interpreter::invalid);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    72
  init_fingerprint();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    73
  set_constants(NULL);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    74
  set_stackmap_data(NULL);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    75
  set_code_size(byte_code_size);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    76
  set_constMethod_size(size);
14586
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 14391
diff changeset
    77
  set_inlined_tables_length(generic_signature_index,
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 14391
diff changeset
    78
                            checked_exceptions_length,
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    79
                            compressed_line_number_size,
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    80
                            localvariable_table_length,
15102
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
    81
                            exception_table_length,
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
    82
                            method_parameters_length);
14385
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents: 13728
diff changeset
    83
  set_method_type(method_type);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    84
  assert(this->size() == size, "wrong size for object");
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
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    87
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    88
// Deallocate metadata fields associated with ConstMethod*
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    89
void ConstMethod::deallocate_contents(ClassLoaderData* loader_data) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    90
  set_interpreter_kind(Interpreter::invalid);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    91
  if (stackmap_data() != NULL) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    92
    MetadataFactory::free_array<u1>(loader_data, stackmap_data());
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    93
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    94
  set_stackmap_data(NULL);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    95
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
// How big must this constMethodObject be?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    99
int ConstMethod::size(int code_size,
15102
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   100
                      int compressed_line_number_size,
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   101
                      int local_variable_table_length,
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   102
                      int exception_table_length,
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   103
                      int checked_exceptions_length,
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   104
                      int method_parameters_length,
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   105
                      u2  generic_signature_index) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  int extra_bytes = code_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  if (compressed_line_number_size > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
    extra_bytes += compressed_line_number_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  if (checked_exceptions_length > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
    extra_bytes += sizeof(u2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
    extra_bytes += checked_exceptions_length * sizeof(CheckedExceptionElement);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  if (local_variable_table_length > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
    extra_bytes += sizeof(u2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
    extra_bytes +=
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
              local_variable_table_length * sizeof(LocalVariableTableElement);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  }
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   119
  if (exception_table_length > 0) {
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   120
    extra_bytes += sizeof(u2);
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   121
    extra_bytes += exception_table_length * sizeof(ExceptionTableElement);
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   122
  }
14586
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 14391
diff changeset
   123
  if (generic_signature_index != 0) {
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 14391
diff changeset
   124
    extra_bytes += sizeof(u2);
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 14391
diff changeset
   125
  }
15102
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   126
  if (method_parameters_length > 0) {
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   127
    extra_bytes += sizeof(u2);
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   128
    extra_bytes += method_parameters_length * sizeof(MethodParametersElement);
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   129
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  int extra_words = align_size_up(extra_bytes, BytesPerWord) / BytesPerWord;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  return align_object_size(header_size() + extra_words);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   134
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
   135
    return _constants->pool_holder()->method_with_idnum(_method_idnum);
12937
0032fb2caff6 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 7397
diff changeset
   136
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
// linenumber table - note that length is unknown until decompression,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
// see class CompressedLineNumberReadStream.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   141
u_char* ConstMethod::compressed_linenumber_table() const {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  // Located immediately following the bytecodes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  assert(has_linenumber_table(), "called only if table is present");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  return code_end();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
14586
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 14391
diff changeset
   147
u2* ConstMethod::generic_signature_index_addr() const {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  // 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
   149
  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
   150
  return last_u2_element();
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 14391
diff changeset
   151
}
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 14391
diff changeset
   152
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 14391
diff changeset
   153
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
   154
  // Located immediately before the generic signature index.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  assert(has_checked_exceptions(), "called only if table is present");
15102
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   156
  if(has_method_parameters()) {
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   157
    // If method parameters present, locate immediately before them.
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   158
    return (u2*)method_parameters_start() - 1;
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   159
  } else {
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   160
    // Else, the exception table is at the end of the constMethod.
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   161
    return has_generic_signature() ? (last_u2_element() - 1) :
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   162
                                     last_u2_element();
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   163
  }
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   164
}
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   165
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   166
u2* ConstMethod::method_parameters_length_addr() const {
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   167
  assert(has_method_parameters(), "called only if table is present");
14586
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 14391
diff changeset
   168
  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
   169
                                    last_u2_element();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   172
u2* ConstMethod::exception_table_length_addr() const {
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   173
  assert(has_exception_handler(), "called only if table is present");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  if (has_checked_exceptions()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
    // If checked_exception present, locate immediately before them.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
    return (u2*) checked_exceptions_start() - 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  } else {
15102
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   178
    if(has_method_parameters()) {
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   179
      // If method parameters present, locate immediately before them.
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   180
      return (u2*)method_parameters_start() - 1;
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   181
    } else {
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   182
      // 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
   183
    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
   184
                                      last_u2_element();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  }
15102
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   186
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   189
u2* ConstMethod::localvariable_table_length_addr() const {
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   190
  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
   191
  if (has_exception_handler()) {
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   192
    // If exception_table present, locate immediately before them.
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   193
    return (u2*) exception_table_start() - 1;
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   194
  } else {
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   195
    if (has_checked_exceptions()) {
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   196
      // If checked_exception present, locate immediately before them.
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   197
      return (u2*) checked_exceptions_start() - 1;
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   198
    } else {
15102
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   199
      if(has_method_parameters()) {
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   200
        // If method parameters present, locate immediately before them.
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   201
        return (u2*)method_parameters_start() - 1;
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   202
      } else {
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   203
        // 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
   204
      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
   205
                                        last_u2_element();
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   206
    }
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   207
  }
15102
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   208
  }
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   209
}
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   210
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
// Update the flags to indicate the presence of these optional fields.
14586
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 14391
diff changeset
   212
void ConstMethod::set_inlined_tables_length(u2  generic_signature_index,
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 14391
diff changeset
   213
                                            int checked_exceptions_len,
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 14391
diff changeset
   214
                                            int compressed_line_number_size,
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 14391
diff changeset
   215
                                            int localvariable_table_len,
15102
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   216
                                            int exception_table_len,
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   217
                                            int method_parameters_len) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  assert(_flags == 0, "Error");
15102
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   219
  if (compressed_line_number_size > 0)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
    _flags |= _has_linenumber_table;
15102
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   221
  if (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
   222
    _flags |= _has_generic_signature;
15102
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   223
  if (method_parameters_len > 0)
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   224
    _flags |= _has_method_parameters;
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   225
  if (checked_exceptions_len > 0)
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   226
    _flags |= _has_checked_exceptions;
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   227
  if (exception_table_len > 0)
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   228
    _flags |= _has_exception_table;
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   229
  if (localvariable_table_len > 0)
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   230
    _flags |= _has_localvariable_table;
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   231
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   232
  // This code is extremely brittle and should possibly be revised.
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   233
  // The *_length_addr functions walk backwards through the
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   234
  // constMethod data, using each of the length indexes ahead of them,
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   235
  // as well as the flags variable.  Therefore, the indexes must be
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   236
  // initialized in reverse order, or else they will compute the wrong
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   237
  // offsets.  Moving the initialization of _flags into a separate
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   238
  // block solves *half* of the problem, but the following part will
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   239
  // still break if the order is not exactly right.
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   240
  //
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   241
  // Also, the servicability agent needs to be informed anytime
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   242
  // 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
   243
  // of indication of this inline.
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   244
  if (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
   245
    *(generic_signature_index_addr()) = generic_signature_index;
15102
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   246
  // New data should probably go here.
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   247
  if (method_parameters_len > 0)
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   248
    *(method_parameters_length_addr()) = method_parameters_len;
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   249
  if (checked_exceptions_len > 0)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
    *(checked_exceptions_length_addr()) = checked_exceptions_len;
15102
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   251
  if (exception_table_len > 0)
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   252
    *(exception_table_length_addr()) = exception_table_len;
15102
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   253
  if (localvariable_table_len > 0)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
    *(localvariable_table_length_addr()) = localvariable_table_len;
15102
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   255
}
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   256
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   257
int ConstMethod::method_parameters_length() const {
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   258
  return has_method_parameters() ? *(method_parameters_length_addr()) : 0;
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   259
}
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   260
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   261
MethodParametersElement* ConstMethod::method_parameters_start() const {
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   262
  u2* addr = method_parameters_length_addr();
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   263
  u2 length = *addr;
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   264
  assert(length > 0, "should only be called if table is present");
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   265
  addr -= length * sizeof(MethodParametersElement) / sizeof(u2);
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   266
  return (MethodParametersElement*) addr;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   270
int ConstMethod::checked_exceptions_length() const {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
  return has_checked_exceptions() ? *(checked_exceptions_length_addr()) : 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   275
CheckedExceptionElement* ConstMethod::checked_exceptions_start() const {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
  u2* addr = checked_exceptions_length_addr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
  u2 length = *addr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
  assert(length > 0, "should only be called if table is present");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
  addr -= length * sizeof(CheckedExceptionElement) / sizeof(u2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
  return (CheckedExceptionElement*) addr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   284
int ConstMethod::localvariable_table_length() const {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
  return has_localvariable_table() ? *(localvariable_table_length_addr()) : 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   289
LocalVariableTableElement* ConstMethod::localvariable_table_start() const {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
  u2* addr = localvariable_table_length_addr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
  u2 length = *addr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
  assert(length > 0, "should only be called if table is present");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
  addr -= length * sizeof(LocalVariableTableElement) / sizeof(u2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  return (LocalVariableTableElement*) addr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
}
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   296
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   297
int ConstMethod::exception_table_length() const {
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   298
  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
   299
}
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   300
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   301
ExceptionTableElement* ConstMethod::exception_table_start() const {
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   302
  u2* addr = exception_table_length_addr();
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   303
  u2 length = *addr;
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   304
  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
   305
  addr -= length * sizeof(ExceptionTableElement) / sizeof(u2);
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   306
  return (ExceptionTableElement*)addr;
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   307
}
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   308
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   309
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   310
// Printing
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   311
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   312
void ConstMethod::print_on(outputStream* st) const {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   313
  ResourceMark rm;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   314
  assert(is_constMethod(), "must be constMethod");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   315
  st->print_cr(internal_name());
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   316
  st->print(" - method:       " INTPTR_FORMAT " ", (address)method());
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   317
  method()->print_value_on(st); st->cr();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   318
  if (has_stackmap_table()) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   319
    st->print(" - stackmap data:       ");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   320
    stackmap_data()->print_value_on(st);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   321
    st->cr();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   322
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   323
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   324
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   325
// 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
   326
// method it belongs to.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   327
void ConstMethod::print_value_on(outputStream* st) const {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   328
  assert(is_constMethod(), "must be constMethod");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   329
  st->print(" const part of method " );
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   330
  method()->print_value_on(st);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   331
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   332
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   333
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   334
// Verification
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   335
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   336
void ConstMethod::verify_on(outputStream* st) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   337
  guarantee(is_constMethod(), "object must be constMethod");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   338
  guarantee(is_metadata(), err_msg("Should be metadata " PTR_FORMAT, this));
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   339
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   340
  // 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
   341
  // other fields have been initialized.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   342
  guarantee(is_metadata(), err_msg("Should be metadata " PTR_FORMAT, this));
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   343
  guarantee(method()->is_method(), "should be method");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   344
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   345
  address m_end = (address)((oop*) this + size());
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   346
  address compressed_table_start = code_end();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   347
  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
   348
  address compressed_table_end = compressed_table_start;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   349
  // Verify line number table
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   350
  if (has_linenumber_table()) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   351
    CompressedLineNumberReadStream stream(compressed_linenumber_table());
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   352
    while (stream.read_pair()) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   353
      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
   354
    }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   355
    compressed_table_end += stream.position();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   356
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   357
  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
   358
  // Verify checked exceptions, exception table and local variable tables
15102
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   359
  if (has_method_parameters()) {
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   360
    u2* addr = method_parameters_length_addr();
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   361
    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
   362
  }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   363
  if (has_checked_exceptions()) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   364
    u2* addr = checked_exceptions_length_addr();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   365
    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
   366
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   367
  if (has_exception_handler()) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   368
    u2* addr = exception_table_length_addr();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   369
     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
   370
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   371
  if (has_localvariable_table()) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   372
    u2* addr = localvariable_table_length_addr();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   373
    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
   374
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   375
  // 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
   376
  u2* uncompressed_table_start;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   377
  if (has_localvariable_table()) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   378
    uncompressed_table_start = (u2*) localvariable_table_start();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   379
  } else if (has_exception_handler()) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   380
    uncompressed_table_start = (u2*) exception_table_start();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   381
  } else if (has_checked_exceptions()) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   382
      uncompressed_table_start = (u2*) checked_exceptions_start();
15102
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   383
  } else if (has_method_parameters()) {
0a86564e5f61 8004728: Add hotspot support for parameter reflection
coleenp
parents: 14586
diff changeset
   384
      uncompressed_table_start = (u2*) method_parameters_start();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   385
  } else {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   386
      uncompressed_table_start = (u2*) m_end;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   387
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   388
  int gap = (intptr_t) uncompressed_table_start - (intptr_t) compressed_table_end;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   389
  int max_gap = align_object_size(1)*BytesPerWord;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   390
  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
   391
}