8319813: Remove upper limit on number of compiler phases in phasetype.hpp
Reviewed-by: chagedorn, rcastanedalo, epeter
This commit is contained in:
parent
c49fb4fca2
commit
8db7bad992
src/hotspot/share
@ -297,8 +297,11 @@ void DirectiveSet::init_control_intrinsic() {
|
||||
}
|
||||
}
|
||||
|
||||
DirectiveSet::DirectiveSet(CompilerDirectives* d) :_inlinematchers(nullptr), _directive(d) {
|
||||
_ideal_phase_name_mask = 0;
|
||||
DirectiveSet::DirectiveSet(CompilerDirectives* d) :
|
||||
_inlinematchers(nullptr),
|
||||
_directive(d),
|
||||
_ideal_phase_name_set(PHASE_NUM_TYPES, mtCompiler)
|
||||
{
|
||||
#define init_defaults_definition(name, type, dvalue, compiler) this->name##Option = dvalue;
|
||||
compilerdirectives_common_flags(init_defaults_definition)
|
||||
compilerdirectives_c2_flags(init_defaults_definition)
|
||||
@ -427,18 +430,17 @@ DirectiveSet* DirectiveSet::compilecommand_compatibility_init(const methodHandle
|
||||
compilerdirectives_c1_flags(init_default_cc)
|
||||
#undef init_default_cc
|
||||
|
||||
// Parse PrintIdealPhaseName and create an efficient lookup mask
|
||||
// Parse PrintIdealPhaseName and create a lookup set
|
||||
#ifndef PRODUCT
|
||||
#ifdef COMPILER2
|
||||
if (!_modified[PrintIdealPhaseIndex]) {
|
||||
// Parse ccstr and create mask
|
||||
// Parse ccstr and create set
|
||||
ccstrlist option;
|
||||
if (CompilerOracle::has_option_value(method, CompileCommand::PrintIdealPhase, option)) {
|
||||
uint64_t mask = 0;
|
||||
PhaseNameValidator validator(option, mask);
|
||||
PhaseNameValidator validator(option);
|
||||
if (validator.is_valid()) {
|
||||
assert(mask != 0, "Must be set");
|
||||
set.cloned()->_ideal_phase_name_mask = mask;
|
||||
assert(!validator.phase_name_set().is_empty(), "Phase name set must be non-empty");
|
||||
set.cloned()->set_ideal_phase_name_set(validator.phase_name_set());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -621,7 +623,7 @@ DirectiveSet* DirectiveSet::clone(DirectiveSet const* src) {
|
||||
#undef copy_string_members_definition
|
||||
|
||||
set->_intrinsic_control_words = src->_intrinsic_control_words;
|
||||
set->_ideal_phase_name_mask = src->_ideal_phase_name_mask;
|
||||
set->set_ideal_phase_name_set(src->_ideal_phase_name_set);
|
||||
return set;
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,8 @@
|
||||
#include "compiler/compiler_globals.hpp"
|
||||
#include "compiler/methodMatcher.hpp"
|
||||
#include "compiler/compilerOracle.hpp"
|
||||
#include "opto/phasetype.hpp"
|
||||
#include "utilities/bitMap.hpp"
|
||||
#include "utilities/exceptions.hpp"
|
||||
#include "utilities/tribool.hpp"
|
||||
|
||||
@ -128,7 +130,7 @@ private:
|
||||
InlineMatcher* _inlinematchers;
|
||||
CompilerDirectives* _directive;
|
||||
TriBoolArray<(size_t)vmIntrinsics::number_of_intrinsics(), int> _intrinsic_control_words;
|
||||
uint64_t _ideal_phase_name_mask;
|
||||
CHeapBitMap _ideal_phase_name_set;
|
||||
|
||||
public:
|
||||
DirectiveSet(CompilerDirectives* directive);
|
||||
@ -197,8 +199,12 @@ void set_##name(void* value) { \
|
||||
compilerdirectives_c1_string_flags(set_string_function_definition)
|
||||
#undef set_string_function_definition
|
||||
|
||||
void set_ideal_phase_mask(uint64_t mask) { _ideal_phase_name_mask = mask; };
|
||||
uint64_t ideal_phase_mask() { return _ideal_phase_name_mask; };
|
||||
void set_ideal_phase_name_set(const BitMap& set) {
|
||||
_ideal_phase_name_set.set_from(set);
|
||||
};
|
||||
bool should_print_phase(const CompilerPhaseType cpt) const {
|
||||
return _ideal_phase_name_set.at(cpt);
|
||||
};
|
||||
|
||||
void print_intx(outputStream* st, ccstr n, intx v, bool mod) { if (mod) { st->print("%s:" INTX_FORMAT " ", n, v); } }
|
||||
void print_uintx(outputStream* st, ccstr n, intx v, bool mod) { if (mod) { st->print("%s:" UINTX_FORMAT " ", n, v); } }
|
||||
|
@ -777,8 +777,7 @@ static void scan_value(enum OptionType type, char* line, int& total_bytes_read,
|
||||
}
|
||||
#ifndef PRODUCT
|
||||
else if (option == CompileCommand::PrintIdealPhase) {
|
||||
uint64_t mask = 0;
|
||||
PhaseNameValidator validator(value, mask);
|
||||
PhaseNameValidator validator(value);
|
||||
|
||||
if (!validator.is_valid()) {
|
||||
jio_snprintf(errorbuf, buf_size, "Unrecognized phase name in %s: %s", option2name(option), validator.what());
|
||||
|
@ -336,12 +336,11 @@ bool DirectivesParser::set_option_flag(JSON_TYPE t, JSON_VAL* v, const key* opti
|
||||
error(VALUE_ERROR, "Unrecognized intrinsic detected in DisableIntrinsic: %s", validator.what());
|
||||
}
|
||||
} else if (strncmp(option_key->name, "PrintIdealPhase", 15) == 0) {
|
||||
uint64_t mask = 0;
|
||||
PhaseNameValidator validator(s, mask);
|
||||
PhaseNameValidator validator(s);
|
||||
|
||||
valid = validator.is_valid();
|
||||
if (valid) {
|
||||
set->set_ideal_phase_mask(mask);
|
||||
set->set_ideal_phase_name_set(validator.phase_name_set());
|
||||
} else {
|
||||
error(VALUE_ERROR, "Unrecognized phase name detected in PrintIdealPhase: %s", validator.what());
|
||||
}
|
||||
|
@ -5143,7 +5143,7 @@ void Compile::end_method() {
|
||||
|
||||
bool Compile::should_print_phase(CompilerPhaseType cpt) {
|
||||
#ifndef PRODUCT
|
||||
if ((_directive->ideal_phase_mask() & CompilerPhaseTypeHelper::to_bitmask(cpt)) != 0) {
|
||||
if (_directive->should_print_phase(cpt)) {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
@ -25,6 +25,8 @@
|
||||
#ifndef SHARE_OPTO_PHASETYPE_HPP
|
||||
#define SHARE_OPTO_PHASETYPE_HPP
|
||||
|
||||
#include "utilities/bitMap.inline.hpp"
|
||||
|
||||
#define COMPILER_PHASES(flags) \
|
||||
flags(BEFORE_STRINGOPTS, "Before StringOpts") \
|
||||
flags(AFTER_STRINGOPTS, "After StringOpts") \
|
||||
@ -100,9 +102,6 @@ class CompilerPhaseTypeHelper {
|
||||
static const char* to_description(CompilerPhaseType cpt) {
|
||||
return phase_descriptions[cpt];
|
||||
}
|
||||
static uint64_t to_bitmask(CompilerPhaseType cpt) {
|
||||
return (UINT64_C(1) << cpt);
|
||||
}
|
||||
};
|
||||
|
||||
static CompilerPhaseType find_phase(const char* str) {
|
||||
@ -157,11 +156,16 @@ class PhaseNameIter {
|
||||
|
||||
class PhaseNameValidator {
|
||||
private:
|
||||
CHeapBitMap _phase_name_set;
|
||||
bool _valid;
|
||||
char* _bad;
|
||||
|
||||
public:
|
||||
PhaseNameValidator(ccstrlist option, uint64_t& mask) : _valid(true), _bad(nullptr) {
|
||||
PhaseNameValidator(ccstrlist option) :
|
||||
_phase_name_set(PHASE_NUM_TYPES, mtCompiler),
|
||||
_valid(true),
|
||||
_bad(nullptr)
|
||||
{
|
||||
for (PhaseNameIter iter(option); *iter != nullptr && _valid; ++iter) {
|
||||
|
||||
CompilerPhaseType cpt = find_phase(*iter);
|
||||
@ -172,10 +176,10 @@ class PhaseNameValidator {
|
||||
strncpy(_bad, *iter, len);
|
||||
_valid = false;
|
||||
} else if (PHASE_ALL == cpt) {
|
||||
mask = ~(UINT64_C(0));
|
||||
_phase_name_set.set_range(0, PHASE_NUM_TYPES);
|
||||
} else {
|
||||
assert(cpt < 64, "out of bounds");
|
||||
mask |= CompilerPhaseTypeHelper::to_bitmask(cpt);
|
||||
assert(cpt < PHASE_NUM_TYPES, "out of bounds");
|
||||
_phase_name_set.set_bit(cpt);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -186,6 +190,11 @@ class PhaseNameValidator {
|
||||
}
|
||||
}
|
||||
|
||||
const BitMap& phase_name_set() const {
|
||||
assert(is_valid(), "Use of invalid phase name set");
|
||||
return _phase_name_set;
|
||||
}
|
||||
|
||||
bool is_valid() const {
|
||||
return _valid;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user