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

Side by Side Diff: runtime/vm/compiler.cc

Issue 1887123002: GC Experiment: move GC call from background compiler thread to the mutator thread (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/compiler.h" 5 #include "vm/compiler.h"
6 6
7 #include "vm/assembler.h" 7 #include "vm/assembler.h"
8 8
9 #include "vm/ast_printer.h" 9 #include "vm/ast_printer.h"
10 #include "vm/block_scheduler.h" 10 #include "vm/block_scheduler.h"
(...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after
1066 // Do not Garbage collect during this stage and instead allow the 1066 // Do not Garbage collect during this stage and instead allow the
1067 // heap to grow. 1067 // heap to grow.
1068 NoHeapGrowthControlScope no_growth_control; 1068 NoHeapGrowthControlScope no_growth_control;
1069 if (!isolate()->background_compiler()->is_running()) { 1069 if (!isolate()->background_compiler()->is_running()) {
1070 // The background compiler is being stopped. 1070 // The background compiler is being stopped.
1071 Compiler::AbortBackgroundCompilation(Thread::kNoDeoptId, 1071 Compiler::AbortBackgroundCompilation(Thread::kNoDeoptId,
1072 "Background compilation is being stopped"); 1072 "Background compilation is being stopped");
1073 } 1073 }
1074 FinalizeCompilation(&assembler, &graph_compiler, flow_graph); 1074 FinalizeCompilation(&assembler, &graph_compiler, flow_graph);
1075 } 1075 }
1076 if (isolate()->heap()->NeedsGarbageCollection()) { 1076 // TODO(srdjan): Enable this and remove the one from
1077 isolate()->heap()->CollectAllGarbage(); 1077 // 'BackgroundCompiler::CompileOptimize'
1078 } 1078 // if (isolate()->heap()->NeedsGarbageCollection()) {
1079 // isolate()->heap()->CollectAllGarbage();
1080 // }
1079 } 1081 }
1080 } 1082 }
1081 // Mark that this isolate now has compiled code. 1083 // Mark that this isolate now has compiled code.
1082 isolate()->set_has_compiled_code(true); 1084 isolate()->set_has_compiled_code(true);
1083 // Exit the loop and the function with the correct result value. 1085 // Exit the loop and the function with the correct result value.
1084 is_compiled = true; 1086 is_compiled = true;
1085 done = true; 1087 done = true;
1086 } else { 1088 } else {
1087 // We bailed out or we encountered an error. 1089 // We bailed out or we encountered an error.
1088 const Error& error = Error::Handle(thread()->sticky_error()); 1090 const Error& error = Error::Handle(thread()->sticky_error());
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after
1805 // Notify that the thread is done. 1807 // Notify that the thread is done.
1806 MonitorLocker ml_done(done_monitor_); 1808 MonitorLocker ml_done(done_monitor_);
1807 *done_ = true; 1809 *done_ = true;
1808 ml_done.Notify(); 1810 ml_done.Notify();
1809 } 1811 }
1810 } 1812 }
1811 1813
1812 1814
1813 void BackgroundCompiler::CompileOptimized(const Function& function) { 1815 void BackgroundCompiler::CompileOptimized(const Function& function) {
1814 ASSERT(Thread::Current()->IsMutatorThread()); 1816 ASSERT(Thread::Current()->IsMutatorThread());
1815 MonitorLocker ml(queue_monitor_); 1817 // TODO(srdjan): Checking different strategy for collecting garbage
1816 ASSERT(running_); 1818 // accumulated by background compiler.
1817 if (function_queue()->ContainsObj(function)) { 1819 if (isolate_->heap()->NeedsGarbageCollection()) {
1818 return; 1820 isolate_->heap()->CollectAllGarbage();
1819 } 1821 }
1820 QueueElement* elem = new QueueElement(function); 1822 {
1821 function_queue()->Add(elem); 1823 MonitorLocker ml(queue_monitor_);
1822 ml.Notify(); 1824 ASSERT(running_);
1825 if (function_queue()->ContainsObj(function)) {
1826 return;
1827 }
1828 QueueElement* elem = new QueueElement(function);
1829 function_queue()->Add(elem);
1830 ml.Notify();
1831 }
1823 } 1832 }
1824 1833
1825 1834
1826 void BackgroundCompiler::VisitPointers(ObjectPointerVisitor* visitor) { 1835 void BackgroundCompiler::VisitPointers(ObjectPointerVisitor* visitor) {
1827 function_queue_->VisitObjectPointers(visitor); 1836 function_queue_->VisitObjectPointers(visitor);
1828 } 1837 }
1829 1838
1830 1839
1831 void BackgroundCompiler::Stop(Isolate* isolate) { 1840 void BackgroundCompiler::Stop(Isolate* isolate) {
1832 BackgroundCompiler* task = isolate->background_compiler(); 1841 BackgroundCompiler* task = isolate->background_compiler();
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
2002 } 2011 }
2003 2012
2004 2013
2005 void BackgroundCompiler::EnsureInit(Thread* thread) { 2014 void BackgroundCompiler::EnsureInit(Thread* thread) {
2006 UNREACHABLE(); 2015 UNREACHABLE();
2007 } 2016 }
2008 2017
2009 #endif // DART_PRECOMPILED_RUNTIME 2018 #endif // DART_PRECOMPILED_RUNTIME
2010 2019
2011 } // namespace dart 2020 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698