hotspot/src/share/vm/code/compiledMethod.cpp
author redestad
Tue, 04 Jul 2017 18:36:50 +0200
changeset 46623 261b9d05b79d
parent 42650 1f304d0c888b
child 46630 75aa3e39d02c
permissions -rw-r--r--
8183299: Improve inlining of CompiledMethod methods into frame::sender Reviewed-by: kvn, neliasso
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
     1
/*
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
     2
 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
     4
 *
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
     7
 * published by the Free Software Foundation.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
     8
 *
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    13
 * accompanied this code).
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    14
 *
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    18
 *
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    21
 * questions.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    22
 *
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    23
 */
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    24
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    25
#include "precompiled.hpp"
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    26
#include "code/compiledIC.hpp"
46623
261b9d05b79d 8183299: Improve inlining of CompiledMethod methods into frame::sender
redestad
parents: 42650
diff changeset
    27
#include "code/compiledMethod.inline.hpp"
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    28
#include "code/scopeDesc.hpp"
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    29
#include "code/codeCache.hpp"
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    30
#include "prims/methodHandles.hpp"
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    31
#include "interpreter/bytecode.hpp"
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    32
#include "memory/resourceArea.hpp"
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    33
#include "runtime/mutexLocker.hpp"
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    34
42040
70ec5a09a0d5 8166377: is_compiled_by_jvmci hot in some profiles - improve nmethod compiler type detection
neliasso
parents: 39430
diff changeset
    35
CompiledMethod::CompiledMethod(Method* method, const char* name, CompilerType type, const CodeBlobLayout& layout, int frame_complete_offset, int frame_size, ImmutableOopMapSet* oop_maps, bool caller_must_gc_arguments)
70ec5a09a0d5 8166377: is_compiled_by_jvmci hot in some profiles - improve nmethod compiler type detection
neliasso
parents: 39430
diff changeset
    36
  : CodeBlob(name, type, layout, frame_complete_offset, frame_size, oop_maps, caller_must_gc_arguments),
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    37
  _method(method), _mark_for_deoptimization_status(not_marked) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    38
  init_defaults();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    39
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    40
42040
70ec5a09a0d5 8166377: is_compiled_by_jvmci hot in some profiles - improve nmethod compiler type detection
neliasso
parents: 39430
diff changeset
    41
CompiledMethod::CompiledMethod(Method* method, const char* name, CompilerType type, int size, int header_size, CodeBuffer* cb, int frame_complete_offset, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments)
70ec5a09a0d5 8166377: is_compiled_by_jvmci hot in some profiles - improve nmethod compiler type detection
neliasso
parents: 39430
diff changeset
    42
  : CodeBlob(name, type, CodeBlobLayout((address) this, size, header_size, cb), cb, frame_complete_offset, frame_size, oop_maps, caller_must_gc_arguments),
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    43
  _method(method), _mark_for_deoptimization_status(not_marked) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    44
  init_defaults();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    45
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    46
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    47
void CompiledMethod::init_defaults() {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    48
  _has_unsafe_access          = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    49
  _has_method_handle_invokes  = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    50
  _lazy_critical_native       = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    51
  _has_wide_vectors           = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    52
  _unloading_clock            = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    53
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    54
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    55
bool CompiledMethod::is_method_handle_return(address return_pc) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    56
  if (!has_method_handle_invokes())  return false;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    57
  PcDesc* pd = pc_desc_at(return_pc);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    58
  if (pd == NULL)
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    59
    return false;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    60
  return pd->is_method_handle_invoke();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    61
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    62
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    63
// Returns a string version of the method state.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    64
const char* CompiledMethod::state() const {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    65
  int state = get_state();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    66
  switch (state) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    67
  case in_use:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    68
    return "in use";
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    69
  case not_used:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    70
    return "not_used";
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    71
  case not_entrant:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    72
    return "not_entrant";
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    73
  case zombie:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    74
    return "zombie";
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    75
  case unloaded:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    76
    return "unloaded";
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    77
  default:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    78
    fatal("unexpected method state: %d", state);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    79
    return NULL;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    80
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    81
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    82
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    83
//-----------------------------------------------------------------------------
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    84
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    85
void CompiledMethod::add_exception_cache_entry(ExceptionCache* new_entry) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    86
  assert(ExceptionCache_lock->owned_by_self(),"Must hold the ExceptionCache_lock");
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    87
  assert(new_entry != NULL,"Must be non null");
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    88
  assert(new_entry->next() == NULL, "Must be null");
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    89
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    90
  ExceptionCache *ec = exception_cache();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    91
  if (ec != NULL) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    92
    new_entry->set_next(ec);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    93
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    94
  release_set_exception_cache(new_entry);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    95
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    96
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    97
void CompiledMethod::clean_exception_cache(BoolObjectClosure* is_alive) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    98
  ExceptionCache* prev = NULL;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    99
  ExceptionCache* curr = exception_cache();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   100
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   101
  while (curr != NULL) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   102
    ExceptionCache* next = curr->next();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   103
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   104
    Klass* ex_klass = curr->exception_type();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   105
    if (ex_klass != NULL && !ex_klass->is_loader_alive(is_alive)) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   106
      if (prev == NULL) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   107
        set_exception_cache(next);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   108
      } else {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   109
        prev->set_next(next);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   110
      }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   111
      delete curr;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   112
      // prev stays the same.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   113
    } else {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   114
      prev = curr;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   115
    }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   116
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   117
    curr = next;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   118
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   119
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   120
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   121
// public method for accessing the exception cache
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   122
// These are the public access methods.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   123
address CompiledMethod::handler_for_exception_and_pc(Handle exception, address pc) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   124
  // We never grab a lock to read the exception cache, so we may
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   125
  // have false negatives. This is okay, as it can only happen during
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   126
  // the first few exception lookups for a given nmethod.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   127
  ExceptionCache* ec = exception_cache();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   128
  while (ec != NULL) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   129
    address ret_val;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   130
    if ((ret_val = ec->match(exception,pc)) != NULL) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   131
      return ret_val;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   132
    }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   133
    ec = ec->next();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   134
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   135
  return NULL;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   136
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   137
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   138
void CompiledMethod::add_handler_for_exception_and_pc(Handle exception, address pc, address handler) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   139
  // There are potential race conditions during exception cache updates, so we
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   140
  // must own the ExceptionCache_lock before doing ANY modifications. Because
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   141
  // we don't lock during reads, it is possible to have several threads attempt
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   142
  // to update the cache with the same data. We need to check for already inserted
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   143
  // copies of the current data before adding it.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   144
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   145
  MutexLocker ml(ExceptionCache_lock);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   146
  ExceptionCache* target_entry = exception_cache_entry_for_exception(exception);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   147
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   148
  if (target_entry == NULL || !target_entry->add_address_and_handler(pc,handler)) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   149
    target_entry = new ExceptionCache(exception,pc,handler);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   150
    add_exception_cache_entry(target_entry);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   151
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   152
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   153
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   154
//-------------end of code for ExceptionCache--------------
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   155
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   156
// private method for handling exception cache
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   157
// These methods are private, and used to manipulate the exception cache
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   158
// directly.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   159
ExceptionCache* CompiledMethod::exception_cache_entry_for_exception(Handle exception) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   160
  ExceptionCache* ec = exception_cache();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   161
  while (ec != NULL) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   162
    if (ec->match_exception_with_space(exception)) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   163
      return ec;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   164
    }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   165
    ec = ec->next();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   166
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   167
  return NULL;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   168
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   169
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   170
bool CompiledMethod::is_at_poll_return(address pc) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   171
  RelocIterator iter(this, pc, pc+1);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   172
  while (iter.next()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   173
    if (iter.type() == relocInfo::poll_return_type)
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   174
      return true;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   175
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   176
  return false;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   177
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   178
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   179
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   180
bool CompiledMethod::is_at_poll_or_poll_return(address pc) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   181
  RelocIterator iter(this, pc, pc+1);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   182
  while (iter.next()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   183
    relocInfo::relocType t = iter.type();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   184
    if (t == relocInfo::poll_return_type || t == relocInfo::poll_type)
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   185
      return true;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   186
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   187
  return false;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   188
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   189
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   190
void CompiledMethod::verify_oop_relocations() {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   191
  // Ensure sure that the code matches the current oop values
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   192
  RelocIterator iter(this, NULL, NULL);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   193
  while (iter.next()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   194
    if (iter.type() == relocInfo::oop_type) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   195
      oop_Relocation* reloc = iter.oop_reloc();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   196
      if (!reloc->oop_is_immediate()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   197
        reloc->verify_oop_relocation();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   198
      }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   199
    }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   200
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   201
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   202
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   203
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   204
ScopeDesc* CompiledMethod::scope_desc_at(address pc) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   205
  PcDesc* pd = pc_desc_at(pc);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   206
  guarantee(pd != NULL, "scope must be present");
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   207
  return new ScopeDesc(this, pd->scope_decode_offset(),
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   208
                       pd->obj_decode_offset(), pd->should_reexecute(), pd->rethrow_exception(),
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   209
                       pd->return_oop());
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   210
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   211
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   212
void CompiledMethod::cleanup_inline_caches(bool clean_all/*=false*/) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   213
  assert_locked_or_safepoint(CompiledIC_lock);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   214
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   215
  // If the method is not entrant or zombie then a JMP is plastered over the
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   216
  // first few bytes.  If an oop in the old code was there, that oop
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   217
  // should not get GC'd.  Skip the first few bytes of oops on
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   218
  // not-entrant methods.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   219
  address low_boundary = verified_entry_point();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   220
  if (!is_in_use() && is_nmethod()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   221
    low_boundary += NativeJump::instruction_size;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   222
    // %%% Note:  On SPARC we patch only a 4-byte trap, not a full NativeJump.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   223
    // This means that the low_boundary is going to be a little too high.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   224
    // This shouldn't matter, since oops of non-entrant methods are never used.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   225
    // In fact, why are we bothering to look at oops in a non-entrant method??
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   226
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   227
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   228
  // Find all calls in an nmethod and clear the ones that point to non-entrant,
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   229
  // zombie and unloaded nmethods.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   230
  ResourceMark rm;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   231
  RelocIterator iter(this, low_boundary);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   232
  while(iter.next()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   233
    switch(iter.type()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   234
      case relocInfo::virtual_call_type:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   235
      case relocInfo::opt_virtual_call_type: {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   236
        CompiledIC *ic = CompiledIC_at(&iter);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   237
        // Ok, to lookup references to zombies here
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   238
        CodeBlob *cb = CodeCache::find_blob_unsafe(ic->ic_destination());
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   239
        if( cb != NULL && cb->is_compiled() ) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   240
          CompiledMethod* nm = cb->as_compiled_method();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   241
          // Clean inline caches pointing to zombie, non-entrant and unloaded methods
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   242
          if (clean_all || !nm->is_in_use() || (nm->method()->code() != nm)) ic->set_to_clean(is_alive());
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   243
        }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   244
        break;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   245
      }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   246
      case relocInfo::static_call_type: {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   247
          CompiledStaticCall *csc = compiledStaticCall_at(iter.reloc());
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   248
          CodeBlob *cb = CodeCache::find_blob_unsafe(csc->destination());
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   249
          if( cb != NULL && cb->is_compiled() ) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   250
            CompiledMethod* cm = cb->as_compiled_method();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   251
            // Clean inline caches pointing to zombie, non-entrant and unloaded methods
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   252
            if (clean_all || !cm->is_in_use() || (cm->method()->code() != cm)) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   253
              csc->set_to_clean();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   254
            }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   255
          }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   256
        break;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   257
      }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   258
    }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   259
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   260
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   261
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   262
int CompiledMethod::verify_icholder_relocations() {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   263
  ResourceMark rm;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   264
  int count = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   265
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   266
  RelocIterator iter(this);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   267
  while(iter.next()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   268
    if (iter.type() == relocInfo::virtual_call_type) {
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42040
diff changeset
   269
      if (CompiledIC::is_icholder_call_site(iter.virtual_call_reloc(), this)) {
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   270
        CompiledIC *ic = CompiledIC_at(&iter);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   271
        if (TraceCompiledIC) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   272
          tty->print("noticed icholder " INTPTR_FORMAT " ", p2i(ic->cached_icholder()));
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   273
          ic->print();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   274
        }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   275
        assert(ic->cached_icholder() != NULL, "must be non-NULL");
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   276
        count++;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   277
      }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   278
    }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   279
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   280
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   281
  return count;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   282
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   283
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   284
// Method that knows how to preserve outgoing arguments at call. This method must be
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   285
// called with a frame corresponding to a Java invoke
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   286
void CompiledMethod::preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   287
#ifndef SHARK
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   288
  if (method() != NULL && !method()->is_native()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   289
    address pc = fr.pc();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   290
    SimpleScopeDesc ssd(this, pc);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   291
    Bytecode_invoke call(ssd.method(), ssd.bci());
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   292
    bool has_receiver = call.has_receiver();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   293
    bool has_appendix = call.has_appendix();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   294
    Symbol* signature = call.signature();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   295
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   296
    // The method attached by JIT-compilers should be used, if present.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   297
    // Bytecode can be inaccurate in such case.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   298
    Method* callee = attached_method_before_pc(pc);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   299
    if (callee != NULL) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   300
      has_receiver = !(callee->access_flags().is_static());
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   301
      has_appendix = false;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   302
      signature = callee->signature();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   303
    }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   304
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   305
    fr.oops_compiled_arguments_do(signature, has_receiver, has_appendix, reg_map, f);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   306
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   307
#endif // !SHARK
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   308
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   309
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   310
Method* CompiledMethod::attached_method(address call_instr) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   311
  assert(code_contains(call_instr), "not part of the nmethod");
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   312
  RelocIterator iter(this, call_instr, call_instr + 1);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   313
  while (iter.next()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   314
    if (iter.addr() == call_instr) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   315
      switch(iter.type()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   316
        case relocInfo::static_call_type:      return iter.static_call_reloc()->method_value();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   317
        case relocInfo::opt_virtual_call_type: return iter.opt_virtual_call_reloc()->method_value();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   318
        case relocInfo::virtual_call_type:     return iter.virtual_call_reloc()->method_value();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   319
      }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   320
    }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   321
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   322
  return NULL; // not found
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   323
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   324
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   325
Method* CompiledMethod::attached_method_before_pc(address pc) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   326
  if (NativeCall::is_call_before(pc)) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   327
    NativeCall* ncall = nativeCall_before(pc);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   328
    return attached_method(ncall->instruction_address());
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   329
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   330
  return NULL; // not a call
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   331
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   332
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   333
void CompiledMethod::clear_inline_caches() {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   334
  assert(SafepointSynchronize::is_at_safepoint(), "cleaning of IC's only allowed at safepoint");
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   335
  if (is_zombie()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   336
    return;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   337
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   338
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   339
  RelocIterator iter(this);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   340
  while (iter.next()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   341
    iter.reloc()->clear_inline_cache();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   342
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   343
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   344
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   345
// Clear ICStubs of all compiled ICs
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   346
void CompiledMethod::clear_ic_stubs() {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   347
  assert_locked_or_safepoint(CompiledIC_lock);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   348
  RelocIterator iter(this);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   349
  while(iter.next()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   350
    if (iter.type() == relocInfo::virtual_call_type) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   351
      CompiledIC* ic = CompiledIC_at(&iter);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   352
      ic->clear_ic_stub();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   353
    }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   354
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   355
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   356
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   357
#ifdef ASSERT
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   358
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   359
class CheckClass : AllStatic {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   360
  static BoolObjectClosure* _is_alive;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   361
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   362
  // Check class_loader is alive for this bit of metadata.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   363
  static void check_class(Metadata* md) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   364
    Klass* klass = NULL;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   365
    if (md->is_klass()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   366
      klass = ((Klass*)md);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   367
    } else if (md->is_method()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   368
      klass = ((Method*)md)->method_holder();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   369
    } else if (md->is_methodData()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   370
      klass = ((MethodData*)md)->method()->method_holder();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   371
    } else {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   372
      md->print();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   373
      ShouldNotReachHere();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   374
    }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   375
    assert(klass->is_loader_alive(_is_alive), "must be alive");
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   376
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   377
 public:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   378
  static void do_check_class(BoolObjectClosure* is_alive, CompiledMethod* nm) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   379
    assert(SafepointSynchronize::is_at_safepoint(), "this is only ok at safepoint");
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   380
    _is_alive = is_alive;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   381
    nm->metadata_do(check_class);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   382
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   383
};
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   384
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   385
// This is called during a safepoint so can use static data
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   386
BoolObjectClosure* CheckClass::_is_alive = NULL;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   387
#endif // ASSERT
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   388
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42040
diff changeset
   389
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   390
void CompiledMethod::clean_ic_if_metadata_is_dead(CompiledIC *ic, BoolObjectClosure *is_alive) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   391
  if (ic->is_icholder_call()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   392
    // The only exception is compiledICHolder oops which may
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   393
    // yet be marked below. (We check this further below).
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   394
    CompiledICHolder* cichk_oop = ic->cached_icholder();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   395
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   396
    if (cichk_oop->holder_method()->method_holder()->is_loader_alive(is_alive) &&
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   397
        cichk_oop->holder_klass()->is_loader_alive(is_alive)) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   398
      return;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   399
    }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   400
  } else {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   401
    Metadata* ic_oop = ic->cached_metadata();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   402
    if (ic_oop != NULL) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   403
      if (ic_oop->is_klass()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   404
        if (((Klass*)ic_oop)->is_loader_alive(is_alive)) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   405
          return;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   406
        }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   407
      } else if (ic_oop->is_method()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   408
        if (((Method*)ic_oop)->method_holder()->is_loader_alive(is_alive)) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   409
          return;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   410
        }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   411
      } else {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   412
        ShouldNotReachHere();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   413
      }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   414
    }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   415
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   416
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   417
  ic->set_to_clean();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   418
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   419
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   420
unsigned char CompiledMethod::_global_unloading_clock = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   421
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   422
void CompiledMethod::increase_unloading_clock() {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   423
  _global_unloading_clock++;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   424
  if (_global_unloading_clock == 0) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   425
    // _nmethods are allocated with _unloading_clock == 0,
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   426
    // so 0 is never used as a clock value.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   427
    _global_unloading_clock = 1;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   428
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   429
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   430
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   431
void CompiledMethod::set_unloading_clock(unsigned char unloading_clock) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   432
  OrderAccess::release_store((volatile jubyte*)&_unloading_clock, unloading_clock);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   433
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   434
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   435
unsigned char CompiledMethod::unloading_clock() {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   436
  return (unsigned char)OrderAccess::load_acquire((volatile jubyte*)&_unloading_clock);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   437
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   438
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   439
// Processing of oop references should have been sufficient to keep
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   440
// all strong references alive.  Any weak references should have been
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   441
// cleared as well.  Visit all the metadata and ensure that it's
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   442
// really alive.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   443
void CompiledMethod::verify_metadata_loaders(address low_boundary, BoolObjectClosure* is_alive) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   444
#ifdef ASSERT
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   445
    RelocIterator iter(this, low_boundary);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   446
    while (iter.next()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   447
    // static_stub_Relocations may have dangling references to
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   448
    // Method*s so trim them out here.  Otherwise it looks like
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   449
    // compiled code is maintaining a link to dead metadata.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   450
    address static_call_addr = NULL;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   451
    if (iter.type() == relocInfo::opt_virtual_call_type) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   452
      CompiledIC* cic = CompiledIC_at(&iter);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   453
      if (!cic->is_call_to_interpreted()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   454
        static_call_addr = iter.addr();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   455
      }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   456
    } else if (iter.type() == relocInfo::static_call_type) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   457
      CompiledStaticCall* csc = compiledStaticCall_at(iter.reloc());
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   458
      if (!csc->is_call_to_interpreted()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   459
        static_call_addr = iter.addr();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   460
      }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   461
    }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   462
    if (static_call_addr != NULL) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   463
      RelocIterator sciter(this, low_boundary);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   464
      while (sciter.next()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   465
        if (sciter.type() == relocInfo::static_stub_type &&
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   466
            sciter.static_stub_reloc()->static_call() == static_call_addr) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   467
          sciter.static_stub_reloc()->clear_inline_cache();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   468
        }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   469
      }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   470
    }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   471
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   472
  // Check that the metadata embedded in the nmethod is alive
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   473
  CheckClass::do_check_class(is_alive, this);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   474
#endif
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   475
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   476
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   477
// This is called at the end of the strong tracing/marking phase of a
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   478
// GC to unload an nmethod if it contains otherwise unreachable
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   479
// oops.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   480
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   481
void CompiledMethod::do_unloading(BoolObjectClosure* is_alive, bool unloading_occurred) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   482
  // Make sure the oop's ready to receive visitors
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   483
  assert(!is_zombie() && !is_unloaded(),
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   484
         "should not call follow on zombie or unloaded nmethod");
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   485
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   486
  // If the method is not entrant then a JMP is plastered over the
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   487
  // first few bytes.  If an oop in the old code was there, that oop
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   488
  // should not get GC'd.  Skip the first few bytes of oops on
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   489
  // not-entrant methods.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   490
  address low_boundary = verified_entry_point();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   491
  if (is_not_entrant()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   492
    low_boundary += NativeJump::instruction_size;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   493
    // %%% Note:  On SPARC we patch only a 4-byte trap, not a full NativeJump.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   494
    // (See comment above.)
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   495
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   496
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   497
  // The RedefineClasses() API can cause the class unloading invariant
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   498
  // to no longer be true. See jvmtiExport.hpp for details.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   499
  // Also, leave a debugging breadcrumb in local flag.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   500
  if (JvmtiExport::has_redefined_a_class()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   501
    // This set of the unloading_occurred flag is done before the
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   502
    // call to post_compiled_method_unload() so that the unloading
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   503
    // of this nmethod is reported.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   504
    unloading_occurred = true;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   505
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   506
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   507
  // Exception cache
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   508
  clean_exception_cache(is_alive);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   509
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   510
  // If class unloading occurred we first iterate over all inline caches and
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   511
  // clear ICs where the cached oop is referring to an unloaded klass or method.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   512
  // The remaining live cached oops will be traversed in the relocInfo::oop_type
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   513
  // iteration below.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   514
  if (unloading_occurred) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   515
    RelocIterator iter(this, low_boundary);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   516
    while(iter.next()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   517
      if (iter.type() == relocInfo::virtual_call_type) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   518
        CompiledIC *ic = CompiledIC_at(&iter);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   519
        clean_ic_if_metadata_is_dead(ic, is_alive);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   520
      }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   521
    }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   522
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   523
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   524
  if (do_unloading_oops(low_boundary, is_alive, unloading_occurred)) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   525
    return;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   526
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   527
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   528
#if INCLUDE_JVMCI
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   529
  if (do_unloading_jvmci(is_alive, unloading_occurred)) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   530
    return;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   531
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   532
#endif
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   533
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   534
  // Ensure that all metadata is still alive
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   535
  verify_metadata_loaders(low_boundary, is_alive);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   536
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   537
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   538
template <class CompiledICorStaticCall>
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   539
static bool clean_if_nmethod_is_unloaded(CompiledICorStaticCall *ic, address addr, BoolObjectClosure *is_alive, CompiledMethod* from) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   540
  // Ok, to lookup references to zombies here
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   541
  CodeBlob *cb = CodeCache::find_blob_unsafe(addr);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   542
  CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   543
  if (nm != NULL) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   544
    if (nm->unloading_clock() != CompiledMethod::global_unloading_clock()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   545
      // The nmethod has not been processed yet.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   546
      return true;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   547
    }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   548
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   549
    // Clean inline caches pointing to both zombie and not_entrant methods
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   550
    if (!nm->is_in_use() || (nm->method()->code() != nm)) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   551
      ic->set_to_clean();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   552
      assert(ic->is_clean(), "nmethod " PTR_FORMAT "not clean %s", p2i(from), from->method()->name_and_sig_as_C_string());
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   553
    }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   554
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   555
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   556
  return false;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   557
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   558
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   559
static bool clean_if_nmethod_is_unloaded(CompiledIC *ic, BoolObjectClosure *is_alive, CompiledMethod* from) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   560
  return clean_if_nmethod_is_unloaded(ic, ic->ic_destination(), is_alive, from);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   561
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   562
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   563
static bool clean_if_nmethod_is_unloaded(CompiledStaticCall *csc, BoolObjectClosure *is_alive, CompiledMethod* from) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   564
  return clean_if_nmethod_is_unloaded(csc, csc->destination(), is_alive, from);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   565
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   566
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   567
bool CompiledMethod::do_unloading_parallel(BoolObjectClosure* is_alive, bool unloading_occurred) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   568
  ResourceMark rm;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   569
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   570
  // Make sure the oop's ready to receive visitors
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   571
  assert(!is_zombie() && !is_unloaded(),
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   572
         "should not call follow on zombie or unloaded nmethod");
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   573
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   574
  // If the method is not entrant then a JMP is plastered over the
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   575
  // first few bytes.  If an oop in the old code was there, that oop
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   576
  // should not get GC'd.  Skip the first few bytes of oops on
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   577
  // not-entrant methods.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   578
  address low_boundary = verified_entry_point();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   579
  if (is_not_entrant()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   580
    low_boundary += NativeJump::instruction_size;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   581
    // %%% Note:  On SPARC we patch only a 4-byte trap, not a full NativeJump.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   582
    // (See comment above.)
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   583
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   584
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   585
  // The RedefineClasses() API can cause the class unloading invariant
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   586
  // to no longer be true. See jvmtiExport.hpp for details.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   587
  // Also, leave a debugging breadcrumb in local flag.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   588
  if (JvmtiExport::has_redefined_a_class()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   589
    // This set of the unloading_occurred flag is done before the
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   590
    // call to post_compiled_method_unload() so that the unloading
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   591
    // of this nmethod is reported.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   592
    unloading_occurred = true;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   593
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   594
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   595
  // Exception cache
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   596
  clean_exception_cache(is_alive);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   597
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   598
  bool postponed = false;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   599
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   600
  RelocIterator iter(this, low_boundary);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   601
  while(iter.next()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   602
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   603
    switch (iter.type()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   604
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   605
    case relocInfo::virtual_call_type:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   606
      if (unloading_occurred) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   607
        // If class unloading occurred we first iterate over all inline caches and
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   608
        // clear ICs where the cached oop is referring to an unloaded klass or method.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   609
        clean_ic_if_metadata_is_dead(CompiledIC_at(&iter), is_alive);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   610
      }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   611
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   612
      postponed |= clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), is_alive, this);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   613
      break;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   614
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   615
    case relocInfo::opt_virtual_call_type:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   616
      postponed |= clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), is_alive, this);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   617
      break;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   618
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   619
    case relocInfo::static_call_type:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   620
      postponed |= clean_if_nmethod_is_unloaded(compiledStaticCall_at(iter.reloc()), is_alive, this);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   621
      break;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   622
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   623
    case relocInfo::oop_type:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   624
      // handled by do_unloading_oops below
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   625
      break;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   626
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   627
    case relocInfo::metadata_type:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   628
      break; // nothing to do.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   629
    }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   630
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   631
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   632
  if (do_unloading_oops(low_boundary, is_alive, unloading_occurred)) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   633
    return postponed;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   634
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   635
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   636
#if INCLUDE_JVMCI
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   637
  if (do_unloading_jvmci(is_alive, unloading_occurred)) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   638
    return postponed;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   639
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   640
#endif
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   641
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   642
  // Ensure that all metadata is still alive
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   643
  verify_metadata_loaders(low_boundary, is_alive);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   644
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   645
  return postponed;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   646
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   647
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   648
void CompiledMethod::do_unloading_parallel_postponed(BoolObjectClosure* is_alive, bool unloading_occurred) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   649
  ResourceMark rm;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   650
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   651
  // Make sure the oop's ready to receive visitors
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   652
  assert(!is_zombie(),
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   653
         "should not call follow on zombie nmethod");
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   654
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   655
  // If the method is not entrant then a JMP is plastered over the
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   656
  // first few bytes.  If an oop in the old code was there, that oop
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   657
  // should not get GC'd.  Skip the first few bytes of oops on
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   658
  // not-entrant methods.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   659
  address low_boundary = verified_entry_point();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   660
  if (is_not_entrant()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   661
    low_boundary += NativeJump::instruction_size;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   662
    // %%% Note:  On SPARC we patch only a 4-byte trap, not a full NativeJump.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   663
    // (See comment above.)
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   664
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   665
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   666
  RelocIterator iter(this, low_boundary);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   667
  while(iter.next()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   668
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   669
    switch (iter.type()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   670
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   671
    case relocInfo::virtual_call_type:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   672
      clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), is_alive, this);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   673
      break;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   674
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   675
    case relocInfo::opt_virtual_call_type:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   676
      clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), is_alive, this);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   677
      break;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   678
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   679
    case relocInfo::static_call_type:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   680
      clean_if_nmethod_is_unloaded(compiledStaticCall_at(iter.reloc()), is_alive, this);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   681
      break;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   682
    }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   683
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   684
}