hotspot/src/share/vm/oops/constMethod.cpp
author kamg
Thu, 11 Oct 2012 12:25:42 -0400
changeset 14385 959bbcc16725
parent 13728 882756847a04
child 14391 df0a1573d5bd
permissions -rw-r--r--
7200776: Implement default methods in interfaces Summary: Add generic type analysis and default method selection algorithms Reviewed-by: coleenp, acorn
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,
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents: 13728
diff changeset
    42
                                   MethodType method_type,
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents: 13728
diff changeset
    43
                                   TRAPS) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    44
  int size = ConstMethod::size(byte_code_size,
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    45
                                      compressed_line_number_size,
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    46
                                      localvariable_table_length,
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    47
                                      exception_table_length,
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    48
                                      checked_exceptions_length);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    49
  return new (loader_data, size, true, THREAD) ConstMethod(
14385
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents: 13728
diff changeset
    50
      byte_code_size, compressed_line_number_size, localvariable_table_length,
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents: 13728
diff changeset
    51
      exception_table_length, checked_exceptions_length, method_type, size);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    52
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    53
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    54
ConstMethod::ConstMethod(int byte_code_size,
14385
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents: 13728
diff changeset
    55
                         int compressed_line_number_size,
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents: 13728
diff changeset
    56
                         int localvariable_table_length,
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents: 13728
diff changeset
    57
                         int exception_table_length,
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents: 13728
diff changeset
    58
                         int checked_exceptions_length,
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents: 13728
diff changeset
    59
                         MethodType method_type,
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents: 13728
diff changeset
    60
                         int size) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    61
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    62
  No_Safepoint_Verifier no_safepoint;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    63
  set_interpreter_kind(Interpreter::invalid);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    64
  init_fingerprint();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    65
  set_constants(NULL);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    66
  set_stackmap_data(NULL);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    67
  set_code_size(byte_code_size);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    68
  set_constMethod_size(size);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    69
  set_inlined_tables_length(checked_exceptions_length,
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    70
                            compressed_line_number_size,
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    71
                            localvariable_table_length,
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    72
                            exception_table_length);
14385
959bbcc16725 7200776: Implement default methods in interfaces
kamg
parents: 13728
diff changeset
    73
  set_method_type(method_type);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    74
  assert(this->size() == size, "wrong size for object");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    75
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    76
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    77
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    78
// Deallocate metadata fields associated with ConstMethod*
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    79
void ConstMethod::deallocate_contents(ClassLoaderData* loader_data) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    80
  set_interpreter_kind(Interpreter::invalid);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    81
  if (stackmap_data() != NULL) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    82
    MetadataFactory::free_array<u1>(loader_data, stackmap_data());
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    83
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    84
  set_stackmap_data(NULL);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    85
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
// How big must this constMethodObject be?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
    89
