Index: test/unittests/compiler-dispatcher/compiler-dispatcher-job-unittest.cc |
diff --git a/test/unittests/compiler-dispatcher/compiler-dispatcher-job-unittest.cc b/test/unittests/compiler-dispatcher/compiler-dispatcher-job-unittest.cc |
index d8fde2b1400b2f0cac9026c946f01c0e3bb59436..13f77ec45831da7610d50b2373312ac227769abf 100644 |
--- a/test/unittests/compiler-dispatcher/compiler-dispatcher-job-unittest.cc |
+++ b/test/unittests/compiler-dispatcher/compiler-dispatcher-job-unittest.cc |
@@ -323,5 +323,36 @@ TEST_F(IgnitionCompilerDispatcherJobTest, CompileOnBackgroundThread) { |
ASSERT_TRUE(job->status() == CompileJobStatus::kInitial); |
} |
+TEST_F(CompilerDispatcherJobTest, LazyInnerFunctions) { |
+ const char script[] = |
+ "function g() {\n" |
+ " f = function() {\n" |
+ " e = (function() { return 42; });\n" |
+ " return e;\n" |
+ " };\n" |
+ " return f;\n" |
+ "}\n" |
+ "g();"; |
+ Handle<JSFunction> f = Handle<JSFunction>::cast(RunJS(isolate(), script)); |
+ |
+ std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob( |
+ i_isolate(), tracer(), handle(f->shared()), FLAG_stack_size)); |
+ |
+ job->PrepareToParseOnMainThread(); |
+ job->Parse(); |
+ ASSERT_TRUE(job->FinalizeParsingOnMainThread()); |
+ ASSERT_TRUE(job->PrepareToCompileOnMainThread()); |
+ job->Compile(); |
+ ASSERT_TRUE(job->FinalizeCompilingOnMainThread()); |
+ ASSERT_TRUE(job->status() == CompileJobStatus::kDone); |
+ |
+ Handle<JSFunction> e = Handle<JSFunction>::cast(RunJS(isolate(), "f();")); |
+ |
+ ASSERT_FALSE(e->shared()->HasBaselineCode()); |
+ |
+ job->ResetOnMainThread(); |
+ ASSERT_TRUE(job->status() == CompileJobStatus::kInitial); |
+} |
+ |
} // namespace internal |
} // namespace v8 |