hotspot/src/share/vm/oops/constMethodKlass.cpp
author dcubed
Wed, 12 Mar 2008 18:06:50 -0700
changeset 220 e6ef4818c49d
parent 1 489c9b5090e2
child 1894 5c343868d071
permissions -rw-r--r--
6497639: 4/3 Profiling Swing application caused JVM crash Summary: Make RedefineClasses() interoperate better with class sharing. Reviewed-by: sspitsyn, jmasa
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2003-2006 Sun Microsystems, Inc.  All Rights Reserved.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
# include "incls/_precompiled.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
# include "incls/_constMethodKlass.cpp.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
klassOop constMethodKlass::create_klass(TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
  constMethodKlass o;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
  KlassHandle h_this_klass(THREAD, Universe::klassKlassObj());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
  KlassHandle k = base_create_klass(h_this_klass, header_size(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
                                    o.vtbl_value(), CHECK_NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
  // Make sure size calculation is right
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
  assert(k()->size() == align_object_size(header_size()),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
         "wrong size for object");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
  //java_lang_Class::create_mirror(k, CHECK_NULL); // Allocate mirror
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  return k();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
int constMethodKlass::oop_size(oop obj) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  assert(obj->is_constMethod(), "must be constMethod oop");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  return constMethodOop(obj)->object_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
bool constMethodKlass::oop_is_parsable(oop obj) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  assert(obj->is_constMethod(), "must be constMethod oop");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  return constMethodOop(obj)->object_is_parsable();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
constMethodOop constMethodKlass::allocate(int byte_code_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
                                          int compressed_line_number_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
                                          int localvariable_table_length,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
                                          int checked_exceptions_length,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
                                          TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  int size = constMethodOopDesc::object_size(byte_code_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
                                             compressed_line_number_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
                                             localvariable_table_length,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
                                             checked_exceptions_length);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  KlassHandle h_k(THREAD, as_klassOop());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  constMethodOop cm = (constMethodOop)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
    CollectedHeap::permanent_obj_allocate(h_k, size, CHECK_NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  assert(!cm->is_parsable(), "Not yet safely parsable");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  No_Safepoint_Verifier no_safepoint;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  cm->set_interpreter_kind(Interpreter::invalid);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  cm->init_fingerprint();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  cm->set_method(NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  cm->set_stackmap_data(NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  cm->set_exception_table(NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  cm->set_code_size(byte_code_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  cm->set_constMethod_size(size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  cm->set_inlined_tables_length(checked_exceptions_length,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
                                compressed_line_number_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
                                localvariable_table_length);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  assert(cm->size() == size, "wrong size for object");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  cm->set_partially_loaded();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  assert(cm->is_parsable(), "Is safely parsable by gc");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  return cm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
void constMethodKlass::oop_follow_contents(oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  assert (obj->is_constMethod(), "object must be constMethod");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  constMethodOop cm = constMethodOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  MarkSweep::mark_and_push(cm->adr_method());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  MarkSweep::mark_and_push(cm->adr_stackmap_data());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  MarkSweep::mark_and_push(cm->adr_exception_table());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  // Performance tweak: We skip iterating over the klass pointer since we
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  // know that Universe::constMethodKlassObj never moves.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
#ifndef SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
void constMethodKlass::oop_follow_contents(ParCompactionManager* cm,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
                                           oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  assert (obj->is_constMethod(), "object must be constMethod");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  constMethodOop cm_oop = constMethodOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  PSParallelCompact::mark_and_push(cm, cm_oop->adr_method());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  PSParallelCompact::mark_and_push(cm, cm_oop->adr_stackmap_data());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  PSParallelCompact::mark_and_push(cm, cm_oop->adr_exception_table());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  // Performance tweak: We skip iterating over the klass pointer since we
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  // know that Universe::constMethodKlassObj never moves.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
#endif // SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
int constMethodKlass::oop_oop_iterate(oop obj, OopClosure* blk) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  assert (obj->is_constMethod(), "object must be constMethod");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  constMethodOop cm = constMethodOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  blk->do_oop(cm->adr_method());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  blk->do_oop(cm->adr_stackmap_data());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  blk->do_oop(cm->adr_exception_table());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  // Get size before changing pointers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  // Don't call size() or oop_size() since that is a virtual call.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  int size = cm->object_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  return size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
int constMethodKlass::oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  assert (obj->is_constMethod(), "object must be constMethod");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  constMethodOop cm = constMethodOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  oop* adr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  adr = cm->adr_method();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  if (mr.contains(adr)) blk->do_oop(adr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  adr = cm->adr_stackmap_data();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  if (mr.contains(adr)) blk->do_oop(adr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  adr = cm->adr_exception_table();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  if (mr.contains(adr)) blk->do_oop(adr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  // Get size before changing pointers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  // Don't call size() or oop_size() since that is a virtual call.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  int size = cm->object_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  // Performance tweak: We skip iterating over the klass pointer since we
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  // know that Universe::constMethodKlassObj never moves.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  return size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
int constMethodKlass::oop_adjust_pointers(oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  assert(obj->is_constMethod(), "should be constMethod");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  constMethodOop cm = constMethodOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  MarkSweep::adjust_pointer(cm->adr_method());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  MarkSweep::adjust_pointer(cm->adr_stackmap_data());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  MarkSweep::adjust_pointer(cm->adr_exception_table());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  // Get size before changing pointers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  // Don't call size() or oop_size() since that is a virtual call.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  int size = cm->object_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  // Performance tweak: We skip iterating over the klass pointer since we
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  // know that Universe::constMethodKlassObj never moves.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  return size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
#ifndef SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
void constMethodKlass::oop_copy_contents(PSPromotionManager* pm, oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  assert(obj->is_constMethod(), "should be constMethod");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
void constMethodKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  assert(obj->is_constMethod(), "should be constMethod");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
int constMethodKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  assert(obj->is_constMethod(), "should be constMethod");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  constMethodOop cm_oop = constMethodOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
#if 0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  PSParallelCompact::adjust_pointer(cm_oop->adr_method());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  PSParallelCompact::adjust_pointer(cm_oop->adr_exception_table());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  PSParallelCompact::adjust_pointer(cm_oop->adr_stackmap_data());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  oop* const beg_oop = cm_oop->oop_block_beg();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  oop* const end_oop = cm_oop->oop_block_end();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  for (oop* cur_oop = beg_oop; cur_oop < end_oop; ++cur_oop) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
    PSParallelCompact::adjust_pointer(cur_oop);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  return cm_oop->object_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
int constMethodKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
                                          HeapWord* beg_addr,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
                                          HeapWord* end_addr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  assert(obj->is_constMethod(), "should be constMethod");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  constMethodOop cm_oop = constMethodOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  oop* const beg_oop = MAX2((oop*)beg_addr, cm_oop->oop_block_beg());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  oop* const end_oop = MIN2((oop*)end_addr, cm_oop->oop_block_end());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  for (oop* cur_oop = beg_oop; cur_oop < end_oop; ++cur_oop) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
    PSParallelCompact::adjust_pointer(cur_oop);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  return cm_oop->object_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
#endif // SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
// Printing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
void constMethodKlass::oop_print_on(oop obj, outputStream* st) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  assert(obj->is_constMethod(), "must be constMethod");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  Klass::oop_print_on(obj, st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  constMethodOop m = constMethodOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  st->print(" - method:       " INTPTR_FORMAT " ", (address)m->method());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  m->method()->print_value_on(st); st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  st->print(" - exceptions:   " INTPTR_FORMAT "\n", (address)m->exception_table());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  if (m->has_stackmap_table()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
    st->print(" - stackmap data:       ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
    m->stackmap_data()->print_value_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
    st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
// Short version of printing constMethodOop - just print the name of the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
// method it belongs to.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
void constMethodKlass::oop_print_value_on(oop obj, outputStream* st) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
  assert(obj->is_constMethod(), "must be constMethod");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  constMethodOop m = constMethodOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  st->print(" const part of method " );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  m->method()->print_value_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
#endif // PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
const char* constMethodKlass::internal_name() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
  return "{constMethod}";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
// Verification
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
void constMethodKlass::oop_verify_on(oop obj, outputStream* st) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
  Klass::oop_verify_on(obj, st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  guarantee(obj->is_constMethod(), "object must be constMethod");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  constMethodOop m = constMethodOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  guarantee(m->is_perm(),                            "should be in permspace");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  // Verification can occur during oop construction before the method or
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  // other fields have been initialized.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
  if (!obj->partially_loaded()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
    guarantee(m->method()->is_perm(), "should be in permspace");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
    guarantee(m->method()->is_method(), "should be method");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
    typeArrayOop stackmap_data = m->stackmap_data();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
    guarantee(stackmap_data == NULL ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
              stackmap_data->is_perm(),  "should be in permspace");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
    guarantee(m->exception_table()->is_perm(), "should be in permspace");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
    guarantee(m->exception_table()->is_typeArray(), "should be type array");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
    address m_end = (address)((oop*) m + m->size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
    address compressed_table_start = m->code_end();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
    guarantee(compressed_table_start <= m_end, "invalid method layout");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
    address compressed_table_end = compressed_table_start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
    // Verify line number table
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
    if (m->has_linenumber_table()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
      CompressedLineNumberReadStream stream(m->compressed_linenumber_table());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
      while (stream.read_pair()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
        guarantee(stream.bci() >= 0 && stream.bci() <= m->code_size(), "invalid bci in line number table");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
      compressed_table_end += stream.position();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
    guarantee(compressed_table_end <= m_end, "invalid method layout");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
    // Verify checked exceptions and local variable tables
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
    if (m->has_checked_exceptions()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
      u2* addr = m->checked_exceptions_length_addr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
      guarantee(*addr > 0 && (address) addr >= compressed_table_end && (address) addr < m_end, "invalid method layout");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
    if (m->has_localvariable_table()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
      u2* addr = m->localvariable_table_length_addr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
      guarantee(*addr > 0 && (address) addr >= compressed_table_end && (address) addr < m_end, "invalid method layout");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
    // Check compressed_table_end relative to uncompressed_table_start
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
    u2* uncompressed_table_start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
    if (m->has_localvariable_table()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
      uncompressed_table_start = (u2*) m->localvariable_table_start();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
      if (m->has_checked_exceptions()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
        uncompressed_table_start = (u2*) m->checked_exceptions_start();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
        uncompressed_table_start = (u2*) m_end;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
    int gap = (intptr_t) uncompressed_table_start - (intptr_t) compressed_table_end;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
    int max_gap = align_object_size(1)*BytesPerWord;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
    guarantee(gap >= 0 && gap < max_gap, "invalid method layout");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
bool constMethodKlass::oop_partially_loaded(oop obj) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
  assert(obj->is_constMethod(), "object must be klass");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  constMethodOop m = constMethodOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
  // check whether exception_table points to self (flag for partially loaded)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
  return m->exception_table() == (typeArrayOop)obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
// The exception_table is the last field set when loading an object.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
void constMethodKlass::oop_set_partially_loaded(oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
  assert(obj->is_constMethod(), "object must be klass");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  constMethodOop m = constMethodOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
  // Temporarily set exception_table to point to self
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  m->set_exception_table((typeArrayOop)obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
}