src/hotspot/share/code/compiledMethod.cpp
author coleenp
Wed, 18 Apr 2018 13:37:39 -0400
changeset 49821 02c08e20d66c
parent 49480 d7df2dd501ce
child 49890 29b94ed63a09
permissions -rw-r--r--
8201537: Remove is_alive closure from Klass::is_loader_alive() Summary: remove is_alive closure from callers of Klass::is_loader_alive so that cleaning metadata doesn't require GC closure. Reviewed-by: adinn, stefank
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
     1
/*
48955
e22914003cf0 8194691: Cleanup unnecessary casts in Atomic/OrderAccess uses
kbarrett
parents: 48557
diff changeset
     2
 * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
38133
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"
49340
4e82736053ae 8191102: Incorrect include file use in classLoader.hpp
hseigel
parents: 48955
diff changeset
    30
#include "interpreter/bytecode.inline.hpp"
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    31
#include "memory/resourceArea.hpp"
49480
d7df2dd501ce 8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents: 49449
diff changeset
    32
#include "oops/methodData.hpp"
49340
4e82736053ae 8191102: Incorrect include file use in classLoader.hpp
hseigel
parents: 48955
diff changeset
    33
#include "oops/method.inline.hpp"
49480
d7df2dd501ce 8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents: 49449
diff changeset
    34
#include "prims/methodHandles.hpp"
49449
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 49340
diff changeset
    35
#include "runtime/handles.inline.hpp"
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    36
#include "runtime/mutexLocker.hpp"
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    37
42040
70ec5a09a0d5 8166377: is_compiled_by_jvmci hot in some profiles - improve nmethod compiler type detection
neliasso
parents: 39430
diff changeset
    38
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
    39
  : 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
    40
  _method(method), _mark_for_deoptimization_status(not_marked) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    41
  init_defaults();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    42
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    43
42040
70ec5a09a0d5 8166377: is_compiled_by_jvmci hot in some profiles - improve nmethod compiler type detection
neliasso
parents: 39430
diff changeset
    44
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
    45
  : 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
    46
  _method(method), _mark_for_deoptimization_status(not_marked) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    47
  init_defaults();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    48
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    49
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    50
void CompiledMethod::init_defaults() {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    51
  _has_unsafe_access          = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    52
  _has_method_handle_invokes  = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    53
  _lazy_critical_native       = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    54
  _has_wide_vectors           = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    55
  _unloading_clock            = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    56
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    57
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    58
bool CompiledMethod::is_method_handle_return(address return_pc) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    59
  if (!has_method_handle_invokes())  return false;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    60
  PcDesc* pd = pc_desc_at(return_pc);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    61
  if (pd == NULL)
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    62
    return false;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    63
  return pd->is_method_handle_invoke();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    64
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    65
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    66
// Returns a string version of the method state.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    67
const char* CompiledMethod::state() const {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    68
  int state = get_state();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    69
  switch (state) {
48007
ab3959df2115 8043070: nmethod::verify_interrupt_point() shouldn't enter safepoint
iveresov
parents: 47687
diff changeset
    70
  case not_installed:
ab3959df2115 8043070: nmethod::verify_interrupt_point() shouldn't enter safepoint
iveresov
parents: 47687
diff changeset
    71
    return "not installed";
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    72
  case in_use:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    73
    return "in use";
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    74
  case not_used:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    75
    return "not_used";
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    76
  case not_entrant:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    77
    return "not_entrant";
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    78
  case zombie:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    79
    return "zombie";
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    80
  case unloaded:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    81
    return "unloaded";
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    82
  default:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    83
    fatal("unexpected method state: %d", state);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    84
    return NULL;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    85
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    86
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    87
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    88
//-----------------------------------------------------------------------------
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
void CompiledMethod::add_exception_cache_entry(ExceptionCache* new_entry) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    91
  assert(ExceptionCache_lock->owned_by_self(),"Must hold the ExceptionCache_lock");
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    92
  assert(new_entry != NULL,"Must be non null");
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    93
  assert(new_entry->next() == NULL, "Must be null");
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    94
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    95
  ExceptionCache *ec = exception_cache();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    96
  if (ec != NULL) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    97
    new_entry->set_next(ec);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    98
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    99
  release_set_exception_cache(new_entry);
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
49821
02c08e20d66c 8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents: 49480
diff changeset
   102
void CompiledMethod::clean_exception_cache() {
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   103
  ExceptionCache* prev = NULL;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   104
  ExceptionCache* curr = exception_cache();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   105
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   106
  while (curr != NULL) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   107
    ExceptionCache* next = curr->next();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   108
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   109
    Klass* ex_klass = curr->exception_type();
49821
02c08e20d66c 8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents: 49480
diff changeset
   110
    if (ex_klass != NULL && !ex_klass->is_loader_alive()) {
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   111
      if (prev == NULL) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   112
        set_exception_cache(next);
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->set_next(next);
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
      delete curr;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   117
      // prev stays the same.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   118
    } else {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   119
      prev = curr;
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
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   122
    curr = next;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   123
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   124
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   125
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   126
// public method for accessing the exception cache
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   127
// These are the public access methods.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   128
address CompiledMethod::handler_for_exception_and_pc(Handle exception, address pc) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   129
  // 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
   130
  // have false negatives. This is okay, as it can only happen during
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   131
  // the first few exception lookups for a given nmethod.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   132
  ExceptionCache* ec = exception_cache();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   133
  while (ec != NULL) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   134
    address ret_val;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   135
    if ((ret_val = ec->match(exception,pc)) != NULL) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   136
      return ret_val;
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
    ec = ec->next();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   139
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   140
  return NULL;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   141
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   142
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   143
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
   144
  // There are potential race conditions during exception cache updates, so we
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   145
  // must own the ExceptionCache_lock before doing ANY modifications. Because
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   146
  // 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
   147
  // 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
   148
  // copies of the current data before adding it.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   149
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   150
  MutexLocker ml(ExceptionCache_lock);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   151
  ExceptionCache* target_entry = exception_cache_entry_for_exception(exception);
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
  if (target_entry == NULL || !target_entry->add_address_and_handler(pc,handler)) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   154
    target_entry = new ExceptionCache(exception,pc,handler);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   155
    add_exception_cache_entry(target_entry);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   156
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   157
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   158
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   159
//-------------end of code for ExceptionCache--------------
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   160
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   161
// private method for handling exception cache
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   162
// These methods are private, and used to manipulate the exception cache
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   163
// directly.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   164
ExceptionCache* CompiledMethod::exception_cache_entry_for_exception(Handle exception) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   165
  ExceptionCache* ec = exception_cache();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   166
  while (ec != NULL) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   167
    if (ec->match_exception_with_space(exception)) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   168
      return ec;
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
    ec = ec->next();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   171
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   172
  return NULL;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   173
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   174
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   175
bool CompiledMethod::is_at_poll_return(address pc) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   176
  RelocIterator iter(this, pc, pc+1);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   177
  while (iter.next()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   178
    if (iter.type() == relocInfo::poll_return_type)
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   179
      return true;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   180
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   181
  return false;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   182
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   183
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   184
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   185
bool CompiledMethod::is_at_poll_or_poll_return(address pc) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   186
  RelocIterator iter(this, pc, pc+1);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   187
  while (iter.next()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   188
    relocInfo::relocType t = iter.type();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   189
    if (t == relocInfo::poll_return_type || t == relocInfo::poll_type)
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   190
      return true;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   191
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   192
  return false;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   193
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   194
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   195
void CompiledMethod::verify_oop_relocations() {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   196
  // Ensure sure that the code matches the current oop values
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   197
  RelocIterator iter(this, NULL, NULL);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   198
  while (iter.next()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   199
    if (iter.type() == relocInfo::oop_type) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   200
      oop_Relocation* reloc = iter.oop_reloc();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   201
      if (!reloc->oop_is_immediate()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   202
        reloc->verify_oop_relocation();
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
    }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   205
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   206
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   207
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   208
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   209
ScopeDesc* CompiledMethod::scope_desc_at(address pc) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   210
  PcDesc* pd = pc_desc_at(pc);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   211
  guarantee(pd != NULL, "scope must be present");
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   212
  return new ScopeDesc(this, pd->scope_decode_offset(),
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   213
                       pd->obj_decode_offset(), pd->should_reexecute(), pd->rethrow_exception(),
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   214
                       pd->return_oop());
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   215
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   216
46796
ec791efbdecf 8172791: Issues with JEP 270 (ReservedStackArea)
fparain
parents: 46630
diff changeset
   217
ScopeDesc* CompiledMethod::scope_desc_near(address pc) {
ec791efbdecf 8172791: Issues with JEP 270 (ReservedStackArea)
fparain
parents: 46630
diff changeset
   218
  PcDesc* pd = pc_desc_near(pc);
ec791efbdecf 8172791: Issues with JEP 270 (ReservedStackArea)
fparain
parents: 46630
diff changeset
   219
  guarantee(pd != NULL, "scope must be present");
ec791efbdecf 8172791: Issues with JEP 270 (ReservedStackArea)
fparain
parents: 46630
diff changeset
   220
  return new ScopeDesc(this, pd->scope_decode_offset(),
ec791efbdecf 8172791: Issues with JEP 270 (ReservedStackArea)
fparain
parents: 46630
diff changeset
   221
                       pd->obj_decode_offset(), pd->should_reexecute(), pd->rethrow_exception(),
ec791efbdecf 8172791: Issues with JEP 270 (ReservedStackArea)
fparain
parents: 46630
diff changeset
   222
                       pd->return_oop());
ec791efbdecf 8172791: Issues with JEP 270 (ReservedStackArea)
fparain
parents: 46630
diff changeset
   223
}
ec791efbdecf 8172791: Issues with JEP 270 (ReservedStackArea)
fparain
parents: 46630
diff changeset
   224
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   225
void CompiledMethod::cleanup_inline_caches(bool clean_all/*=false*/) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   226
  assert_locked_or_safepoint(CompiledIC_lock);
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
  // 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
   229
  // 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
   230
  // 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
   231
  // not-entrant methods.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   232
  address low_boundary = verified_entry_point();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   233
  if (!is_in_use() && is_nmethod()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   234
    low_boundary += NativeJump::instruction_size;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   235
    // %%% 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
   236
    // 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
   237
    // 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
   238
    // 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
   239
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   240
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   241
  // 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
   242
  // zombie and unloaded nmethods.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   243
  ResourceMark rm;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   244
  RelocIterator iter(this, low_boundary);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   245
  while(iter.next()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   246
    switch(iter.type()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   247
      case relocInfo::virtual_call_type:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   248
      case relocInfo::opt_virtual_call_type: {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   249
        CompiledIC *ic = CompiledIC_at(&iter);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   250
        // Ok, to lookup references to zombies here
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   251
        CodeBlob *cb = CodeCache::find_blob_unsafe(ic->ic_destination());
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   252
        if( cb != NULL && cb->is_compiled() ) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   253
          CompiledMethod* nm = cb->as_compiled_method();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   254
          // Clean inline caches pointing to zombie, non-entrant and unloaded methods
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   255
          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
   256
        }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   257
        break;
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
      case relocInfo::static_call_type: {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   260
          CompiledStaticCall *csc = compiledStaticCall_at(iter.reloc());
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   261
          CodeBlob *cb = CodeCache::find_blob_unsafe(csc->destination());
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   262
          if( cb != NULL && cb->is_compiled() ) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   263
            CompiledMethod* cm = cb->as_compiled_method();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   264
            // Clean inline caches pointing to zombie, non-entrant and unloaded methods
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   265
            if (clean_all || !cm->is_in_use() || (cm->method()->code() != cm)) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   266
              csc->set_to_clean();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   267
            }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   268
          }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   269
        break;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   270
      }
46630
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46623
diff changeset
   271
      default:
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46623
diff changeset
   272
        break;
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   273
    }
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
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   276
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   277
int CompiledMethod::verify_icholder_relocations() {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   278
  ResourceMark rm;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   279
  int count = 0;
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
  RelocIterator iter(this);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   282
  while(iter.next()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   283
    if (iter.type() == relocInfo::virtual_call_type) {
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42040
diff changeset
   284
      if (CompiledIC::is_icholder_call_site(iter.virtual_call_reloc(), this)) {
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   285
        CompiledIC *ic = CompiledIC_at(&iter);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   286
        if (TraceCompiledIC) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   287
          tty->print("noticed icholder " INTPTR_FORMAT " ", p2i(ic->cached_icholder()));
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   288
          ic->print();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   289
        }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   290
        assert(ic->cached_icholder() != NULL, "must be non-NULL");
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   291
        count++;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   292
      }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   293
    }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   294
  }
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
  return count;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   297
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   298
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   299
// 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
   300
