[Interpreter] Make ignition compiler eagerly.

Makes --ignition cause eager compilation if we aren't building the startup
snapshot.

BUG=v8:4280
LOG=N

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

Cr-Commit-Position: refs/heads/master@{#35066}
This commit is contained in:
rmcilroy 2016-03-24 11:37:56 -07:00 committed by Commit bot
parent 25d2b24771
commit 838cea4e4e
12 changed files with 113 additions and 35 deletions

View File

@ -32,7 +32,8 @@ BackgroundParsingTask::BackgroundParsingTask(
info->set_global();
info->set_unicode_cache(&source_->unicode_cache);
info->set_compile_options(options);
info->set_allow_lazy_parsing(true);
// Parse eagerly with ignition since we will compile eagerly.
info->set_allow_lazy_parsing(!(i::FLAG_ignition && i::FLAG_ignition_eager));
}

View File

@ -1271,6 +1271,10 @@ Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) {
// Consider parsing eagerly when targeting the code cache.
parse_allow_lazy &= !(FLAG_serialize_eager && info->will_serialize());
// Consider parsing eagerly when targeting Ignition.
parse_allow_lazy &= !(FLAG_ignition && FLAG_ignition_eager &&
!isolate->serializer_enabled());
parse_info->set_allow_lazy_parsing(parse_allow_lazy);
if (!parse_allow_lazy &&
(options == ScriptCompiler::kProduceParserCache ||
@ -1786,6 +1790,10 @@ Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfo(
// Consider compiling eagerly when targeting the code cache.
lazy &= !(FLAG_serialize_eager && info.will_serialize());
// Consider compiling eagerly when compiling bytecode for Ignition.
lazy &=
!(FLAG_ignition && FLAG_ignition_eager && !isolate->serializer_enabled());
// Generate code
TimerEventScope<TimerEventCompileCode> timer(isolate);
TRACE_EVENT0("v8", "V8.CompileCode");

View File

@ -290,6 +290,7 @@ DEFINE_BOOL(string_slices, true, "use string slices")
// Flags for Ignition.
DEFINE_BOOL(ignition, false, "use ignition interpreter")
DEFINE_BOOL(ignition_eager, true, "eagerly compile and parse with ignition")
DEFINE_STRING(ignition_filter, "*", "filter for ignition interpreter")
DEFINE_BOOL(print_bytecode, false,
"print bytecode generated by ignition interpreter")

View File

@ -485,9 +485,6 @@
##############################################################################
['ignition == True', {
# BUG(4333). Function name inferrer does not work for ES6 clases.
'test-func-name-inference/UpperCaseClass': [TIMEOUT],
'test-func-name-inference/LowerCaseClass': [TIMEOUT],
# TODO(rmcilroy,4680): The function_data field should be a BytecodeArray on interpreter entry
'test-api/SetFunctionEntryHook': [FAIL],
@ -503,6 +500,15 @@
'test-run-jsexceptions/ThrowMessagePosition': [FAIL],
'test-api/TryCatchMixedNesting': [FAIL],
# TODO(rmcilroy,4766): Requires BytecodeGraphBuilder to track source position
# on nodes (behind --turbo_source_positions flag).
'test-cpu-profiler/TickLinesOptimized': [FAIL],
# TODO(rmcilroy,4680): Fails to find the correct function name for the
# anonymous function. Fails without ignition but with --no-lazy also, so seems
# to be an issue when eagerly parsing.
'test-func-name-inference/ReturnAnonymousFunction': [FAIL],
# TODO(mythria,4780): Related to type feedback support for calls.
'test-feedback-vector/VectorCallICStates': [FAIL],
'test-compiler/FeedbackVectorPreservedAcrossRecompiles': [FAIL],
@ -521,6 +527,43 @@
# TODO(mythria,4680): Incorrect column number on eval.
'test-api/PromiseRejectCallback': [FAIL],
# TODO(rmcilroy,4680): Fails with eager compilation due to SharedFunctionInfo
# being null in compiler.cc Renumber(), meaning MaybeDisableOptimization never
# gets called.
'test-profile-generator/BailoutReason': [FAIL],
# TODO(mstarzinger,4680): Fails due to the turbo-asm pipeline only being taken
# in compiler.cc GetLazyCode for uncompiled code, and no similar path for eager
# code.
'test-api/TurboAsmDisablesNeuter': [FAIL],
# TODO(rmcilroy,4837): We don't set a LoadContextSlot for a function as
# immutable in the BytecodeGraphBuilder, therefore no inlining happens.
'test-run-inlining/InlineLoopGuardedTwice': [FAIL],
'test-run-inlining/InlineSurplusArgumentsDeopt': [FAIL],
'test-run-inlining/InlineTwice': [FAIL],
'test-run-inlining/InlineSurplusArgumentsObject': [FAIL],
'test-run-inlining/InlineTwiceDependentDiamond': [FAIL],
'test-run-inlining/InlineWithArguments': [FAIL],
'test-run-inlining/InlineLoopUnguardedTwice': [FAIL],
'test-run-inlining/InlineOmitArgumentsObject': [FAIL],
'test-run-inlining/InlineLoopUnguardedOnce': [FAIL],
'test-run-inlining/InlineOmitArgumentsDeopt': [FAIL],
'test-run-inlining/InlineTwiceDependentDiamondDifferent': [FAIL],
'test-run-inlining/SimpleInliningContext': [FAIL],
'test-run-inlining/InlineMutuallyRecursive': [FAIL],
'test-run-inlining/InlineLoopGuardedEmpty': [FAIL],
'test-run-inlining/InlineLoopGuardedOnce': [FAIL],
'test-run-inlining/InlineOmitArguments': [FAIL],
'test-run-inlining/SimpleInlining': [FAIL],
'test-run-inlining/InlineLoopUnguardedEmpty': [FAIL],
'test-run-inlining/InlineNestedBuiltin': [FAIL],
'test-run-inlining/InlineSurplusArguments': [FAIL],
'test-run-inlining/InlineBuiltin': [FAIL],
'test-run-inlining/InlineTwiceDependent': [FAIL],
'test-run-inlining/SimpleInliningContextDeopt': [FAIL],
'test-debug/DebugBreakInline': [FAIL],
}], # ignition == True
]

View File

@ -79,12 +79,6 @@ class BytecodeGraphTester {
i::FLAG_always_opt = false;
i::FLAG_allow_natives_syntax = true;
i::FLAG_loop_assignment_analysis = false;
// Set ignition filter flag via SetFlagsFromString to avoid double-free
// (or potential leak with StrDup() based on ownership confusion).
ScopedVector<char> ignition_filter(64);
SNPrintF(ignition_filter, "--ignition-filter=%s", filter);
FlagList::SetFlagsFromString(ignition_filter.start(),
ignition_filter.length());
// Ensure handler table is generated.
isolate->interpreter()->Initialize();
}

View File

@ -23,12 +23,6 @@ InterpreterTester::InterpreterTester(
feedback_vector_(feedback_vector) {
i::FLAG_ignition = true;
i::FLAG_always_opt = false;
// Set ignition filter flag via SetFlagsFromString to avoid double-free
// (or potential leak with StrDup() based on ownership confusion).
ScopedVector<char> ignition_filter(64);
SNPrintF(ignition_filter, "--ignition-filter=%s", filter);
FlagList::SetFlagsFromString(ignition_filter.start(),
ignition_filter.length());
// Ensure handler table is generated.
isolate->interpreter()->Initialize();
}

View File

@ -14516,12 +14516,17 @@ static int move_events = 0;
static bool FunctionNameIs(const char* expected,
const v8::JitCodeEvent* event) {
// Log lines for functions are of the general form:
// "LazyCompile:<type><function_name>", where the type is one of
// "*", "~" or "".
static const char kPreamble[] = "LazyCompile:";
static size_t kPreambleLen = sizeof(kPreamble) - 1;
// "LazyCompile:<type><function_name>" or Function:<type><function_name>,
// where the type is one of "*", "~" or "".
static const char* kPreamble;
if (!i::FLAG_lazy || (i::FLAG_ignition && i::FLAG_ignition_eager)) {
kPreamble = "Function:";
} else {
kPreamble = "LazyCompile:";
}
static size_t kPreambleLen = strlen(kPreamble);
if (event->name.len < sizeof(kPreamble) - 1 ||
if (event->name.len < kPreambleLen ||
strncmp(kPreamble, event->name.str, kPreambleLen) != 0) {
return false;
}
@ -14689,7 +14694,8 @@ UNINITIALIZED_TEST(SetJitCodeEventHandler) {
for (int i = 0; i < kIterations; ++i) {
LocalContext env(isolate);
i::AlwaysAllocateScope always_allocate(i_isolate);
SimulateFullSpace(heap->code_space());
SimulateFullSpace(i::FLAG_ignition ? heap->old_space()
: heap->code_space());
CompileRun(script);
// Keep a strong reference to the code object in the handle scope.
@ -15130,6 +15136,9 @@ THREADED_TEST(AccessChecksReenabledCorrectly) {
// Tests that ScriptData can be serialized and deserialized.
TEST(PreCompileSerialization) {
// Producing cached parser data while parsing eagerly is not supported.
if (!i::FLAG_lazy || (i::FLAG_ignition && i::FLAG_ignition_eager)) return;
v8::V8::Initialize();
LocalContext env;
v8::Isolate* isolate = env->GetIsolate();
@ -24061,12 +24070,18 @@ TEST(InvalidCacheData) {
v8::V8::Initialize();
v8::HandleScope scope(CcTest::isolate());
LocalContext context;
TestInvalidCacheData(v8::ScriptCompiler::kConsumeParserCache);
if (i::FLAG_lazy && !(i::FLAG_ignition && i::FLAG_ignition_eager)) {
// Cached parser data is not consumed while parsing eagerly.
TestInvalidCacheData(v8::ScriptCompiler::kConsumeParserCache);
}
TestInvalidCacheData(v8::ScriptCompiler::kConsumeCodeCache);
}
TEST(ParserCacheRejectedGracefully) {
// Producing cached parser data while parsing eagerly is not supported.
if (!i::FLAG_lazy || (i::FLAG_ignition && i::FLAG_ignition_eager)) return;
i::FLAG_min_preparse_length = 0;
v8::V8::Initialize();
v8::HandleScope scope(CcTest::isolate());

View File

@ -327,7 +327,10 @@ TEST(FeedbackVectorPreservedAcrossRecompiles) {
TEST(FeedbackVectorUnaffectedByScopeChanges) {
if (i::FLAG_always_opt || !i::FLAG_lazy) return;
if (i::FLAG_always_opt || !i::FLAG_lazy ||
(FLAG_ignition && FLAG_ignition_eager)) {
return;
}
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Context> context = CcTest::isolate()->GetCurrentContext();
@ -349,7 +352,8 @@ TEST(FeedbackVectorUnaffectedByScopeChanges) {
->Get(context, v8_str("morphing_call"))
.ToLocalChecked())));
// Not compiled, and so no feedback vector allocated yet.
// If we are compiling lazily then it should not be compiled, and so no
// feedback vector allocated yet.
CHECK(!f->shared()->is_compiled());
CHECK(f->shared()->feedback_vector()->is_empty());

View File

@ -367,7 +367,9 @@ TEST(HeapSnapshotCodeObjects) {
}
}
CHECK(compiled_references_x);
CHECK(!lazy_references_x);
if (i::FLAG_lazy && !(i::FLAG_ignition && i::FLAG_ignition_eager)) {
CHECK(!lazy_references_x);
}
}

View File

@ -200,6 +200,9 @@ class ScriptResource : public v8::String::ExternalOneByteStringResource {
TEST(UsingCachedData) {
// Producing cached parser data while parsing eagerly is not supported.
if (!i::FLAG_lazy || (i::FLAG_ignition && i::FLAG_ignition_eager)) return;
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope handles(isolate);
v8::Local<v8::Context> context = v8::Context::New(isolate);
@ -250,6 +253,9 @@ TEST(UsingCachedData) {
TEST(PreparseFunctionDataIsUsed) {
// Producing cached parser data while parsing eagerly is not supported.
if (!i::FLAG_lazy || (i::FLAG_ignition && i::FLAG_ignition_eager)) return;
// This tests that we actually do use the function data generated by the
// preparser.
@ -3236,6 +3242,9 @@ TEST(FuncNameInferrerEscaped) {
TEST(RegressionLazyFunctionWithErrorWithArg) {
// Test only applies when lazy parsing.
if (!i::FLAG_lazy || (i::FLAG_ignition && i::FLAG_ignition_eager)) return;
// The bug occurred when a lazy function had an error which requires a
// parameter (such as "unknown label" here). The error message was processed
// before the AstValueFactory containing the error message string was

View File

@ -672,10 +672,13 @@ TEST(LineNumber) {
profiler->processor()->StopSynchronously();
bool is_lazy = i::FLAG_lazy && !(i::FLAG_ignition && i::FLAG_ignition_eager);
CHECK_EQ(1, GetFunctionLineNumber(&env, "foo_at_the_first_line"));
CHECK_EQ(0, GetFunctionLineNumber(&env, "lazy_func_at_forth_line"));
CHECK_EQ(is_lazy ? 0 : 4,
GetFunctionLineNumber(&env, "lazy_func_at_forth_line"));
CHECK_EQ(2, GetFunctionLineNumber(&env, "bar_at_the_second_line"));
CHECK_EQ(0, GetFunctionLineNumber(&env, "lazy_func_at_6th_line"));
CHECK_EQ(is_lazy ? 0 : 6,
GetFunctionLineNumber(&env, "lazy_func_at_6th_line"));
profiler->StopProfiling("LineNumber");
}

View File

@ -784,12 +784,6 @@
'es6/debug-liveedit-new-target-3': [FAIL],
'es6/generators-debug-liveedit': [FAIL],
# TODO(yangguo/rmcilroy,4690): Related to Debugger. Goes into a loop
# in function: Debug::FindSharedFunctionInfoInScript and times out.
'regress/regress-crbug-517592': [SKIP],
'regress/regress-1853': [SKIP],
'regress/regress-crbug-424142': [SKIP],
# TODO(mythria, 4780): Related to type feedback for calls in interpreter.
'array-literal-feedback': [FAIL],
'regress/regress-4121': [FAIL],
@ -804,13 +798,23 @@
# objects.
'es6/mirror-collections': [FAIL],
# TODO(mythria, 4680): line numbers in eval test. Coloumn number is
# TODO(mythria, 4680): line numbers in eval test. Column number is
# incorrect.
'regress/regress-crbug-109362': [FAIL],
# TODO(mythria, 4680): possibly problem with line numbers.
'es6/regress/regress-468661': [FAIL],
# TODO(mythria, 4680): Fails with context_register_count_ > 0 (0 vs. 0) when
# trying to get a context register in BytecodeGenerator.
'harmony/regress/regress-4658': [FAIL, ['mode == release and dcheck_always_on == False', PASS],],
# TODO(rmcilroy, 4680): Script throws RangeError as expected, but does so during
# eager compile of the whole script instead of during lazy compile of the function
# f(), so we can't catch the exception in the try/catch. Skip because on some
# platforms the stack limit is different and the exception doesn't fire.
'regress/regress-crbug-589472': [SKIP],
# Debugger test cases that pass with ignition, but not full-codegen.
# These differences between full-codegen and ignition are deliberate.
'ignition/elided-instruction-no-ignition': [FAIL],