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

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

Issue 2558293004: Add a basic compiler dispatcher (Closed)
Patch Set: updates Created 4 years 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
new file mode 100644
index 0000000000000000000000000000000000000000..3f84b6859936c5f31528df3b65819ea1c2705ec0
--- /dev/null
+++ b/test/unittests/compiler-dispatcher/compiler-dispatcher-unittest.cc
@@ -0,0 +1,61 @@
+// Copyright 2016 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <memory>
+
+#include "src/compiler-dispatcher/compiler-dispatcher.h"
+#include "src/flags.h"
+#include "src/handles.h"
+#include "src/objects-inl.h"
+#include "test/unittests/compiler-dispatcher/compiler-dispatcher-helper.h"
+#include "test/unittests/test-utils.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace v8 {
+namespace internal {
+
+typedef TestWithContext CompilerDispatcherTest;
+
+TEST_F(CompilerDispatcherTest, Construct) {
+ std::unique_ptr<CompilerDispatcher> dispatcher(
+ new CompilerDispatcher(i_isolate(), FLAG_stack_size));
+}
+
+TEST_F(CompilerDispatcherTest, IsEnqueued) {
+ std::unique_ptr<CompilerDispatcher> dispatcher(
+ new CompilerDispatcher(i_isolate(), FLAG_stack_size));
+
+ const char script[] =
+ "function g() { var y = 1; function f(x) { return x * y }; return f; } "
+ "g();";
+ Handle<JSFunction> f = Handle<JSFunction>::cast(RunJS(isolate(), script));
+ Handle<SharedFunctionInfo> shared(f->shared(), i_isolate());
+
+ ASSERT_FALSE(dispatcher->IsEnqueued(shared));
+ ASSERT_TRUE(dispatcher->Enqueue(shared));
+ ASSERT_TRUE(dispatcher->IsEnqueued(shared));
+ dispatcher->Abort(shared, CompilerDispatcher::BlockingBehavior::kBlock);
+ ASSERT_FALSE(dispatcher->IsEnqueued(shared));
+}
+
+TEST_F(CompilerDispatcherTest, FinishNow) {
+ std::unique_ptr<CompilerDispatcher> dispatcher(
+ new CompilerDispatcher(i_isolate(), FLAG_stack_size));
+
+ const char script[] =
+ "function g() { var y = 1; function f(x) { return x * y }; return f; } "
+ "g();";
+ Handle<JSFunction> f = Handle<JSFunction>::cast(RunJS(isolate(), script));
+ Handle<SharedFunctionInfo> shared(f->shared(), i_isolate());
+
+ ASSERT_FALSE(shared->HasBaselineCode());
+ ASSERT_TRUE(dispatcher->Enqueue(shared));
+ ASSERT_TRUE(dispatcher->FinishNow(shared));
+ // Finishing removes the SFI from the queue.
+ ASSERT_FALSE(dispatcher->IsEnqueued(shared));
+ ASSERT_TRUE(shared->HasBaselineCode());
+}
+
+} // namespace internal
+} // namespace v8
« no previous file with comments | « test/unittests/compiler-dispatcher/compiler-dispatcher-job-unittest.cc ('k') | test/unittests/unittests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698