Skip to content

Commit a74a839

Browse files
author
Vladimir Kozlov
committed
8276571: C2: pass compilation options as structure
Reviewed-by: shade, chagedorn
1 parent c393ee8 commit a74a839

File tree

4 files changed

+59
-36
lines changed

4 files changed

+59
-36
lines changed

src/hotspot/share/opto/c2compiler.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ void C2Compiler::compile_method(ciEnv* env, ciMethod* target, int entry_bci, boo
104104

105105
while (!env->failing()) {
106106
// Attempt to compile while subsuming loads into machine instructions.
107-
Compile C(env, target, entry_bci, subsume_loads, do_escape_analysis, eliminate_boxing, do_locks_coarsening, install_code, directive);
107+
Options options(subsume_loads, do_escape_analysis, eliminate_boxing, do_locks_coarsening, install_code);
108+
Compile C(env, target, entry_bci, options, directive);
108109

109110
// Check result and retry if appropriate.
110111
if (C.failure_reason() != NULL) {

src/hotspot/share/opto/compile.cpp

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -487,25 +487,25 @@ CompileWrapper::~CompileWrapper() {
487487
void Compile::print_compile_messages() {
488488
#ifndef PRODUCT
489489
// Check if recompiling
490-
if (_subsume_loads == false && PrintOpto) {
490+
if (!subsume_loads() && PrintOpto) {
491491
// Recompiling without allowing machine instructions to subsume loads
492492
tty->print_cr("*********************************************************");
493493
tty->print_cr("** Bailout: Recompile without subsuming loads **");
494494
tty->print_cr("*********************************************************");
495495
}
496-
if (_do_escape_analysis != DoEscapeAnalysis && PrintOpto) {
496+
if ((do_escape_analysis() != DoEscapeAnalysis) && PrintOpto) {
497497
// Recompiling without escape analysis
498498
tty->print_cr("*********************************************************");
499499
tty->print_cr("** Bailout: Recompile without escape analysis **");
500500
tty->print_cr("*********************************************************");
501501
}
502-
if (_eliminate_boxing != EliminateAutoBox && PrintOpto) {
502+
if ((eliminate_boxing() != EliminateAutoBox) && PrintOpto) {
503503
// Recompiling without boxing elimination
504504
tty->print_cr("*********************************************************");
505505
tty->print_cr("** Bailout: Recompile without boxing elimination **");
506506
tty->print_cr("*********************************************************");
507507
}
508-
if ((_do_locks_coarsening != EliminateLocks) && PrintOpto) {
508+
if ((do_locks_coarsening() != EliminateLocks) && PrintOpto) {
509509
// Recompiling without locks coarsening
510510
tty->print_cr("*********************************************************");
511511
tty->print_cr("** Bailout: Recompile without locks coarsening **");
@@ -538,15 +538,10 @@ debug_only( int Compile::_debug_idx = 100000; )
538538

539539

540540
Compile::Compile( ciEnv* ci_env, ciMethod* target, int osr_bci,
541-
bool subsume_loads, bool do_escape_analysis, bool eliminate_boxing,
542-
bool do_locks_coarsening, bool install_code, DirectiveSet* directive)
541+
Options options, DirectiveSet* directive)
543542
: Phase(Compiler),
544543
_compile_id(ci_env->compile_id()),
545-
_subsume_loads(subsume_loads),
546-
_do_escape_analysis(do_escape_analysis),
547-
_install_code(install_code),
548-
_eliminate_boxing(eliminate_boxing),
549-
_do_locks_coarsening(do_locks_coarsening),
544+
_options(options),
550545
_method(target),
551546
_entry_bci(osr_bci),
552547
_ilt(NULL),
@@ -846,11 +841,7 @@ Compile::Compile( ciEnv* ci_env,
846841
DirectiveSet* directive)
847842
: Phase(Compiler),
848843
_compile_id(0),
849-
_subsume_loads(true),
850-
_do_escape_analysis(false),
851-
_install_code(true),
852-
_eliminate_boxing(false),
853-
_do_locks_coarsening(false),
844+
_options(Options::for_runtime_stub()),
854845
_method(NULL),
855846
_entry_bci(InvocationEntryBci),
856847
_stub_function(stub_function),
@@ -1034,8 +1025,9 @@ void Compile::Init(int aliaslevel) {
10341025
// Type::update_loaded_types(_method, _method->constants());
10351026

10361027
// Init alias_type map.
1037-
if (!_do_escape_analysis && aliaslevel == 3)
1028+
if (!do_escape_analysis() && aliaslevel == 3) {
10381029
aliaslevel = 2; // No unique types without escape analysis
1030+
}
10391031
_AliasLevel = aliaslevel;
10401032
const int grow_ats = 16;
10411033
_max_alias_types = grow_ats;
@@ -2160,7 +2152,7 @@ void Compile::Optimize() {
21602152
remove_root_to_sfpts_edges(igvn);
21612153

21622154
// Perform escape analysis
2163-
if (_do_escape_analysis && ConnectionGraph::has_candidates(this)) {
2155+
if (do_escape_analysis() && ConnectionGraph::has_candidates(this)) {
21642156
if (has_loops()) {
21652157
// Cleanup graph (remove dead nodes).
21662158
TracePhase tp("idealLoop", &timers[_t_idealLoop]);

src/hotspot/share/opto/compile.hpp

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,37 @@ class CloneMap {
162162
bool same_gen(node_idx_t k1, node_idx_t k2) const { return gen(k1) == gen(k2); }
163163
};
164164

165+
class Options {
166+
friend class Compile;
167+
friend class VMStructs;
168+
private:
169+
const bool _subsume_loads; // Load can be matched as part of a larger op.
170+
const bool _do_escape_analysis; // Do escape analysis.
171+
const bool _eliminate_boxing; // Do boxing elimination.
172+
const bool _do_locks_coarsening; // Do locks coarsening
173+
const bool _install_code; // Install the code that was compiled
174+
public:
175+
Options(bool subsume_loads, bool do_escape_analysis,
176+
bool eliminate_boxing, bool do_locks_coarsening,
177+
bool install_code) :
178+
_subsume_loads(subsume_loads),
179+
_do_escape_analysis(do_escape_analysis),
180+
_eliminate_boxing(eliminate_boxing),
181+
_do_locks_coarsening(do_locks_coarsening),
182+
_install_code(install_code) {
183+
}
184+
185+
static Options for_runtime_stub() {
186+
return Options(
187+
/* subsume_loads = */ true,
188+
/* do_escape_analysis = */ false,
189+
/* eliminate_boxing = */ false,
190+
/* do_lock_coarsening = */ false,
191+
/* install_code = */ true
192+
);
193+
}
194+
};
195+
165196
//------------------------------Compile----------------------------------------
166197
// This class defines a top-level Compiler invocation.
167198

@@ -246,11 +277,7 @@ class Compile : public Phase {
246277
private:
247278
// Fixed parameters to this compilation.
248279
const int _compile_id;
249-
const bool _subsume_loads; // Load can be matched as part of a larger op.
250-
const bool _do_escape_analysis; // Do escape analysis.
251-
const bool _install_code; // Install the code that was compiled
252-
const bool _eliminate_boxing; // Do boxing elimination.
253-
const bool _do_locks_coarsening; // Do locks coarsening
280+
const Options _options; // Compilation options
254281
ciMethod* _method; // The method being compiled.
255282
int _entry_bci; // entry bci for osr methods.
256283
const TypeFunc* _tf; // My kind of signature
@@ -504,16 +531,16 @@ class Compile : public Phase {
504531
// Does this compilation allow instructions to subsume loads? User
505532
// instructions that subsume a load may result in an unschedulable
506533
// instruction sequence.
507-
bool subsume_loads() const { return _subsume_loads; }
534+
bool subsume_loads() const { return _options._subsume_loads; }
508535
/** Do escape analysis. */
509-
bool do_escape_analysis() const { return _do_escape_analysis; }
536+
bool do_escape_analysis() const { return _options._do_escape_analysis; }
510537
/** Do boxing elimination. */
511-
bool eliminate_boxing() const { return _eliminate_boxing; }
538+
bool eliminate_boxing() const { return _options._eliminate_boxing; }
512539
/** Do aggressive boxing elimination. */
513-
bool aggressive_unboxing() const { return _eliminate_boxing && AggressiveUnboxing; }
514-
bool should_install_code() const { return _install_code; }
540+
bool aggressive_unboxing() const { return _options._eliminate_boxing && AggressiveUnboxing; }
541+
bool should_install_code() const { return _options._install_code; }
515542
/** Do locks coarsening. */
516-
bool do_locks_coarsening() const { return _do_locks_coarsening; }
543+
bool do_locks_coarsening() const { return _options._do_locks_coarsening; }
517544

518545
// Other fixed compilation parameters.
519546
ciMethod* method() const { return _method; }
@@ -1034,9 +1061,7 @@ class Compile : public Phase {
10341061
// replacement, entry_bci indicates the bytecode for which to compile a
10351062
// continuation.
10361063
Compile(ciEnv* ci_env, ciMethod* target,
1037-
int entry_bci, bool subsume_loads, bool do_escape_analysis,
1038-
bool eliminate_boxing, bool do_locks_coarsening,
1039-
bool install_code, DirectiveSet* directive);
1064+
int entry_bci, Options options, DirectiveSet* directive);
10401065

10411066
// Second major entry point. From the TypeFunc signature, generate code
10421067
// to pass arguments from the Java calling convention to the C calling

src/hotspot/share/runtime/vmStructs.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -885,11 +885,15 @@
885885
c2_nonstatic_field(Compile, _regalloc, PhaseRegAlloc*) \
886886
c2_nonstatic_field(Compile, _method, ciMethod*) \
887887
c2_nonstatic_field(Compile, _compile_id, const int) \
888-
c2_nonstatic_field(Compile, _subsume_loads, const bool) \
889-
c2_nonstatic_field(Compile, _do_escape_analysis, const bool) \
890-
c2_nonstatic_field(Compile, _eliminate_boxing, const bool) \
888+
c2_nonstatic_field(Compile, _options, const Options) \
891889
c2_nonstatic_field(Compile, _ilt, InlineTree*) \
892890
\
891+
c2_nonstatic_field(Options, _subsume_loads, const bool) \
892+
c2_nonstatic_field(Options, _do_escape_analysis, const bool) \
893+
c2_nonstatic_field(Options, _eliminate_boxing, const bool) \
894+
c2_nonstatic_field(Options, _do_locks_coarsening, const bool) \
895+
c2_nonstatic_field(Options, _install_code, const bool) \
896+
\
893897
c2_nonstatic_field(InlineTree, _caller_jvms, JVMState*) \
894898
c2_nonstatic_field(InlineTree, _method, ciMethod*) \
895899
c2_nonstatic_field(InlineTree, _caller_tree, InlineTree*) \
@@ -1441,6 +1445,7 @@
14411445
\
14421446
declare_c2_toplevel_type(Matcher) \
14431447
declare_c2_toplevel_type(Compile) \
1448+
declare_c2_toplevel_type(Options) \
14441449
declare_c2_toplevel_type(InlineTree) \
14451450
declare_c2_toplevel_type(OptoRegPair) \
14461451
declare_c2_toplevel_type(JVMState) \

0 commit comments

Comments
 (0)