Commit 31d3c8a0 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[compiler] Move PassesFilter onto SharedFunctionInfo.

The JSFunction::PassesFilter predicate is not fine-grained enough to
actually distinguish different closures and hence can be changed into
SharedFunctionInfo::PassesFilter instead. This will allow the compiler
to use is more broadly.

R=jkummerow@chromium.org

Review URL: https://codereview.chromium.org/1823033002

Cr-Commit-Position: refs/heads/master@{#34981}
parent 3a69da39
......@@ -410,7 +410,7 @@ OptimizedCompileJob::Status OptimizedCompileJob::CreateGraph() {
}
// Check the whitelist for Crankshaft.
if (!info()->closure()->PassesFilter(FLAG_hydrogen_filter)) {
if (!info()->shared_info()->PassesFilter(FLAG_hydrogen_filter)) {
return AbortOptimization(kHydrogenFilter);
}
......@@ -451,7 +451,8 @@ OptimizedCompileJob::Status OptimizedCompileJob::CreateGraph() {
!optimization_disabled;
// 3. Explicitly enabled by the command-line filter.
bool passes_turbo_filter = info()->closure()->PassesFilter(FLAG_turbo_filter);
bool passes_turbo_filter =
info()->shared_info()->PassesFilter(FLAG_turbo_filter);
// If this is OSR request, OSR must be enabled by Turbofan.
bool passes_osr_test = FLAG_turbo_osr || !info()->is_osr();
......@@ -820,7 +821,7 @@ bool UseIgnition(CompilationInfo* info) {
}
// Finally respect the filter.
return info->closure()->PassesFilter(FLAG_ignition_filter);
return info->closure()->shared()->PassesFilter(FLAG_ignition_filter);
}
int CodeAndMetadataSize(CompilationInfo* info) {
......
......@@ -34,7 +34,7 @@ bool CompilationPhase::ShouldProduceTraceOutput() const {
info()->IsStub()
? FLAG_trace_hydrogen_stubs
: (FLAG_trace_hydrogen &&
info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter));
info()->shared_info()->PassesFilter(FLAG_trace_hydrogen_filter));
return (tracing_on &&
base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) !=
NULL);
......
......@@ -13140,43 +13140,6 @@ void JSFunction::PrintName(FILE* out) {
}
// The filter is a pattern that matches function names in this way:
// "*" all; the default
// "-" all but the top-level function
// "-name" all but the function "name"
// "" only the top-level function
// "name" only the function "name"
// "name*" only functions starting with "name"
// "~" none; the tilde is not an identifier
bool JSFunction::PassesFilter(const char* raw_filter) {
if (*raw_filter == '*') return true;
String* name = shared()->DebugName();
Vector<const char> filter = CStrVector(raw_filter);
if (filter.length() == 0) return name->length() == 0;
if (filter[0] == '-') {
// Negative filter.
if (filter.length() == 1) {
return (name->length() != 0);
} else if (name->IsUtf8EqualTo(filter.SubVector(1, filter.length()))) {
return false;
}
if (filter[filter.length() - 1] == '*' &&
name->IsUtf8EqualTo(filter.SubVector(1, filter.length() - 1), true)) {
return false;
}
return true;
} else if (name->IsUtf8EqualTo(filter)) {
return true;
}
if (filter[filter.length() - 1] == '*' &&
name->IsUtf8EqualTo(filter.SubVector(0, filter.length() - 1), true)) {
return true;
}
return false;
}
Handle<String> JSFunction::GetName(Handle<JSFunction> function) {
Isolate* isolate = function->GetIsolate();
Handle<Object> name =
......@@ -13542,6 +13505,41 @@ String* SharedFunctionInfo::DebugName() {
return String::cast(n);
}
// The filter is a pattern that matches function names in this way:
// "*" all; the default
// "-" all but the top-level function
// "-name" all but the function "name"
// "" only the top-level function
// "name" only the function "name"
// "name*" only functions starting with "name"
// "~" none; the tilde is not an identifier
bool SharedFunctionInfo::PassesFilter(const char* raw_filter) {
if (*raw_filter == '*') return true;
String* name = DebugName();
Vector<const char> filter = CStrVector(raw_filter);
if (filter.length() == 0) return name->length() == 0;
if (filter[0] == '-') {
// Negative filter.
if (filter.length() == 1) {
return (name->length() != 0);
} else if (name->IsUtf8EqualTo(filter.SubVector(1, filter.length()))) {
return false;
}
if (filter[filter.length() - 1] == '*' &&
name->IsUtf8EqualTo(filter.SubVector(1, filter.length() - 1), true)) {
return false;
}
return true;
} else if (name->IsUtf8EqualTo(filter)) {
return true;
}
if (filter[filter.length() - 1] == '*' &&
name->IsUtf8EqualTo(filter.SubVector(0, filter.length() - 1), true)) {
return true;
}
return false;
}
bool SharedFunctionInfo::HasSourceCode() const {
return !script()->IsUndefined() &&
......
......@@ -6829,6 +6829,9 @@ class SharedFunctionInfo: public HeapObject {
// The function's name if it is non-empty, otherwise the inferred name.
String* DebugName();
// Used for flags such as --hydrogen-filter.
bool PassesFilter(const char* raw_filter);
// Position of the 'function' token in the script source.
inline int function_token_position() const;
inline void set_function_token_position(int function_token_position);
......@@ -7608,9 +7611,6 @@ class JSFunction: public JSObject {
// Returns the number of allocated literals.
inline int NumberOfLiterals();
// Used for flags such as --hydrogen-filter.
bool PassesFilter(const char* raw_filter);
// The function's name if it is configured, otherwise shared function info
// debug name.
static Handle<String> GetName(Handle<JSFunction> function);
......
......@@ -90,7 +90,8 @@ static void GetICCounts(SharedFunctionInfo* shared,
void RuntimeProfiler::Optimize(JSFunction* function, const char* reason) {
if (FLAG_trace_opt && function->PassesFilter(FLAG_hydrogen_filter)) {
if (FLAG_trace_opt &&
function->shared()->PassesFilter(FLAG_hydrogen_filter)) {
PrintF("[marking ");
function->ShortPrint();
PrintF(" for recompilation, reason: %s", reason);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment