Skip to content
Permalink
Browse files
8258074: Move some flags related to compiler to compiler_globals.hpp
Reviewed-by: kvn, coleenp
  • Loading branch information
iklam committed Dec 16, 2020
1 parent 47ba652 commit 17ace8339dd8235f3811e3975d9ccc77910b0c77
Showing 12 changed files with 481 additions and 440 deletions.
@@ -29,6 +29,7 @@
#include "ci/ciField.hpp"
#include "ci/ciMethodBlocks.hpp"
#include "ci/ciStreams.hpp"
#include "compiler/compiler_globals.hpp"
#include "interpreter/bytecode.hpp"
#include "oops/oop.inline.hpp"
#include "utilities/align.hpp"
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
#include "ci/ciMethodData.hpp"
#include "ci/ciReplay.hpp"
#include "ci/ciUtilities.inline.hpp"
#include "compiler/compiler_globals.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/resourceArea.hpp"
#include "runtime/deoptimization.hpp"
@@ -44,6 +44,7 @@
#include "ci/ciUtilities.inline.hpp"
#include "classfile/javaClasses.inline.hpp"
#include "classfile/systemDictionary.hpp"
#include "compiler/compiler_globals.hpp"
#include "gc/shared/collectedHeap.inline.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/universe.hpp"

Large diffs are not rendered by default.

@@ -23,6 +23,7 @@
*/

#include "precompiled.hpp"
#include "compiler/compiler_globals.hpp"
#include "interpreter/invocationCounter.hpp"

