Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(330)

Unified Diff: test/unittests/compiler-dispatcher/compiler-dispatcher-unittest.cc

Issue 2612753002: Add more tests for compiler-dispatcher (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: test/unittests/compiler-dispatcher/compiler-dispatcher-unittest.cc
diff --git a/test/unittests/compiler-dispatcher/compiler-dispatcher-unittest.cc b/test/unittests/compiler-dispatcher/compiler-dispatcher-unittest.cc
index 338041ed8a3411cf48c6d2e5037247144dda6910..bef225efaf299b0b2afc2e27399b684b7e9a49c3 100644
--- a/test/unittests/compiler-dispatcher/compiler-dispatcher-unittest.cc
+++ b/test/unittests/compiler-dispatcher/compiler-dispatcher-unittest.cc
@@ -306,16 +306,13 @@ TEST_F(CompilerDispatcherTest, IdleTaskException) {
ASSERT_TRUE(dispatcher.Enqueue(shared));
ASSERT_TRUE(platform.IdleTaskPending());
- // Idle tasks shouldn't leave exceptions behind.
- v8::TryCatch try_catch(isolate());
-
// Since time doesn't progress on the MockPlatform, this is enough idle time
// to finish compiling the function.
platform.RunIdleTask(1000.0, 0.0);
ASSERT_FALSE(dispatcher.IsEnqueued(shared));
ASSERT_FALSE(shared->is_compiled());
- ASSERT_FALSE(try_catch.HasCaught());
+ ASSERT_FALSE(i_isolate()->has_pending_exception());
}
TEST_F(IgnitionCompilerDispatcherTest, CompileOnBackgroundThread) {
@@ -404,5 +401,63 @@ TEST_F(IgnitionCompilerDispatcherTest, FinishNowWithBackgroundTask) {
ASSERT_FALSE(platform.BackgroundTasksPending());
}
+TEST_F(CompilerDispatcherTest, IdleTaskMultipleJobs) {
+ MockPlatform platform;
+ CompilerDispatcher dispatcher(i_isolate(), &platform, FLAG_stack_size);
+
+ const char script1[] =
+ "function g() { var y = 1; function f8(x) { return x * y }; return f8; } "
+ "g();";
+ Handle<JSFunction> f1 = Handle<JSFunction>::cast(RunJS(isolate(), script1));
+ Handle<SharedFunctionInfo> shared1(f1->shared(), i_isolate());
+
+ const char script2[] =
+ "function g() { var y = 1; function f9(x) { return x * y }; return f9; } "
+ "g();";
+ Handle<JSFunction> f2 = Handle<JSFunction>::cast(RunJS(isolate(), script2));
+ Handle<SharedFunctionInfo> shared2(f2->shared(), i_isolate());
+
+ ASSERT_FALSE(platform.IdleTaskPending());
+ ASSERT_TRUE(dispatcher.Enqueue(shared1));
+ ASSERT_TRUE(dispatcher.Enqueue(shared2));
+ ASSERT_TRUE(platform.IdleTaskPending());
+
+ // Since time doesn't progress on the MockPlatform, this is enough idle time
+ // to finish compiling the function.
+ platform.RunIdleTask(1000.0, 0.0);
+
+ ASSERT_FALSE(dispatcher.IsEnqueued(shared1));
+ ASSERT_FALSE(dispatcher.IsEnqueued(shared2));
+ ASSERT_TRUE(shared1->is_compiled());
+ ASSERT_TRUE(shared2->is_compiled());
+}
+
+TEST_F(CompilerDispatcherTest, FinishNowException) {
+ MockPlatform platform;
+ CompilerDispatcher dispatcher(i_isolate(), &platform, 50);
vogelheim 2017/01/04 10:08:49 For my understanding: The point is to over-run an
jochen (gone - plz use gerrit) 2017/01/04 10:23:18 yes we can't put a real syntax error here, becaus
+
+ std::string script("function g() { function f10(x) { var a = ");
+ for (int i = 0; i < 1000; i++) {
+ script += "'x' + ";
+ }
+ script += " 'x'; }; return f10; } g();";
+ Handle<JSFunction> f =
+ Handle<JSFunction>::cast(RunJS(isolate(), script.c_str()));
+ Handle<SharedFunctionInfo> shared(f->shared(), i_isolate());
+
+ ASSERT_FALSE(platform.IdleTaskPending());
+ ASSERT_TRUE(dispatcher.Enqueue(shared));
+ ASSERT_TRUE(platform.IdleTaskPending());
+
+ ASSERT_FALSE(dispatcher.FinishNow(shared));
+
+ ASSERT_FALSE(dispatcher.IsEnqueued(shared));
+ ASSERT_FALSE(shared->is_compiled());
+ ASSERT_TRUE(i_isolate()->has_pending_exception());
+
+ i_isolate()->clear_pending_exception();
+ platform.ClearIdleTask();
+}
+
} // namespace internal
} // namespace v8

Powered by Google App Engine
This is Rietveld 408576698