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 1652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1663 | 1663 |
1664 | 1664 |
1665 void BackgroundCompiler::Run() { | 1665 void BackgroundCompiler::Run() { |
1666 while (running_) { | 1666 while (running_) { |
1667 // Maybe something is already in the queue, check first before waiting | 1667 // Maybe something is already in the queue, check first before waiting |
1668 // to be notified. | 1668 // to be notified. |
1669 bool result = Thread::EnterIsolateAsHelper(isolate_, Thread::kCompilerTask); | 1669 bool result = Thread::EnterIsolateAsHelper(isolate_, Thread::kCompilerTask); |
1670 ASSERT(result); | 1670 ASSERT(result); |
1671 { | 1671 { |
1672 Thread* thread = Thread::Current(); | 1672 Thread* thread = Thread::Current(); |
| 1673 Isolate* isolate = thread->isolate(); |
1673 StackZone stack_zone(thread); | 1674 StackZone stack_zone(thread); |
1674 Zone* zone = stack_zone.GetZone(); | 1675 Zone* zone = stack_zone.GetZone(); |
1675 HANDLESCOPE(thread); | 1676 HANDLESCOPE(thread); |
1676 Function& function = Function::Handle(zone); | 1677 Function& function = Function::Handle(zone); |
1677 function = function_queue()->PeekFunction(); | 1678 function = function_queue()->PeekFunction(); |
1678 while (running_ && !function.IsNull()) { | 1679 while (running_ && !function.IsNull()) { |
| 1680 // Check that we have aggregated and cleared the stats. |
| 1681 ASSERT(thread->compiler_stats()->IsCleared()); |
1679 const Error& error = Error::Handle(zone, | 1682 const Error& error = Error::Handle(zone, |
1680 Compiler::CompileOptimizedFunction(thread, | 1683 Compiler::CompileOptimizedFunction(thread, |
1681 function, | 1684 function, |
1682 Compiler::kNoOSRDeoptId)); | 1685 Compiler::kNoOSRDeoptId)); |
1683 // TODO(srdjan): We do not expect errors while compiling optimized | 1686 // TODO(srdjan): We do not expect errors while compiling optimized |
1684 // code, any errors should have been caught when compiling | 1687 // code, any errors should have been caught when compiling |
1685 // unoptimized code. Any issues while optimizing are flagged by | 1688 // unoptimized code. Any issues while optimizing are flagged by |
1686 // making the result invalid. | 1689 // making the result invalid. |
1687 ASSERT(error.IsNull()); | 1690 ASSERT(error.IsNull()); |
| 1691 isolate->aggregate_compiler_stats()->Add(*thread->compiler_stats()); |
| 1692 thread->compiler_stats()->Clear(); |
1688 QueueElement* qelem = function_queue()->Remove(); | 1693 QueueElement* qelem = function_queue()->Remove(); |
1689 delete qelem; | 1694 delete qelem; |
1690 function = function_queue()->PeekFunction(); | 1695 function = function_queue()->PeekFunction(); |
1691 } | 1696 } |
1692 } | 1697 } |
1693 Thread::ExitIsolateAsHelper(); | 1698 Thread::ExitIsolateAsHelper(); |
1694 { | 1699 { |
1695 // Wait to be notified when the work queue is not empty. | 1700 // Wait to be notified when the work queue is not empty. |
1696 MonitorLocker ml(queue_monitor_); | 1701 MonitorLocker ml(queue_monitor_); |
1697 while (function_queue()->IsEmpty() && running_) { | 1702 while (function_queue()->IsEmpty() && running_) { |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1897 } | 1902 } |
1898 | 1903 |
1899 | 1904 |
1900 void BackgroundCompiler::EnsureInit(Thread* thread) { | 1905 void BackgroundCompiler::EnsureInit(Thread* thread) { |
1901 UNREACHABLE(); | 1906 UNREACHABLE(); |
1902 } | 1907 } |
1903 | 1908 |
1904 #endif // DART_PRECOMPILED_RUNTIME | 1909 #endif // DART_PRECOMPILED_RUNTIME |
1905 | 1910 |
1906 } // namespace dart | 1911 } // namespace dart |
OLD | NEW |