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

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

Issue 1433463002: Allocate some data structures in old instead of in new space. Early inlining bailout for native fun… (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Spelling error 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 | « no previous file | runtime/vm/dart_api_impl.cc » ('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 1479 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 private: 1490 private:
1491 // Adds to the queue only if 'function' is not already in there. 1491 // Adds to the queue only if 'function' is not already in there.
1492 void PushFront(const Object& value) { 1492 void PushFront(const Object& value) {
1493 for (intptr_t i = 0; i < data_->Length(); i++) { 1493 for (intptr_t i = 0; i < data_->Length(); i++) {
1494 if (data_->At(i) == value.raw()) { 1494 if (data_->At(i) == value.raw()) {
1495 return; 1495 return;
1496 } 1496 }
1497 } 1497 }
1498 // Insert new element in front. 1498 // Insert new element in front.
1499 Object& f = Object::Handle(); 1499 Object& f = Object::Handle();
1500 data_->Add(f); 1500 data_->Add(f, Heap::kOld);
1501 for (intptr_t i = data_->Length() - 1; i > 0; i--) { 1501 for (intptr_t i = data_->Length() - 1; i > 0; i--) {
1502 f = data_->At(i - 1); 1502 f = data_->At(i - 1);
1503 data_->SetAt(i, f); 1503 data_->SetAt(i, f);
1504 } 1504 }
1505 data_->SetAt(0, value); 1505 data_->SetAt(0, value);
1506 } 1506 }
1507 1507
1508 1508
1509 void PushBack(const Object& value) { 1509 void PushBack(const Object& value) {
1510 data_->Add(value, Heap::kOld); 1510 data_->Add(value, Heap::kOld);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1622 1622
1623 1623
1624 void BackgroundCompiler::Run() { 1624 void BackgroundCompiler::Run() {
1625 while (running_) { 1625 while (running_) {
1626 // Maybe something is already in the queue, check first before waiting 1626 // Maybe something is already in the queue, check first before waiting
1627 // to be notified. 1627 // to be notified.
1628 Thread::EnterIsolateAsHelper(isolate_); 1628 Thread::EnterIsolateAsHelper(isolate_);
1629 { 1629 {
1630 Thread* thread = Thread::Current(); 1630 Thread* thread = Thread::Current();
1631 StackZone stack_zone(thread); 1631 StackZone stack_zone(thread);
1632 Zone* zone = stack_zone.GetZone();
1632 HANDLESCOPE(thread); 1633 HANDLESCOPE(thread);
1633 Zone* zone = stack_zone.GetZone();
1634 Function& function = Function::Handle(zone); 1634 Function& function = Function::Handle(zone);
1635 Function& temp_function = Function::Handle(zone); 1635 Function& temp_function = Function::Handle(zone);
1636 function = LastFunctionOrNull(); 1636 function = LastFunctionOrNull();
1637 BackgroundCompilationResult result; 1637 BackgroundCompilationResult result;
1638 // Finish all compilation before exiting (even if running_ is changed to 1638 // Finish all compilation before exiting (even if running_ is changed to
1639 // false). 1639 // false).
1640 while (!function.IsNull()) { 1640 while (!function.IsNull()) {
1641 result.Init(); 1641 result.Init();
1642 const Error& error = Error::Handle(zone, 1642 const Error& error = Error::Handle(zone,
1643 Compiler::CompileOptimizedFunction(thread, 1643 Compiler::CompileOptimizedFunction(thread,
(...skipping 13 matching lines...) Expand all
1657 } 1657 }
1658 } 1658 }
1659 Thread::ExitIsolateAsHelper(); 1659 Thread::ExitIsolateAsHelper();
1660 { 1660 {
1661 // Wait to be notified when the work queue is not empty. 1661 // Wait to be notified when the work queue is not empty.
1662 MonitorLocker ml(queue_monitor_); 1662 MonitorLocker ml(queue_monitor_);
1663 while ((function_queue_length() == 0) && running_) { 1663 while ((function_queue_length() == 0) && running_) {
1664 ml.Wait(); 1664 ml.Wait();
1665 } 1665 }
1666 } 1666 }
1667 } 1667 } // while running
1668
1669 compilation_function_queue_ = GrowableObjectArray::null();
1670 compilation_result_queue_ = GrowableObjectArray::null();
1668 { 1671 {
1669 // Notify that the thread is done. 1672 // Notify that the thread is done.
1670 MonitorLocker ml_done(done_monitor_); 1673 MonitorLocker ml_done(done_monitor_);
1671 *done_ = true; 1674 *done_ = true;
1672 ml_done.Notify(); 1675 ml_done.Notify();
1673 } 1676 }
1674 } 1677 }
1675 1678
1676 1679
1677 void BackgroundCompiler::CompileOptimized(const Function& function) { 1680 void BackgroundCompiler::CompileOptimized(const Function& function) {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1765 visitor->VisitPointer(reinterpret_cast<RawObject**>( 1768 visitor->VisitPointer(reinterpret_cast<RawObject**>(
1766 &compilation_result_queue_)); 1769 &compilation_result_queue_));
1767 } 1770 }
1768 1771
1769 1772
1770 void BackgroundCompiler::Stop(BackgroundCompiler* task) { 1773 void BackgroundCompiler::Stop(BackgroundCompiler* task) {
1771 ASSERT(Isolate::Current()->background_compiler() == task); 1774 ASSERT(Isolate::Current()->background_compiler() == task);
1772 if (task == NULL) { 1775 if (task == NULL) {
1773 return; 1776 return;
1774 } 1777 }
1775 Monitor* monitor = task->queue_monitor_; 1778 Monitor* queue_monitor = task->queue_monitor_;
1776 Monitor* done_monitor = task->done_monitor_; 1779 Monitor* done_monitor = task->done_monitor_;
1777 bool* task_done = task->done_; 1780 bool* task_done = task->done_;
1778 // Wake up compiler task and stop it. 1781 // Wake up compiler task and stop it.
1779 { 1782 {
1780 MonitorLocker ml(task->queue_monitor_); 1783 MonitorLocker ml(task->queue_monitor_);
1781 task->running_ = false; 1784 task->running_ = false;
1782 // 'task' will be deleted by thread pool. 1785 // 'task' will be deleted by thread pool.
1783 task = NULL; 1786 task = NULL;
1784 ml.Notify(); // Stop waiting for the queue. 1787 ml.Notify(); // Stop waiting for the queue.
1785 } 1788 }
1786 1789
1787 { 1790 {
1788 MonitorLocker ml_done(done_monitor); 1791 MonitorLocker ml_done(done_monitor);
1789 while (!(*task_done)) { 1792 while (!(*task_done)) {
1790 ml_done.Wait(); 1793 ml_done.Wait();
1791 } 1794 }
1792 } 1795 }
1793 delete task_done; 1796 delete task_done;
1794 delete done_monitor; 1797 delete done_monitor;
1795 delete monitor; 1798 delete queue_monitor;
1796 Isolate::Current()->set_background_compiler(NULL); 1799 Isolate::Current()->set_background_compiler(NULL);
1797 } 1800 }
1798 1801
1799 1802
1800 void BackgroundCompiler::EnsureInit(Thread* thread) { 1803 void BackgroundCompiler::EnsureInit(Thread* thread) {
1801 bool start_task = false; 1804 bool start_task = false;
1802 Isolate* isolate = thread->isolate(); 1805 Isolate* isolate = thread->isolate();
1803 { 1806 {
1804 MutexLocker ml(isolate->mutex()); 1807 MutexLocker ml(isolate->mutex());
1805 if (isolate->background_compiler() == NULL) { 1808 if (isolate->background_compiler() == NULL) {
1806 BackgroundCompiler* task = new BackgroundCompiler(isolate); 1809 BackgroundCompiler* task = new BackgroundCompiler(isolate);
1807 isolate->set_background_compiler(task); 1810 isolate->set_background_compiler(task);
1808 task->set_compilation_function_queue(GrowableObjectArray::Handle( 1811 // TODO(srdjan): Temporary fix to prevent growing (and thus GC-ing) of
1809 thread->zone(), GrowableObjectArray::New())); 1812 // queues while inside a MonitorLocker. Will replace GrowableObjectArray
1810 task->set_compilation_result_queue(GrowableObjectArray::Handle( 1813 // with C heap allocated linked list.
1811 thread->zone(), GrowableObjectArray::New())); 1814 GrowableObjectArray& a = GrowableObjectArray::Handle(
1815 thread->zone(), GrowableObjectArray::New(Heap::kOld));
1816 a.Grow(1000, Heap::kOld);
1817 task->set_compilation_function_queue(a);
1818
1819 a = GrowableObjectArray::New(Heap::kOld);
1820 a.Grow(1000, Heap::kOld);
1821 task->set_compilation_result_queue(a);
1812 start_task = true; 1822 start_task = true;
1813 } 1823 }
1814 } 1824 }
1815 if (start_task) { 1825 if (start_task) {
1816 Dart::thread_pool()->Run(isolate->background_compiler()); 1826 Dart::thread_pool()->Run(isolate->background_compiler());
1817 } 1827 }
1818 } 1828 }
1819 1829
1820 } // namespace dart 1830 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/dart_api_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698