// called with a frame corresponding to a Java invoke
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   301
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
   302
  if (method() != NULL && !method()->is_native()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   303
    address pc = fr.pc();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   304
    SimpleScopeDesc ssd(this, pc);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   305
    Bytecode_invoke call(ssd.method(), ssd.bci());
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   306
    bool has_receiver = call.has_receiver();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   307
    bool has_appendix = call.has_appendix();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   308
    Symbol* signature = call.signature();
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
    // The method attached by JIT-compilers should be used, if present.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   311
    // Bytecode can be inaccurate in such case.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   312
    Method* callee = attached_method_before_pc(pc);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   313
    if (callee != NULL) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   314
      has_receiver = !(callee->access_flags().is_static());
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   315
      has_appendix = false;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   316
      signature = callee->signature();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   317
    }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   318
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   319
    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
   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
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   323
Method* CompiledMethod::attached_method(address call_instr) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   324
  assert(code_contains(call_instr), "not part of the nmethod");
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   325
  RelocIterator iter(this, call_instr, call_instr + 1);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   326
  while (iter.next()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   327
    if (iter.addr() == call_instr) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   328
      switch(iter.type()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   329
        case relocInfo::static_call_type:      return iter.static_call_reloc()->method_value();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   330
        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
   331
        case relocInfo::virtual_call_type:     return iter.virtual_call_reloc()->method_value();
46630
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46623
diff changeset
   332
        default:                               break;
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   333
      }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   334
    }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   335
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   336
  return NULL; // not found
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
Method* CompiledMethod::attached_method_before_pc(address pc) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   340
  if (NativeCall::is_call_before(pc)) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   341
    NativeCall* ncall = nativeCall_before(pc);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   342
    return attached_method(ncall->instruction_address());
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
  return NULL; // not a call
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   345
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   346
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   347
void CompiledMethod::clear_inline_caches() {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   348
  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
   349
  if (is_zombie()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   350
    return;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   351
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   352
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   353
  RelocIterator iter(this);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   354
  while (iter.next()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   355
    iter.reloc()->clear_inline_cache();
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
}
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
// Clear ICStubs of all compiled ICs
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   360
void CompiledMethod::clear_ic_stubs() {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   361
  assert_locked_or_safepoint(CompiledIC_lock);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   362
  RelocIterator iter(this);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   363
  while(iter.next()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   364
    if (iter.type() == relocInfo::virtual_call_type) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   365
      CompiledIC* ic = CompiledIC_at(&iter);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   366
      ic->clear_ic_stub();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   367
    }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   368
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   369
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   370
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   371
#ifdef ASSERT
49821
02c08e20d66c 8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents: 49480
diff changeset
   372
// Check class_loader is alive for this bit of metadata.
02c08e20d66c 8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents: 49480
diff changeset
   373
static void check_class(Metadata* md) {
02c08e20d66c 8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents: 49480
diff changeset
   374
   Klass* klass = NULL;
02c08e20d66c 8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents: 49480
diff changeset
   375
   if (md->is_klass()) {
02c08e20d66c 8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents: 49480
diff changeset
   376
     klass = ((Klass*)md);
02c08e20d66c 8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents: 49480
diff changeset
   377
   } else if (md->is_method()) {
02c08e20d66c 8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents: 49480
diff changeset
   378
     klass = ((Method*)md)->method_holder();
02c08e20d66c 8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents: 49480
diff changeset
   379
   } else if (md->is_methodData()) {
02c08e20d66c 8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents: 49480
diff changeset
   380
     klass = ((MethodData*)md)->method()->method_holder();
02c08e20d66c 8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents: 49480
diff changeset
   381
   } else {
02c08e20d66c 8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents: 49480
diff changeset
   382
     md->print();
02c08e20d66c 8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents: 49480
diff changeset
   383
     ShouldNotReachHere();
02c08e20d66c 8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents: 49480
diff changeset
   384
   }
02c08e20d66c 8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents: 49480
diff changeset
   385
   assert(klass->is_loader_alive(), "must be alive");
02c08e20d66c 8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents: 49480
diff changeset
   386
}
38133
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
49821
02c08e20d66c 8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents: 49480
diff changeset
   390
void CompiledMethod::clean_ic_if_metadata_is_dead(CompiledIC *ic) {
38133
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
49821
02c08e20d66c 8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents: 49480
diff changeset
   396
    if (cichk_oop->is_loader_alive()) {
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   397
      return;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   398
    }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   399
  } else {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   400
    Metadata* ic_oop = ic->cached_metadata();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   401
    if (ic_oop != NULL) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   402
      if (ic_oop->is_klass()) {
49821
02c08e20d66c 8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents: 49480
diff changeset
   403
        if (((Klass*)ic_oop)->is_loader_alive()) {
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   404
          return;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   405
        }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   406
      } else if (ic_oop->is_method()) {
49821
02c08e20d66c 8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents: 49480
diff changeset
   407
        if (((Method*)ic_oop)->method_holder()->is_loader_alive()) {
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   408
          return;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   409
        }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   410
      } else {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   411
        ShouldNotReachHere();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   412
      }
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
  ic->set_to_clean();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   417
}
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
unsigned char CompiledMethod::_global_unloading_clock = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   420
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   421
void CompiledMethod::increase_unloading_clock() {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   422
  _global_unloading_clock++;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   423
  if (_global_unloading_clock == 0) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   424
    // _nmethods are allocated with _unloading_clock == 0,
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   425
    // so 0 is never used as a clock value.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   426
    _global_unloading_clock = 1;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   427
  }
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
void CompiledMethod::set_unloading_clock(unsigned char unloading_clock) {
48955
e22914003cf0 8194691: Cleanup unnecessary casts in Atomic/OrderAccess uses
kbarrett
parents: 48557
diff changeset
   431
  OrderAccess::release_store(&_unloading_clock, unloading_clock);
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   432
}
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
unsigned char CompiledMethod::unloading_clock() {
48955
e22914003cf0 8194691: Cleanup unnecessary casts in Atomic/OrderAccess uses
kbarrett
parents: 48557
diff changeset
   435
  return OrderAccess::load_acquire(&_unloading_clock);
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   436
}
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
// Processing of oop references should have been sufficient to keep
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   439
// all strong references alive.  Any weak references should have been
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   440
// cleared as well.  Visit all the metadata and ensure that it's
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   441
// really alive.
49821
02c08e20d66c 8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents: 49480
diff changeset
   442
void CompiledMethod::verify_metadata_loaders(address low_boundary) {
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   443
#ifdef ASSERT
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   444
    RelocIterator iter(this, low_boundary);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   445
    while (iter.next()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   446
    // static_stub_Relocations may have dangling references to
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   447
    // Method*s so trim them out here.  Otherwise it looks like
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   448
    // compiled code is maintaining a link to dead metadata.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   449
    address static_call_addr = NULL;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   450
    if (iter.type() == relocInfo::opt_virtual_call_type) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   451
      CompiledIC* cic = CompiledIC_at(&iter);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   452
      if (!cic->is_call_to_interpreted()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   453
        static_call_addr = iter.addr();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   454
      }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   455
    } else if (iter.type() == relocInfo::static_call_type) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   456
      CompiledStaticCall* csc = compiledStaticCall_at(iter.reloc());
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   457
      if (!csc->is_call_to_interpreted()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   458
        static_call_addr = iter.addr();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   459
      }
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
    if (static_call_addr != NULL) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   462
      RelocIterator sciter(this, low_boundary);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   463
      while (sciter.next()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   464
        if (sciter.type() == relocInfo::static_stub_type &&
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   465
            sciter.static_stub_reloc()->static_call() == static_call_addr) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   466
          sciter.static_stub_reloc()->clear_inline_cache();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   467
        }
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
  // Check that the metadata embedded in the nmethod is alive
49821
02c08e20d66c 8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents: 49480
diff changeset
   472
  metadata_do(check_class);
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   473
#endif
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   474
}
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
// 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
   477
// GC to unload an nmethod if it contains otherwise unreachable
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   478
// oops.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   479
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   480
void CompiledMethod::do_unloading(BoolObjectClosure* is_alive, bool unloading_occurred) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   481
  // Make sure the oop's ready to receive visitors
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   482
  assert(!is_zombie() && !is_unloaded(),
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   483
         "should not call follow on zombie or unloaded nmethod");
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   484
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   485
  // 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
   486
  // 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
   487
  // 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
   488
  // not-entrant methods.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   489
  address low_boundary = verified_entry_point();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   490
  if (is_not_entrant()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   491
    low_boundary += NativeJump::instruction_size;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   492
    // %%% 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
   493
    // (See comment above.)
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   494
  }
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
  // The RedefineClasses() API can cause the class unloading invariant
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   497
  // to no longer be true. See jvmtiExport.hpp for details.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   498
  // Also, leave a debugging breadcrumb in local flag.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   499
  if (JvmtiExport::has_redefined_a_class()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   500
    // This set of the unloading_occurred flag is done before the
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   501
    // call to post_compiled_method_unload() so that the unloading
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   502
    // of this nmethod is reported.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   503
    unloading_occurred = true;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   504
  }
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
  // Exception cache
49821
02c08e20d66c 8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents: 49480
diff changeset
   507
  clean_exception_cache();
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   508
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   509
  // If class unloading occurred we first iterate over all inline caches and
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   510
  // 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
   511
  // 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
   512
  // iteration below.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   513
  if (unloading_occurred) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   514
    RelocIterator iter(this, low_boundary);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   515
    while(iter.next()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   516
      if (iter.type() == relocInfo::virtual_call_type) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   517
        CompiledIC *ic = CompiledIC_at(&iter);
49821
02c08e20d66c 8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents: 49480
diff changeset
   518
        clean_ic_if_metadata_is_dead(ic);
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   519
      }
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
  if (do_unloading_oops(low_boundary, is_alive, unloading_occurred)) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   524
    return;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   525
  }
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
#if INCLUDE_JVMCI
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   528
  if (do_unloading_jvmci(is_alive, unloading_occurred)) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   529
    return;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   530
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   531
#endif
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   532
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   533
  // Ensure that all metadata is still alive
49821
02c08e20d66c 8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents: 49480
diff changeset
   534
  verify_metadata_loaders(low_boundary);
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   535
}
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
template <class CompiledICorStaticCall>
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   538
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
   539
  // Ok, to lookup references to zombies here
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   540
  CodeBlob *cb = CodeCache::find_blob_unsafe(addr);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   541
  CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   542
  if (nm != NULL) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   543
    if (nm->unloading_clock() != CompiledMethod::global_unloading_clock()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   544
      // The nmethod has not been processed yet.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   545
      return true;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   546
    }
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
    // Clean inline caches pointing to both zombie and not_entrant methods
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   549
    if (!nm->is_in_use() || (nm->method()->code() != nm)) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   550
      ic->set_to_clean();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   551
      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
   552
    }
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
  return false;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   556
}
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
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
   559
  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
   560
}
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
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
   563
  return clean_if_nmethod_is_unloaded(csc, csc->destination(), is_alive, from);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   564
}
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
bool CompiledMethod::do_unloading_parallel(BoolObjectClosure* is_alive, bool unloading_occurred) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   567
  ResourceMark rm;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   568
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   569
  // Make sure the oop's ready to receive visitors
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   570
  assert(!is_zombie() && !is_unloaded(),
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   571
         "should not call follow on zombie or unloaded nmethod");
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   572
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   573
  // 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
   574
  // 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
   575
  // 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
   576
  // not-entrant methods.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   577
  address low_boundary = verified_entry_point();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   578
  if (is_not_entrant()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   579
    low_boundary += NativeJump::instruction_size;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   580
    // %%% 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
   581
    // (See comment above.)
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   582
  }
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
  // The RedefineClasses() API can cause the class unloading invariant
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   585
  // to no longer be true. See jvmtiExport.hpp for details.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   586
  // Also, leave a debugging breadcrumb in local flag.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   587
  if (JvmtiExport::has_redefined_a_class()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   588
    // This set of the unloading_occurred flag is done before the
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   589
    // call to post_compiled_method_unload() so that the unloading
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   590
    // of this nmethod is reported.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   591
    unloading_occurred = true;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   592
  }
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
  // Exception cache
