Skip to content

Commit

Permalink
8262476: Add filter to speed up CompileCommand lookup
Browse files Browse the repository at this point in the history
Reviewed-by: kvn, thartmann
  • Loading branch information
Nils Eliasson committed Mar 19, 2021
1 parent 454af87 commit 701fd9d
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions src/hotspot/share/compiler/compilerOracle.cpp
Expand Up @@ -101,6 +101,25 @@ class TypedMethodOptionMatcher;
static TypedMethodOptionMatcher* option_list = NULL;
static bool any_set = false;

// A filter for quick lookup if an option is set
static bool option_filter[static_cast<int>(CompileCommand::Unknown) + 1] = { 0 };

void command_set_in_filter(enum CompileCommand option) {
assert(option != CompileCommand::Unknown, "sanity");
assert(option2type(option) != OptionType::Unknown, "sanity");

if ((option != CompileCommand::DontInline) &&
(option != CompileCommand::Inline) &&
(option != CompileCommand::Log)) {
any_set = true;
}
option_filter[static_cast<int>(option)] = true;
}

bool has_command(enum CompileCommand option) {
return option_filter[static_cast<int>(option)];
}

class TypedMethodOptionMatcher : public MethodMatcher {
private:
TypedMethodOptionMatcher* _next;
Expand Down Expand Up @@ -290,11 +309,8 @@ static void register_command(TypedMethodOptionMatcher* matcher,
matcher->init(option, option_list);
matcher->set_value<T>(value);
option_list = matcher;
if ((option != CompileCommand::DontInline) &&
(option != CompileCommand::Inline) &&
(option != CompileCommand::Log)) {
any_set = true;
}
command_set_in_filter(option);

if (!CompilerOracle::be_quiet()) {
// Print out the successful registration of a compile command
ttyLocker ttyl;
Expand All @@ -307,6 +323,9 @@ static void register_command(TypedMethodOptionMatcher* matcher,
template<typename T>
bool CompilerOracle::has_option_value(const methodHandle& method, enum CompileCommand option, T& value) {
assert(option_matches_type(option, value), "Value must match option type");
if (!has_command(option)) {
return false;
}
if (option_list != NULL) {
TypedMethodOptionMatcher* m = option_list->match(method, option);
if (m != NULL) {
Expand All @@ -325,18 +344,6 @@ static bool check_predicate(enum CompileCommand option, const methodHandle& meth
return false;
}

static bool has_command(enum CompileCommand option) {
TypedMethodOptionMatcher* m = option_list;
while (m != NULL) {
if (m->option() == option) {
return true;
} else {
m = m->next();
}
}
return false;
}

bool CompilerOracle::has_any_command_set() {
return any_set;
}
Expand Down

0 comments on commit 701fd9d

Please sign in to comment.