src/hotspot/share/oops/methodCounters.cpp
author ccheung
Wed, 02 Oct 2019 16:55:08 -0700
changeset 58447 319173c62caa
parent 47216 71c04702a3d5
permissions -rw-r--r--
8231606: _method_ordering is not set during CDS dynamic dump time Summary: Add the missing DynamicDumpSharedSpaces check in sort_methods(); replace the (DumpSharedSpaces || DynamicDumpSharedSpaces) with the Arguments::is_dumping_archive() function call. Reviewed-by: iklam, coleenp, jiangli
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
     1
/*
46727
6e4a84748e2c 8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents: 44630
diff changeset
     2
 * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
     4
 *
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
     7
 * published by the Free Software Foundation.
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
     8
 *
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    13
 * accompanied this code).
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    14
 *
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    18
 *
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    21
 * questions.
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    22
 *
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    23
 */
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    24
#include "precompiled.hpp"
46746
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46727
diff changeset
    25
#include "memory/metaspaceClosure.hpp"
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    26
#include "oops/methodCounters.hpp"
28650
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
    27
#include "runtime/handles.inline.hpp"
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    28
46727
6e4a84748e2c 8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents: 44630
diff changeset
    29
MethodCounters* MethodCounters::allocate(const methodHandle& mh, TRAPS) {
28650
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26586
diff changeset
    30
  ClassLoaderData* loader_data = mh->method_holder()->class_loader_data();
46746
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46727
diff changeset
    31
  return new(loader_data, method_counters_size(), MetaspaceObj::MethodCountersType, THREAD) MethodCounters(mh);
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    32
}
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    33
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    34
void MethodCounters::clear_counters() {
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    35
  invocation_counter()->reset();
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    36
  backedge_counter()->reset();
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    37
  set_interpreter_throwout_count(0);
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    38
  set_interpreter_invocation_count(0);
24442
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 17858
diff changeset
    39
  set_nmethod_age(INT_MAX);
26586
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
    40
#ifdef TIERED
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
    41
  set_prev_time(0);
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
    42
  set_rate(0);
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
    43
  set_highest_comp_level(0);
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
    44
  set_highest_osr_comp_level(0);
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
    45
#endif
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
diff changeset
    46
}
26586
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
    47
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
    48
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
    49
int MethodCounters::highest_comp_level() const {
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
    50
#ifdef TIERED
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
    51
  return _highest_comp_level;
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
    52
#else
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
    53
  return CompLevel_none;
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
    54
#endif
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
    55
}
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
    56
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
    57
void MethodCounters::set_highest_comp_level(int level) {
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
    58
#ifdef TIERED
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
    59
  _highest_comp_level = level;
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
    60
#endif
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
    61
}
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
    62
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
    63
int MethodCounters::highest_osr_comp_level() const {
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
    64
#ifdef TIERED
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
    65
  return _highest_osr_comp_level;
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
    66
#else
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
    67
  return CompLevel_none;
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
    68
#endif
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
    69
}
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
    70
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
    71
void MethodCounters::set_highest_osr_comp_level(int level) {
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
    72
#ifdef TIERED
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
    73
  _highest_osr_comp_level = level;
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
    74
#endif
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
    75
}
992efa57514f 8058184: Move _highest_comp_level and _highest_osr_comp_level from MethodData to MethodCounters
iveresov
parents: 24442
diff changeset
    76
46746
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46727
diff changeset
    77
void MethodCounters::metaspace_pointers_do(MetaspaceClosure* it) {
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46727
diff changeset
    78
  log_trace(cds)("Iter(MethodCounters): %p", this);
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46727
diff changeset
    79
#if INCLUDE_AOT
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46727
diff changeset
    80
  it->push(&_method);
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46727
diff changeset
    81
#endif
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46727
diff changeset
    82
}
44630
54aa492f2b19 8176887: AOT: SIGSEGV in AOTCodeHeap::next when using specific configuration
iveresov
parents: 28650
diff changeset
    83
54aa492f2b19 8176887: AOT: SIGSEGV in AOTCodeHeap::next when using specific configuration
iveresov
parents: 28650
diff changeset
    84
void MethodCounters::print_value_on(outputStream* st) const {
54aa492f2b19 8176887: AOT: SIGSEGV in AOTCodeHeap::next when using specific configuration
iveresov
parents: 28650
diff changeset
    85
  assert(is_methodCounters(), "must be methodCounters");
54aa492f2b19 8176887: AOT: SIGSEGV in AOTCodeHeap::next when using specific configuration
iveresov
parents: 28650
diff changeset
    86
  st->print("method counters");
54aa492f2b19 8176887: AOT: SIGSEGV in AOTCodeHeap::next when using specific configuration
iveresov
parents: 28650
diff changeset
    87
  print_address_on(st);
54aa492f2b19 8176887: AOT: SIGSEGV in AOTCodeHeap::next when using specific configuration
iveresov
parents: 28650
diff changeset
    88
}
54aa492f2b19 8176887: AOT: SIGSEGV in AOTCodeHeap::next when using specific configuration
iveresov
parents: 28650
diff changeset
    89
54aa492f2b19 8176887: AOT: SIGSEGV in AOTCodeHeap::next when using specific configuration
iveresov
parents: 28650
diff changeset
    90