49821
02c08e20d66c 8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents: 49480
diff changeset
   595
  clean_exception_cache();
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   596
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   597
  bool postponed = false;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   598
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   599
  RelocIterator iter(this, low_boundary);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   600
  while(iter.next()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   601
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   602
    switch (iter.type()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   603
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   604
    case relocInfo::virtual_call_type:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   605
      if (unloading_occurred) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   606
        // If class unloading occurred we first iterate over all inline caches and
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   607
        // clear ICs where the cached oop is referring to an unloaded klass or method.
49821
02c08e20d66c 8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents: 49480
diff changeset
   608
        clean_ic_if_metadata_is_dead(CompiledIC_at(&iter));
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   609
      }
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
      postponed |= clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), is_alive, this);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   612
      break;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   613
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   614
    case relocInfo::opt_virtual_call_type:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   615
      postponed |= clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), is_alive, this);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   616
      break;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   617
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   618
    case relocInfo::static_call_type:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   619
      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
   620
      break;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   621
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   622
    case relocInfo::oop_type:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   623
      // handled by do_unloading_oops below
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   624
      break;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   625
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   626
    case relocInfo::metadata_type:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   627
      break; // nothing to do.
46630
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46623
diff changeset
   628
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46623
diff changeset
   629
    default:
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46623
diff changeset
   630
      break;
