hotspot/src/share/vm/interpreter/rewriter.cpp
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 1 489c9b5090e2
child 2006 f2d2f0f20063
permissions -rw-r--r--
Initial load
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 1998-2005 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/_rewriter.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
// Computes an index_map (new_index -> original_index) for contant pool entries
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
// that are referred to by the interpreter at runtime via the constant pool cache.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
void Rewriter::compute_index_maps(constantPoolHandle pool, intArray*& index_map, intStack*& inverse_index_map) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
  const int length  = pool->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
  index_map         = new intArray(length, -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
  // Choose an initial value large enough that we don't get frequent
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
  // calls to grow().
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
  inverse_index_map = new intStack(length / 2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
  for (int i = 0; i < length; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
    switch (pool->tag_at(i).value()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
      case JVM_CONSTANT_Fieldref          : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
      case JVM_CONSTANT_Methodref         : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
      case JVM_CONSTANT_InterfaceMethodref: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
        index_map->at_put(i, inverse_index_map->length());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
        inverse_index_map->append(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
// Creates a constant pool cache given an inverse_index_map
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
constantPoolCacheHandle Rewriter::new_constant_pool_cache(intArray& inverse_index_map, TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  const int length = inverse_index_map.length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  constantPoolCacheOop cache = oopFactory::new_constantPoolCache(length, CHECK_(constantPoolCacheHandle()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  cache->initialize(inverse_index_map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  return constantPoolCacheHandle(THREAD, cache);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
// The new finalization semantics says that registration of
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
// finalizable objects must be performed on successful return from the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
// Object.<init> constructor.  We could implement this trivially if
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
// <init> were never rewritten but since JVMTI allows this to occur, a
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
// more complicated solution is required.  A special return bytecode
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
// is used only by Object.<init> to signal the finalization
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
// registration point.  Additionally local 0 must be preserved so it's
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
// available to pass to the registration function.  For simplicty we
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
// require that local 0 is never overwritten so it's available as an
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
// argument for registration.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
void Rewriter::rewrite_Object_init(methodHandle method, TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  RawBytecodeStream bcs(method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  while (!bcs.is_last_bytecode()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
    Bytecodes::Code opcode = bcs.raw_next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
    switch (opcode) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
      case Bytecodes::_return: *bcs.bcp() = Bytecodes::_return_register_finalizer; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
      case Bytecodes::_istore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
      case Bytecodes::_lstore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
      case Bytecodes::_fstore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
      case Bytecodes::_dstore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
      case Bytecodes::_astore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
        if (bcs.get_index() != 0) continue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
        // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
      case Bytecodes::_istore_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
      case Bytecodes::_lstore_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
      case Bytecodes::_fstore_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
      case Bytecodes::_dstore_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
      case Bytecodes::_astore_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
        THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
                  "can't overwrite local 0 in Object.<init>");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
// Rewrites a method given the index_map information
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
methodHandle Rewriter::rewrite_method(methodHandle method, intArray& index_map, TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  int nof_jsrs = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  bool has_monitor_bytecodes = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
    // We cannot tolerate a GC in this block, because we've
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
    // cached the bytecodes in 'code_base'. If the methodOop
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
    // moves, the bytecodes will also move.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
    No_Safepoint_Verifier nsv;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
    Bytecodes::Code c;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
    // Bytecodes and their length
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
    const address code_base = method->code_base();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
    const int code_length = method->code_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
    int bc_length;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
    for (int bci = 0; bci < code_length; bci += bc_length) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
      address bcp = code_base + bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
      c = (Bytecodes::Code)(*bcp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
      // Since we have the code, see if we can get the length
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
      // directly. Some more complicated bytecodes will report
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
      // a length of zero, meaning we need to make another method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
      // call to calculate the length.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
      bc_length = Bytecodes::length_for(c);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
      if (bc_length == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
        bc_length = Bytecodes::length_at(bcp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
        // length_at will put us at the bytecode after the one modified
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
        // by 'wide'. We don't currently examine any of the bytecodes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
        // modified by wide, but in case we do in the future...
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
        if (c == Bytecodes::_wide) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
          c = (Bytecodes::Code)bcp[1];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
      assert(bc_length != 0, "impossible bytecode length");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
      switch (c) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
        case Bytecodes::_lookupswitch   : {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
#ifndef CC_INTERP
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
          Bytecode_lookupswitch* bc = Bytecode_lookupswitch_at(bcp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
          bc->set_code(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
            bc->number_of_pairs() < BinarySwitchThreshold
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
            ? Bytecodes::_fast_linearswitch
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
            : Bytecodes::_fast_binaryswitch
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
          );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
        case Bytecodes::_getstatic      : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
        case Bytecodes::_putstatic      : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
        case Bytecodes::_getfield       : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
        case Bytecodes::_putfield       : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
        case Bytecodes::_invokevirtual  : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
        case Bytecodes::_invokespecial  : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
        case Bytecodes::_invokestatic   : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
        case Bytecodes::_invokeinterface: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
          address p = bcp + 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
          Bytes::put_native_u2(p, index_map[Bytes::get_Java_u2(p)]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
        case Bytecodes::_jsr            : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
        case Bytecodes::_jsr_w          : nof_jsrs++;                   break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
        case Bytecodes::_monitorenter   : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
        case Bytecodes::_monitorexit    : has_monitor_bytecodes = true; break;
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
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  // Update access flags
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  if (has_monitor_bytecodes) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
    method->set_has_monitor_bytecodes();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  // The present of a jsr bytecode implies that the method might potentially
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  // have to be rewritten, so we run the oopMapGenerator on the method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  if (nof_jsrs > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
    method->set_has_jsrs();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
    ResolveOopMapConflicts romc(method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
    methodHandle original_method = method;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
    method = romc.do_potential_rewrite(CHECK_(methodHandle()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
    if (method() != original_method()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
      // Insert invalid bytecode into original methodOop and set
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
      // interpreter entrypoint, so that a executing this method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
      // will manifest itself in an easy recognizable form.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
      address bcp = original_method->bcp_from(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
      *bcp = (u1)Bytecodes::_shouldnotreachhere;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
      int kind = Interpreter::method_kind(original_method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
      original_method->set_interpreter_kind(kind);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
    // Update monitor matching info.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
    if (romc.monitor_safe()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
      method->set_guaranteed_monitor_matching();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  // Setup method entrypoints for compiler and interpreter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  method->link_method(method, CHECK_(methodHandle()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  return method;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
void Rewriter::rewrite(instanceKlassHandle klass, TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  // gather starting points
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  ResourceMark rm(THREAD);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  constantPoolHandle pool (THREAD, klass->constants());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  objArrayHandle methods  (THREAD, klass->methods());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  assert(pool->cache() == NULL, "constant pool cache must not be set yet");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  // determine index maps for methodOop rewriting
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
  intArray* index_map         = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  intStack* inverse_index_map = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
  compute_index_maps(pool, index_map, inverse_index_map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  // allocate constant pool cache
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  constantPoolCacheHandle cache = new_constant_pool_cache(*inverse_index_map, CHECK);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
  pool->set_cache(cache());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  cache->set_constant_pool(pool());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
  if (RegisterFinalizersAtInit && klass->name() == vmSymbols::java_lang_Object()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
    int i = methods->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
    while (i-- > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
      methodOop method = (methodOop)methods->obj_at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
      if (method->intrinsic_id() == vmIntrinsics::_Object_init) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
        // rewrite the return bytecodes of Object.<init> to register the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
        // object for finalization if needed.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
        methodHandle m(THREAD, method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
        rewrite_Object_init(m, CHECK);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  // rewrite methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  { int i = methods->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
    while (i-- > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
      methodHandle m(THREAD, (methodOop)methods->obj_at(i));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
      m = rewrite_method(m, *index_map, CHECK);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
      // Method might have gotten rewritten.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
      methods->obj_at_put(i, m());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
}