void InvocationCounter::init() {
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -22,10 +22,52 @@
*
*/
#include "precompiled.hpp"
#include "compiler/compiler_globals.hpp"
#include "memory/metaspaceClosure.hpp"
#include "oops/methodCounters.hpp"
#include "runtime/handles.inline.hpp"

MethodCounters::MethodCounters(const methodHandle& mh) :
#if INCLUDE_AOT
_method(mh()),
#endif
_nmethod_age(INT_MAX)
#ifdef TIERED
, _rate(0),
_prev_time(0),
_highest_comp_level(0),
_highest_osr_comp_level(0)
#endif
{
set_interpreter_invocation_count(0);
set_interpreter_throwout_count(0);
JVMTI_ONLY(clear_number_of_breakpoints());
invocation_counter()->init();
backedge_counter()->init();

if (StressCodeAging) {
set_nmethod_age(HotMethodDetectionLimit);
}

// Set per-method thresholds.
double scale = 1.0;
CompilerOracle::has_option_value(mh, CompileCommand::CompileThresholdScaling, scale);

int compile_threshold = CompilerConfig::scaled_compile_threshold(CompileThreshold, scale);
_interpreter_invocation_limit = compile_threshold << InvocationCounter::count_shift;
if (ProfileInterpreter) {
// If interpreter profiling is enabled, the backward branch limit
// is compared against the method data counter rather than an invocation
// counter, therefore no shifting of bits is required.
_interpreter_backward_branch_limit = (int)((int64_t)compile_threshold * (OnStackReplacePercentage - InterpreterProfilePercentage) / 100);
} else {
_interpreter_backward_branch_limit = (int)(((int64_t)compile_threshold * OnStackReplacePercentage / 100) << InvocationCounter::count_shift);
}
_interpreter_profile_limit = ((compile_threshold * InterpreterProfilePercentage) / 100) << InvocationCounter::count_shift;
_invoke_mask = right_n_bits(CompilerConfig::scaled_freq_log(Tier0InvokeNotifyFreqLog, scale)) << InvocationCounter::count_shift;
_backedge_mask = right_n_bits(CompilerConfig::scaled_freq_log(Tier0BackedgeNotifyFreqLog, scale)) << InvocationCounter::count_shift;
}

MethodCounters* MethodCounters::allocate(const methodHandle& mh, TRAPS) {
ClassLoaderData* loader_data = mh->method_holder()->class_loader_data();
return new(loader_data, method_counters_size(), MetaspaceObj::MethodCountersType, THREAD) MethodCounters(mh);
@@ -70,46 +70,7 @@ class MethodCounters : public Metadata {
u1 _highest_osr_comp_level; // Same for OSR level
#endif

MethodCounters(const methodHandle& mh) :
#if INCLUDE_AOT
_method(mh()),
#endif
_nmethod_age(INT_MAX)
#ifdef TIERED
, _rate(0),
_prev_time(0),
_highest_comp_level(0),
_highest_osr_comp_level(0)
#endif
{
set_interpreter_invocation_count(0);
set_interpreter_throwout_count(0);
JVMTI_ONLY(clear_number_of_breakpoints());
invocation_counter()->init();
backedge_counter()->init();

if (StressCodeAging) {
set_nmethod_age(HotMethodDetectionLimit);
}

// Set per-method thresholds.
double scale = 1.0;
CompilerOracle::has_option_value(mh, CompileCommand::CompileThresholdScaling, scale);

int compile_threshold = CompilerConfig::scaled_compile_threshold(CompileThreshold, scale);
_interpreter_invocation_limit = compile_threshold << InvocationCounter::count_shift;
if (ProfileInterpreter) {
// If interpreter profiling is enabled, the backward branch limit
// is compared against the method data counter rather than an invocation
// counter, therefore no shifting of bits is required.
_interpreter_backward_branch_limit = (int)((int64_t)compile_threshold * (OnStackReplacePercentage - InterpreterProfilePercentage) / 100);
} else {
_interpreter_backward_branch_limit = (int)(((int64_t)compile_threshold * OnStackReplacePercentage / 100) << InvocationCounter::count_shift);
}
_interpreter_profile_limit = ((compile_threshold * InterpreterProfilePercentage) / 100) << InvocationCounter::count_shift;
_invoke_mask = right_n_bits(CompilerConfig::scaled_freq_log(Tier0InvokeNotifyFreqLog, scale)) << InvocationCounter::count_shift;
_backedge_mask = right_n_bits(CompilerConfig::scaled_freq_log(Tier0BackedgeNotifyFreqLog, scale)) << InvocationCounter::count_shift;
}
MethodCounters(const methodHandle& mh);

public:
virtual bool is_methodCounters() const { return true; }
@@ -38,6 +38,7 @@
#include "classfile/symbolTable.hpp"
#include "classfile/systemDictionary.hpp"
#include "classfile/vmSymbols.hpp"
#include "compiler/compiler_globals.hpp"
#include "gc/shared/gcLocker.inline.hpp"
#include "interpreter/linkResolver.hpp"
#include "jfr/jfrEvents.hpp"
@@ -28,9 +28,8 @@
#include "compiler/compiler_globals.hpp"
#include "runtime/globals.hpp"

// Put the LP64/JVMCI/COMPILER1/COMPILER1/ARCH at
// the top, as they are processed by jvmFlags.cpp in that
// order.
// Put LP64/ARCH/JVMCI/COMPILER1/COMPILER2 at the top,
// as they are processed by jvmFlag.cpp in that order.

#define ALL_FLAGS( \
develop, \
@@ -50,6 +49,13 @@
range, \
constraint) \
\
ARCH_FLAGS( \
develop, \
product, \
notproduct, \
range, \
constraint) \
\
JVMCI_ONLY(JVMCI_FLAGS( \
develop, \
develop_pd, \
@@ -77,9 +83,11 @@
range, \
constraint)) \
\
ARCH_FLAGS( \
COMPILER_FLAGS( \
develop, \
develop_pd, \
product, \
product_pd, \
notproduct, \
range, \
constraint) \
@@ -466,32 +466,32 @@ const char* JVMFlag::flag_error_str(JVMFlag::Error error) {
//----------------------------------------------------------------------
// Build flagTable[]

// Find out the number of LP64/JVMCI/COMPILER1/COMPILER1/ARCH flags,
// Find out the number of LP64/ARCH/JVMCI/COMPILER1/COMPILER2 flags,
// for JVMFlag::flag_group()

#define ENUM_F(type, name, ...) enum_##name,
#define IGNORE_F(...)

// dev dev-pd pro pro-pd notpro range constraint
enum FlagCounter_LP64 { LP64_RUNTIME_FLAGS( ENUM_F, ENUM_F, ENUM_F, ENUM_F, ENUM_F, IGNORE_F, IGNORE_F) num_flags_LP64 };
enum FlagCounter_ARCH { ARCH_FLAGS( ENUM_F, ENUM_F, ENUM_F, IGNORE_F, IGNORE_F) num_flags_ARCH };
enum FlagCounter_JVMCI { JVMCI_ONLY(JVMCI_FLAGS( ENUM_F, ENUM_F, ENUM_F, ENUM_F, ENUM_F, IGNORE_F, IGNORE_F)) num_flags_JVMCI };
enum FlagCounter_C1 { COMPILER1_PRESENT(C1_FLAGS(ENUM_F, ENUM_F, ENUM_F, ENUM_F, ENUM_F, IGNORE_F, IGNORE_F)) num_flags_C1 };
enum FlagCounter_C2 { COMPILER2_PRESENT(C2_FLAGS(ENUM_F, ENUM_F, ENUM_F, ENUM_F, ENUM_F, IGNORE_F, IGNORE_F)) num_flags_C2 };
enum FlagCounter_ARCH { ARCH_FLAGS( ENUM_F, ENUM_F, ENUM_F, IGNORE_F, IGNORE_F) num_flags_ARCH };

const int first_flag_enum_LP64 = 0;
const int first_flag_enum_JVMCI = first_flag_enum_LP64 + num_flags_LP64;
const int first_flag_enum_ARCH = first_flag_enum_LP64 + num_flags_LP64;
const int first_flag_enum_JVMCI = first_flag_enum_ARCH + num_flags_ARCH;
const int first_flag_enum_C1 = first_flag_enum_JVMCI + num_flags_JVMCI;
const int first_flag_enum_C2 = first_flag_enum_C1 + num_flags_C1;
const int first_flag_enum_ARCH = first_flag_enum_C2 + num_flags_C2;
const int first_flag_enum_other = first_flag_enum_ARCH + num_flags_ARCH;
const int first_flag_enum_other = first_flag_enum_C2 + num_flags_C2;

static constexpr int flag_group(int flag_enum) {
if (flag_enum < first_flag_enum_JVMCI) return JVMFlag::KIND_LP64_PRODUCT;
if (flag_enum < first_flag_enum_ARCH) return JVMFlag::KIND_LP64_PRODUCT;
if (flag_enum < first_flag_enum_JVMCI) return JVMFlag::KIND_ARCH;
if (flag_enum < first_flag_enum_C1) return JVMFlag::KIND_JVMCI;
if (flag_enum < first_flag_enum_C2) return JVMFlag::KIND_C1;
if (flag_enum < first_flag_enum_ARCH) return JVMFlag::KIND_C2;
if (flag_enum < first_flag_enum_other) return JVMFlag::KIND_ARCH;
if (flag_enum < first_flag_enum_other) return JVMFlag::KIND_C2;

return 0;
}

1 comment on commit 17ace83

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 17ace83 Dec 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.