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

Unified Diff: runtime/vm/compiler_test.cc

Issue 1410363005: Make ICData changes thread safe (first compute array, then set it). Install code in the main thread… (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Address comments Created 5 years, 2 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/vm/compiler.cc ('k') | runtime/vm/flow_graph_builder.h » ('j') | 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 19e495385d8c71c0febc1c7c6365072e8d0eda0f..a231839e553e2f70160b3c12528bc6480ceba90f 100644
--- a/runtime/vm/compiler_test.cc
+++ b/runtime/vm/compiler_test.cc
@@ -70,59 +70,7 @@ TEST_CASE(CompileFunction) {
}
-class CompileFunctionTask : public ThreadPool::Task {
- public:
- CompileFunctionTask(Isolate* isolate,
- const Function& func,
- Monitor* done_monitor,
- bool* done)
- : isolate_(isolate),
- func_(func),
- done_monitor_(done_monitor),
- done_(done) {
- }
-
- virtual void Run() {
- Thread::EnterIsolateAsHelper(isolate_);
- {
- Thread* thread = Thread::Current();
- StackZone stack_zone(thread);
- HANDLESCOPE(thread);
- EXPECT(func_.HasCode());
- EXPECT(!func_.HasOptimizedCode());
- const Error& err =
- Error::Handle(Compiler::CompileOptimizedFunction(thread, func_));
- EXPECT(err.IsNull());
- EXPECT(func_.HasOptimizedCode());
- }
- Thread::ExitIsolateAsHelper();
- // Tell main thread that we are done.
- {
- MonitorLocker ml(done_monitor_);
- ASSERT(!*done_);
- *done_ = true;
- ml.Notify();
- }
- }
-
- private:
- Isolate* isolate_;
- const Function& func_;
- 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();
-
// Create a simple function and compile it without optimization.
const char* kScriptChars =
"class A {\n"
@@ -147,19 +95,17 @@ TEST_CASE(CompileFunctionOnHelperThread) {
CompilerTest::TestCompileFunction(func);
EXPECT(func.HasCode());
EXPECT(!func.HasOptimizedCode());
-
- // Now optimize it on a helper thread.
- Dart::thread_pool()->Run(
- new CompileFunctionTask(isolate, func, &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();
- }
+ BackgroundCompiler::EnsureInit(thread);
+ Isolate* isolate = thread->isolate();
+ ASSERT(isolate->background_compiler() != NULL);
+ isolate->background_compiler()->CompileOptimized(func);
+ Monitor* m = new Monitor();
+ MonitorLocker ml(m);
+ while (!func.HasOptimizedCode()) {
+ isolate->background_compiler()->InstallGeneratedCode();
+ ml.Wait(1);
}
+ BackgroundCompiler::Stop(isolate->background_compiler());
}
« no previous file with comments | « runtime/vm/compiler.cc ('k') | runtime/vm/flow_graph_builder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698