38133
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
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   633
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   634
  if (do_unloading_oops(low_boundary, is_alive, unloading_occurred)) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   635
    return postponed;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   636
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   637
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   638
#if INCLUDE_JVMCI
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   639
  if (do_unloading_jvmci(is_alive, unloading_occurred)) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   640
    return postponed;
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
#endif
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   643
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   644
  // Ensure that all metadata is still alive
49821
02c08e20d66c 8201537: Remove is_alive closure from Klass::is_loader_alive()
coleenp
parents: 49480
diff changeset
   645
  verify_metadata_loaders(low_boundary);
38133
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
  return postponed;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   648
}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   649
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   650
void CompiledMethod::do_unloading_parallel_postponed(BoolObjectClosure* is_alive, bool unloading_occurred) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   651
  ResourceMark rm;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   652
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   653
  // Make sure the oop's ready to receive visitors
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   654
  assert(!is_zombie(),
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   655
         "should not call follow on zombie nmethod");
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   656
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   657
  // 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
   658
  // 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
   659
  // 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
   660
  // not-entrant methods.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   661
  address low_boundary = verified_entry_point();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   662
  if (is_not_entrant()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   663
    low_boundary += NativeJump::instruction_size;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   664
    // %%% 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
   665
    // (See comment above.)
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   666
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   667
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   668
  RelocIterator iter(this, low_boundary);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   669
  while(iter.next()) {
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
    switch (iter.type()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   672
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   673
    case relocInfo::virtual_call_type:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   674
      clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), is_alive, this);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   675
      break;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   676
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   677
    case relocInfo::opt_virtual_call_type:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   678
      clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), is_alive, this);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   679
      break;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   680
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   681
    case relocInfo::static_call_type:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   682
      clean_if_nmethod_is_unloaded(compiledStaticCall_at(iter.reloc()), is_alive, this);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   683
      break;
46630
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46623
diff changeset
   684
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46623
diff changeset
   685
    default:
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46623
diff changeset
   686
      break;
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   687
    }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   688
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   689
}