mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-16 17:14:41 +02:00
8276571
: C2: pass compilation options as structure
Reviewed-by: shade, chagedorn
This commit is contained in:
parent
c393ee8f59
commit
a74a839af0
4 changed files with 59 additions and 36 deletions
|
@ -104,7 +104,8 @@ void C2Compiler::compile_method(ciEnv* env, ciMethod* target, int entry_bci, boo
|
|||
|
||||
while (!env->failing()) {
|
||||
// Attempt to compile while subsuming loads into machine instructions.
|
||||
Compile C(env, target, entry_bci, subsume_loads, do_escape_analysis, eliminate_boxing, do_locks_coarsening, install_code, directive);
|
||||
Options options(subsume_loads, do_escape_analysis, eliminate_boxing, do_locks_coarsening, install_code);
|
||||
Compile C(env, target, entry_bci, options, directive);
|
||||
|
||||
// Check result and retry if appropriate.
|
||||
if (C.failure_reason() != NULL) {
|
||||
|
|
|
@ -487,25 +487,25 @@ CompileWrapper::~CompileWrapper() {
|
|||
void Compile::print_compile_messages() {
|
||||
#ifndef PRODUCT
|
||||
// Check if recompiling
|
||||
if (_subsume_loads == false && PrintOpto) {
|
||||
if (!subsume_loads() && PrintOpto) {
|
||||
// Recompiling without allowing machine instructions to subsume loads
|
||||
tty->print_cr("*********************************************************");
|
||||
tty->print_cr("** Bailout: Recompile without subsuming loads **");
|
||||
tty->print_cr("*********************************************************");
|
||||
}
|
||||
if (_do_escape_analysis != DoEscapeAnalysis && PrintOpto) {
|
||||
if ((do_escape_analysis() != DoEscapeAnalysis) && PrintOpto) {
|
||||
// Recompiling without escape analysis
|
||||
tty->print_cr("*********************************************************");
|
||||
tty->print_cr("** Bailout: Recompile without escape analysis **");
|
||||
tty->print_cr("*********************************************************");
|
||||
}
|
||||
if (_eliminate_boxing != EliminateAutoBox && PrintOpto) {
|
||||
if ((eliminate_boxing() != EliminateAutoBox) && PrintOpto) {
|
||||
// Recompiling without boxing elimination
|
||||
tty->print_cr("*********************************************************");
|
||||
tty->print_cr("** Bailout: Recompile without boxing elimination **");
|
||||
tty->print_cr("*********************************************************");
|
||||
}
|
||||
if ((_do_locks_coarsening != EliminateLocks) && PrintOpto) {
|
||||
if ((do_locks_coarsening() != EliminateLocks) && PrintOpto) {
|
||||
// Recompiling without locks coarsening
|
||||
tty->print_cr("*********************************************************");
|
||||
tty->print_cr("** Bailout: Recompile without locks coarsening **");
|
||||
|
@ -538,15 +538,10 @@ debug_only( int Compile::_debug_idx = 100000; )
|
|||
|
||||
|
||||
Compile::Compile( ciEnv* ci_env, ciMethod* target, int osr_bci,
|
||||
bool subsume_loads, bool do_escape_analysis, bool eliminate_boxing,
|
||||
bool do_locks_coarsening, bool install_code, DirectiveSet* directive)
|
||||
Options options, DirectiveSet* directive)
|
||||
: Phase(Compiler),
|
||||
_compile_id(ci_env->compile_id()),
|
||||
_subsume_loads(subsume_loads),
|
||||
_do_escape_analysis(do_escape_analysis),
|
||||
_install_code(install_code),
|
||||
_eliminate_boxing(eliminate_boxing),
|
||||
_do_locks_coarsening(do_locks_coarsening),
|
||||
_options(options),
|
||||
_method(target),
|
||||
_entry_bci(osr_bci),
|
||||
_ilt(NULL),
|
||||
|
@ -846,11 +841,7 @@ Compile::Compile( ciEnv* ci_env,
|
|||
DirectiveSet* directive)
|
||||
: Phase(Compiler),
|
||||
_compile_id(0),
|
||||
_subsume_loads(true),
|
||||
_do_escape_analysis(false),
|
||||
_install_code(true),
|
||||
_eliminate_boxing(false),
|
||||
_do_locks_coarsening(false),
|
||||
_options(Options::for_runtime_stub()),
|
||||
_method(NULL),
|
||||
_entry_bci(InvocationEntryBci),
|
||||
_stub_function(stub_function),
|
||||
|
@ -1034,8 +1025,9 @@ void Compile::Init(int aliaslevel) {
|
|||
// Type::update_loaded_types(_method, _method->constants());
|
||||
|
||||
// Init alias_type map.
|
||||
if (!_do_escape_analysis && aliaslevel == 3)
|
||||
if (!do_escape_analysis() && aliaslevel == 3) {
|
||||
aliaslevel = 2; // No unique types without escape analysis
|
||||
}
|
||||
_AliasLevel = aliaslevel;
|
||||
const int grow_ats = 16;
|
||||
_max_alias_types = grow_ats;
|
||||
|
@ -2160,7 +2152,7 @@ void Compile::Optimize() {
|
|||
remove_root_to_sfpts_edges(igvn);
|
||||
|
||||
// Perform escape analysis
|
||||
if (_do_escape_analysis && ConnectionGraph::has_candidates(this)) {
|
||||
if (do_escape_analysis() && ConnectionGraph::has_candidates(this)) {
|
||||
if (has_loops()) {
|
||||
// Cleanup graph (remove dead nodes).
|
||||
TracePhase tp("idealLoop", &timers[_t_idealLoop]);
|
||||
|
|
|
@ -162,6 +162,37 @@ class CloneMap {
|
|||
bool same_gen(node_idx_t k1, node_idx_t k2) const { return gen(k1) == gen(k2); }
|
||||
};
|
||||
|
||||
class Options {
|
||||
friend class Compile;
|
||||
friend class VMStructs;
|
||||
private:
|
||||
const bool _subsume_loads; // Load can be matched as part of a larger op.
|
||||
const bool _do_escape_analysis; // Do escape analysis.
|
||||
const bool _eliminate_boxing; // Do boxing elimination.
|
||||
const bool _do_locks_coarsening; // Do locks coarsening
|
||||
const bool _install_code; // Install the code that was compiled
|
||||
public:
|
||||
Options(bool subsume_loads, bool do_escape_analysis,
|
||||
bool eliminate_boxing, bool do_locks_coarsening,
|
||||
bool install_code) :
|
||||
_subsume_loads(subsume_loads),
|
||||
_do_escape_analysis(do_escape_analysis),
|
||||
_eliminate_boxing(eliminate_boxing),
|
||||
_do_locks_coarsening(do_locks_coarsening),
|
||||
_install_code(install_code) {
|
||||
}
|
||||
|
||||
static Options for_runtime_stub() {
|
||||
return Options(
|
||||
/* subsume_loads = */ true,
|
||||
/* do_escape_analysis = */ false,
|
||||
/* eliminate_boxing = */ false,
|
||||
/* do_lock_coarsening = */ false,
|
||||
/* install_code = */ true
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
//------------------------------Compile----------------------------------------
|
||||
// This class defines a top-level Compiler invocation.
|
||||
|
||||
|
@ -246,11 +277,7 @@ class Compile : public Phase {
|
|||
private:
|
||||
// Fixed parameters to this compilation.
|
||||
const int _compile_id;
|
||||
const bool _subsume_loads; // Load can be matched as part of a larger op.
|
||||
const bool _do_escape_analysis; // Do escape analysis.
|
||||
const bool _install_code; // Install the code that was compiled
|
||||
const bool _eliminate_boxing; // Do boxing elimination.
|
||||
const bool _do_locks_coarsening; // Do locks coarsening
|
||||
const Options _options; // Compilation options
|
||||
ciMethod* _method; // The method being compiled.
|
||||
int _entry_bci; // entry bci for osr methods.
|
||||
const TypeFunc* _tf; // My kind of signature
|
||||
|
@ -504,16 +531,16 @@ class Compile : public Phase {
|
|||
// Does this compilation allow instructions to subsume loads? User
|
||||
// instructions that subsume a load may result in an unschedulable
|
||||
// instruction sequence.
|
||||
bool subsume_loads() const { return _subsume_loads; }
|
||||
bool subsume_loads() const { return _options._subsume_loads; }
|
||||
/** Do escape analysis. */
|
||||
bool do_escape_analysis() const { return _do_escape_analysis; }
|
||||
bool do_escape_analysis() const { return _options._do_escape_analysis; }
|
||||
/** Do boxing elimination. */
|
||||
bool eliminate_boxing() const { return _eliminate_boxing; }
|
||||
bool eliminate_boxing() const { return _options._eliminate_boxing; }
|
||||
/** Do aggressive boxing elimination. */
|
||||
bool aggressive_unboxing() const { return _eliminate_boxing && AggressiveUnboxing; }
|
||||
bool should_install_code() const { return _install_code; }
|
||||
bool aggressive_unboxing() const { return _options._eliminate_boxing && AggressiveUnboxing; }
|
||||
bool should_install_code() const { return _options._install_code; }
|
||||
/** Do locks coarsening. */
|
||||
bool do_locks_coarsening() const { return _do_locks_coarsening; }
|
||||
bool do_locks_coarsening() const { return _options._do_locks_coarsening; }
|
||||
|
||||
// Other fixed compilation parameters.
|
||||
ciMethod* method() const { return _method; }
|
||||
|
@ -1034,9 +1061,7 @@ class Compile : public Phase {
|
|||
// replacement, entry_bci indicates the bytecode for which to compile a
|
||||
// continuation.
|
||||
Compile(ciEnv* ci_env, ciMethod* target,
|
||||
int entry_bci, bool subsume_loads, bool do_escape_analysis,
|
||||
bool eliminate_boxing, bool do_locks_coarsening,
|
||||
bool install_code, DirectiveSet* directive);
|
||||
int entry_bci, Options options, DirectiveSet* directive);
|
||||
|
||||
// Second major entry point. From the TypeFunc signature, generate code
|
||||
// to pass arguments from the Java calling convention to the C calling
|
||||
|
|
|
@ -885,11 +885,15 @@
|
|||
c2_nonstatic_field(Compile, _regalloc, PhaseRegAlloc*) \
|
||||
c2_nonstatic_field(Compile, _method, ciMethod*) \
|
||||
c2_nonstatic_field(Compile, _compile_id, const int) \
|
||||
c2_nonstatic_field(Compile, _subsume_loads, const bool) \
|
||||
c2_nonstatic_field(Compile, _do_escape_analysis, const bool) \
|
||||
c2_nonstatic_field(Compile, _eliminate_boxing, const bool) \
|
||||
c2_nonstatic_field(Compile, _options, const Options) \
|
||||
c2_nonstatic_field(Compile, _ilt, InlineTree*) \
|
||||
\
|
||||
c2_nonstatic_field(Options, _subsume_loads, const bool) \
|
||||
c2_nonstatic_field(Options, _do_escape_analysis, const bool) \
|
||||
c2_nonstatic_field(Options, _eliminate_boxing, const bool) \
|
||||
c2_nonstatic_field(Options, _do_locks_coarsening, const bool) \
|
||||
c2_nonstatic_field(Options, _install_code, const bool) \
|
||||
\
|
||||
c2_nonstatic_field(InlineTree, _caller_jvms, JVMState*) \
|
||||
c2_nonstatic_field(InlineTree, _method, ciMethod*) \
|
||||
c2_nonstatic_field(InlineTree, _caller_tree, InlineTree*) \
|
||||
|
@ -1441,6 +1445,7 @@
|
|||
\
|
||||
declare_c2_toplevel_type(Matcher) \
|
||||
declare_c2_toplevel_type(Compile) \
|
||||
declare_c2_toplevel_type(Options) \
|
||||
declare_c2_toplevel_type(InlineTree) \
|
||||
declare_c2_toplevel_type(OptoRegPair) \
|
||||
declare_c2_toplevel_type(JVMState) \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue