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 1657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1668 | 1668 |
1669 | 1669 |
1670 void BackgroundCompiler::Run() { | 1670 void BackgroundCompiler::Run() { |
1671 while (running_) { | 1671 while (running_) { |
1672 // Maybe something is already in the queue, check first before waiting | 1672 // Maybe something is already in the queue, check first before waiting |
1673 // to be notified. | 1673 // to be notified. |
1674 bool result = Thread::EnterIsolateAsHelper(isolate_, Thread::kCompilerTask); | 1674 bool result = Thread::EnterIsolateAsHelper(isolate_, Thread::kCompilerTask); |
1675 ASSERT(result); | 1675 ASSERT(result); |
1676 { | 1676 { |
1677 Thread* thread = Thread::Current(); | 1677 Thread* thread = Thread::Current(); |
1678 Isolate* isolate = thread->isolate(); | |
1679 StackZone stack_zone(thread); | 1678 StackZone stack_zone(thread); |
1680 Zone* zone = stack_zone.GetZone(); | 1679 Zone* zone = stack_zone.GetZone(); |
1681 HANDLESCOPE(thread); | 1680 HANDLESCOPE(thread); |
1682 Function& function = Function::Handle(zone); | 1681 Function& function = Function::Handle(zone); |
1683 function = function_queue()->PeekFunction(); | 1682 function = function_queue()->PeekFunction(); |
1684 while (running_ && !function.IsNull()) { | 1683 while (running_ && !function.IsNull()) { |
1685 // Check that we have aggregated and cleared the stats. | 1684 // Check that we have aggregated and cleared the stats. |
1686 ASSERT(thread->compiler_stats()->IsCleared()); | 1685 ASSERT(thread->compiler_stats()->IsCleared()); |
1687 const Error& error = Error::Handle(zone, | 1686 const Error& error = Error::Handle(zone, |
1688 Compiler::CompileOptimizedFunction(thread, | 1687 Compiler::CompileOptimizedFunction(thread, |
1689 function, | 1688 function, |
1690 Compiler::kNoOSRDeoptId)); | 1689 Compiler::kNoOSRDeoptId)); |
1691 // TODO(srdjan): We do not expect errors while compiling optimized | 1690 // TODO(srdjan): We do not expect errors while compiling optimized |
1692 // code, any errors should have been caught when compiling | 1691 // code, any errors should have been caught when compiling |
1693 // unoptimized code. Any issues while optimizing are flagged by | 1692 // unoptimized code. Any issues while optimizing are flagged by |
1694 // making the result invalid. | 1693 // making the result invalid. |
1695 ASSERT(error.IsNull()); | 1694 ASSERT(error.IsNull()); |
| 1695 #ifndef PRODUCT |
| 1696 Isolate* isolate = thread->isolate(); |
1696 // We cannot aggregate stats if isolate is shutting down. | 1697 // We cannot aggregate stats if isolate is shutting down. |
1697 if (isolate->HasMutatorThread()) { | 1698 if (isolate->HasMutatorThread()) { |
1698 isolate->aggregate_compiler_stats()->Add(*thread->compiler_stats()); | 1699 isolate->aggregate_compiler_stats()->Add(*thread->compiler_stats()); |
1699 } | 1700 } |
1700 thread->compiler_stats()->Clear(); | 1701 thread->compiler_stats()->Clear(); |
| 1702 #endif // PRODUCT |
1701 QueueElement* qelem = function_queue()->Remove(); | 1703 QueueElement* qelem = function_queue()->Remove(); |
1702 delete qelem; | 1704 delete qelem; |
1703 function = function_queue()->PeekFunction(); | 1705 function = function_queue()->PeekFunction(); |
1704 } | 1706 } |
1705 } | 1707 } |
1706 Thread::ExitIsolateAsHelper(); | 1708 Thread::ExitIsolateAsHelper(); |
1707 { | 1709 { |
1708 // Wait to be notified when the work queue is not empty. | 1710 // Wait to be notified when the work queue is not empty. |
1709 MonitorLocker ml(queue_monitor_); | 1711 MonitorLocker ml(queue_monitor_); |
1710 while (function_queue()->IsEmpty() && running_) { | 1712 while (function_queue()->IsEmpty() && running_) { |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1910 } | 1912 } |
1911 | 1913 |
1912 | 1914 |
1913 void BackgroundCompiler::EnsureInit(Thread* thread) { | 1915 void BackgroundCompiler::EnsureInit(Thread* thread) { |
1914 UNREACHABLE(); | 1916 UNREACHABLE(); |
1915 } | 1917 } |
1916 | 1918 |
1917 #endif // DART_PRECOMPILED_RUNTIME | 1919 #endif // DART_PRECOMPILED_RUNTIME |
1918 | 1920 |
1919 } // namespace dart | 1921 } // namespace dart |
OLD | NEW |