hotspot/src/share/vm/oops/methodKlass.cpp
author iveresov
Fri, 03 Sep 2010 17:51:07 -0700
changeset 6453 970dc585ab63
parent 6248 2e661807cef0
child 7397 5b173b4ca846
permissions -rw-r--r--
6953144: Tiered compilation Summary: Infrastructure for tiered compilation support (interpreter + c1 + c2) for 32 and 64 bit. Simple tiered policy implementation. Reviewed-by: kvn, never, phh, twisti
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6248
diff changeset
     2
 * Copyright (c) 1997, 2010, 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: 5420
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5420
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: 5420
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
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
# include "incls/_precompiled.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
# include "incls/_methodKlass.cpp.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
klassOop methodKlass::create_klass(TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
  methodKlass o;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
  KlassHandle h_this_klass(THREAD, Universe::klassKlassObj());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
  KlassHandle k = base_create_klass(h_this_klass, header_size(), o.vtbl_value(), CHECK_NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
  // Make sure size calculation is right
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
  assert(k()->size() == align_object_size(header_size()), "wrong size for object");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
  java_lang_Class::create_mirror(k, CHECK_NULL); // Allocate mirror
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
  return k();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
int methodKlass::oop_size(oop obj) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  assert(obj->is_method(), "must be method oop");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  return methodOop(obj)->object_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
bool methodKlass::oop_is_parsable(oop obj) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  assert(obj->is_method(), "must be method oop");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  return methodOop(obj)->object_is_parsable();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
methodOop methodKlass::allocate(constMethodHandle xconst,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
                                AccessFlags access_flags, TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  int size = methodOopDesc::object_size(access_flags.is_native());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  KlassHandle h_k(THREAD, as_klassOop());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  assert(xconst()->is_parsable(), "possible publication protocol violation");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  methodOop m = (methodOop)CollectedHeap::permanent_obj_allocate(h_k, size, CHECK_NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  assert(!m->is_parsable(), "not expecting parsability yet.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  No_Safepoint_Verifier no_safepoint;  // until m becomes parsable below
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  m->set_constMethod(xconst());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  m->set_access_flags(access_flags);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  m->set_method_size(size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  m->set_name_index(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  m->set_signature_index(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
#ifdef CC_INTERP
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  m->set_result_index(T_VOID);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  m->set_constants(NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  m->set_max_stack(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  m->set_max_locals(0);
3273
6acf7084b1d3 6862576: vmIntrinsics needs cleanup in order to support JSR 292 intrinsics
jrose
parents: 2534
diff changeset
    71
  m->set_intrinsic_id(vmIntrinsics::_none);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  m->set_method_data(NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  m->set_interpreter_throwout_count(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  m->set_vtable_index(methodOopDesc::garbage_vtable_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  // Fix and bury in methodOop
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  m->set_interpreter_entry(NULL); // sets i2i entry and from_int
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  m->set_adapter_entry(NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  m->clear_code(); // from_c/from_i get set to c2i/i2i
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  if (access_flags.is_native()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
    m->clear_native_function();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
    m->set_signature_handler(NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  NOT_PRODUCT(m->set_compiled_invocation_count(0);)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  m->set_interpreter_invocation_count(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  m->invocation_counter()->init();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  m->backedge_counter()->init();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  m->clear_number_of_breakpoints();
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6248
diff changeset
    91
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  assert(m->is_parsable(), "must be parsable here.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  assert(m->size() == size, "wrong size for object");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  // We should not publish an uprasable object's reference
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  // into one that is parsable, since that presents problems
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  // for the concurrent parallel marking and precleaning phases
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  // of concurrent gc (CMS).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  xconst->set_method(m);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  return m;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
void methodKlass::oop_follow_contents(oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  assert (obj->is_method(), "object must be method");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  methodOop m = methodOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  // Performance tweak: We skip iterating over the klass pointer since we
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  // know that Universe::methodKlassObj never moves.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  MarkSweep::mark_and_push(m->adr_constMethod());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  MarkSweep::mark_and_push(m->adr_constants());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  if (m->method_data() != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
    MarkSweep::mark_and_push(m->adr_method_data());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
#ifndef SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
void methodKlass::oop_follow_contents(ParCompactionManager* cm,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
                                      oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  assert (obj->is_method(), "object must be method");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  methodOop m = methodOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  // Performance tweak: We skip iterating over the klass pointer since we
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  // know that Universe::methodKlassObj never moves.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  PSParallelCompact::mark_and_push(cm, m->adr_constMethod());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  PSParallelCompact::mark_and_push(cm, m->adr_constants());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
#ifdef COMPILER2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  if (m->method_data() != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
    PSParallelCompact::mark_and_push(cm, m->adr_method_data());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
#endif // COMPILER2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
#endif // SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
int methodKlass::oop_oop_iterate(oop obj, OopClosure* blk) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  assert (obj->is_method(), "object must be method");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  methodOop m = methodOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  // Get size before changing pointers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  // Don't call size() or oop_size() since that is a virtual call.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  int size = m->object_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  // Performance tweak: We skip iterating over the klass pointer since we
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  // know that Universe::methodKlassObj never moves
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  blk->do_oop(m->adr_constMethod());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  blk->do_oop(m->adr_constants());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  if (m->method_data() != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
    blk->do_oop(m->adr_method_data());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  return size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
int methodKlass::oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  assert (obj->is_method(), "object must be method");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  methodOop m = methodOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  // Get size before changing pointers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  // Don't call size() or oop_size() since that is a virtual call.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  int size = m->object_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  // Performance tweak: We skip iterating over the klass pointer since we
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  // know that Universe::methodKlassObj never moves.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  oop* adr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  adr = m->adr_constMethod();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  if (mr.contains(adr)) blk->do_oop(adr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  adr = m->adr_constants();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  if (mr.contains(adr)) blk->do_oop(adr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  if (m->method_data() != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
    adr = m->adr_method_data();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
    if (mr.contains(adr)) blk->do_oop(adr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  return size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
int methodKlass::oop_adjust_pointers(oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  assert(obj->is_method(), "should be method");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  methodOop m = methodOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  // Get size before changing pointers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  // Don't call size() or oop_size() since that is a virtual call.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  int size = m->object_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  // Performance tweak: We skip iterating over the klass pointer since we
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  // know that Universe::methodKlassObj never moves.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  MarkSweep::adjust_pointer(m->adr_constMethod());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  MarkSweep::adjust_pointer(m->adr_constants());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  if (m->method_data() != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
    MarkSweep::adjust_pointer(m->adr_method_data());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  return size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
#ifndef SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
void methodKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  assert(obj->is_method(), "should be method");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
int methodKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  assert(obj->is_method(), "should be method");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  methodOop m = methodOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  PSParallelCompact::adjust_pointer(m->adr_constMethod());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  PSParallelCompact::adjust_pointer(m->adr_constants());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
#ifdef COMPILER2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  if (m->method_data() != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
    PSParallelCompact::adjust_pointer(m->adr_method_data());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
#endif // COMPILER2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  return m->object_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
int methodKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
                                     HeapWord* beg_addr, HeapWord* end_addr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  assert(obj->is_method(), "should be method");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  oop* p;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  methodOop m = methodOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  p = m->adr_constMethod();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  p = m->adr_constants();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
#ifdef COMPILER2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  if (m->method_data() != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
    p = m->adr_method_data();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
    PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
#endif // COMPILER2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  return m->object_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
#endif // SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
// Printing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
void methodKlass::oop_print_on(oop obj, outputStream* st) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
  ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
  assert(obj->is_method(), "must be method");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  Klass::oop_print_on(obj, st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  methodOop m = methodOop(obj);
5420
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 4584
diff changeset
   235
  // get the effect of PrintOopAddress, always, for methods:
5696
93e15b419ad4 6957004: MethodComparator uses the wrong CP index accessor
jrose
parents: 5420
diff changeset
   236
  st->print_cr(" - this oop:          "INTPTR_FORMAT, (intptr_t)m);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  st->print   (" - method holder:     ");    m->method_holder()->print_value_on(st); st->cr();
5420
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 4584
diff changeset
   238
  st->print   (" - constants:         "INTPTR_FORMAT" ", (address)m->constants());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
  m->constants()->print_value_on(st); st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  st->print   (" - access:            0x%x  ", m->access_flags().as_int()); m->access_flags().print_on(st); st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  st->print   (" - name:              ");    m->name()->print_value_on(st); st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  st->print   (" - signature:         ");    m->signature()->print_value_on(st); st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
  st->print_cr(" - max stack:         %d",   m->max_stack());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  st->print_cr(" - max locals:        %d",   m->max_locals());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  st->print_cr(" - size of params:    %d",   m->size_of_parameters());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  st->print_cr(" - method size:       %d",   m->method_size());
5420
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 4584
diff changeset
   247
  if (m->intrinsic_id() != vmIntrinsics::_none)
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 4584
diff changeset
   248
    st->print_cr(" - intrinsic id:      %d %s", m->intrinsic_id(), vmIntrinsics::name_at(m->intrinsic_id()));
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6248
diff changeset
   249
  if (m->highest_comp_level() != CompLevel_none)
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6248
diff changeset
   250
    st->print_cr(" - highest level:     %d", m->highest_comp_level());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
  st->print_cr(" - vtable index:      %d",   m->_vtable_index);
2332
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1
diff changeset
   252
  st->print_cr(" - i2i entry:         " INTPTR_FORMAT, m->interpreter_entry());
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1
diff changeset
   253
  st->print_cr(" - adapter:           " INTPTR_FORMAT, m->adapter());
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1
diff changeset
   254
  st->print_cr(" - compiled entry     " INTPTR_FORMAT, m->from_compiled_entry());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  st->print_cr(" - code size:         %d",   m->code_size());
2332
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1
diff changeset
   256
  if (m->code_size() != 0) {
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1
diff changeset
   257
    st->print_cr(" - code start:        " INTPTR_FORMAT, m->code_base());
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1
diff changeset
   258
    st->print_cr(" - code end (excl):   " INTPTR_FORMAT, m->code_base() + m->code_size());
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1
diff changeset
   259
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  if (m->method_data() != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
    st->print_cr(" - method data:       " INTPTR_FORMAT, (address)m->method_data());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  st->print_cr(" - checked ex length: %d",   m->checked_exceptions_length());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
  if (m->checked_exceptions_length() > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
    CheckedExceptionElement* table = m->checked_exceptions_start();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
    st->print_cr(" - checked ex start:  " INTPTR_FORMAT, table);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
    if (Verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
      for (int i = 0; i < m->checked_exceptions_length(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
        st->print_cr("   - throws %s", m->constants()->printable_name_at(table[i].class_cp_index));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
  if (m->has_linenumber_table()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
    u_char* table = m->compressed_linenumber_table();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
    st->print_cr(" - linenumber start:  " INTPTR_FORMAT, table);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
    if (Verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
      CompressedLineNumberReadStream stream(table);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
      while (stream.read_pair()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
        st->print_cr("   - line %d: %d", stream.line(), stream.bci());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
  st->print_cr(" - localvar length:   %d",   m->localvariable_table_length());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
  if (m->localvariable_table_length() > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
    LocalVariableTableElement* table = m->localvariable_table_start();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
    st->print_cr(" - localvar start:    " INTPTR_FORMAT, table);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
    if (Verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
      for (int i = 0; i < m->localvariable_table_length(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
        int bci = table[i].start_bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
        int len = table[i].length;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
        const char* name = m->constants()->printable_name_at(table[i].name_cp_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
        const char* desc = m->constants()->printable_name_at(table[i].descriptor_cp_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
        int slot = table[i].slot;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
        st->print_cr("   - %s %s bci=%d len=%d slot=%d", desc, name, bci, len, slot);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  if (m->code() != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
    st->print   (" - compiled code: ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
    m->code()->print_value_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
    st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
  }
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 2332
diff changeset
   303
  if (m->is_method_handle_invoke()) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 2332
diff changeset
   304
    st->print_cr(" - invoke method type: " INTPTR_FORMAT, (address) m->method_handle_type());
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 2332
diff changeset
   305
    // m is classified as native, but it does not have an interesting
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 2332
diff changeset
   306
    // native_function or signature handler
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 2332
diff changeset
   307
  } else if (m->is_native()) {
2332
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1
diff changeset
   308
    st->print_cr(" - native function:   " INTPTR_FORMAT, m->native_function());
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1
diff changeset
   309
    st->print_cr(" - signature handler: " INTPTR_FORMAT, m->signature_handler());
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1
diff changeset
   310
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
4584
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 3273
diff changeset
   313
#endif //PRODUCT
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
void methodKlass::oop_print_value_on(oop obj, outputStream* st) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
  assert(obj->is_method(), "must be method");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
  Klass::oop_print_value_on(obj, st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
  methodOop m = methodOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
  st->print(" ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
  m->name()->print_value_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
  st->print(" ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
  m->signature()->print_value_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
  st->print(" in ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
  m->method_holder()->print_value_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
  if (WizardMode) st->print("[%d,%d]", m->size_of_parameters(), m->max_locals());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
  if (WizardMode && m->code() != NULL) st->print(" ((nmethod*)%p)", m->code());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
const char* methodKlass::internal_name() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
  return "{method}";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
// Verification
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
void methodKlass::oop_verify_on(oop obj, outputStream* st) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
  Klass::oop_verify_on(obj, st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
  guarantee(obj->is_method(), "object must be method");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
  if (!obj->partially_loaded()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
    methodOop m = methodOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
    guarantee(m->is_perm(),  "should be in permspace");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
    guarantee(m->name()->is_perm(), "should be in permspace");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
    guarantee(m->name()->is_symbol(), "should be symbol");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
    guarantee(m->signature()->is_perm(), "should be in permspace");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
    guarantee(m->signature()->is_symbol(), "should be symbol");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
    guarantee(m->constants()->is_perm(), "should be in permspace");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
    guarantee(m->constants()->is_constantPool(), "should be constant pool");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
    guarantee(m->constMethod()->is_constMethod(), "should be constMethodOop");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
    guarantee(m->constMethod()->is_perm(), "should be in permspace");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
    methodDataOop method_data = m->method_data();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
    guarantee(method_data == NULL ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
              method_data->is_perm(), "should be in permspace");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
    guarantee(method_data == NULL ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
              method_data->is_methodData(), "should be method data");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
bool methodKlass::oop_partially_loaded(oop obj) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
  assert(obj->is_method(), "object must be method");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
  methodOop m = methodOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
  constMethodOop xconst = m->constMethod();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
  assert(xconst != NULL, "const method must be set");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
  constMethodKlass* ck = constMethodKlass::cast(xconst->klass());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
  return ck->oop_partially_loaded(xconst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
void methodKlass::oop_set_partially_loaded(oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
  assert(obj->is_method(), "object must be method");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
  methodOop m = methodOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
  constMethodOop xconst = m->constMethod();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
  assert(xconst != NULL, "const method must be set");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
  constMethodKlass* ck = constMethodKlass::cast(xconst->klass());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
  ck->oop_set_partially_loaded(xconst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
}