src/hotspot/share/code/compiledMethod.hpp
author hseigel
Mon, 05 Mar 2018 10:29:23 -0500
changeset 49340 4e82736053ae
parent 48007 ab3959df2115
child 49373 47b5652f2928
permissions -rw-r--r--
8191102: Incorrect include file use in classLoader.hpp Summary: Move appropriate methods to <fiile>.inline.hpp files. Create <file>.inline.hpp files when needed. Reviewed-by: coleenp, dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
     1
/*
49340
4e82736053ae 8191102: Incorrect include file use in classLoader.hpp
hseigel
parents: 48007
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
#ifndef SHARE_VM_CODE_COMPILEDMETHOD_HPP
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    26
#define SHARE_VM_CODE_COMPILEDMETHOD_HPP
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    27
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    28
#include "code/codeBlob.hpp"
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    29
#include "code/pcDesc.hpp"
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    30
#include "oops/metadata.hpp"
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    31
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    32
class Dependencies;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    33
class ExceptionHandlerTable;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    34
class ImplicitExceptionTable;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    35
class AbstractCompiler;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    36
class xmlStream;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    37
class CompiledStaticCall;
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42040
diff changeset
    38
class NativeCallWrapper;
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    39
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    40
// This class is used internally by nmethods, to cache
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    41
// exception/pc/handler information.
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
class ExceptionCache : public CHeapObj<mtCode> {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    44
  friend class VMStructs;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    45
 private:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    46
  enum { cache_size = 16 };
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    47
  Klass*   _exception_type;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    48
  address  _pc[cache_size];
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    49
  address  _handler[cache_size];
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    50
  volatile int _count;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    51
  ExceptionCache* _next;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    52
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    53
  address pc_at(int index)                     { assert(index >= 0 && index < count(),""); return _pc[index]; }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    54
  void    set_pc_at(int index, address a)      { assert(index >= 0 && index < cache_size,""); _pc[index] = a; }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    55
  address handler_at(int index)                { assert(index >= 0 && index < count(),""); return _handler[index]; }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    56
  void    set_handler_at(int index, address a) { assert(index >= 0 && index < cache_size,""); _handler[index] = a; }
49340
4e82736053ae 8191102: Incorrect include file use in classLoader.hpp
hseigel
parents: 48007
diff changeset
    57
  int     count();
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    58
  // increment_count is only called under lock, but there may be concurrent readers.
49340
4e82736053ae 8191102: Incorrect include file use in classLoader.hpp
hseigel
parents: 48007
diff changeset
    59
  void    increment_count();
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    60
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    61
 public:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    62
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    63
  ExceptionCache(Handle exception, address pc, address handler);
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
  Klass*    exception_type()                { return _exception_type; }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    66
  ExceptionCache* next()                    { return _next; }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    67
  void      set_next(ExceptionCache *ec)    { _next = ec; }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    68
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    69
  address match(Handle exception, address pc);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    70
  bool    match_exception_with_space(Handle exception) ;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    71
  address test_address(address addr);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    72
  bool    add_address_and_handler(address addr, address handler) ;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    73
};
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    74
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    75
class nmethod;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    76
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    77
// cache pc descs found in earlier inquiries
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    78
class PcDescCache VALUE_OBJ_CLASS_SPEC {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    79
  friend class VMStructs;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    80
 private:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    81
  enum { cache_size = 4 };
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    82
  // The array elements MUST be volatile! Several threads may modify
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    83
  // and read from the cache concurrently. find_pc_desc_internal has
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    84
  // returned wrong results. C++ compiler (namely xlC12) may duplicate
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    85
  // C++ field accesses if the elements are not volatile.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    86
  typedef PcDesc* PcDescPtr;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    87
  volatile PcDescPtr _pc_descs[cache_size]; // last cache_size pc_descs found
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    88
 public:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    89
  PcDescCache() { debug_only(_pc_descs[0] = NULL); }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    90
  void    reset_to(PcDesc* initial_pc_desc);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    91
  PcDesc* find_pc_desc(int pc_offset, bool approximate);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    92
  void    add_pc_desc(PcDesc* pc_desc);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    93
  PcDesc* last_pc_desc() { return _pc_descs[0]; }
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
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    96
class PcDescSearch {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    97
private:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    98
  address _code_begin;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
    99
  PcDesc* _lower;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   100
  PcDesc* _upper;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   101
public:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   102
  PcDescSearch(address code, PcDesc* lower, PcDesc* upper) :
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   103
    _code_begin(code), _lower(lower), _upper(upper)
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   104
  {
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
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   107
  address code_begin() const { return _code_begin; }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   108
  PcDesc* scopes_pcs_begin() const { return _lower; }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   109
  PcDesc* scopes_pcs_end() const { return _upper; }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   110
};
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   111
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   112
class PcDescContainer VALUE_OBJ_CLASS_SPEC {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   113
private:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   114
  PcDescCache _pc_desc_cache;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   115
public:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   116
  PcDescContainer() {}
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   117
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   118
  PcDesc* find_pc_desc_internal(address pc, bool approximate, const PcDescSearch& search);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   119
  void    reset_to(PcDesc* initial_pc_desc) { _pc_desc_cache.reset_to(initial_pc_desc); }
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
  PcDesc* find_pc_desc(address pc, bool approximate, const PcDescSearch& search) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   122
    address base_address = search.code_begin();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   123
    PcDesc* desc = _pc_desc_cache.last_pc_desc();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   124
    if (desc != NULL && desc->pc_offset() == pc - base_address) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   125
      return desc;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   126
    }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   127
    return find_pc_desc_internal(pc, approximate, search);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   128
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   129
};
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   130
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   131
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   132
class CompiledMethod : public CodeBlob {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   133
  friend class VMStructs;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   134
  friend class NMethodSweeper;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   135
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   136
  void init_defaults();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   137
protected:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   138
  enum MarkForDeoptimizationStatus {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   139
    not_marked,
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   140
    deoptimize,
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   141
    deoptimize_noupdate
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
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   144
  MarkForDeoptimizationStatus _mark_for_deoptimization_status; // Used for stack deoptimization
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   145
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   146
  bool _is_far_code; // Code is far from CodeCache.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   147
                     // Have to use far call instructions to call it from code in CodeCache.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   148
  // set during construction
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   149
  unsigned int _has_unsafe_access:1;         // May fault due to unsafe access.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   150
  unsigned int _has_method_handle_invokes:1; // Has this method MethodHandle invokes?
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   151
  unsigned int _lazy_critical_native:1;      // Lazy JNI critical native
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   152
  unsigned int _has_wide_vectors:1;          // Preserve wide vectors at safepoints
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   153
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   154
  Method*   _method;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   155
  address _scopes_data_begin;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   156
  // All deoptee's will resume execution at this location described by
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   157
  // this address.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   158
  address _deopt_handler_begin;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   159
  // All deoptee's at a MethodHandle call site will resume execution
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   160
  // at this location described by this offset.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   161
  address _deopt_mh_handler_begin;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   162
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   163
  PcDescContainer _pc_desc_container;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   164
  ExceptionCache * volatile _exception_cache;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   165
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   166
  virtual void flush() = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   167
protected:
42040
70ec5a09a0d5 8166377: is_compiled_by_jvmci hot in some profiles - improve nmethod compiler type detection
neliasso
parents: 38133
diff changeset
   168
  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: 38133
diff changeset
   169
  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);
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   170
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   171
public:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   172
  virtual bool is_compiled() const                { return true; }
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
  bool  has_unsafe_access() const                 { return _has_unsafe_access; }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   175
  void  set_has_unsafe_access(bool z)             { _has_unsafe_access = z; }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   176
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   177
  bool  has_method_handle_invokes() const         { return _has_method_handle_invokes; }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   178
  void  set_has_method_handle_invokes(bool z)     { _has_method_handle_invokes = z; }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   179
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   180
  bool  is_lazy_critical_native() const           { return _lazy_critical_native; }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   181
  void  set_lazy_critical_native(bool z)          { _lazy_critical_native = z; }
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
  bool  has_wide_vectors() const                  { return _has_wide_vectors; }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   184
  void  set_has_wide_vectors(bool z)              { _has_wide_vectors = z; }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   185
48007
ab3959df2115 8043070: nmethod::verify_interrupt_point() shouldn't enter safepoint
iveresov
parents: 47634
diff changeset
   186
  enum { not_installed = -1, // in construction, only the owner doing the construction is
ab3959df2115 8043070: nmethod::verify_interrupt_point() shouldn't enter safepoint
iveresov
parents: 47634
diff changeset
   187
                             // allowed to advance state
ab3959df2115 8043070: nmethod::verify_interrupt_point() shouldn't enter safepoint
iveresov
parents: 47634
diff changeset
   188
         in_use        = 0,  // executable nmethod
ab3959df2115 8043070: nmethod::verify_interrupt_point() shouldn't enter safepoint
iveresov
parents: 47634
diff changeset
   189
         not_used      = 1,  // not entrant, but revivable
ab3959df2115 8043070: nmethod::verify_interrupt_point() shouldn't enter safepoint
iveresov
parents: 47634
diff changeset
   190
         not_entrant   = 2,  // marked for deoptimization but activations may still exist,
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   191
                             // will be transformed to zombie when all activations are gone
48007
ab3959df2115 8043070: nmethod::verify_interrupt_point() shouldn't enter safepoint
iveresov
parents: 47634
diff changeset
   192
         zombie        = 3,  // no activations exist, nmethod is ready for purge
ab3959df2115 8043070: nmethod::verify_interrupt_point() shouldn't enter safepoint
iveresov
parents: 47634
diff changeset
   193
         unloaded      = 4   // there should be no activations, should not be called,
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   194
                             // will be transformed to zombie immediately
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   195
  };
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   196
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   197
  virtual bool  is_in_use() const = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   198
  virtual int   comp_level() const = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   199
  virtual int   compile_id() const = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   200
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   201
  virtual address verified_entry_point() const = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   202
  virtual void log_identity(xmlStream* log) const = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   203
  virtual void log_state_change() const = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   204
  virtual bool make_not_used() = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   205
  virtual bool make_not_entrant() = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   206
  virtual bool make_entrant() = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   207
  virtual address entry_point() const = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   208
  virtual bool make_zombie() = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   209
  virtual bool is_osr_method() const = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   210
  virtual int osr_entry_bci() const = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   211
  Method* method() const                          { return _method; }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   212
  virtual void print_pcs() = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   213
  bool is_native_method() const { return _method != NULL && _method->is_native(); }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   214
  bool is_java_method() const { return _method != NULL && !_method->is_native(); }
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
  // ScopeDesc retrieval operation
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   217
  PcDesc* pc_desc_at(address pc)   { return find_pc_desc(pc, false); }
46796
ec791efbdecf 8172791: Issues with JEP 270 (ReservedStackArea)
fparain
parents: 46364
diff changeset
   218
  // pc_desc_near returns the first PcDesc at or after the given pc.
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   219
  PcDesc* pc_desc_near(address pc) { return find_pc_desc(pc, true); }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   220
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   221
  // ScopeDesc for an instruction
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   222
  ScopeDesc* scope_desc_at(address pc);
46796
ec791efbdecf 8172791: Issues with JEP 270 (ReservedStackArea)
fparain
parents: 46364
diff changeset
   223
  ScopeDesc* scope_desc_near(address pc);
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   224
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   225
  bool is_at_poll_return(address pc);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   226
  bool is_at_poll_or_poll_return(address pc);
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
  bool  is_marked_for_deoptimization() const      { return _mark_for_deoptimization_status != not_marked; }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   229
  void  mark_for_deoptimization(bool inc_recompile_counts = true) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   230
    _mark_for_deoptimization_status = (inc_recompile_counts ? deoptimize : deoptimize_noupdate);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   231
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   232
  bool update_recompile_counts() const {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   233
    // Update recompile counts when either the update is explicitly requested (deoptimize)
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   234
    // or the nmethod is not marked for deoptimization at all (not_marked).
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   235
    // The latter happens during uncommon traps when deoptimized nmethod is made not entrant.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   236
    return _mark_for_deoptimization_status != deoptimize_noupdate;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   237
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   238
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   239
  // tells whether frames described by this nmethod can be deoptimized
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   240
  // note: native wrappers cannot be deoptimized.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   241
  bool can_be_deoptimized() const { return is_java_method(); }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   242
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   243
  virtual oop oop_at(int index) const = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   244
  virtual Metadata* metadata_at(int index) const = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   245
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   246
  address scopes_data_begin() const { return _scopes_data_begin; }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   247
  virtual address scopes_data_end() const = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   248
  int scopes_data_size() const { return scopes_data_end() - scopes_data_begin(); }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   249
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   250
  virtual PcDesc* scopes_pcs_begin() const = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   251
  virtual PcDesc* scopes_pcs_end() const = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   252
  int scopes_pcs_size() const { return (intptr_t) scopes_pcs_end() - (intptr_t) scopes_pcs_begin(); }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   253
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   254
  address insts_begin() const { return code_begin(); }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   255
  address insts_end() const { return stub_begin(); }
43474
8fbf946045f6 8172844: Assert fails in deoptimization due to original PC at the end of code section
zmajo
parents: 42650
diff changeset
   256
  // Returns true if a given address is in the 'insts' section. The method
8fbf946045f6 8172844: Assert fails in deoptimization due to original PC at the end of code section
zmajo
parents: 42650
diff changeset
   257
  // insts_contains_inclusive() is end-inclusive.
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   258
  bool insts_contains(address addr) const { return insts_begin() <= addr && addr < insts_end(); }
43474
8fbf946045f6 8172844: Assert fails in deoptimization due to original PC at the end of code section
zmajo
parents: 42650
diff changeset
   259
  bool insts_contains_inclusive(address addr) const { return insts_begin() <= addr && addr <= insts_end(); }
8fbf946045f6 8172844: Assert fails in deoptimization due to original PC at the end of code section
zmajo
parents: 42650
diff changeset
   260
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   261
  int insts_size() const { return insts_end() - insts_begin(); }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   262
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   263
  virtual address consts_begin() const = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   264
  virtual address consts_end() const = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   265
  bool consts_contains(address addr) const { return consts_begin() <= addr && addr < consts_end(); }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   266
  int consts_size() const { return consts_end() - consts_begin(); }
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
  virtual address stub_begin() const = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   269
  virtual address stub_end() const = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   270
  bool stub_contains(address addr) const { return stub_begin() <= addr && addr < stub_end(); }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   271
  int stub_size() const { return stub_end() - stub_begin(); }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   272
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   273
  virtual address handler_table_begin() const = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   274
  virtual address handler_table_end() const = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   275
  bool handler_table_contains(address addr) const { return handler_table_begin() <= addr && addr < handler_table_end(); }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   276
  int handler_table_size() const { return handler_table_end() - handler_table_begin(); }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   277
46364
00a21c0ff97e 8173795: AOT support in raw_exception_handler_for_return_address is broken
dlong
parents: 43474
diff changeset
   278
  virtual address exception_begin() const = 0;
00a21c0ff97e 8173795: AOT support in raw_exception_handler_for_return_address is broken
dlong
parents: 43474
diff changeset
   279
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   280
  virtual address nul_chk_table_begin() const = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   281
  virtual address nul_chk_table_end() const = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   282
  bool nul_chk_table_contains(address addr) const { return nul_chk_table_begin() <= addr && addr < nul_chk_table_end(); }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   283
  int nul_chk_table_size() const { return nul_chk_table_end() - nul_chk_table_begin(); }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   284
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   285
  virtual oop* oop_addr_at(int index) const = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   286
  virtual Metadata** metadata_addr_at(int index) const = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   287
  virtual void    set_original_pc(const frame* fr, address pc) = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   288
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   289
  // Exception cache support
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   290
  // Note: _exception_cache may be read concurrently. We rely on memory_order_consume here.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   291
  ExceptionCache* exception_cache() const         { return _exception_cache; }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   292
  void set_exception_cache(ExceptionCache *ec)    { _exception_cache = ec; }
49340
4e82736053ae 8191102: Incorrect include file use in classLoader.hpp
hseigel
parents: 48007
diff changeset
   293
  void release_set_exception_cache(ExceptionCache *ec);
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   294
  address handler_for_exception_and_pc(Handle exception, address pc);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   295
  void add_handler_for_exception_and_pc(Handle exception, address pc, address handler);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   296
  void clean_exception_cache(BoolObjectClosure* is_alive);
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
  void add_exception_cache_entry(ExceptionCache* new_entry);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   299
  ExceptionCache* exception_cache_entry_for_exception(Handle exception);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   300
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   301
  // MethodHandle
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   302
  bool is_method_handle_return(address return_pc);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   303
  address deopt_mh_handler_begin() const  { return _deopt_mh_handler_begin; }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   304
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   305
  address deopt_handler_begin() const { return _deopt_handler_begin; }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   306
  virtual address get_original_pc(const frame* fr) = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   307
  // Deopt
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   308
  // Return true is the PC is one would expect if the frame is being deopted.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   309
  bool is_deopt_pc      (address pc) { return is_deopt_entry(pc) || is_deopt_mh_entry(pc); }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   310
  bool is_deopt_mh_entry(address pc) { return pc == deopt_mh_handler_begin(); }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   311
  bool is_deopt_entry(address pc);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   312
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   313
  virtual bool can_convert_to_zombie() = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   314
  virtual const char* compile_kind() const = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   315
  virtual int get_state() const = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   316
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   317
  const char* state() const;
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
  bool is_far_code() const { return _is_far_code; }
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
  bool inlinecache_check_contains(address addr) const {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   322
    return (addr >= code_begin() && addr < verified_entry_point());
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   323
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   324
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   325
  void preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   326
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   327
  // implicit exceptions support
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   328
  virtual address continuation_for_implicit_exception(address pc) { return NULL; }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   329
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   330
  static address get_deopt_original_pc(const frame* fr);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   331
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   332
  // Inline cache support
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   333
  void cleanup_inline_caches(bool clean_all = false);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   334
  virtual void clear_inline_caches();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   335
  void clear_ic_stubs();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   336
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   337
  // Verify and count cached icholder relocations.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   338
  int  verify_icholder_relocations();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   339
  void verify_oop_relocations();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   340
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   341
  virtual bool is_evol_dependent_on(Klass* dependee) = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   342
  // Fast breakpoint support. Tells if this compiled method is
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   343
  // dependent on the given method. Returns true if this nmethod
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   344
  // corresponds to the given method as well.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   345
  virtual bool is_dependent_on_method(Method* dependee) = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   346
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42040
diff changeset
   347
  virtual NativeCallWrapper* call_wrapper_at(address call) const = 0;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42040
diff changeset
   348
  virtual NativeCallWrapper* call_wrapper_before(address return_pc) const = 0;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42040
diff changeset
   349
  virtual address call_instruction_address(address pc) const = 0;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42040
diff changeset
   350
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42040
diff changeset
   351
  virtual CompiledStaticCall* compiledStaticCall_at(Relocation* call_site) const = 0;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42040
diff changeset
   352
  virtual CompiledStaticCall* compiledStaticCall_at(address addr) const = 0;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42040
diff changeset
   353
  virtual CompiledStaticCall* compiledStaticCall_before(address addr) const = 0;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42040
diff changeset
   354
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   355
  Method* attached_method(address call_pc);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   356
  Method* attached_method_before_pc(address pc);
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
  virtual void metadata_do(void f(Metadata*)) = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   359
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   360
  // GC support
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   361
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   362
  void set_unloading_next(CompiledMethod* next) { _unloading_next = next; }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   363
  CompiledMethod* unloading_next()              { return _unloading_next; }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   364
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   365
  void static clean_ic_if_metadata_is_dead(CompiledIC *ic, BoolObjectClosure *is_alive);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   366
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   367
  // Check that all metadata is still alive
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   368
  void verify_metadata_loaders(address low_boundary, BoolObjectClosure* is_alive);
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
  virtual void do_unloading(BoolObjectClosure* is_alive, bool unloading_occurred);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   371
  //  The parallel versions are used by G1.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   372
  virtual bool do_unloading_parallel(BoolObjectClosure* is_alive, bool unloading_occurred);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   373
  virtual void do_unloading_parallel_postponed(BoolObjectClosure* is_alive, bool unloading_occurred);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   374
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   375
  static unsigned char global_unloading_clock()   { return _global_unloading_clock; }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   376
  static void increase_unloading_clock();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   377
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   378
  void set_unloading_clock(unsigned char unloading_clock);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   379
  unsigned char unloading_clock();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   380
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   381
protected:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   382
  virtual bool do_unloading_oops(address low_boundary, BoolObjectClosure* is_alive, bool unloading_occurred) = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   383
#if INCLUDE_JVMCI
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   384
  virtual bool do_unloading_jvmci(BoolObjectClosure* is_alive, bool unloading_occurred) = 0;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   385
#endif
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   386
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   387
private:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   388
  // GC support to help figure out if an nmethod has been
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   389
  // cleaned/unloaded by the current GC.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   390
  static unsigned char _global_unloading_clock;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   391
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   392
  volatile unsigned char _unloading_clock;   // Incremented after GC unloaded/cleaned the nmethod
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   393
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   394
  PcDesc* find_pc_desc(address pc, bool approximate) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   395
    return _pc_desc_container.find_pc_desc(pc, approximate, PcDescSearch(code_begin(), scopes_pcs_begin(), scopes_pcs_end()));
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   396
  }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   397
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   398
protected:
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   399
  union {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   400
    // Used by G1 to chain nmethods.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   401
    CompiledMethod* _unloading_next;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   402
    // Used by non-G1 GCs to chain nmethods.
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   403
    nmethod* _scavenge_root_link; // from CodeCache::scavenge_root_nmethods
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   404
  };
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
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
diff changeset
   407
#endif //SHARE_VM_CODE_COMPILEDMETHOD_HPP