int ConstMethod::size(int code_size,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
                                    int compressed_line_number_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
                                    int local_variable_table_length,
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
    92
                                    int exception_table_length,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
                                    int checked_exceptions_length) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  int extra_bytes = code_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  if (compressed_line_number_size > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
    extra_bytes += compressed_line_number_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  if (checked_exceptions_length > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
    extra_bytes += sizeof(u2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
    extra_bytes += checked_exceptions_length * sizeof(CheckedExceptionElement);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  if (local_variable_table_length > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
    extra_bytes += sizeof(u2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
    extra_bytes +=
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
              local_variable_table_length * sizeof(LocalVariableTableElement);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  }
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   107
  if (exception_table_length > 0) {
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   108
    extra_bytes += sizeof(u2);
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   109
    extra_bytes += exception_table_length * sizeof(ExceptionTableElement);
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   110
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  int extra_words = align_size_up(extra_bytes, BytesPerWord) / BytesPerWord;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  return align_object_size(header_size() + extra_words);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   115
Method* ConstMethod::method() const {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   116
    return InstanceKlass::cast(_constants->pool_holder())->method_with_idnum(
12937
0032fb2caff6 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 7397
diff changeset
   117
                               _method_idnum);
0032fb2caff6 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 7397
diff changeset
   118
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
// linenumber table - note that length is unknown until decompression,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
// see class CompressedLineNumberReadStream.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   123
u_char* ConstMethod::compressed_linenumber_table() const {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  // Located immediately following the bytecodes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  assert(has_linenumber_table(), "called only if table is present");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  return code_end();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   129
u2* ConstMethod::checked_exceptions_length_addr() const {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  // Located at the end of the constMethod.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  assert(has_checked_exceptions(), "called only if table is present");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  return last_u2_element();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   135
u2* ConstMethod::exception_table_length_addr() const {
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   136
  assert(has_exception_handler(), "called only if table is present");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  if (has_checked_exceptions()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
    // If checked_exception present, locate immediately before them.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
    return (u2*) checked_exceptions_start() - 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  } else {
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   141
    // Else, the exception table is at the end of the constMethod.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
    return last_u2_element();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   146
u2* ConstMethod::localvariable_table_length_addr() const {
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   147
  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
   148
  if (has_exception_handler()) {
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   149
    // If exception_table present, locate immediately before them.
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   150
    return (u2*) exception_table_start() - 1;
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   151
  } else {
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   152
    if (has_checked_exceptions()) {
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   153
      // If checked_exception present, locate immediately before them.
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   154
      return (u2*) checked_exceptions_start() - 1;
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   155
    } else {
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   156
      // Else, the linenumber table is at the end of the constMethod.
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   157
      return last_u2_element();
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   158
    }
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   159
  }
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   160
}
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   161
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
// Update the flags to indicate the presence of these optional fields.
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   164
void ConstMethod::set_inlined_tables_length(
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
                                              int checked_exceptions_len,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
                                              int compressed_line_number_size,
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   167
                                              int localvariable_table_len,
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   168
                                              int exception_table_len) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  // Must be done in the order below, otherwise length_addr accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  // will not work. Only set bit in header if length is positive.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  assert(_flags == 0, "Error");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  if (compressed_line_number_size > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
    _flags |= _has_linenumber_table;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  if (checked_exceptions_len > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
    _flags |= _has_checked_exceptions;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
    *(checked_exceptions_length_addr()) = checked_exceptions_len;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  }
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   179
  if (exception_table_len > 0) {
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   180
    _flags |= _has_exception_table;
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   181
    *(exception_table_length_addr()) = exception_table_len;
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   182
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  if (localvariable_table_len > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
    _flags |= _has_localvariable_table;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
    *(localvariable_table_length_addr()) = localvariable_table_len;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   190
int ConstMethod::checked_exceptions_length() const {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  return has_checked_exceptions() ? *(checked_exceptions_length_addr()) : 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   195
CheckedExceptionElement* ConstMethod::checked_exceptions_start() const {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  u2* addr = checked_exceptions_length_addr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  u2 length = *addr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  assert(length > 0, "should only be called if table is present");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  addr -= length * sizeof(CheckedExceptionElement) / sizeof(u2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  return (CheckedExceptionElement*) addr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   204
int ConstMethod::localvariable_table_length() const {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  return has_localvariable_table() ? *(localvariable_table_length_addr()) : 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   209
LocalVariableTableElement* ConstMethod::localvariable_table_start() const {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  u2* addr = localvariable_table_length_addr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  u2 length = *addr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  assert(length > 0, "should only be called if table is present");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  addr -= length * sizeof(LocalVariableTableElement) / sizeof(u2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
  return (LocalVariableTableElement*) addr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
}
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   216
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   217
int ConstMethod::exception_table_length() const {
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   218
  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
   219
}
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   220
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   221
ExceptionTableElement* ConstMethod::exception_table_start() const {
13282
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   222
  u2* addr = exception_table_length_addr();
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   223
  u2 length = *addr;
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   224
  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
   225
  addr -= length * sizeof(ExceptionTableElement) / sizeof(u2);
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   226
  return (ExceptionTableElement*)addr;
9872915dd78d 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 12937
diff changeset
   227
}
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   228
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   229
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   230
// Printing
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   231
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   232
void ConstMethod::print_on(outputStream* st) const {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   233
  ResourceMark rm;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   234
  assert(is_constMethod(), "must be constMethod");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   235
  st->print_cr(internal_name());
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   236
  st->print(" - method:       " INTPTR_FORMAT " ", (address)method());
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   237
  method()->print_value_on(st); st->cr();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   238
  if (has_stackmap_table()) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   239
    st->print(" - stackmap data:       ");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   240
    stackmap_data()->print_value_on(st);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   241
    st->cr();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   242
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   243
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   244
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   245
// 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
   246
// method it belongs to.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   247
void ConstMethod::print_value_on(outputStream* st) const {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   248
  assert(is_constMethod(), "must be constMethod");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   249
  st->print(" const part of method " );
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   250
  method()->print_value_on(st);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   251
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   252
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   253
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   254
// Verification
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   255
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   256
void ConstMethod::verify_on(outputStream* st) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   257
  guarantee(is_constMethod(), "object must be constMethod");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   258
  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
   259
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   260
  // 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
   261
  // other fields have been initialized.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   262
  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
   263
  guarantee(method()->is_method(), "should be method");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   264
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   265
  address m_end = (address)((oop*) this + size());
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   266
  address compressed_table_start = code_end();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   267
  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
   268
  address compressed_table_end = compressed_table_start;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   269
  // Verify line number table
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   270
  if (has_linenumber_table()) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   271
    CompressedLineNumberReadStream stream(compressed_linenumber_table());
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   272
    while (stream.read_pair()) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   273
      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
   274
    }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   275
    compressed_table_end += stream.position();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   276
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   277
  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
   278
  // Verify checked exceptions, exception table and local variable tables
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   279
  if (has_checked_exceptions()) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   280
    u2* addr = checked_exceptions_length_addr();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   281
    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
   282
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   283
  if (has_exception_handler()) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   284
    u2* addr = exception_table_length_addr();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   285
     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
   286
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   287
  if (has_localvariable_table()) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   288
    u2* addr = localvariable_table_length_addr();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   289
    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
   290
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   291
  // 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
   292
  u2* uncompressed_table_start;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   293
  if (has_localvariable_table()) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   294
    uncompressed_table_start = (u2*) localvariable_table_start();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   295
  } else if (has_exception_handler()) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   296
    uncompressed_table_start = (u2*) exception_table_start();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   297
  } else if (has_checked_exceptions()) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   298
      uncompressed_table_start = (u2*) checked_exceptions_start();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   299
  } else {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   300
      uncompressed_table_start = (u2*) m_end;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   301
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   302
  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
   303
  int max_gap = align_object_size(1)*BytesPerWord;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13282
diff changeset
   304
  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
   305
}