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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 bool optimized, | 375 bool optimized, |
376 intptr_t osr_id) | 376 intptr_t osr_id) |
377 : parsed_function_(parsed_function), | 377 : parsed_function_(parsed_function), |
378 optimized_(optimized), | 378 optimized_(optimized), |
379 osr_id_(osr_id), | 379 osr_id_(osr_id), |
380 thread_(Thread::Current()), | 380 thread_(Thread::Current()), |
381 field_invalidation_gen_at_start_(isolate()->field_invalidation_gen()), | 381 field_invalidation_gen_at_start_(isolate()->field_invalidation_gen()), |
382 loading_invalidation_gen_at_start_( | 382 loading_invalidation_gen_at_start_( |
383 isolate()->loading_invalidation_gen()) { | 383 isolate()->loading_invalidation_gen()) { |
384 if (Compiler::IsBackgroundCompilation()) { | 384 if (Compiler::IsBackgroundCompilation()) { |
385 Isolate::Current()->ClearDisablingFieldList(); | 385 isolate()->ClearDisablingFieldList(); |
386 } | 386 } |
387 } | 387 } |
388 | 388 |
389 bool Compile(CompilationPipeline* pipeline); | 389 bool Compile(CompilationPipeline* pipeline); |
390 | 390 |
391 private: | 391 private: |
392 ParsedFunction* parsed_function() const { return parsed_function_; } | 392 ParsedFunction* parsed_function() const { return parsed_function_; } |
393 bool optimized() const { return optimized_; } | 393 bool optimized() const { return optimized_; } |
394 intptr_t osr_id() const { return osr_id_; } | 394 intptr_t osr_id() const { return osr_id_; } |
395 Thread* thread() const { return thread_; } | 395 Thread* thread() const { return thread_; } |
(...skipping 1422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1818 function_queue()->Add(elem); | 1818 function_queue()->Add(elem); |
1819 ml.Notify(); | 1819 ml.Notify(); |
1820 } | 1820 } |
1821 | 1821 |
1822 | 1822 |
1823 void BackgroundCompiler::VisitPointers(ObjectPointerVisitor* visitor) { | 1823 void BackgroundCompiler::VisitPointers(ObjectPointerVisitor* visitor) { |
1824 function_queue_->VisitObjectPointers(visitor); | 1824 function_queue_->VisitObjectPointers(visitor); |
1825 } | 1825 } |
1826 | 1826 |
1827 | 1827 |
1828 void BackgroundCompiler::Stop(BackgroundCompiler* task) { | 1828 void BackgroundCompiler::Stop(Isolate* isolate) { |
1829 ASSERT(Isolate::Current()->background_compiler() == task); | 1829 BackgroundCompiler* task = isolate->background_compiler(); |
1830 ASSERT(task != NULL); | 1830 ASSERT(task != NULL); |
1831 BackgroundCompilationQueue* function_queue = task->function_queue(); | 1831 BackgroundCompilationQueue* function_queue = task->function_queue(); |
1832 | 1832 |
1833 Monitor* queue_monitor = task->queue_monitor_; | 1833 Monitor* queue_monitor = task->queue_monitor_; |
1834 Monitor* done_monitor = task->done_monitor_; | 1834 Monitor* done_monitor = task->done_monitor_; |
1835 bool* task_done = task->done_; | 1835 bool* task_done = task->done_; |
1836 // Wake up compiler task and stop it. | 1836 // Wake up compiler task and stop it. |
1837 { | 1837 { |
1838 MonitorLocker ml(queue_monitor); | 1838 MonitorLocker ml(queue_monitor); |
1839 task->running_ = false; | 1839 task->running_ = false; |
1840 function_queue->Clear(); | 1840 function_queue->Clear(); |
1841 // 'task' will be deleted by thread pool. | 1841 // 'task' will be deleted by thread pool. |
1842 task = NULL; | 1842 task = NULL; |
1843 ml.Notify(); // Stop waiting for the queue. | 1843 ml.Notify(); // Stop waiting for the queue. |
1844 } | 1844 } |
1845 | 1845 |
1846 { | 1846 { |
1847 MonitorLocker ml_done(done_monitor); | 1847 MonitorLocker ml_done(done_monitor); |
1848 while (!(*task_done)) { | 1848 while (!(*task_done)) { |
1849 ml_done.WaitWithSafepointCheck(Thread::Current()); | 1849 ml_done.WaitWithSafepointCheck(Thread::Current()); |
1850 } | 1850 } |
1851 } | 1851 } |
1852 delete task_done; | 1852 delete task_done; |
1853 delete done_monitor; | 1853 delete done_monitor; |
1854 delete queue_monitor; | 1854 delete queue_monitor; |
1855 delete function_queue; | 1855 delete function_queue; |
1856 Isolate::Current()->set_background_compiler(NULL); | 1856 isolate->set_background_compiler(NULL); |
1857 } | 1857 } |
1858 | 1858 |
1859 | 1859 |
1860 void BackgroundCompiler::EnsureInit(Thread* thread) { | 1860 void BackgroundCompiler::EnsureInit(Thread* thread) { |
1861 ASSERT(thread->IsMutatorThread()); | 1861 ASSERT(thread->IsMutatorThread()); |
1862 // Finalize NoSuchMethodError, _Mint; occasionally needed in optimized | 1862 // Finalize NoSuchMethodError, _Mint; occasionally needed in optimized |
1863 // compilation. | 1863 // compilation. |
1864 Class& cls = Class::Handle(thread->zone(), | 1864 Class& cls = Class::Handle(thread->zone(), |
1865 Library::LookupCoreClass(Symbols::NoSuchMethodError())); | 1865 Library::LookupCoreClass(Symbols::NoSuchMethodError())); |
1866 ASSERT(!cls.IsNull()); | 1866 ASSERT(!cls.IsNull()); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1987 void BackgroundCompiler::CompileOptimized(const Function& function) { | 1987 void BackgroundCompiler::CompileOptimized(const Function& function) { |
1988 UNREACHABLE(); | 1988 UNREACHABLE(); |
1989 } | 1989 } |
1990 | 1990 |
1991 | 1991 |
1992 void BackgroundCompiler::VisitPointers(ObjectPointerVisitor* visitor) { | 1992 void BackgroundCompiler::VisitPointers(ObjectPointerVisitor* visitor) { |
1993 UNREACHABLE(); | 1993 UNREACHABLE(); |
1994 } | 1994 } |
1995 | 1995 |
1996 | 1996 |
1997 void BackgroundCompiler::Stop(BackgroundCompiler* task) { | 1997 void BackgroundCompiler::Stop(Isolate* isolate) { |
1998 UNREACHABLE(); | 1998 UNREACHABLE(); |
1999 } | 1999 } |
2000 | 2000 |
2001 | 2001 |
2002 void BackgroundCompiler::EnsureInit(Thread* thread) { | 2002 void BackgroundCompiler::EnsureInit(Thread* thread) { |
2003 UNREACHABLE(); | 2003 UNREACHABLE(); |
2004 } | 2004 } |
2005 | 2005 |
2006 #endif // DART_PRECOMPILED_RUNTIME | 2006 #endif // DART_PRECOMPILED_RUNTIME |
2007 | 2007 |
2008 } // namespace dart | 2008 } // namespace dart |
OLD | NEW |