hotspot/src/share/vm/code/codeCache.cpp
author coleenp
Wed, 28 Jun 2017 19:12:58 -0400
changeset 46589 f1c04490ded1
parent 46527 df19f7e4b9f7
child 46619 a3919f5e8d2b
permissions -rw-r--r--
8182848: Some functions misplaced in debug.hpp Summary: moved to vmError.hpp,cpp where they seemed more appropriate Reviewed-by: stefank, stuefe
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46327
diff changeset
     2
 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5533
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5533
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5533
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    25
#include "precompiled.hpp"
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
    26
#include "aot/aotLoader.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    27
#include "code/codeBlob.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    28
#include "code/codeCache.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
    29
#include "code/compiledIC.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    30
#include "code/dependencies.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
    31
#include "code/icBuffer.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    32
#include "code/nmethod.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    33
#include "code/pcDesc.hpp"
15201
f3d755b11424 8005204: Code Cache Reduction: command line options implementation
vladidan
parents: 13878
diff changeset
    34
#include "compiler/compileBroker.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30607
diff changeset
    35
#include "gc/shared/gcLocker.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    36
#include "memory/allocation.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    37
#include "memory/iterator.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    38
#include "memory/resourceArea.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
    39
#include "oops/method.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    40
#include "oops/objArrayOop.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    41
#include "oops/oop.inline.hpp"
29084
1b732f2836ce 8073387: Move VerifyOopClosures out from genOopClosures.hpp
stefank
parents: 28730
diff changeset
    42
#include "oops/verifyOopClosure.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30607
diff changeset
    43
#include "runtime/arguments.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30607
diff changeset
    44
#include "runtime/compilationPolicy.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30607
diff changeset
    45
#include "runtime/deoptimization.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    46
#include "runtime/handles.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    47
#include "runtime/icache.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    48
#include "runtime/java.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    49
#include "runtime/mutexLocker.hpp"
27420
04e6f914cce1 8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents: 27410
diff changeset
    50
#include "runtime/sweeper.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    51
#include "services/memoryService.hpp"
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17617
diff changeset
    52
#include "trace/tracing.hpp"
46589
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46527
diff changeset
    53
#include "utilities/vmError.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    54
#include "utilities/xmlstream.hpp"
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
    55
#ifdef COMPILER1
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
    56
#include "c1/c1_Compilation.hpp"
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
    57
#include "c1/c1_Compiler.hpp"
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
    58
#endif
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
    59
#ifdef COMPILER2
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
    60
#include "opto/c2compiler.hpp"
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
    61
#include "opto/compile.hpp"
26805
73f3e9ac86f5 8058716: Add include missing in 8015774
goetz
parents: 26796
diff changeset
    62
#include "opto/node.hpp"
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
    63
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
// Helper class for printing in CodeCache
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
class CodeBlob_sizes {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  int count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  int total_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  int header_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  int code_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  int stub_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  int relocation_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  int scopes_oop_size;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
    75
  int scopes_metadata_size;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  int scopes_data_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  int scopes_pcs_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  CodeBlob_sizes() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
    count            = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
    total_size       = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
    header_size      = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
    code_size        = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
    stub_size        = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
    relocation_size  = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
    scopes_oop_size  = 0;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
    88
    scopes_metadata_size  = 0;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
    scopes_data_size = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
    scopes_pcs_size  = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  int total()                                    { return total_size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  bool is_empty()                                { return count == 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  void print(const char* title) {
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 23214
diff changeset
    97
    tty->print_cr(" #%d %s = %dK (hdr %d%%,  loc %d%%, code %d%%, stub %d%%, [oops %d%%, metadata %d%%, data %d%%, pcs %d%%])",
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
                  count,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
                  title,
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 23214
diff changeset
   100
                  (int)(total() / K),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
                  header_size             * 100 / total_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
                  relocation_size         * 100 / total_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
                  code_size               * 100 / total_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
                  stub_size               * 100 / total_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
                  scopes_oop_size         * 100 / total_size,
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   106
                  scopes_metadata_size    * 100 / total_size,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
                  scopes_data_size        * 100 / total_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
                  scopes_pcs_size         * 100 / total_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  void add(CodeBlob* cb) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
    count++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
    total_size       += cb->size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
    header_size      += cb->header_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
    relocation_size  += cb->relocation_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
    if (cb->is_nmethod()) {
5686
5435e77aa3df 6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents: 5533
diff changeset
   117
      nmethod* nm = cb->as_nmethod_or_null();
6418
6671edbd230e 6978355: renaming for 6961697
twisti
parents: 5924
diff changeset
   118
      code_size        += nm->insts_size();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
      stub_size        += nm->stub_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
5686
5435e77aa3df 6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents: 5533
diff changeset
   121
      scopes_oop_size  += nm->oops_size();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   122
      scopes_metadata_size  += nm->metadata_size();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
      scopes_data_size += nm->scopes_data_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
      scopes_pcs_size  += nm->scopes_pcs_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
    } else {
6418
6671edbd230e 6978355: renaming for 6961697
twisti
parents: 5924
diff changeset
   126
      code_size        += cb->code_size();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   131
// Iterate over all CodeHeaps
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   132
#define FOR_ALL_HEAPS(heap) for (GrowableArrayIterator<CodeHeap*> heap = _heaps->begin(); heap != _heaps->end(); ++heap)
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   133
#define FOR_ALL_NMETHOD_HEAPS(heap) for (GrowableArrayIterator<CodeHeap*> heap = _nmethod_heaps->begin(); heap != _nmethod_heaps->end(); ++heap)
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   134
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   135
// Iterate over all CodeBlobs (cb) on the given CodeHeap
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   136
#define FOR_ALL_BLOBS(cb, heap) for (CodeBlob* cb = first_blob(heap); cb != NULL; cb = next_blob(heap, cb))
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   138
address CodeCache::_low_bound = 0;
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   139
address CodeCache::_high_bound = 0;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
int CodeCache::_number_of_nmethods_with_dependencies = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
bool CodeCache::_needs_cache_clean = false;
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   142
nmethod* CodeCache::_scavenge_root_nmethods = NULL;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   144
// Initialize array of CodeHeaps
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   145
GrowableArray<CodeHeap*>* CodeCache::_heaps = new(ResourceObj::C_HEAP, mtCode) GrowableArray<CodeHeap*> (CodeBlobType::All, true);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   146
GrowableArray<CodeHeap*>* CodeCache::_compiled_heaps = new(ResourceObj::C_HEAP, mtCode) GrowableArray<CodeHeap*> (CodeBlobType::All, true);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   147
GrowableArray<CodeHeap*>* CodeCache::_nmethod_heaps = new(ResourceObj::C_HEAP, mtCode) GrowableArray<CodeHeap*> (CodeBlobType::All, true);
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   148
34182
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   149
void CodeCache::check_heap_sizes(size_t non_nmethod_size, size_t profiled_size, size_t non_profiled_size, size_t cache_size, bool all_set) {
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   150
  size_t total_size = non_nmethod_size + profiled_size + non_profiled_size;
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   151
  // Prepare error message
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   152
  const char* error = "Invalid code heap sizes";
43407
f6dc40ed6ce9 8171924: Use SIZE_FORMAT to print size_t values.
goetz
parents: 42650
diff changeset
   153
  err_msg message("NonNMethodCodeHeapSize (" SIZE_FORMAT "K) + ProfiledCodeHeapSize (" SIZE_FORMAT "K)"
f6dc40ed6ce9 8171924: Use SIZE_FORMAT to print size_t values.
goetz
parents: 42650
diff changeset
   154
                  " + NonProfiledCodeHeapSize (" SIZE_FORMAT "K) = " SIZE_FORMAT "K",
34182
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   155
          non_nmethod_size/K, profiled_size/K, non_profiled_size/K, total_size/K);
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   156
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   157
  if (total_size > cache_size) {
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   158
    // Some code heap sizes were explicitly set: total_size must be <= cache_size
43407
f6dc40ed6ce9 8171924: Use SIZE_FORMAT to print size_t values.
goetz
parents: 42650
diff changeset
   159
    message.append(" is greater than ReservedCodeCacheSize (" SIZE_FORMAT "K).", cache_size/K);
34182
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   160
    vm_exit_during_initialization(error, message);
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   161
  } else if (all_set && total_size != cache_size) {
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   162
    // All code heap sizes were explicitly set: total_size must equal cache_size
43407
f6dc40ed6ce9 8171924: Use SIZE_FORMAT to print size_t values.
goetz
parents: 42650
diff changeset
   163
    message.append(" is not equal to ReservedCodeCacheSize (" SIZE_FORMAT "K).", cache_size/K);
34182
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   164
    vm_exit_during_initialization(error, message);
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   165
  }
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   166
}
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   167
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   168
void CodeCache::initialize_heaps() {
34182
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   169
  bool non_nmethod_set      = FLAG_IS_CMDLINE(NonNMethodCodeHeapSize);
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   170
  bool profiled_set         = FLAG_IS_CMDLINE(ProfiledCodeHeapSize);
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   171
  bool non_profiled_set     = FLAG_IS_CMDLINE(NonProfiledCodeHeapSize);
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   172
  size_t min_size           = os::vm_page_size();
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   173
  size_t cache_size         = ReservedCodeCacheSize;
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   174
  size_t non_nmethod_size   = NonNMethodCodeHeapSize;
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   175
  size_t profiled_size      = ProfiledCodeHeapSize;
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   176
  size_t non_profiled_size  = NonProfiledCodeHeapSize;
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   177
  // Check if total size set via command line flags exceeds the reserved size
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   178
  check_heap_sizes((non_nmethod_set  ? non_nmethod_size  : min_size),
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   179
                   (profiled_set     ? profiled_size     : min_size),
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   180
                   (non_profiled_set ? non_profiled_size : min_size),
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   181
                   cache_size,
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   182
                   non_nmethod_set && profiled_set && non_profiled_set);
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   183
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   184
  // Determine size of compiler buffers
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   185
  size_t code_buffers_size = 0;
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   186
#ifdef COMPILER1
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   187
  // C1 temporary code buffers (see Compiler::init_buffer_blob())
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   188
  const int c1_count = CompilationPolicy::policy()->compiler_count(CompLevel_simple);
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   189
  code_buffers_size += c1_count * Compiler::code_buffer_size();
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   190
#endif
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   191
#ifdef COMPILER2
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   192
  // C2 scratch buffers (see Compile::init_scratch_buffer_blob())
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   193
  const int c2_count = CompilationPolicy::policy()->compiler_count(CompLevel_full_optimization);
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   194
  // Initial size of constant table (this may be increased if a compiled method needs more space)
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   195
  code_buffers_size += c2_count * C2Compiler::initial_code_buffer_size();
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   196
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
34182
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   198
  // Increase default non_nmethod_size to account for compiler buffers
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   199
  if (!non_nmethod_set) {
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   200
    non_nmethod_size += code_buffers_size;
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   201
  }
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   202
  // Calculate default CodeHeap sizes if not set by user
34182
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   203
  if (!non_nmethod_set && !profiled_set && !non_profiled_set) {
26919
361b4b4c92c0 8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents: 26918
diff changeset
   204
    // Check if we have enough space for the non-nmethod code heap
34182
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   205
    if (cache_size > non_nmethod_size) {
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   206
      // Use the default value for non_nmethod_size and one half of the
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   207
      // remaining size for non-profiled and one half for profiled methods
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   208
      size_t remaining_size = cache_size - non_nmethod_size;
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   209
      profiled_size = remaining_size / 2;
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   210
      non_profiled_size = remaining_size - profiled_size;
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   211
    } else {
26919
361b4b4c92c0 8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents: 26918
diff changeset
   212
      // Use all space for the non-nmethod heap and set other heaps to minimal size
34182
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   213
      non_nmethod_size = cache_size - 2 * min_size;
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   214
      profiled_size = min_size;
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   215
      non_profiled_size = min_size;
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   216
    }
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   217
  } else if (!non_nmethod_set || !profiled_set || !non_profiled_set) {
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   218
    // The user explicitly set some code heap sizes. Increase or decrease the (default)
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   219
    // sizes of the other code heaps accordingly. First adapt non-profiled and profiled
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   220
    // code heap sizes and then only change non-nmethod code heap size if still necessary.
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   221
    intx diff_size = cache_size - (non_nmethod_size + profiled_size + non_profiled_size);
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   222
    if (non_profiled_set) {
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   223
      if (!profiled_set) {
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   224
        // Adapt size of profiled code heap
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   225
        if (diff_size < 0 && ((intx)profiled_size + diff_size) <= 0) {
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   226
          // Not enough space available, set to minimum size
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   227
          diff_size += profiled_size - min_size;
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   228
          profiled_size = min_size;
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   229
        } else {
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   230
          profiled_size += diff_size;
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   231
          diff_size = 0;
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   232
        }
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   233
      }
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   234
    } else if (profiled_set) {
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   235
      // Adapt size of non-profiled code heap
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   236
      if (diff_size < 0 && ((intx)non_profiled_size + diff_size) <= 0) {
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   237
        // Not enough space available, set to minimum size
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   238
        diff_size += non_profiled_size - min_size;
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   239
        non_profiled_size = min_size;
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   240
      } else {
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   241
        non_profiled_size += diff_size;
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   242
        diff_size = 0;
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   243
      }
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   244
    } else if (non_nmethod_set) {
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   245
      // Distribute remaining size between profiled and non-profiled code heaps
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   246
      diff_size = cache_size - non_nmethod_size;
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   247
      profiled_size = diff_size / 2;
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   248
      non_profiled_size = diff_size - profiled_size;
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   249
      diff_size = 0;
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   250
    }
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   251
    if (diff_size != 0) {
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   252
      // Use non-nmethod code heap for remaining space requirements
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   253
      assert(!non_nmethod_set && ((intx)non_nmethod_size + diff_size) > 0, "sanity");
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   254
      non_nmethod_size += diff_size;
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   255
    }
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   256
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   258
  // We do not need the profiled CodeHeap, use all space for the non-profiled CodeHeap
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   259
  if(!heap_available(CodeBlobType::MethodProfiled)) {
34182
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   260
    non_profiled_size += profiled_size;
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   261
    profiled_size = 0;
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   262
  }
26919
361b4b4c92c0 8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents: 26918
diff changeset
   263
  // We do not need the non-profiled CodeHeap, use all space for the non-nmethod CodeHeap
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   264
  if(!heap_available(CodeBlobType::MethodNonProfiled)) {
34182
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   265
    non_nmethod_size += non_profiled_size;
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   266
    non_profiled_size = 0;
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   267
  }
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   268
  // Make sure we have enough space for VM internal code
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   269
  uint min_code_cache_size = CodeCacheMinimumUseSpace DEBUG_ONLY(* 3);
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   270
  if (non_nmethod_size < (min_code_cache_size + code_buffers_size)) {
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   271
    vm_exit_during_initialization(err_msg(
43407
f6dc40ed6ce9 8171924: Use SIZE_FORMAT to print size_t values.
goetz
parents: 42650
diff changeset
   272
        "Not enough space in non-nmethod code heap to run VM: " SIZE_FORMAT "K < " SIZE_FORMAT "K",
34182
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   273
        non_nmethod_size/K, (min_code_cache_size + code_buffers_size)/K));
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   274
  }
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   275
34182
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   276
  // Verify sizes and update flag values
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   277
  assert(non_profiled_size + profiled_size + non_nmethod_size == cache_size, "Invalid code heap sizes");
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   278
  FLAG_SET_ERGO(uintx, NonNMethodCodeHeapSize, non_nmethod_size);
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   279
  FLAG_SET_ERGO(uintx, ProfiledCodeHeapSize, profiled_size);
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   280
  FLAG_SET_ERGO(uintx, NonProfiledCodeHeapSize, non_profiled_size);
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   281
28730
106944a21769 8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents: 28631
diff changeset
   282
  // Align CodeHeaps
106944a21769 8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents: 28631
diff changeset
   283
  size_t alignment = heap_alignment();
34182
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   284
  non_nmethod_size = align_size_up(non_nmethod_size, alignment);
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   285
  profiled_size   = align_size_down(profiled_size, alignment);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   287
  // Reserve one continuous chunk of memory for CodeHeaps and split it into
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   288
  // parts for the individual heaps. The memory layout looks like this:
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   289
  // ---------- high -----------
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   290
  //    Non-profiled nmethods
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   291
  //      Profiled nmethods
26919
361b4b4c92c0 8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents: 26918
diff changeset
   292
  //         Non-nmethods
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   293
  // ---------- low ------------
34182
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   294
  ReservedCodeSpace rs = reserve_heap_memory(cache_size);
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   295
  ReservedSpace non_method_space    = rs.first_part(non_nmethod_size);
82d1b1696016 8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents: 34174
diff changeset
   296
  ReservedSpace rest                = rs.last_part(non_nmethod_size);
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   297
  ReservedSpace profiled_space      = rest.first_part(profiled_size);
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   298
  ReservedSpace non_profiled_space  = rest.last_part(profiled_size);
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   299
26919
361b4b4c92c0 8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents: 26918
diff changeset
   300
  // Non-nmethods (stubs, adapters, ...)
28730
106944a21769 8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents: 28631
diff changeset
   301
  add_heap(non_method_space, "CodeHeap 'non-nmethods'", CodeBlobType::NonNMethod);
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   302
  // Tier 2 and tier 3 (profiled) methods
28730
106944a21769 8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents: 28631
diff changeset
   303
  add_heap(profiled_space, "CodeHeap 'profiled nmethods'", CodeBlobType::MethodProfiled);
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   304
  // Tier 1 and tier 4 (non-profiled) methods and native methods
28730
106944a21769 8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents: 28631
diff changeset
   305
  add_heap(non_profiled_space, "CodeHeap 'non-profiled nmethods'", CodeBlobType::MethodNonProfiled);
106944a21769 8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents: 28631
diff changeset
   306
}
106944a21769 8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents: 28631
diff changeset
   307
106944a21769 8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents: 28631
diff changeset
   308
size_t CodeCache::heap_alignment() {
106944a21769 8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents: 28631
diff changeset
   309
  // If large page support is enabled, align code heaps according to large
106944a21769 8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents: 28631
diff changeset
   310
  // page size to make sure that code cache is covered by large pages.
106944a21769 8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents: 28631
diff changeset
   311
  const size_t page_size = os::can_execute_large_page_memory() ?
106944a21769 8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents: 28631
diff changeset
   312
             os::page_size_for_region_unaligned(ReservedCodeCacheSize, 8) :
106944a21769 8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents: 28631
diff changeset
   313
             os::vm_page_size();
106944a21769 8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents: 28631
diff changeset
   314
  return MAX2(page_size, (size_t) os::vm_allocation_granularity());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   317
ReservedCodeSpace CodeCache::reserve_heap_memory(size_t size) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   318
  // Determine alignment
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   319
  const size_t page_size = os::can_execute_large_page_memory() ?
28631
a56cae1b428d 8066875: VirtualSpace does not use large pages
ehelin
parents: 28374
diff changeset
   320
          MIN2(os::page_size_for_region_aligned(InitialCodeCacheSize, 8),
a56cae1b428d 8066875: VirtualSpace does not use large pages
ehelin
parents: 28374
diff changeset
   321
               os::page_size_for_region_aligned(size, 8)) :
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   322
          os::vm_page_size();
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   323
  const size_t granularity = os::vm_allocation_granularity();
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   324
  const size_t r_align = MAX2(page_size, granularity);
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   325
  const size_t r_size = align_size_up(size, r_align);
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   326
  const size_t rs_align = page_size == (size_t) os::vm_page_size() ? 0 :
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   327
    MAX2(page_size, granularity);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   329
  ReservedCodeSpace rs(r_size, rs_align, rs_align > 0);
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   330
35203
3e70c7dc0772 8144949: TestOptionsWithRanges -XX:NUMAInterleaveGranularity=2147483648 crashes VM
sangheki
parents: 34182
diff changeset
   331
  if (!rs.is_reserved()) {
3e70c7dc0772 8144949: TestOptionsWithRanges -XX:NUMAInterleaveGranularity=2147483648 crashes VM
sangheki
parents: 34182
diff changeset
   332
    vm_exit_during_initialization("Could not reserve enough space for code cache");
3e70c7dc0772 8144949: TestOptionsWithRanges -XX:NUMAInterleaveGranularity=2147483648 crashes VM
sangheki
parents: 34182
diff changeset
   333
  }
3e70c7dc0772 8144949: TestOptionsWithRanges -XX:NUMAInterleaveGranularity=2147483648 crashes VM
sangheki
parents: 34182
diff changeset
   334
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   335
  // Initialize bounds
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   336
  _low_bound = (address)rs.base();
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   337
  _high_bound = _low_bound + rs.size();
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   338
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   339
  return rs;
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   340
}
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   341
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   342
bool CodeCache::heap_available(int code_blob_type) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   343
  if (!SegmentedCodeCache) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   344
    // No segmentation: use a single code heap
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   345
    return (code_blob_type == CodeBlobType::All);
38055
9dddf9056918 8086068: VM crashes with "-Xint -XX:+UseCompiler" options
thartmann
parents: 37289
diff changeset
   346
  } else if (Arguments::is_interpreter_only()) {
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   347
    // Interpreter only: we don't need any method code heaps
26919
361b4b4c92c0 8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents: 26918
diff changeset
   348
    return (code_blob_type == CodeBlobType::NonNMethod);
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   349
  } else if (TieredCompilation && (TieredStopAtLevel > CompLevel_simple)) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   350
    // Tiered compilation: use all code heaps
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   351
    return (code_blob_type < CodeBlobType::All);
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   352
  } else {
26919
361b4b4c92c0 8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents: 26918
diff changeset
   353
    // No TieredCompilation: we only need the non-nmethod and non-profiled code heap
361b4b4c92c0 8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents: 26918
diff changeset
   354
    return (code_blob_type == CodeBlobType::NonNMethod) ||
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   355
           (code_blob_type == CodeBlobType::MethodNonProfiled);
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   356
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
27410
dd80df7cfa2b 8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents: 27015
diff changeset
   359
const char* CodeCache::get_code_heap_flag_name(int code_blob_type) {
dd80df7cfa2b 8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents: 27015
diff changeset
   360
  switch(code_blob_type) {
dd80df7cfa2b 8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents: 27015
diff changeset
   361
  case CodeBlobType::NonNMethod:
dd80df7cfa2b 8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents: 27015
diff changeset
   362
    return "NonNMethodCodeHeapSize";
dd80df7cfa2b 8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents: 27015
diff changeset
   363
    break;
dd80df7cfa2b 8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents: 27015
diff changeset
   364
  case CodeBlobType::MethodNonProfiled:
dd80df7cfa2b 8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents: 27015
diff changeset
   365
    return "NonProfiledCodeHeapSize";
dd80df7cfa2b 8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents: 27015
diff changeset
   366
    break;
dd80df7cfa2b 8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents: 27015
diff changeset
   367
  case CodeBlobType::MethodProfiled:
dd80df7cfa2b 8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents: 27015
diff changeset
   368
    return "ProfiledCodeHeapSize";
dd80df7cfa2b 8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents: 27015
diff changeset
   369
    break;
dd80df7cfa2b 8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents: 27015
diff changeset
   370
  }
dd80df7cfa2b 8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents: 27015
diff changeset
   371
  ShouldNotReachHere();
dd80df7cfa2b 8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents: 27015
diff changeset
   372
  return NULL;
dd80df7cfa2b 8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents: 27015
diff changeset
   373
}
dd80df7cfa2b 8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents: 27015
diff changeset
   374
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   375
int CodeCache::code_heap_compare(CodeHeap* const &lhs, CodeHeap* const &rhs) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   376
  if (lhs->code_blob_type() == rhs->code_blob_type()) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   377
    return (lhs > rhs) ? 1 : ((lhs < rhs) ? -1 : 0);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   378
  } else {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   379
    return lhs->code_blob_type() - rhs->code_blob_type();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   380
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   381
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   382
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   383
void CodeCache::add_heap(CodeHeap* heap) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   384
  assert(!Universe::is_fully_initialized(), "late heap addition?");
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   385
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   386
  _heaps->insert_sorted<code_heap_compare>(heap);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   387
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   388
  int type = heap->code_blob_type();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   389
  if (code_blob_type_accepts_compiled(type)) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   390
    _compiled_heaps->insert_sorted<code_heap_compare>(heap);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   391
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   392
  if (code_blob_type_accepts_nmethod(type)) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   393
    _nmethod_heaps->insert_sorted<code_heap_compare>(heap);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   394
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   395
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   396
28730
106944a21769 8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents: 28631
diff changeset
   397
void CodeCache::add_heap(ReservedSpace rs, const char* name, int code_blob_type) {
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   398
  // Check if heap is needed
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   399
  if (!heap_available(code_blob_type)) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   400
    return;
5533
e8d9ff82ec62 6950075: nmethod sweeper should operate concurrently
never
parents: 5247
diff changeset
   401
  }
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   402
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   403
  // Create CodeHeap
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   404
  CodeHeap* heap = new CodeHeap(name, code_blob_type);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   405
  add_heap(heap);
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   406
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   407
  // Reserve Space
28730
106944a21769 8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents: 28631
diff changeset
   408
  size_t size_initial = MIN2(InitialCodeCacheSize, rs.size());
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   409
  size_initial = round_to(size_initial, os::vm_page_size());
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   410
  if (!heap->reserve(rs, size_initial, CodeCacheSegmentSize)) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   411
    vm_exit_during_initialization("Could not reserve enough space for code cache");
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   412
  }
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   413
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   414
  // Register the CodeHeap
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   415
  MemoryService::add_code_heap_memory_pool(heap, name);
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   416
}
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   417
27642
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents: 27420
diff changeset
   418
CodeHeap* CodeCache::get_code_heap(const CodeBlob* cb) {
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   419
  assert(cb != NULL, "CodeBlob is null");
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   420
  FOR_ALL_HEAPS(heap) {
43945
e7f2e49d2274 8173151: Code heap corruption due to incorrect inclusion test
zmajo
parents: 43675
diff changeset
   421
    if ((*heap)->contains_blob(cb)) {
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   422
      return *heap;
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   423
    }
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   424
  }
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   425
  ShouldNotReachHere();
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   426
  return NULL;
5533
e8d9ff82ec62 6950075: nmethod sweeper should operate concurrently
never
parents: 5247
diff changeset
   427
}
e8d9ff82ec62 6950075: nmethod sweeper should operate concurrently
never
parents: 5247
diff changeset
   428
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   429
CodeHeap* CodeCache::get_code_heap(int code_blob_type) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   430
  FOR_ALL_HEAPS(heap) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   431
    if ((*heap)->accepts(code_blob_type)) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   432
      return *heap;
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   433
    }
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   434
  }
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   435
  return NULL;
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   436
}
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   437
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   438
CodeBlob* CodeCache::first_blob(CodeHeap* heap) {
5533
e8d9ff82ec62 6950075: nmethod sweeper should operate concurrently
never
parents: 5247
diff changeset
   439
  assert_locked_or_safepoint(CodeCache_lock);
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   440
  assert(heap != NULL, "heap is null");
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   441
  return (CodeBlob*)heap->first();
5533
e8d9ff82ec62 6950075: nmethod sweeper should operate concurrently
never
parents: 5247
diff changeset
   442
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   444
CodeBlob* CodeCache::first_blob(int code_blob_type) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   445
  if (heap_available(code_blob_type)) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   446
    return first_blob(get_code_heap(code_blob_type));
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   447
  } else {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   448
    return NULL;
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   449
  }
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   450
}
15201
f3d755b11424 8005204: Code Cache Reduction: command line options implementation
vladidan
parents: 13878
diff changeset
   451
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   452
CodeBlob* CodeCache::next_blob(CodeHeap* heap, CodeBlob* cb) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   453
  assert_locked_or_safepoint(CodeCache_lock);
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   454
  assert(heap != NULL, "heap is null");
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   455
  return (CodeBlob*)heap->next(cb);
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   456
}
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   457
27420
04e6f914cce1 8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents: 27410
diff changeset
   458
