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

Unified Diff: runtime/vm/compiler_test.cc

Issue 1297663003: Test running compiler on a helper thread with mutator paused. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: indent Created 5 years, 4 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
« no previous file with comments | « runtime/tests/vm/vm.status ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/compiler_test.cc
diff --git a/runtime/vm/compiler_test.cc b/runtime/vm/compiler_test.cc
index aa5b8929c607cf53de5f41f2577444c4eff92bc3..c56ba377bebdbfd9c0e3ba6cb8f5375c1a686e82 100644
--- a/runtime/vm/compiler_test.cc
+++ b/runtime/vm/compiler_test.cc
@@ -9,6 +9,7 @@
#include "vm/dart_api_impl.h"
#include "vm/object.h"
#include "vm/symbols.h"
+#include "vm/thread_pool.h"
#include "vm/unit_test.h"
namespace dart {
@@ -28,7 +29,7 @@ TEST_CASE(CompileScript) {
}
-TEST_CASE(CompileFunction) {
+static void CompileFunctionImpl() {
const char* kScriptChars =
"class A {\n"
" static foo() { return 42; }\n"
@@ -69,6 +70,70 @@ TEST_CASE(CompileFunction) {
}
+TEST_CASE(CompileFunction) {
+ CompileFunctionImpl();
+}
+
+
+// Runs 'CompileFunctionImpl' on a helper thread.
+class CompileFunctionTask : public ThreadPool::Task {
+ public:
+ CompileFunctionTask(Isolate* isolate,
+ Monitor* done_monitor,
+ bool* done)
+ : isolate_(isolate),
+ done_monitor_(done_monitor),
+ done_(done) {
+ }
+
+ virtual void Run() {
+ Thread::EnterIsolateAsHelper(isolate_);
+ {
+ Thread* thread = Thread::Current();
+ StackZone stack_zone(thread);
+ HANDLESCOPE(thread);
+ CompileFunctionImpl();
+ }
+ Thread::ExitIsolateAsHelper();
+ // Tell main thread that we are done.
+ {
+ MonitorLocker ml(done_monitor_);
+ ASSERT(!*done_);
+ *done_ = true;
+ ml.Notify();
+ }
+ }
+
+ private:
+ Isolate* isolate_;
+ Monitor* done_monitor_;
+ bool* done_;
+};
+
+
+TEST_CASE(CompileFunctionOnHelperThread) {
+ Monitor done_monitor;
+ bool done = false;
+ Isolate* isolate = Thread::Current()->isolate();
+ // Flush store buffers, etc.
+ // TODO(koda): Currently, the GC only does this for the current thread, (i.e,
+ // the helper, in this test), but it should be done for all *threads*
+ // after/at safepointing.
+ Thread::PrepareForGC();
+ Dart::thread_pool()->Run(
+ new CompileFunctionTask(isolate, &done_monitor, &done));
+ {
+ // Manually wait.
+ // TODO(koda): Replace with execution of Dart and/or VM code when GC
+ // actually safepoints everything.
+ MonitorLocker ml(&done_monitor);
+ while (!done) {
+ ml.Wait();
+ }
+ }
+}
+
+
TEST_CASE(RegenerateAllocStubs) {
const char* kScriptChars =
"class A {\n"
« no previous file with comments | « runtime/tests/vm/vm.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698