[interpreter] Make --ignition-filter script filtering explicit.

This makes it explicit when the --ignition-filter pattern should be
applied to the script name instead of the function name by using a
proper "s:{name}" pattern. It also hardcodes it to be a prefix match
instead of an exact match, because that is all we need for test262.

R=rmcilroy@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#31153}
This commit is contained in:
mstarzinger 2015-10-07 07:27:24 -07:00 committed by Commit bot
parent 24aca87090
commit 6c97e54f27
4 changed files with 42 additions and 48 deletions

View File

@ -1153,6 +1153,18 @@ void Compiler::CompileForLiveEdit(Handle<Script> script) {
}
// Checks whether the passed {raw_filter} is a script filter (i.e. it matches
// the "s:{name}" pattern) and {name} is a prefix of the given scripts name.
// TODO(rmcilroy): Remove filtering once ignition can handle test262 harness.
static bool ScriptPassesFilter(const char* raw_filter, Handle<Script> script) {
if (!script->name()->IsString()) return false;
String* name = String::cast(script->name());
Vector<const char> filter = CStrVector(raw_filter);
if (filter.length() < 2 || filter[0] != 's' || filter[1] != ':') return false;
return name->IsUtf8EqualTo(filter.SubVector(2, filter.length()), true);
}
static Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) {
Isolate* isolate = info->isolate();
PostponeInterruptsScope postpone(isolate);
@ -1215,13 +1227,8 @@ static Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) {
: info->isolate()->counters()->compile();
HistogramTimerScope timer(rate);
Handle<String> script_name =
script->name()->IsString()
? Handle<String>(String::cast(script->name()))
: isolate->factory()->empty_string();
// Compile the code.
if (FLAG_ignition && script_name->PassesFilter(FLAG_ignition_filter)) {
if (FLAG_ignition && ScriptPassesFilter(FLAG_ignition_filter, script)) {
if (!GenerateBytecode(info)) {
return Handle<SharedFunctionInfo>::null();
}
@ -1252,6 +1259,10 @@ static Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) {
result->set_allows_lazy_compilation_without_context(false);
}
Handle<String> script_name =
script->name()->IsString()
? Handle<String>(String::cast(script->name()))
: isolate->factory()->empty_string();
Logger::LogEventsAndTags log_tag = info->is_eval()
? Logger::EVAL_TAG
: Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script);

View File

@ -1552,41 +1552,6 @@ void String::PrintUC16(std::ostream& os, int start, int end) { // NOLINT
}
// The filter is a pattern that matches string names in this way:
// "*" all; the default
// "-name" all but "name"
// "name" only the function "name"
// "name*" only functions starting with "name"
// "~" none; the tilde is not an identifier
bool String::PassesFilter(const char* raw_filter) {
if (*raw_filter == '*') return true;
Vector<const char> filter = CStrVector(raw_filter);
if (filter.length() == 0) return length() == 0;
if (filter[0] == '-') {
// Negative filter.
if (filter.length() == 1) {
return (length() != 0);
} else if (IsUtf8EqualTo(filter.SubVector(1, filter.length()))) {
return false;
}
if (filter[filter.length() - 1] == '*' &&
IsUtf8EqualTo(filter.SubVector(1, filter.length() - 1), true)) {
return false;
}
return true;
} else if (IsUtf8EqualTo(filter)) {
return true;
}
if (filter[filter.length() - 1] == '*' &&
IsUtf8EqualTo(filter.SubVector(0, filter.length() - 1), true)) {
return true;
}
return false;
}
void JSObject::JSObjectShortPrint(StringStream* accumulator) {
switch (map()->instance_type()) {
case JS_ARRAY_TYPE: {
@ -11007,8 +10972,31 @@ void JSFunction::PrintName(FILE* out) {
// "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();
return name->PassesFilter(raw_filter);
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;
}

View File

@ -7289,8 +7289,6 @@ class JSFunction: public JSObject {
inline int NumberOfLiterals();
// Used for flags such as --hydrogen-filter.
// TODO(rmcilroy/mstarzinger): Move this back to JSFunction when compiler.cc
// is refactored to allow use of JSFunction::PassesFilter for top-level code.
bool PassesFilter(const char* raw_filter);
// The function's name if it is configured, otherwise shared function info
@ -8693,9 +8691,6 @@ class String: public Name {
// For use during stack traces. Performs rudimentary sanity check.
bool LooksValid();
// Used for flags such as --hydrogen-filter.
bool PassesFilter(const char* raw_filter);
// Dispatched behavior.
void StringShortPrint(StringStream* accumulator);
void PrintUC16(std::ostream& os, int start = 0, int end = -1); // NOLINT

View File

@ -107,7 +107,7 @@ class Test262TestSuite(testsuite.TestSuite):
self.harness = [os.path.join(self.harnesspath, f)
for f in TEST_262_HARNESS_FILES]
self.harness += [os.path.join(self.root, "harness-adapt.js")]
self.ignition_filter = "--ignition-filter=" + self.testroot + "/*"
self.ignition_filter = "--ignition-filter=s:" + self.testroot
self.ParseTestRecord = None
def ListTests(self, context):