/**
04e6f914cce1 8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents: 27410
diff changeset
   459
 * Do not seize the CodeCache lock here--if the caller has not
04e6f914cce1 8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents: 27410
diff changeset
   460
 * already done so, we are going to lose bigtime, since the code
04e6f914cce1 8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents: 27410
diff changeset
   461
 * cache will contain a garbage CodeBlob until the caller can
04e6f914cce1 8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents: 27410
diff changeset
   462
 * run the constructor for the CodeBlob subclass he is busy
04e6f914cce1 8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents: 27410
diff changeset
   463
 * instantiating.
04e6f914cce1 8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents: 27410
diff changeset
   464
 */
40863
f5fec6a2dc9e 8064892: Non-methods code cache overflow is not handled correctly
thartmann
parents: 38133
diff changeset
   465
CodeBlob* CodeCache::allocate(int size, int code_blob_type, int orig_code_blob_type) {
27420
04e6f914cce1 8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents: 27410
diff changeset
   466
  // Possibly wakes up the sweeper thread.
04e6f914cce1 8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents: 27410
diff changeset
   467
  NMethodSweeper::notify(code_blob_type);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
  assert_locked_or_safepoint(CodeCache_lock);
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32466
diff changeset
   469
  assert(size > 0, "Code cache allocation request must be > 0 but is %d", size);
24439
252c634b2e1c 8029343: CodeCache::allocate increments '_number_of_blobs' even if allocation fails.
anoll
parents: 23214
diff changeset
   470
  if (size <= 0) {
252c634b2e1c 8029343: CodeCache::allocate increments '_number_of_blobs' even if allocation fails.
anoll
parents: 23214
diff changeset
   471
    return NULL;
252c634b2e1c 8029343: CodeCache::allocate increments '_number_of_blobs' even if allocation fails.
anoll
parents: 23214
diff changeset
   472
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
  CodeBlob* cb = NULL;
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   474
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   475
  // Get CodeHeap for the given CodeBlobType
26942
fa5ea7ff078d 8059390: code cache fills up for bigapps/Weblogic+medrec/nowarnings
zmajo
parents: 26919
diff changeset
   476
  CodeHeap* heap = get_code_heap(code_blob_type);
fa5ea7ff078d 8059390: code cache fills up for bigapps/Weblogic+medrec/nowarnings
zmajo
parents: 26919
diff changeset
   477
  assert(heap != NULL, "heap is null");
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   478
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
  while (true) {
27420
04e6f914cce1 8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents: 27410
diff changeset
   480
    cb = (CodeBlob*)heap->allocate(size);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
    if (cb != NULL) break;
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   482
    if (!heap->expand_by(CodeCacheExpansionSize)) {
40863
f5fec6a2dc9e 8064892: Non-methods code cache overflow is not handled correctly
thartmann
parents: 38133
diff changeset
   483
      // Save original type for error reporting
f5fec6a2dc9e 8064892: Non-methods code cache overflow is not handled correctly
thartmann
parents: 38133
diff changeset
   484
      if (orig_code_blob_type == CodeBlobType::All) {
f5fec6a2dc9e 8064892: Non-methods code cache overflow is not handled correctly
thartmann
parents: 38133
diff changeset
   485
        orig_code_blob_type = code_blob_type;
f5fec6a2dc9e 8064892: Non-methods code cache overflow is not handled correctly
thartmann
parents: 38133
diff changeset
   486
      }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
      // Expansion failed
40863
f5fec6a2dc9e 8064892: Non-methods code cache overflow is not handled correctly
thartmann
parents: 38133
diff changeset
   488
      if (SegmentedCodeCache) {
29338
92297a8bd48e 8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents: 28730
diff changeset
   489
        // Fallback solution: Try to store code in another code heap.
40863
f5fec6a2dc9e 8064892: Non-methods code cache overflow is not handled correctly
thartmann
parents: 38133
diff changeset
   490
        // NonNMethod -> MethodNonProfiled -> MethodProfiled (-> MethodNonProfiled)
29338
92297a8bd48e 8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents: 28730
diff changeset
   491
        // Note that in the sweeper, we check the reverse_free_ratio of the code heap
92297a8bd48e 8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents: 28730
diff changeset
   492
        // and force stack scanning if less than 10% of the code heap are free.
92297a8bd48e 8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents: 28730
diff changeset
   493
        int type = code_blob_type;
92297a8bd48e 8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents: 28730
diff changeset
   494
        switch (type) {
92297a8bd48e 8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents: 28730
diff changeset
   495
        case CodeBlobType::NonNMethod:
92297a8bd48e 8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents: 28730
diff changeset
   496
          type = CodeBlobType::MethodNonProfiled;
92297a8bd48e 8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents: 28730
diff changeset
   497
          break;
92297a8bd48e 8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents: 28730
diff changeset
   498
        case CodeBlobType::MethodNonProfiled:
92297a8bd48e 8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents: 28730
diff changeset
   499
          type = CodeBlobType::MethodProfiled;
40863
f5fec6a2dc9e 8064892: Non-methods code cache overflow is not handled correctly
thartmann
parents: 38133
diff changeset
   500
          break;
f5fec6a2dc9e 8064892: Non-methods code cache overflow is not handled correctly
thartmann
parents: 38133
diff changeset
   501
        case CodeBlobType::MethodProfiled:
f5fec6a2dc9e 8064892: Non-methods code cache overflow is not handled correctly
thartmann
parents: 38133
diff changeset
   502
          // Avoid loop if we already tried that code heap
f5fec6a2dc9e 8064892: Non-methods code cache overflow is not handled correctly
thartmann
parents: 38133
diff changeset
   503
          if (type == orig_code_blob_type) {
f5fec6a2dc9e 8064892: Non-methods code cache overflow is not handled correctly
thartmann
parents: 38133
diff changeset
   504
            type = CodeBlobType::MethodNonProfiled;
f5fec6a2dc9e 8064892: Non-methods code cache overflow is not handled correctly
thartmann
parents: 38133
diff changeset
   505
          }
29338
92297a8bd48e 8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents: 28730
diff changeset
   506
          break;
92297a8bd48e 8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents: 28730
diff changeset
   507
        }
40863
f5fec6a2dc9e 8064892: Non-methods code cache overflow is not handled correctly
thartmann
parents: 38133
diff changeset
   508
        if (type != code_blob_type && type != orig_code_blob_type && heap_available(type)) {
f5fec6a2dc9e 8064892: Non-methods code cache overflow is not handled correctly
thartmann
parents: 38133
diff changeset
   509
          if (PrintCodeCacheExtension) {
f5fec6a2dc9e 8064892: Non-methods code cache overflow is not handled correctly
thartmann
parents: 38133
diff changeset
   510
            tty->print_cr("Extension of %s failed. Trying to allocate in %s.",
f5fec6a2dc9e 8064892: Non-methods code cache overflow is not handled correctly
thartmann
parents: 38133
diff changeset
   511
                          heap->name(), get_code_heap(type)->name());
f5fec6a2dc9e 8064892: Non-methods code cache overflow is not handled correctly
thartmann
parents: 38133
diff changeset
   512
          }
f5fec6a2dc9e 8064892: Non-methods code cache overflow is not handled correctly
thartmann
parents: 38133
diff changeset
   513
          return allocate(size, type, orig_code_blob_type);
29338
92297a8bd48e 8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents: 28730
diff changeset
   514
        }
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   515
      }
27420
04e6f914cce1 8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents: 27410
diff changeset
   516
      MutexUnlockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
40863
f5fec6a2dc9e 8064892: Non-methods code cache overflow is not handled correctly
thartmann
parents: 38133
diff changeset
   517
      CompileBroker::handle_full_code_cache(orig_code_blob_type);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
      return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
    if (PrintCodeCacheExtension) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
      ResourceMark rm;
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   522
      if (_nmethod_heaps->length() >= 1) {
26918
4e1761669426 8059137: MemoryPoolMXBeans for different code heaps should contain 'Code heap' in their names
thartmann
parents: 26809
diff changeset
   523
        tty->print("%s", heap->name());
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   524
      } else {
26919
361b4b4c92c0 8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents: 26918
diff changeset
   525
        tty->print("CodeCache");
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   526
      }
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   527
      tty->print_cr(" extended to [" INTPTR_FORMAT ", " INTPTR_FORMAT "] (" SSIZE_FORMAT " bytes)",
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   528
                    (intptr_t)heap->low_boundary(), (intptr_t)heap->high(),
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   529
                    (address)heap->high() - (address)heap->low_boundary());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
  }
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   532
  print_trace("allocation", cb, size);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
  return cb;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
void CodeCache::free(CodeBlob* cb) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
  assert_locked_or_safepoint(CodeCache_lock);
34158
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   538
  CodeHeap* heap = get_code_heap(cb);
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   539
  print_trace("free", cb);
5924
dc9d04930c82 6965184: possible races in make_not_entrant_or_zombie
never
parents: 5702
diff changeset
   540
  if (cb->is_nmethod()) {
34158
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   541
    heap->set_nmethod_count(heap->nmethod_count() - 1);
5924
dc9d04930c82 6965184: possible races in make_not_entrant_or_zombie
never
parents: 5702
diff changeset
   542
    if (((nmethod *)cb)->has_dependencies()) {
dc9d04930c82 6965184: possible races in make_not_entrant_or_zombie
never
parents: 5702
diff changeset
   543
      _number_of_nmethods_with_dependencies--;
dc9d04930c82 6965184: possible races in make_not_entrant_or_zombie
never
parents: 5702
diff changeset
   544
    }
dc9d04930c82 6965184: possible races in make_not_entrant_or_zombie
never
parents: 5702
diff changeset
   545
  }
dc9d04930c82 6965184: possible races in make_not_entrant_or_zombie
never
parents: 5702
diff changeset
   546
  if (cb->is_adapter_blob()) {
34158
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   547
    heap->set_adapter_count(heap->adapter_count() - 1);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   550
  // Get heap for given CodeBlob and deallocate
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   551
  get_code_heap(cb)->deallocate(cb);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
34158
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   553
  assert(heap->blob_count() >= 0, "sanity check");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
void CodeCache::commit(CodeBlob* cb) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
  // this is called by nmethod::nmethod, which must already own CodeCache_lock
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
  assert_locked_or_safepoint(CodeCache_lock);
34158
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   559
  CodeHeap* heap = get_code_heap(cb);
5924
dc9d04930c82 6965184: possible races in make_not_entrant_or_zombie
never
parents: 5702
diff changeset
   560
  if (cb->is_nmethod()) {
34158
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   561
    heap->set_nmethod_count(heap->nmethod_count() + 1);
5924
dc9d04930c82 6965184: possible races in make_not_entrant_or_zombie
never
parents: 5702
diff changeset
   562
    if (((nmethod *)cb)->has_dependencies()) {
dc9d04930c82 6965184: possible races in make_not_entrant_or_zombie
never
parents: 5702
diff changeset
   563
      _number_of_nmethods_with_dependencies++;
dc9d04930c82 6965184: possible races in make_not_entrant_or_zombie
never
parents: 5702
diff changeset
   564
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
  }
5924
dc9d04930c82 6965184: possible races in make_not_entrant_or_zombie
never
parents: 5702
diff changeset
   566
  if (cb->is_adapter_blob()) {
34158
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   567
    heap->set_adapter_count(heap->adapter_count() + 1);
5924
dc9d04930c82 6965184: possible races in make_not_entrant_or_zombie
never
parents: 5702
diff changeset
   568
  }
dc9d04930c82 6965184: possible races in make_not_entrant_or_zombie
never
parents: 5702
diff changeset
   569
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
  // flush the hardware I-cache
6418
6671edbd230e 6978355: renaming for 6961697
twisti
parents: 5924
diff changeset
   571
  ICache::invalidate_range(cb->content_begin(), cb->content_size());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
bool CodeCache::contains(void *p) {
42062
473286891dd8 8166560: [s390] Basic enablement of s390 port.
goetz
parents: 41056
diff changeset
   575
  // S390 uses contains() in current_frame(), which is used before
473286891dd8 8166560: [s390] Basic enablement of s390 port.
goetz
parents: 41056
diff changeset
   576
  // code cache initialization if NativeMemoryTracking=detail is set.
473286891dd8 8166560: [s390] Basic enablement of s390 port.
goetz
parents: 41056
diff changeset
   577
  S390_ONLY(if (_heaps == NULL) return false;)
473286891dd8 8166560: [s390] Basic enablement of s390 port.
goetz
parents: 41056
diff changeset
   578
  // It should be ok to call contains without holding a lock.
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   579
  FOR_ALL_HEAPS(heap) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   580
    if ((*heap)->contains(p)) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   581
      return true;
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   582
    }
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   583
  }
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   584
  return false;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   587
bool CodeCache::contains(nmethod *nm) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   588
  return contains((void *)nm);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   589
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   590
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   591
// This method is safe to call without holding the CodeCache_lock, as long as a dead CodeBlob is not
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   592
// looked up (i.e., one that has been marked for deletion). It only depends on the _segmap to contain
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
// valid indices, which it will always do, as long as the CodeBlob is not in the process of being recycled.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
CodeBlob* CodeCache::find_blob(void* start) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
  CodeBlob* result = find_blob_unsafe(start);
23214
b6426873cb37 8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents: 22921
diff changeset
   596
  // We could potentially look up non_entrant methods
46589
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46527
diff changeset
   597
  guarantee(result == NULL || !result->is_zombie() || result->is_locked_by_vm() || VMError::is_error_reported(), "unsafe access to zombie method");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
  return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   601
// Lookup that does not fail if you lookup a zombie method (if you call this, be sure to know
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   602
// what you are doing)
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   603
CodeBlob* CodeCache::find_blob_unsafe(void* start) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   604
  // NMT can walk the stack before code cache is created
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 38055
diff changeset
   605
  if (_heaps != NULL && !_heaps->is_empty()) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 38055
diff changeset
   606
    FOR_ALL_HEAPS(heap) {
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   607
      CodeBlob* result = (*heap)->find_blob_unsafe(start);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   608
      if (result != NULL) {
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 38055
diff changeset
   609
        return result;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 38055
diff changeset
   610
      }
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   611
    }
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   612
  }
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   613
  return NULL;
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   614
}
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   615
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
nmethod* CodeCache::find_nmethod(void* start) {
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   617
  CodeBlob* cb = find_blob(start);
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   618
  assert(cb->is_nmethod(), "did not find an nmethod");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
  return (nmethod*)cb;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
void CodeCache::blobs_do(void f(CodeBlob* nm)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
  assert_locked_or_safepoint(CodeCache_lock);
46527
df19f7e4b9f7 8171365: nsk/jvmti/scenarios/events/EM04/em04t001: many errors for missed events
cjplummer
parents: 46329
diff changeset
   624
  FOR_ALL_HEAPS(heap) {
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   625
    FOR_ALL_BLOBS(cb, *heap) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   626
      f(cb);
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   627
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   630
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
void CodeCache::nmethods_do(void f(nmethod* nm)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
  assert_locked_or_safepoint(CodeCache_lock);
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   633
  NMethodIterator iter;
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   634
  while(iter.next()) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   635
    f(iter.method());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   637
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 38055
diff changeset
   639
void CodeCache::metadata_do(void f(Metadata* m)) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   640
  assert_locked_or_safepoint(CodeCache_lock);
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   641
  NMethodIterator iter;
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   642
  while(iter.next_alive()) {
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 38055
diff changeset
   643
    iter.method()->metadata_do(f);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   644
  }
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   645
  AOTLoader::metadata_do(f);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   646
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   647
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
int CodeCache::alignment_unit() {
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   649
  return (int)_heaps->first()->alignment_unit();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652
int CodeCache::alignment_offset() {
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   653
  return (int)_heaps->first()->alignment_offset();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   654
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   655
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   656
// Mark nmethods for unloading if they contain otherwise unreachable oops.
13878
6e6a462a6cff 7200470: KeepAliveClosure not needed in CodeCache::do_unloading
brutisso
parents: 13728
diff changeset
   657
void CodeCache::do_unloading(BoolObjectClosure* is_alive, bool unloading_occurred) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   658
  assert_locked_or_safepoint(CodeCache_lock);
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 38055
diff changeset
   659
  CompiledMethodIterator iter;
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   660
  while(iter.next_alive()) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   661
    iter.method()->do_unloading(is_alive, unloading_occurred);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   662
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   663
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   664
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   665
void CodeCache::blobs_do(CodeBlobClosure* f) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   666
  assert_locked_or_safepoint(CodeCache_lock);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   667
  FOR_ALL_NMETHOD_HEAPS(heap) {
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   668
    FOR_ALL_BLOBS(cb, *heap) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   669
      if (cb->is_alive()) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   670
        f->do_code_blob(cb);
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   671
#ifdef ASSERT
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   672
        if (cb->is_nmethod())
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   673
        ((nmethod*)cb)->verify_scavenge_root_oops();
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   674
#endif //ASSERT
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   675
      }
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   676
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   677
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   678
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   679
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   680
// Walk the list of methods which might contain non-perm oops.
36591
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 35825
diff changeset
   681
void CodeCache::scavenge_root_nmethods_do(CodeBlobToOopClosure* f) {
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   682
  assert_locked_or_safepoint(CodeCache_lock);
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   683
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   684
  if (UseG1GC) {
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   685
    return;
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   686
  }
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   687
36591
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 35825
diff changeset
   688
  const bool fix_relocations = f->fix_relocations();
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   689
  debug_only(mark_scavenge_root_nmethods());
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   690
36591
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 35825
diff changeset
   691
  nmethod* prev = NULL;
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 35825
diff changeset
   692
  nmethod* cur = scavenge_root_nmethods();
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 35825
diff changeset
   693
  while (cur != NULL) {
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   694
    debug_only(cur->clear_scavenge_root_marked());
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   695
    assert(cur->scavenge_root_not_marked(), "");
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   696
    assert(cur->on_scavenge_root_list(), "else shouldn't be on this list");
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   697
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   698
    bool is_live = (!cur->is_zombie() && !cur->is_unloaded());
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   699
    if (TraceScavenge) {
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   700
      cur->print_on(tty, is_live ? "scavenge root" : "dead scavenge root"); tty->cr();
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   701
    }
5247
c2b4e525b3e5 6940520: CodeCache::scavenge_root_nmethods_do must fix oop relocations
twisti
parents: 4750
diff changeset
   702
    if (is_live) {
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   703
      // Perform cur->oops_do(f), maybe just once per nmethod.
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   704
      f->do_code_blob(cur);
5247
c2b4e525b3e5 6940520: CodeCache::scavenge_root_nmethods_do must fix oop relocations
twisti
parents: 4750
diff changeset
   705
    }
36591
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 35825
diff changeset
   706
    nmethod* const next = cur->scavenge_root_link();
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 35825
diff changeset
   707
    // The scavengable nmethod list must contain all methods with scavengable
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 35825
diff changeset
   708
    // oops. It is safe to include more nmethod on the list, but we do not
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 35825
diff changeset
   709
    // expect any live non-scavengable nmethods on the list.
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 35825
diff changeset
   710
    if (fix_relocations) {
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 35825
diff changeset
   711
      if (!is_live || !cur->detect_scavenge_root_oops()) {
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 35825
diff changeset
   712
        unlink_scavenge_root_nmethod(cur, prev);
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 35825
diff changeset
   713
      } else {
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 35825
diff changeset
   714
        prev = cur;
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 35825
diff changeset
   715
      }
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 35825
diff changeset
   716
    }
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 35825
diff changeset
   717
    cur = next;
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   718
  }
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   719
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   720
  // Check for stray marks.
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   721
  debug_only(verify_perm_nmethods(NULL));
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   722
}
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   723
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   724
void CodeCache::add_scavenge_root_nmethod(nmethod* nm) {
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   725
  assert_locked_or_safepoint(CodeCache_lock);
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   726
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   727
  if (UseG1GC) {
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   728
    return;
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   729
  }
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   730
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   731
  nm->set_on_scavenge_root_list();
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   732
  nm->set_scavenge_root_link(_scavenge_root_nmethods);
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   733
  set_scavenge_root_nmethods(nm);
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   734
  print_trace("add_scavenge_root", nm);
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   735
}
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   736
36591
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 35825
diff changeset
   737
void CodeCache::unlink_scavenge_root_nmethod(nmethod* nm, nmethod* prev) {
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 35825
diff changeset
   738
  assert_locked_or_safepoint(CodeCache_lock);
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 35825
diff changeset
   739
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 35825
diff changeset
   740
  assert((prev == NULL && scavenge_root_nmethods() == nm) ||
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 35825
diff changeset
   741
         (prev != NULL && prev->scavenge_root_link() == nm), "precondition");
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 35825
diff changeset
   742
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 35825
diff changeset
   743
  assert(!UseG1GC, "G1 does not use the scavenge_root_nmethods list");
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 35825
diff changeset
   744
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 35825
diff changeset
   745
  print_trace("unlink_scavenge_root", nm);
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 35825
diff changeset
   746
  if (prev == NULL) {
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 35825
diff changeset
   747
    set_scavenge_root_nmethods(nm->scavenge_root_link());
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 35825
diff changeset
   748
  } else {
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 35825
diff changeset
   749
    prev->set_scavenge_root_link(nm->scavenge_root_link());
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 35825
diff changeset
   750
  }
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 35825
diff changeset
   751
  nm->set_scavenge_root_link(NULL);
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 35825
diff changeset
   752
  nm->clear_on_scavenge_root_list();
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 35825
diff changeset
   753
}
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 35825
diff changeset
   754
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   755
void CodeCache::drop_scavenge_root_nmethod(nmethod* nm) {
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   756
  assert_locked_or_safepoint(CodeCache_lock);
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   757
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   758
  if (UseG1GC) {
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   759
    return;
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   760
  }
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   761
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   762
  print_trace("drop_scavenge_root", nm);
36591
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 35825
diff changeset
   763
  nmethod* prev = NULL;
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 35825
diff changeset
   764
  for (nmethod* cur = scavenge_root_nmethods(); cur != NULL; cur = cur->scavenge_root_link()) {
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   765
    if (cur == nm) {
36591
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 35825
diff changeset
   766
      unlink_scavenge_root_nmethod(cur, prev);
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   767
      return;
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   768
    }
36591
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 35825
diff changeset
   769
    prev = cur;
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   770
  }
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   771
  assert(false, "should have been on list");
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   772
}
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   773
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   774
void CodeCache::prune_scavenge_root_nmethods() {
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   775
  assert_locked_or_safepoint(CodeCache_lock);
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   776
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   777
  if (UseG1GC) {
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   778
    return;
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   779
  }
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   780
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   781
  debug_only(mark_scavenge_root_nmethods());
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   782
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   783
  nmethod* last = NULL;
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   784
  nmethod* cur = scavenge_root_nmethods();
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   785
  while (cur != NULL) {
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   786
    nmethod* next = cur->scavenge_root_link();
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   787
    debug_only(cur->clear_scavenge_root_marked());
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   788
    assert(cur->scavenge_root_not_marked(), "");
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   789
    assert(cur->on_scavenge_root_list(), "else shouldn't be on this list");
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   790
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   791
    if (!cur->is_zombie() && !cur->is_unloaded()
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   792
        && cur->detect_scavenge_root_oops()) {
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   793
      // Keep it.  Advance 'last' to prevent deletion.
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   794
      last = cur;
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   795
    } else {
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   796
      // Prune it from the list, so we don't have to look at it any more.
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   797
      print_trace("prune_scavenge_root", cur);
36591
d0622cab5983 8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents: 35825
diff changeset
   798
      unlink_scavenge_root_nmethod(cur, last);
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   799
    }
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   800
    cur = next;
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   801
  }
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   802
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   803
  // Check for stray marks.
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   804
  debug_only(verify_perm_nmethods(NULL));
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   805
}
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   806
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   807
#ifndef PRODUCT
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   808
void CodeCache::asserted_non_scavengable_nmethods_do(CodeBlobClosure* f) {
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   809
  if (UseG1GC) {
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   810
    return;
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   811
  }
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   812
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   813
  // While we are here, verify the integrity of the list.
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   814
  mark_scavenge_root_nmethods();
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   815
  for (nmethod* cur = scavenge_root_nmethods(); cur != NULL; cur = cur->scavenge_root_link()) {
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   816
    assert(cur->on_scavenge_root_list(), "else shouldn't be on this list");
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   817
    cur->clear_scavenge_root_marked();
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   818
  }
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   819
  verify_perm_nmethods(f);
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   820
}
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   821
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   822
// Temporarily mark nmethods that are claimed to be on the non-perm list.
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   823
void CodeCache::mark_scavenge_root_nmethods() {
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   824
  NMethodIterator iter;
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   825
  while(iter.next_alive()) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   826
    nmethod* nm = iter.method();
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   827
    assert(nm->scavenge_root_not_marked(), "clean state");
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   828
    if (nm->on_scavenge_root_list())
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   829
      nm->set_scavenge_root_marked();
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   830
  }
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   831
}
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   832
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   833
// If the closure is given, run it on the unlisted nmethods.
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   834
// Also make sure that the effects of mark_scavenge_root_nmethods is gone.
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   835
void CodeCache::verify_perm_nmethods(CodeBlobClosure* f_or_null) {
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   836
  NMethodIterator iter;
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   837
  while(iter.next_alive()) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   838
    nmethod* nm = iter.method();
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   839
    bool call_f = (f_or_null != NULL);
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   840
    assert(nm->scavenge_root_not_marked(), "must be already processed");
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   841
    if (nm->on_scavenge_root_list())
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   842
      call_f = false;  // don't show this one to the client
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   843
    nm->verify_scavenge_root_oops();
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   844
    if (call_f)  f_or_null->do_code_blob(nm);
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   845
  }
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   846
}
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   847
#endif //PRODUCT
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   848
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   849
void CodeCache::verify_clean_inline_caches() {
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   850
#ifdef ASSERT
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   851
  NMethodIterator iter;
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   852
  while(iter.next_alive()) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   853
    nmethod* nm = iter.method();
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   854
    assert(!nm->is_unloaded(), "Tautology");
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   855
    nm->verify_clean_inline_caches();
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   856
    nm->verify();
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   857
  }
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   858
#endif
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   859
}
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   860
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   861
void CodeCache::verify_icholder_relocations() {
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   862
#ifdef ASSERT
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   863
  // make sure that we aren't leaking icholders
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   864
  int count = 0;
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   865
  FOR_ALL_HEAPS(heap) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   866
    FOR_ALL_BLOBS(cb, *heap) {
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   867
      CompiledMethod *nm = cb->as_compiled_method_or_null();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   868
      if (nm != NULL) {
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   869
        count += nm->verify_icholder_relocations();
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   870
      }
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   871
    }
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   872
  }
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   873
  assert(count + InlineCacheBuffer::pending_icholder_count() + CompiledICHolder::live_not_claimed_count() ==
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   874
         CompiledICHolder::live_count(), "must agree");
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   875
#endif
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   876
}
4750
71fd601907dc 4360113: Evict nmethods when code cache gets full
kvn
parents: 3908
diff changeset
   877
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   878
void CodeCache::gc_prologue() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   879
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   880
489c9b5090e2 Initial load
duke
parents:
diff changeset
   881
void CodeCache::gc_epilogue() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   882
  assert_locked_or_safepoint(CodeCache_lock);
32466
915d0c3d25aa 8134493: Cleaning inline caches of unloaded nmethods should be done in sweeper
thartmann
parents: 32401
diff changeset
   883
  NOT_DEBUG(if (needs_cache_clean())) {
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 38055
diff changeset
   884
    CompiledMethodIterator iter;
32466
915d0c3d25aa 8134493: Cleaning inline caches of unloaded nmethods should be done in sweeper
thartmann
parents: 32401
diff changeset
   885
    while(iter.next_alive()) {
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 38055
diff changeset
   886
      CompiledMethod* cm = iter.method();
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 38055
diff changeset
   887
      assert(!cm->is_unloaded(), "Tautology");
32466
915d0c3d25aa 8134493: Cleaning inline caches of unloaded nmethods should be done in sweeper
thartmann
parents: 32401
diff changeset
   888
      DEBUG_ONLY(if (needs_cache_clean())) {
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 38055
diff changeset
   889
        cm->cleanup_inline_caches();
32401
cc58aeaec340 8075805: Crash while trying to release CompiledICHolder
thartmann
parents: 31620
diff changeset
   890
      }
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 38055
diff changeset
   891
      DEBUG_ONLY(cm->verify());
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 38055
diff changeset
   892
      DEBUG_ONLY(cm->verify_oop_relocations());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   893
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   894
  }
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 38055
diff changeset
   895
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   896
  set_needs_cache_clean(false);
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
   897
  prune_scavenge_root_nmethods();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   898
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   899
  verify_icholder_relocations();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   900
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   901
8724
693c6b883b54 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 8672
diff changeset
   902
void CodeCache::verify_oops() {
693c6b883b54 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 8672
diff changeset
   903
  MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
693c6b883b54 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 8672
diff changeset
   904
  VerifyOopClosure voc;
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   905
  NMethodIterator iter;
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   906
  while(iter.next_alive()) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   907
    nmethod* nm = iter.method();
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   908
    nm->oops_do(&voc);
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   909
    nm->verify_oop_relocations();
8724
693c6b883b54 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 8672
diff changeset
   910
  }
693c6b883b54 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 8672
diff changeset
   911
}
693c6b883b54 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 8672
diff changeset
   912
34158
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   913
int CodeCache::blob_count(int code_blob_type) {
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   914
  CodeHeap* heap = get_code_heap(code_blob_type);
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   915
  return (heap != NULL) ? heap->blob_count() : 0;
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   916
}
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   917
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   918
int CodeCache::blob_count() {
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   919
  int count = 0;
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   920
  FOR_ALL_HEAPS(heap) {
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   921
    count += (*heap)->blob_count();
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   922
  }
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   923
  return count;
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   924
}
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   925
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   926
int CodeCache::nmethod_count(int code_blob_type) {
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   927
  CodeHeap* heap = get_code_heap(code_blob_type);
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   928
  return (heap != NULL) ? heap->nmethod_count() : 0;
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   929
}
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   930
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   931
int CodeCache::nmethod_count() {
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   932
  int count = 0;
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   933
  FOR_ALL_NMETHOD_HEAPS(heap) {
34158
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   934
    count += (*heap)->nmethod_count();
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   935
  }
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   936
  return count;
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   937
}
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   938
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   939
int CodeCache::adapter_count(int code_blob_type) {
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   940
  CodeHeap* heap = get_code_heap(code_blob_type);
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   941
  return (heap != NULL) ? heap->adapter_count() : 0;
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   942
}
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   943
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   944
int CodeCache::adapter_count() {
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   945
  int count = 0;
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   946
  FOR_ALL_HEAPS(heap) {
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   947
    count += (*heap)->adapter_count();
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   948
  }
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   949
  return count;
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   950
}
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   951
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   952
address CodeCache::low_bound(int code_blob_type) {
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   953
  CodeHeap* heap = get_code_heap(code_blob_type);
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   954
  return (heap != NULL) ? (address)heap->low_boundary() : NULL;
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   955
}
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   956
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   957
address CodeCache::high_bound(int code_blob_type) {
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   958
  CodeHeap* heap = get_code_heap(code_blob_type);
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   959
  return (heap != NULL) ? (address)heap->high_boundary() : NULL;
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   960
}
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
   961
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   962
size_t CodeCache::capacity() {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   963
  size_t cap = 0;
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   964
  FOR_ALL_NMETHOD_HEAPS(heap) {
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   965
    cap += (*heap)->capacity();
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   966
  }
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   967
  return cap;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   968
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   969
26942
fa5ea7ff078d 8059390: code cache fills up for bigapps/Weblogic+medrec/nowarnings
zmajo
parents: 26919
diff changeset
   970
size_t CodeCache::unallocated_capacity(int code_blob_type) {
fa5ea7ff078d 8059390: code cache fills up for bigapps/Weblogic+medrec/nowarnings
zmajo
parents: 26919
diff changeset
   971
  CodeHeap* heap = get_code_heap(code_blob_type);
fa5ea7ff078d 8059390: code cache fills up for bigapps/Weblogic+medrec/nowarnings
zmajo
parents: 26919
diff changeset
   972
  return (heap != NULL) ? heap->unallocated_capacity() : 0;
fa5ea7ff078d 8059390: code cache fills up for bigapps/Weblogic+medrec/nowarnings
zmajo
parents: 26919
diff changeset
   973
}
fa5ea7ff078d 8059390: code cache fills up for bigapps/Weblogic+medrec/nowarnings
zmajo
parents: 26919
diff changeset
   974
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   975
size_t CodeCache::unallocated_capacity() {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   976
  size_t unallocated_cap = 0;
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   977
  FOR_ALL_NMETHOD_HEAPS(heap) {
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   978
    unallocated_cap += (*heap)->unallocated_capacity();
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   979
  }
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   980
  return unallocated_cap;
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   981
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   982
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   983
size_t CodeCache::max_capacity() {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   984
  size_t max_cap = 0;
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
   985
  FOR_ALL_NMETHOD_HEAPS(heap) {
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   986
    max_cap += (*heap)->max_capacity();
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   987
  }
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   988
  return max_cap;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   989
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   990
17617
4e330bce1812 8012371: Adjust Tiered compile threshold according to available space in code cache
anoll
parents: 17132
diff changeset
   991
/**
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   992
 * Returns the reverse free ratio. E.g., if 25% (1/4) of the code heap
17617
4e330bce1812 8012371: Adjust Tiered compile threshold according to available space in code cache
anoll
parents: 17132
diff changeset
   993
 * is free, reverse_free_ratio() returns 4.
4e330bce1812 8012371: Adjust Tiered compile threshold according to available space in code cache
anoll
parents: 17132
diff changeset
   994
 */
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   995
double CodeCache::reverse_free_ratio(int code_blob_type) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   996
  CodeHeap* heap = get_code_heap(code_blob_type);
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   997
  if (heap == NULL) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   998
    return 0;
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
   999
  }
27420
04e6f914cce1 8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents: 27410
diff changeset
  1000
04e6f914cce1 8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents: 27410
diff changeset
  1001
  double unallocated_capacity = MAX2((double)heap->unallocated_capacity(), 1.0); // Avoid division by 0;
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1002
  double max_capacity = (double)heap->max_capacity();
27420
04e6f914cce1 8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents: 27410
diff changeset
  1003
  double result = max_capacity / unallocated_capacity;
04e6f914cce1 8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents: 27410
diff changeset
  1004
  assert (max_capacity >= unallocated_capacity, "Must be");
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32466
diff changeset
  1005
  assert (result >= 1.0, "reverse_free_ratio must be at least 1. It is %f", result);
27420
04e6f914cce1 8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents: 27410
diff changeset
  1006
  return result;
17617
4e330bce1812 8012371: Adjust Tiered compile threshold according to available space in code cache
anoll
parents: 17132
diff changeset
  1007
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1008
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1009
size_t CodeCache::bytes_allocated_in_freelists() {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1010
  size_t allocated_bytes = 0;
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
  1011
  FOR_ALL_NMETHOD_HEAPS(heap) {
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1012
    allocated_bytes += (*heap)->allocated_in_freelist();
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1013
  }
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1014
  return allocated_bytes;
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1015
}
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1016
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1017
int CodeCache::allocated_segments() {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1018
  int number_of_segments = 0;
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
  1019
  FOR_ALL_NMETHOD_HEAPS(heap) {
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1020
    number_of_segments += (*heap)->allocated_segments();
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1021
  }
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1022
  return number_of_segments;
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1023
}
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1024
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1025
size_t CodeCache::freelists_length() {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1026
  size_t length = 0;
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
  1027
  FOR_ALL_NMETHOD_HEAPS(heap) {
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1028
    length += (*heap)->freelist_length();
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1029
  }
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1030
  return length;
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1031
}
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1032
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1033
void icache_init();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1034
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1035
void CodeCache::initialize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1036
  assert(CodeCacheSegmentSize >= (uintx)CodeEntryAlignment, "CodeCacheSegmentSize must be large enough to align entry points");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1037
#ifdef COMPILER2
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1038
  assert(CodeCacheSegmentSize >= (uintx)OptoLoopAlignment,  "CodeCacheSegmentSize must be large enough to align inner loops");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1039
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1040
  assert(CodeCacheSegmentSize >= sizeof(jdouble),    "CodeCacheSegmentSize must be large enough to align constants");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1041
  // This was originally just a check of the alignment, causing failure, instead, round
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1042
  // the code cache to the page size.  In particular, Solaris is moving to a larger
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1043
  // default page size.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1044
  CodeCacheExpansionSize = round_to(CodeCacheExpansionSize, os::vm_page_size());
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1045
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1046
  if (SegmentedCodeCache) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1047
    // Use multiple code heaps
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1048
    initialize_heaps();
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1049
  } else {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1050
    // Use a single code heap
34158
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
  1051
    FLAG_SET_ERGO(uintx, NonNMethodCodeHeapSize, 0);
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
  1052
    FLAG_SET_ERGO(uintx, ProfiledCodeHeapSize, 0);
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
  1053
    FLAG_SET_ERGO(uintx, NonProfiledCodeHeapSize, 0);
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1054
    ReservedCodeSpace rs = reserve_heap_memory(ReservedCodeCacheSize);
28730
106944a21769 8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents: 28631
diff changeset
  1055
    add_heap(rs, "CodeCache", CodeBlobType::All);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1056
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1057
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1058
  // Initialize ICache flush mechanism
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1059
  // This service is needed for os::register_code_area
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1060
  icache_init();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1061
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1062
  // Give OS a chance to register generated code area.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1063
  // This is used on Windows 64 bit platforms to register
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1064
  // Structured Exception Handlers for our generated code.
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1065
  os::register_code_area((char*)low_bound(), (char*)high_bound());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1066
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1067
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1068
void codeCache_init() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1069
  CodeCache::initialize();
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
  1070
  // Load AOT libraries and add AOT code heaps.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
  1071
  AOTLoader::initialize();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1072
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1073
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1074
//------------------------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1075
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1076
int CodeCache::number_of_nmethods_with_dependencies() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1077
  return _number_of_nmethods_with_dependencies;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1078
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1079
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1080
void CodeCache::clear_inline_caches() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1081
  assert_locked_or_safepoint(CodeCache_lock);
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 38055
diff changeset
  1082
  CompiledMethodIterator iter;
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1083
  while(iter.next_alive()) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1084
    iter.method()->clear_inline_caches();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1085
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1086
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1087
37289
9989add27bf4 8067247: Crash: assert(method_holder->data() == 0 ...) failed: a) MT-unsafe modification of inline cache
jcm
parents: 36593
diff changeset
  1088
void CodeCache::cleanup_inline_caches() {
9989add27bf4 8067247: Crash: assert(method_holder->data() == 0 ...) failed: a) MT-unsafe modification of inline cache
jcm
parents: 36593
diff changeset
  1089
  assert_locked_or_safepoint(CodeCache_lock);
9989add27bf4 8067247: Crash: assert(method_holder->data() == 0 ...) failed: a) MT-unsafe modification of inline cache
jcm
parents: 36593
diff changeset
  1090
  NMethodIterator iter;
9989add27bf4 8067247: Crash: assert(method_holder->data() == 0 ...) failed: a) MT-unsafe modification of inline cache
jcm
parents: 36593
diff changeset
  1091
  while(iter.next_alive()) {
9989add27bf4 8067247: Crash: assert(method_holder->data() == 0 ...) failed: a) MT-unsafe modification of inline cache
jcm
parents: 36593
diff changeset
  1092
    iter.method()->cleanup_inline_caches(/*clean_all=*/true);
9989add27bf4 8067247: Crash: assert(method_holder->data() == 0 ...) failed: a) MT-unsafe modification of inline cache
jcm
parents: 36593
diff changeset
  1093
  }
9989add27bf4 8067247: Crash: assert(method_holder->data() == 0 ...) failed: a) MT-unsafe modification of inline cache
jcm
parents: 36593
diff changeset
  1094
}
9989add27bf4 8067247: Crash: assert(method_holder->data() == 0 ...) failed: a) MT-unsafe modification of inline cache
jcm
parents: 36593
diff changeset
  1095
22506
0759c126204d 7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents: 20290
diff changeset
  1096
// Keeps track of time spent for checking dependencies
22921
ee35d5c0b1dc 8034839: jvm hangs with gc/gctests/LoadUnloadGC test
anoll
parents: 22506
diff changeset
  1097
NOT_PRODUCT(static elapsedTimer dependentCheckTime;)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1098
36300
5b47f168b948 7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents: 35825
diff changeset
  1099
int CodeCache::mark_for_deoptimization(KlassDepChange& changes) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1100
  MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1101
  int number_of_marked_CodeBlobs = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1102
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1103
  // search the hierarchy looking for nmethods which are affected by the loading of this class
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1104
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1105
  // then search the interfaces this class implements looking for nmethods
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1106
  // which might be dependent of the fact that an interface only had one
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1107
  // implementor.
22506
0759c126204d 7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents: 20290
diff changeset
  1108
  // nmethod::check_all_dependencies works only correctly, if no safepoint
0759c126204d 7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents: 20290
diff changeset
  1109
  // can happen
35492
c8c0273e6b91 8146690: Make all classes in GC follow the naming convention.
david
parents: 35203
diff changeset
  1110
  NoSafepointVerifier nsv;
22506
0759c126204d 7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents: 20290
diff changeset
  1111
  for (DepChange::ContextStream str(changes, nsv); str.next(); ) {
0759c126204d 7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents: 20290
diff changeset
  1112
    Klass* d = str.klass();
0759c126204d 7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents: 20290
diff changeset
  1113
    number_of_marked_CodeBlobs += InstanceKlass::cast(d)->mark_dependent_nmethods(changes);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1114
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1115
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1116
#ifndef PRODUCT
22506
0759c126204d 7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents: 20290
diff changeset
  1117
  if (VerifyDependencies) {
0759c126204d 7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents: 20290
diff changeset
  1118
    // Object pointers are used as unique identifiers for dependency arguments. This
0759c126204d 7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents: 20290
diff changeset
  1119
    // is only possible if no safepoint, i.e., GC occurs during the verification code.
0759c126204d 7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents: 20290
diff changeset
  1120
    dependentCheckTime.start();
0759c126204d 7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents: 20290
diff changeset
  1121
    nmethod::check_all_dependencies(changes);
0759c126204d 7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents: 20290
diff changeset
  1122
    dependentCheckTime.stop();
0759c126204d 7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents: 20290
diff changeset
  1123
  }
0759c126204d 7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents: 20290
diff changeset
  1124
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1125
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1126
  return number_of_marked_CodeBlobs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1127
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1128
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 38055
diff changeset
  1129
CompiledMethod* CodeCache::find_compiled(void* start) {
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 38055
diff changeset
  1130
  CodeBlob *cb = find_blob(start);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 38055
diff changeset
  1131
  assert(cb == NULL || cb->is_compiled(), "did not find an compiled_method");
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 38055
diff changeset
  1132
  return (CompiledMethod*)cb;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 38055
diff changeset
  1133
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1134
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
  1135
bool CodeCache::is_far_target(address target) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
  1136
#if INCLUDE_AOT
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
  1137
  return NativeCall::is_far_call(_low_bound,  target) ||
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
  1138
         NativeCall::is_far_call(_high_bound, target);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
  1139
#else
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
  1140
  return false;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
  1141
#endif
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
  1142
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
  1143
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1144
#ifdef HOTSWAP
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46327
diff changeset
  1145
int CodeCache::mark_for_evol_deoptimization(InstanceKlass* dependee) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1146
  MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1147
  int number_of_marked_CodeBlobs = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1148
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1149
  // Deoptimize all methods of the evolving class itself
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1150
  Array<Method*>* old_methods = dependee->methods();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1151
  for (int i = 0; i < old_methods->length(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1152
    ResourceMark rm;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1153
    Method* old_method = old_methods->at(i);
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 38055
diff changeset
  1154
    CompiledMethod* nm = old_method->code();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1155
    if (nm != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1156
      nm->mark_for_deoptimization();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1157
      number_of_marked_CodeBlobs++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1158
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1159
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1160
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 38055
diff changeset
  1161
  CompiledMethodIterator iter;
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1162
  while(iter.next_alive()) {
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 38055
diff changeset
  1163
    CompiledMethod* nm = iter.method();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1164
    if (nm->is_marked_for_deoptimization()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1165
      // ...Already marked in the previous pass; don't count it again.
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46327
diff changeset
  1166
    } else if (nm->is_evol_dependent_on(dependee)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1167
      ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1168
      nm->mark_for_deoptimization();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1169
      number_of_marked_CodeBlobs++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1170
    } else  {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1171
      // flush caches in case they refer to a redefined Method*
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1172
      nm->clear_inline_caches();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1173
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1174
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1175
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1176
  return number_of_marked_CodeBlobs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1177
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1178
#endif // HOTSWAP
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1179
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1180
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1181
// Deoptimize all methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1182
void CodeCache::mark_all_nmethods_for_deoptimization() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1183
  MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 38055
diff changeset
  1184
  CompiledMethodIterator iter;
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1185
  while(iter.next_alive()) {
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 38055
diff changeset
  1186
    CompiledMethod* nm = iter.method();
26580
8cca7fbe77b8 8056154: JVM crash with EXCEPTION_ACCESS_VIOLATION when there are many threads running
iveresov
parents: 25492
diff changeset
  1187
    if (!nm->method()->is_method_handle_intrinsic()) {
8cca7fbe77b8 8056154: JVM crash with EXCEPTION_ACCESS_VIOLATION when there are many threads running
iveresov
parents: 25492
diff changeset
  1188
      nm->mark_for_deoptimization();
8cca7fbe77b8 8056154: JVM crash with EXCEPTION_ACCESS_VIOLATION when there are many threads running
iveresov
parents: 25492
diff changeset
  1189
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1190
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1191
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1192
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1193
int CodeCache::mark_for_deoptimization(Method* dependee) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1194
  MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1195
  int number_of_marked_CodeBlobs = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1196
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 38055
diff changeset
  1197
  CompiledMethodIterator iter;
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1198
  while(iter.next_alive()) {
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 38055
diff changeset
  1199
    CompiledMethod* nm = iter.method();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1200
    if (nm->is_dependent_on_method(dependee)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1201
      ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1202
      nm->mark_for_deoptimization();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1203
      number_of_marked_CodeBlobs++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1204
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1205
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1206
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1207
  return number_of_marked_CodeBlobs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1208
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1209
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1210
void CodeCache::make_marked_nmethods_not_entrant() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1211
  assert_locked_or_safepoint(CodeCache_lock);
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 38055
diff changeset
  1212
  CompiledMethodIterator iter;
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1213
  while(iter.next_alive()) {
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 38055
diff changeset
  1214
    CompiledMethod* nm = iter.method();
43675
a2b322083029 8173338: C2: continuous CallSite relinkage eventually disables compilation for a method
vlivanov
parents: 43407
diff changeset
  1215
    if (nm->is_marked_for_deoptimization() && !nm->is_not_entrant()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1216
      nm->make_not_entrant();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1217
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1218
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1219
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1220
28374
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1221
// Flushes compiled methods dependent on dependee.
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46327
diff changeset
  1222
void CodeCache::flush_dependents_on(InstanceKlass* dependee) {
28374
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1223
  assert_lock_strong(Compile_lock);
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1224
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1225
  if (number_of_nmethods_with_dependencies() == 0) return;
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1226
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1227
  // CodeCache can only be updated by a thread_in_VM and they will all be
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1228
  // stopped during the safepoint so CodeCache will be safe to update without
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1229
  // holding the CodeCache_lock.
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1230
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1231
  KlassDepChange changes(dependee);
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1232
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1233
  // Compute the dependent nmethods
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1234
  if (mark_for_deoptimization(changes) > 0) {
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1235
    // At least one nmethod has been marked for deoptimization
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1236
    VM_Deoptimize op;
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1237
    VMThread::execute(&op);
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1238
  }
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1239
}
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1240
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1241
#ifdef HOTSWAP
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1242
// Flushes compiled methods dependent on dependee in the evolutionary sense
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46327
diff changeset
  1243
void CodeCache::flush_evol_dependents_on(InstanceKlass* ev_k) {
28374
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1244
  // --- Compile_lock is not held. However we are at a safepoint.
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1245
  assert_locked_or_safepoint(Compile_lock);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
  1246
  if (number_of_nmethods_with_dependencies() == 0 && !UseAOT) return;
28374
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1247
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1248
  // CodeCache can only be updated by a thread_in_VM and they will all be
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1249
  // stopped during the safepoint so CodeCache will be safe to update without
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1250
  // holding the CodeCache_lock.
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1251
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1252
  // Compute the dependent nmethods
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46327
diff changeset
  1253
  if (mark_for_evol_deoptimization(ev_k) > 0) {
28374
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1254
    // At least one nmethod has been marked for deoptimization
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1255
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1256
    // All this already happens inside a VM_Operation, so we'll do all the work here.
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1257
    // Stuff copied from VM_Deoptimize and modified slightly.
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1258
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1259
    // We do not want any GCs to happen while we are in the middle of this VM operation
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1260
    ResourceMark rm;
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1261
    DeoptimizationMarker dm;
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1262
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1263
    // Deoptimize all activations depending on marked nmethods
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1264
    Deoptimization::deoptimize_dependents();
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1265
32401
cc58aeaec340 8075805: Crash while trying to release CompiledICHolder
thartmann
parents: 31620
diff changeset
  1266
    // Make the dependent methods not entrant
28374
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1267
    make_marked_nmethods_not_entrant();
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1268
  }
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1269
}
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1270
#endif // HOTSWAP
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1271
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1272
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1273
// Flushes compiled methods dependent on dependee
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1274
void CodeCache::flush_dependents_on_method(methodHandle m_h) {
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1275
  // --- Compile_lock is not held. However we are at a safepoint.
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1276
  assert_locked_or_safepoint(Compile_lock);
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1277
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1278
  // CodeCache can only be updated by a thread_in_VM and they will all be
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1279
  // stopped dring the safepoint so CodeCache will be safe to update without
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1280
  // holding the CodeCache_lock.
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1281
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1282
  // Compute the dependent nmethods
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1283
  if (mark_for_deoptimization(m_h()) > 0) {
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1284
    // At least one nmethod has been marked for deoptimization
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1285
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1286
    // All this already happens inside a VM_Operation, so we'll do all the work here.
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1287
    // Stuff copied from VM_Deoptimize and modified slightly.
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1288
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1289
    // We do not want any GCs to happen while we are in the middle of this VM operation
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1290
    ResourceMark rm;
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1291
    DeoptimizationMarker dm;
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1292
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1293
    // Deoptimize all activations depending on marked nmethods
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1294
    Deoptimization::deoptimize_dependents();
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1295
32401
cc58aeaec340 8075805: Crash while trying to release CompiledICHolder
thartmann
parents: 31620
diff changeset
  1296
    // Make the dependent methods not entrant
28374
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1297
    make_marked_nmethods_not_entrant();
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1298
  }
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1299
}
0558e321c027 8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents: 27880
diff changeset
  1300
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1301
void CodeCache::verify() {
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1302
  assert_locked_or_safepoint(CodeCache_lock);
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1303
  FOR_ALL_HEAPS(heap) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1304
    (*heap)->verify();
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1305
    FOR_ALL_BLOBS(cb, *heap) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1306
      if (cb->is_alive()) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1307
        cb->verify();
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1308
      }
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1309
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1310
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1311
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1312
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1313
// A CodeHeap is full. Print out warning and report event.
46269
7e725659ea12 8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents: 42650
diff changeset
  1314
PRAGMA_DIAG_PUSH
7e725659ea12 8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents: 42650
diff changeset
  1315
PRAGMA_FORMAT_NONLITERAL_IGNORED
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1316
void CodeCache::report_codemem_full(int code_blob_type, bool print) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1317
  // Get nmethod heap for the given CodeBlobType and build CodeCacheFull event
26942
fa5ea7ff078d 8059390: code cache fills up for bigapps/Weblogic+medrec/nowarnings
zmajo
parents: 26919
diff changeset
  1318
  CodeHeap* heap = get_code_heap(code_blob_type);
fa5ea7ff078d 8059390: code cache fills up for bigapps/Weblogic+medrec/nowarnings
zmajo
parents: 26919
diff changeset
  1319
  assert(heap != NULL, "heap is null");
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1320
34158
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
  1321
  if ((heap->full_count() == 0) || print) {
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1322
    // Not yet reported for this heap, report
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1323
    if (SegmentedCodeCache) {
46269
7e725659ea12 8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents: 42650
diff changeset
  1324
      ResourceMark rm;
7e725659ea12 8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents: 42650
diff changeset
  1325
      stringStream msg1_stream, msg2_stream;
7e725659ea12 8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents: 42650
diff changeset
  1326
      msg1_stream.print("%s is full. Compiler has been disabled.",
7e725659ea12 8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents: 42650
diff changeset
  1327
                        get_code_heap_name(code_blob_type));
7e725659ea12 8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents: 42650
diff changeset
  1328
      msg2_stream.print("Try increasing the code heap size using -XX:%s=",
7e725659ea12 8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents: 42650
diff changeset
  1329
                 get_code_heap_flag_name(code_blob_type));
7e725659ea12 8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents: 42650
diff changeset
  1330
      const char *msg1 = msg1_stream.as_string();
7e725659ea12 8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents: 42650
diff changeset
  1331
      const char *msg2 = msg2_stream.as_string();
7e725659ea12 8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents: 42650
diff changeset
  1332
7e725659ea12 8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents: 42650
diff changeset
  1333
      log_warning(codecache)(msg1);
7e725659ea12 8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents: 42650
diff changeset
  1334
      log_warning(codecache)(msg2);
7e725659ea12 8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents: 42650
diff changeset
  1335
      warning(msg1);
7e725659ea12 8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents: 42650
diff changeset
  1336
      warning(msg2);
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1337
    } else {
46269
7e725659ea12 8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents: 42650
diff changeset
  1338
      const char *msg1 = "CodeCache is full. Compiler has been disabled.";
7e725659ea12 8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents: 42650
diff changeset
  1339
      const char *msg2 = "Try increasing the code cache size using -XX:ReservedCodeCacheSize=";
7e725659ea12 8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents: 42650
diff changeset
  1340
7e725659ea12 8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents: 42650
diff changeset
  1341
      log_warning(codecache)(msg1);
7e725659ea12 8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents: 42650
diff changeset
  1342
      log_warning(codecache)(msg2);
7e725659ea12 8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents: 42650
diff changeset
  1343
      warning(msg1);
7e725659ea12 8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents: 42650
diff changeset
  1344
      warning(msg2);
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1345
    }
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1346
    ResourceMark rm;
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1347
    stringStream s;
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1348
    // Dump code cache  into a buffer before locking the tty,
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1349
    {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1350
      MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1351
      print_summary(&s);
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1352
    }
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1353
    ttyLocker ttyl;
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1354
    tty->print("%s", s.as_string());
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1355
  }
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1356
34158
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
  1357
  heap->report_full();
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
  1358
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17617
diff changeset
  1359
  EventCodeCacheFull event;
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17617
diff changeset
  1360
  if (event.should_commit()) {
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1361
    event.set_codeBlobType((u1)code_blob_type);
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1362
    event.set_startAddress((u8)heap->low_boundary());
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1363
    event.set_commitedTopAddress((u8)heap->high());
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1364
    event.set_reservedTopAddress((u8)heap->high_boundary());
34158
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
  1365
    event.set_entryCount(heap->blob_count());
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
  1366
    event.set_methodCount(heap->nmethod_count());
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
  1367
    event.set_adaptorCount(heap->adapter_count());
41056
8b4c1a429e5d 8157024: CodeCache JFR events reporting wrong data
neliasso
parents: 40863
diff changeset
  1368
    event.set_unallocatedCapacity(heap->unallocated_capacity());
34158
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
  1369
    event.set_fullCount(heap->full_count());
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17617
diff changeset
  1370
    event.commit();
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17617
diff changeset
  1371
  }
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17617
diff changeset
  1372
}
46269
7e725659ea12 8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents: 42650
diff changeset
  1373
PRAGMA_DIAG_POP
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17617
diff changeset
  1374
23214
b6426873cb37 8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents: 22921
diff changeset
  1375
void CodeCache::print_memory_overhead() {
b6426873cb37 8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents: 22921
diff changeset
  1376
  size_t wasted_bytes = 0;
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
  1377
  FOR_ALL_NMETHOD_HEAPS(heap) {
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1378
      CodeHeap* curr_heap = *heap;
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1379
      for (CodeBlob* cb = (CodeBlob*)curr_heap->first(); cb != NULL; cb = (CodeBlob*)curr_heap->next(cb)) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1380
        HeapBlock* heap_block = ((HeapBlock*)cb) - 1;
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1381
        wasted_bytes += heap_block->length() * CodeCacheSegmentSize - cb->size();
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1382
      }
23214
b6426873cb37 8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents: 22921
diff changeset
  1383
  }
b6426873cb37 8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents: 22921
diff changeset
  1384
  // Print bytes that are allocated in the freelist
b6426873cb37 8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents: 22921
diff changeset
  1385
  ttyLocker ttl;
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1386
  tty->print_cr("Number of elements in freelist: " SSIZE_FORMAT,       freelists_length());
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1387
  tty->print_cr("Allocated in freelist:          " SSIZE_FORMAT "kB",  bytes_allocated_in_freelists()/K);
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 23214
diff changeset
  1388
  tty->print_cr("Unused bytes in CodeBlobs:      " SSIZE_FORMAT "kB",  (wasted_bytes/K));
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 23214
diff changeset
  1389
  tty->print_cr("Segment map size:               " SSIZE_FORMAT "kB",  allocated_segments()/K); // 1 byte per segment
23214
b6426873cb37 8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents: 22921
diff changeset
  1390
}
b6426873cb37 8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents: 22921
diff changeset
  1391
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1392
//------------------------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1393
// Non-product version
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1394
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1395
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1396
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
  1397
void CodeCache::print_trace(const char* event, CodeBlob* cb, int size) {
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
  1398
  if (PrintCodeCache2) {  // Need to add a new flag
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
  1399
    ResourceMark rm;
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
  1400
    if (size == 0)  size = cb->size();
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 23214
diff changeset
  1401
    tty->print_cr("CodeCache %s:  addr: " INTPTR_FORMAT ", size: 0x%x", event, p2i(cb), size);
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
  1402
  }
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
  1403
}
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1
diff changeset
  1404
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1405
void CodeCache::print_internals() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1406
  int nmethodCount = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1407
  int runtimeStubCount = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1408
  int adapterCount = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1409
  int deoptimizationStubCount = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1410
  int uncommonTrapStubCount = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1411
  int bufferBlobCount = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1412
  int total = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1413
  int nmethodAlive = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1414
  int nmethodNotEntrant = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1415
  int nmethodZombie = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1416
  int nmethodUnloaded = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1417
  int nmethodJava = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1418
  int nmethodNative = 0;
23214
b6426873cb37 8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents: 22921
diff changeset
  1419
  int max_nm_size = 0;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1420
  ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1421
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1422
  int i = 0;
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
  1423
  FOR_ALL_NMETHOD_HEAPS(heap) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
  1424
    if ((_nmethod_heaps->length() >= 1) && Verbose) {
26918
4e1761669426 8059137: MemoryPoolMXBeans for different code heaps should contain 'Code heap' in their names
thartmann
parents: 26809
diff changeset
  1425
      tty->print_cr("-- %s --", (*heap)->name());
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1426
    }
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1427
    FOR_ALL_BLOBS(cb, *heap) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1428
      total++;
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1429
      if (cb->is_nmethod()) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1430
        nmethod* nm = (nmethod*)cb;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1431
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1432
        if (Verbose && nm->method() != NULL) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1433
          ResourceMark rm;
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1434
          char *method_name = nm->method()->name_and_sig_as_C_string();
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1435
          tty->print("%s", method_name);
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1436
          if(nm->is_alive()) { tty->print_cr(" alive"); }
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1437
          if(nm->is_not_entrant()) { tty->print_cr(" not-entrant"); }
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1438
          if(nm->is_zombie()) { tty->print_cr(" zombie"); }
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1439
        }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1440
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1441
        nmethodCount++;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1442
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1443
        if(nm->is_alive()) { nmethodAlive++; }
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1444
        if(nm->is_not_entrant()) { nmethodNotEntrant++; }
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1445
        if(nm->is_zombie()) { nmethodZombie++; }
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1446
        if(nm->is_unloaded()) { nmethodUnloaded++; }
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1447
        if(nm->method() != NULL && nm->is_native_method()) { nmethodNative++; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1448
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1449
        if(nm->method() != NULL && nm->is_java_method()) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1450
          nmethodJava++;
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1451
          max_nm_size = MAX2(max_nm_size, nm->size());
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1452
        }
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1453
      } else if (cb->is_runtime_stub()) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1454
        runtimeStubCount++;
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1455
      } else if (cb->is_deoptimization_stub()) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1456
        deoptimizationStubCount++;
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1457
      } else if (cb->is_uncommon_trap_stub()) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1458
        uncommonTrapStubCount++;
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1459
      } else if (cb->is_adapter_blob()) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1460
        adapterCount++;
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1461
      } else if (cb->is_buffer_blob()) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1462
        bufferBlobCount++;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1463
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1464
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1465
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1466
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1467
  int bucketSize = 512;
23214
b6426873cb37 8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents: 22921
diff changeset
  1468
  int bucketLimit = max_nm_size / bucketSize + 1;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 9630
diff changeset
  1469
  int *buckets = NEW_C_HEAP_ARRAY(int, bucketLimit, mtCode);
23214
b6426873cb37 8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents: 22921
diff changeset
  1470
  memset(buckets, 0, sizeof(int) * bucketLimit);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1471
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1472
  NMethodIterator iter;
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1473
  while(iter.next()) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1474
    nmethod* nm = iter.method();
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1475
    if(nm->method() != NULL && nm->is_java_method()) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1476
      buckets[nm->size() / bucketSize]++;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1477
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1478
  }
23214
b6426873cb37 8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents: 22921
diff changeset
  1479
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1480
  tty->print_cr("Code Cache Entries (total of %d)",total);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1481
  tty->print_cr("-------------------------------------------------");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1482
  tty->print_cr("nmethods: %d",nmethodCount);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1483
  tty->print_cr("\talive: %d",nmethodAlive);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1484
  tty->print_cr("\tnot_entrant: %d",nmethodNotEntrant);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1485
  tty->print_cr("\tzombie: %d",nmethodZombie);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1486
  tty->print_cr("\tunloaded: %d",nmethodUnloaded);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1487
  tty->print_cr("\tjava: %d",nmethodJava);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1488
  tty->print_cr("\tnative: %d",nmethodNative);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1489
  tty->print_cr("runtime_stubs: %d",runtimeStubCount);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1490
  tty->print_cr("adapters: %d",adapterCount);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1491
  tty->print_cr("buffer blobs: %d",bufferBlobCount);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1492
  tty->print_cr("deoptimization_stubs: %d",deoptimizationStubCount);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1493
  tty->print_cr("uncommon_traps: %d",uncommonTrapStubCount);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1494
  tty->print_cr("\nnmethod size distribution (non-zombie java)");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1495
  tty->print_cr("-------------------------------------------------");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1496
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1497
  for(int i=0; i<bucketLimit; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1498
    if(buckets[i] != 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1499
      tty->print("%d - %d bytes",i*bucketSize,(i+1)*bucketSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1500
      tty->fill_to(40);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1501
      tty->print_cr("%d",buckets[i]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1502
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1503
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1504
27880
afb974a04396 8060074: os::free() takes MemoryTrackingLevel but doesn't need it
coleenp
parents: 27642
diff changeset
  1505
  FREE_C_HEAP_ARRAY(int, buckets);
23214
b6426873cb37 8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents: 22921
diff changeset
  1506
  print_memory_overhead();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1507
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1508
15201
f3d755b11424 8005204: Code Cache Reduction: command line options implementation
vladidan
parents: 13878
diff changeset
  1509
#endif // !PRODUCT
f3d755b11424 8005204: Code Cache Reduction: command line options implementation
vladidan
parents: 13878
diff changeset
  1510
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1511
void CodeCache::print() {
15201
f3d755b11424 8005204: Code Cache Reduction: command line options implementation
vladidan
parents: 13878
diff changeset
  1512
  print_summary(tty);
f3d755b11424 8005204: Code Cache Reduction: command line options implementation
vladidan
parents: 13878
diff changeset
  1513
f3d755b11424 8005204: Code Cache Reduction: command line options implementation
vladidan
parents: 13878
diff changeset
  1514
#ifndef PRODUCT
f3d755b11424 8005204: Code Cache Reduction: command line options implementation
vladidan
parents: 13878
diff changeset
  1515
  if (!Verbose) return;
f3d755b11424 8005204: Code Cache Reduction: command line options implementation
vladidan
parents: 13878
diff changeset
  1516
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1517
  CodeBlob_sizes live;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1518
  CodeBlob_sizes dead;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1519
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
  1520
  FOR_ALL_NMETHOD_HEAPS(heap) {
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1521
    FOR_ALL_BLOBS(cb, *heap) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1522
      if (!cb->is_alive()) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1523
        dead.add(cb);
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1524
      } else {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1525
        live.add(cb);
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1526
      }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1527
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1528
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1529
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1530
  tty->print_cr("CodeCache:");
22506
0759c126204d 7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents: 20290
diff changeset
  1531
  tty->print_cr("nmethod dependency checking time %fs", dependentCheckTime.seconds());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1532
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1533
  if (!live.is_empty()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1534
    live.print("live");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1535
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1536
  if (!dead.is_empty()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1537
    dead.print("dead");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1538
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1539
15201
f3d755b11424 8005204: Code Cache Reduction: command line options implementation
vladidan
parents: 13878
diff changeset
  1540
  if (WizardMode) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1541
     // print the oop_map usage
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1542
    int code_size = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1543
    int number_of_blobs = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1544
    int number_of_oop_maps = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1545
    int map_size = 0;
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42062
diff changeset
  1546
    FOR_ALL_NMETHOD_HEAPS(heap) {
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1547
      FOR_ALL_BLOBS(cb, *heap) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1548
        if (cb->is_alive()) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1549
          number_of_blobs++;
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1550
          code_size += cb->code_size();
30590
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 30296
diff changeset
  1551
          ImmutableOopMapSet* set = cb->oop_maps();
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1552
          if (set != NULL) {
30590
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 30296
diff changeset
  1553
            number_of_oop_maps += set->count();
30628
3c15b4a3bf4d 8079797: assert(index >= 0 && index < _count) failed: check
rbackman
parents: 30590
diff changeset
  1554
            map_size           += set->nr_of_bytes();
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1555
          }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1556
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1557
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1558
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1559
    tty->print_cr("OopMaps");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1560
    tty->print_cr("  #blobs    = %d", number_of_blobs);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1561
    tty->print_cr("  code size = %d", code_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1562
    tty->print_cr("  #oop_maps = %d", number_of_oop_maps);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1563
    tty->print_cr("  map size  = %d", map_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1564
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1565
15201
f3d755b11424 8005204: Code Cache Reduction: command line options implementation
vladidan
parents: 13878
diff changeset
  1566
#endif // !PRODUCT
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1567
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1568
15201
f3d755b11424 8005204: Code Cache Reduction: command line options implementation
vladidan
parents: 13878
diff changeset
  1569
void CodeCache::print_summary(outputStream* st, bool detailed) {
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1570
  FOR_ALL_HEAPS(heap_iterator) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1571
    CodeHeap* heap = (*heap_iterator);
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1572
    size_t total = (heap->high_boundary() - heap->low_boundary());
31620
53be635ad49c 8087333: Optionally Pre-Generate the HotSpot Template Interpreter
bdelsart
parents: 31592
diff changeset
  1573
    if (_heaps->length() >= 1) {
26918
4e1761669426 8059137: MemoryPoolMXBeans for different code heaps should contain 'Code heap' in their names
thartmann
parents: 26809
diff changeset
  1574
      st->print("%s:", heap->name());
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1575
    } else {
26919
361b4b4c92c0 8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents: 26918
diff changeset
  1576
      st->print("CodeCache:");
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1577
    }
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1578
    st->print_cr(" size=" SIZE_FORMAT "Kb used=" SIZE_FORMAT
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1579
                 "Kb max_used=" SIZE_FORMAT "Kb free=" SIZE_FORMAT "Kb",
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1580
                 total/K, (total - heap->unallocated_capacity())/K,
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1581
                 heap->max_allocated_capacity()/K, heap->unallocated_capacity()/K);
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1582
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1583
    if (detailed) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1584
      st->print_cr(" bounds [" INTPTR_FORMAT ", " INTPTR_FORMAT ", " INTPTR_FORMAT "]",
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1585
                   p2i(heap->low_boundary()),
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1586
                   p2i(heap->high()),
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1587
                   p2i(heap->high_boundary()));
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1588
    }
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1589
  }
7108
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 6418
diff changeset
  1590
15201
f3d755b11424 8005204: Code Cache Reduction: command line options implementation
vladidan
parents: 13878
diff changeset
  1591
  if (detailed) {
f3d755b11424 8005204: Code Cache Reduction: command line options implementation
vladidan
parents: 13878
diff changeset
  1592
    st->print_cr(" total_blobs=" UINT32_FORMAT " nmethods=" UINT32_FORMAT
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1593
                       " adapters=" UINT32_FORMAT,
34158
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
  1594
                       blob_count(), nmethod_count(), adapter_count());
15201
f3d755b11424 8005204: Code Cache Reduction: command line options implementation
vladidan
parents: 13878
diff changeset
  1595
    st->print_cr(" compilation: %s", CompileBroker::should_compile_new_jobs() ?
f3d755b11424 8005204: Code Cache Reduction: command line options implementation
vladidan
parents: 13878
diff changeset
  1596
                 "enabled" : Arguments::mode() == Arguments::_int ?
f3d755b11424 8005204: Code Cache Reduction: command line options implementation
vladidan
parents: 13878
diff changeset
  1597
                 "disabled (interpreter mode)" :
f3d755b11424 8005204: Code Cache Reduction: command line options implementation
vladidan
parents: 13878
diff changeset
  1598
                 "disabled (not enough contiguous free space left)");
f3d755b11424 8005204: Code Cache Reduction: command line options implementation
vladidan
parents: 13878
diff changeset
  1599
  }
7108
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 6418
diff changeset
  1600
}
8672
26a427ab6f32 7025742: Can not use CodeCache::unallocated_capacity() with fragmented CodeCache
kvn
parents: 7715
diff changeset
  1601
26587
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 26580
diff changeset
  1602
void CodeCache::print_codelist(outputStream* st) {
35825
7c7652ee137b 8063112: Compiler diagnostic commands should have locking instead of safepoint
neliasso
parents: 35492
diff changeset
  1603
  MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
26587
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 26580
diff changeset
  1604
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1605
  NMethodIterator iter;
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1606
  while(iter.next_alive()) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1607
    nmethod* nm = iter.method();
26587
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 26580
diff changeset
  1608
    ResourceMark rm;
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1609
    char *method_name = nm->method()->name_and_sig_as_C_string();
31592
43f48e165466 8081202: Hotspot compile warning: "Invalid suffix on literal; C++11 requires a space between literal and identifier"
bpittore
parents: 31041
diff changeset
  1610
    st->print_cr("%d %d %s [" INTPTR_FORMAT ", " INTPTR_FORMAT " - " INTPTR_FORMAT "]",
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1611
                 nm->compile_id(), nm->comp_level(), method_name, (intptr_t)nm->header_begin(),
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 26587
diff changeset
  1612
                 (intptr_t)nm->code_begin(), (intptr_t)nm->code_end());
26587
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 26580
diff changeset
  1613
  }
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 26580
diff changeset
  1614
}
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 26580
diff changeset
  1615
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 26580
diff changeset
  1616
void CodeCache::print_layout(outputStream* st) {
35825
7c7652ee137b 8063112: Compiler diagnostic commands should have locking instead of safepoint
neliasso
parents: 35492
diff changeset
  1617
  MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
26587
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 26580
diff changeset
  1618
  ResourceMark rm;
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 26580
diff changeset
  1619
  print_summary(st, true);
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 26580
diff changeset
  1620
}
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 26580
diff changeset
  1621
8672
26a427ab6f32 7025742: Can not use CodeCache::unallocated_capacity() with fragmented CodeCache
kvn
parents: 7715
diff changeset
  1622
void CodeCache::log_state(outputStream* st) {
26a427ab6f32 7025742: Can not use CodeCache::unallocated_capacity() with fragmented CodeCache
kvn
parents: 7715
diff changeset
  1623
  st->print(" total_blobs='" UINT32_FORMAT "' nmethods='" UINT32_FORMAT "'"
17016
78b1c3670525 8006952: Slow VM due to excessive code cache freelist iteration
neliasso
parents: 15201
diff changeset
  1624
            " adapters='" UINT32_FORMAT "' free_code_cache='" SIZE_FORMAT "'",
34158
1f8d643b02d5 8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents: 33105
diff changeset
  1625
            blob_count(), nmethod_count(), adapter_count(),
17016
78b1c3670525 8006952: Slow VM due to excessive code cache freelist iteration
neliasso
parents: 15201
diff changeset
  1626
            unallocated_capacity());
8672
26a427ab6f32 7025742: Can not use CodeCache::unallocated_capacity() with fragmented CodeCache
kvn
parents: 7715
diff changeset
  1627
}
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 38055
diff changeset
  1628