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

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

Issue 1412463007: Move compilation queues into BackgroundCompiler class (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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 | « runtime/vm/compiler.h ('k') | runtime/vm/isolate.h » ('j') | 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 1596 matching lines...) Expand 10 before | Expand all | Expand 10 after
1607 prefix_invalidation_gen_ = queue->PopBackInteger(); 1607 prefix_invalidation_gen_ = queue->PopBackInteger();
1608 field_invalidation_gen_ = queue->PopBackInteger(); 1608 field_invalidation_gen_ = queue->PopBackInteger();
1609 cha_invalidation_gen_ = queue->PopBackInteger(); 1609 cha_invalidation_gen_ = queue->PopBackInteger();
1610 result_code_ = queue->PopBackCode(); 1610 result_code_ = queue->PopBackCode();
1611 } 1611 }
1612 1612
1613 1613
1614 BackgroundCompiler::BackgroundCompiler(Isolate* isolate) 1614 BackgroundCompiler::BackgroundCompiler(Isolate* isolate)
1615 : isolate_(isolate), running_(true), done_(new bool()), 1615 : isolate_(isolate), running_(true), done_(new bool()),
1616 queue_monitor_(new Monitor()), done_monitor_(new Monitor()), 1616 queue_monitor_(new Monitor()), done_monitor_(new Monitor()),
1617 function_queue_length_(0) { 1617 function_queue_length_(0),
1618 compilation_function_queue_(GrowableObjectArray::null()),
1619 compilation_result_queue_(GrowableObjectArray::null()) {
1618 *done_ = false; 1620 *done_ = false;
1619 } 1621 }
1620 1622
1621 1623
1622 void BackgroundCompiler::Run() { 1624 void BackgroundCompiler::Run() {
1623 while (running_) { 1625 while (running_) {
1624 // Maybe something is already in the queue, check first before waiting 1626 // Maybe something is already in the queue, check first before waiting
1625 // to be notified. 1627 // to be notified.
1626 Thread::EnterIsolateAsHelper(isolate_); 1628 Thread::EnterIsolateAsHelper(isolate_);
1627 { 1629 {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1695 } 1697 }
1696 if (function.usage_counter() < 0) { 1698 if (function.usage_counter() < 0) {
1697 // Reset to 0 so that it can be recompiled if needed. 1699 // Reset to 0 so that it can be recompiled if needed.
1698 function.set_usage_counter(0); 1700 function.set_usage_counter(0);
1699 } 1701 }
1700 } 1702 }
1701 } 1703 }
1702 1704
1703 1705
1704 GrowableObjectArray* BackgroundCompiler::FunctionsQueue() const { 1706 GrowableObjectArray* BackgroundCompiler::FunctionsQueue() const {
1705 return 1707 return &GrowableObjectArray::ZoneHandle(compilation_function_queue_);
1706 &GrowableObjectArray::ZoneHandle(isolate_->compilation_function_queue());
1707 } 1708 }
1708 1709
1709 1710
1710 GrowableObjectArray* BackgroundCompiler::ResultQueue() const { 1711 GrowableObjectArray* BackgroundCompiler::ResultQueue() const {
1711 return &GrowableObjectArray::ZoneHandle(isolate_->compilation_result_queue()); 1712 return &GrowableObjectArray::ZoneHandle(compilation_result_queue_);
1712 } 1713 }
1713 1714
1714 1715
1715 void BackgroundCompiler::AddFunction(const Function& f) { 1716 void BackgroundCompiler::AddFunction(const Function& f) {
1716 MonitorLocker ml(queue_monitor_); 1717 MonitorLocker ml(queue_monitor_);
1717 CompilationWorkQueue queue(FunctionsQueue()); 1718 CompilationWorkQueue queue(FunctionsQueue());
1718 queue.PushFrontFunction(f); 1719 queue.PushFrontFunction(f);
1719 set_function_queue_length(queue.Length()); 1720 set_function_queue_length(queue.Length());
1720 // Notify waiting background compiler task. 1721 // Notify waiting background compiler task.
1721 ml.Notify(); 1722 ml.Notify();
(...skipping 16 matching lines...) Expand all
1738 } 1739 }
1739 1740
1740 1741
1741 void BackgroundCompiler::AddResult(const BackgroundCompilationResult& value) { 1742 void BackgroundCompiler::AddResult(const BackgroundCompilationResult& value) {
1742 MonitorLocker ml(queue_monitor_); 1743 MonitorLocker ml(queue_monitor_);
1743 CompilationWorkQueue queue(ResultQueue()); 1744 CompilationWorkQueue queue(ResultQueue());
1744 value.PushOnQueue(&queue); 1745 value.PushOnQueue(&queue);
1745 } 1746 }
1746 1747
1747 1748
1749 void BackgroundCompiler::set_compilation_function_queue(
1750 const GrowableObjectArray& value) {
1751 compilation_function_queue_ = value.raw();
1752 }
1753
1754
1755 void BackgroundCompiler::set_compilation_result_queue(
1756 const GrowableObjectArray& value) {
1757 compilation_result_queue_ = value.raw();
1758 }
1759
1760
1761 void BackgroundCompiler::VisitPointers(ObjectPointerVisitor* visitor) {
1762 visitor->VisitPointer(reinterpret_cast<RawObject**>(
1763 &compilation_function_queue_));
1764
1765 visitor->VisitPointer(reinterpret_cast<RawObject**>(
1766 &compilation_result_queue_));
1767 }
1768
1769
1748 void BackgroundCompiler::Stop(BackgroundCompiler* task) { 1770 void BackgroundCompiler::Stop(BackgroundCompiler* task) {
1749 ASSERT(Isolate::Current()->background_compiler() == task); 1771 ASSERT(Isolate::Current()->background_compiler() == task);
1750 if (task == NULL) { 1772 if (task == NULL) {
1751 return; 1773 return;
1752 } 1774 }
1753 Monitor* monitor = task->queue_monitor_; 1775 Monitor* monitor = task->queue_monitor_;
1754 Monitor* done_monitor = task->done_monitor_; 1776 Monitor* done_monitor = task->done_monitor_;
1755 bool* task_done = task->done_; 1777 bool* task_done = task->done_;
1756 // Wake up compiler task and stop it. 1778 // Wake up compiler task and stop it.
1757 { 1779 {
(...skipping 18 matching lines...) Expand all
1776 1798
1777 1799
1778 void BackgroundCompiler::EnsureInit(Thread* thread) { 1800 void BackgroundCompiler::EnsureInit(Thread* thread) {
1779 bool start_task = false; 1801 bool start_task = false;
1780 Isolate* isolate = thread->isolate(); 1802 Isolate* isolate = thread->isolate();
1781 { 1803 {
1782 MutexLocker ml(isolate->mutex()); 1804 MutexLocker ml(isolate->mutex());
1783 if (isolate->background_compiler() == NULL) { 1805 if (isolate->background_compiler() == NULL) {
1784 BackgroundCompiler* task = new BackgroundCompiler(isolate); 1806 BackgroundCompiler* task = new BackgroundCompiler(isolate);
1785 isolate->set_background_compiler(task); 1807 isolate->set_background_compiler(task);
1786 isolate->set_compilation_function_queue(GrowableObjectArray::Handle( 1808 task->set_compilation_function_queue(GrowableObjectArray::Handle(
1787 thread->zone(), GrowableObjectArray::New())); 1809 thread->zone(), GrowableObjectArray::New()));
1788 isolate->set_compilation_result_queue(GrowableObjectArray::Handle( 1810 task->set_compilation_result_queue(GrowableObjectArray::Handle(
1789 thread->zone(), GrowableObjectArray::New())); 1811 thread->zone(), GrowableObjectArray::New()));
1790 start_task = true; 1812 start_task = true;
1791 } 1813 }
1792 } 1814 }
1793 if (start_task) { 1815 if (start_task) {
1794 Dart::thread_pool()->Run(isolate->background_compiler()); 1816 Dart::thread_pool()->Run(isolate->background_compiler());
1795 } 1817 }
1796 } 1818 }
1797 1819
1798 } // namespace dart 1820 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/compiler.h ('k') | runtime/vm/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698