OLD | NEW |
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 Loading... |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |