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

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

Issue 1113243002: Add the --steal-breakpoints flag. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: switch branch Created 5 years, 7 months 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/isolate.h ('k') | no next file » | 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/isolate.h" 5 #include "vm/isolate.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "platform/json.h" 9 #include "platform/json.h"
10 #include "vm/code_observers.h" 10 #include "vm/code_observers.h"
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 trace_buffer_(NULL), 604 trace_buffer_(NULL),
605 profiler_data_(NULL), 605 profiler_data_(NULL),
606 thread_state_(NULL), 606 thread_state_(NULL),
607 tag_table_(GrowableObjectArray::null()), 607 tag_table_(GrowableObjectArray::null()),
608 current_tag_(UserTag::null()), 608 current_tag_(UserTag::null()),
609 default_tag_(UserTag::null()), 609 default_tag_(UserTag::null()),
610 deoptimized_code_array_(GrowableObjectArray::null()), 610 deoptimized_code_array_(GrowableObjectArray::null()),
611 metrics_list_head_(NULL), 611 metrics_list_head_(NULL),
612 cha_(NULL), 612 cha_(NULL),
613 next_(NULL), 613 next_(NULL),
614 pause_loop_monitor_(NULL),
614 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_INITIALIZERS) 615 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_INITIALIZERS)
615 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_SCOPE_INIT) 616 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_SCOPE_INIT)
616 reusable_handles_() { 617 reusable_handles_() {
617 set_vm_tag(VMTag::kEmbedderTagId); 618 set_vm_tag(VMTag::kEmbedderTagId);
618 set_user_tag(UserTags::kDefaultUserTag); 619 set_user_tag(UserTags::kDefaultUserTag);
619 } 620 }
620 621
621 Isolate::Isolate(Isolate* original) 622 Isolate::Isolate(Isolate* original)
622 : mutator_thread_(NULL), 623 : mutator_thread_(NULL),
623 vm_tag_(0), 624 vm_tag_(0),
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 object_id_ring_(NULL), 669 object_id_ring_(NULL),
669 trace_buffer_(NULL), 670 trace_buffer_(NULL),
670 profiler_data_(NULL), 671 profiler_data_(NULL),
671 thread_state_(NULL), 672 thread_state_(NULL),
672 tag_table_(GrowableObjectArray::null()), 673 tag_table_(GrowableObjectArray::null()),
673 current_tag_(UserTag::null()), 674 current_tag_(UserTag::null()),
674 default_tag_(UserTag::null()), 675 default_tag_(UserTag::null()),
675 metrics_list_head_(NULL), 676 metrics_list_head_(NULL),
676 cha_(NULL), 677 cha_(NULL),
677 next_(NULL), 678 next_(NULL),
679 pause_loop_monitor_(NULL),
678 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_INITIALIZERS) 680 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_INITIALIZERS)
679 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_SCOPE_INIT) 681 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_SCOPE_INIT)
680 reusable_handles_() { 682 reusable_handles_() {
681 } 683 }
682 #undef REUSABLE_HANDLE_SCOPE_INIT 684 #undef REUSABLE_HANDLE_SCOPE_INIT
683 #undef REUSABLE_HANDLE_INITIALIZERS 685 #undef REUSABLE_HANDLE_INITIALIZERS
684 686
685 Isolate::~Isolate() { 687 Isolate::~Isolate() {
686 free(name_); 688 free(name_);
687 free(debugger_name_); 689 free(debugger_name_);
688 delete heap_; 690 delete heap_;
689 delete object_store_; 691 delete object_store_;
690 delete api_state_; 692 delete api_state_;
691 delete stub_code_; 693 delete stub_code_;
692 delete debugger_; 694 delete debugger_;
693 #if defined(USING_SIMULATOR) 695 #if defined(USING_SIMULATOR)
694 delete simulator_; 696 delete simulator_;
695 #endif 697 #endif
696 delete mutex_; 698 delete mutex_;
697 mutex_ = NULL; // Fail fast if interrupts are scheduled on a dead isolate. 699 mutex_ = NULL; // Fail fast if interrupts are scheduled on a dead isolate.
698 delete message_handler_; 700 delete message_handler_;
699 message_handler_ = NULL; // Fail fast if we send messages to a dead isolate. 701 message_handler_ = NULL; // Fail fast if we send messages to a dead isolate.
700 ASSERT(deopt_context_ == NULL); // No deopt in progress when isolate deleted. 702 ASSERT(deopt_context_ == NULL); // No deopt in progress when isolate deleted.
701 delete spawn_state_; 703 delete spawn_state_;
702 delete log_; 704 delete log_;
703 log_ = NULL; 705 log_ = NULL;
706 delete pause_loop_monitor_;
707 pause_loop_monitor_ = NULL;
704 } 708 }
705 709
706 710
707 #if defined(DEBUG) 711 #if defined(DEBUG)
708 bool Isolate::IsIsolateOf(Thread* thread) { 712 bool Isolate::IsIsolateOf(Thread* thread) {
709 return this == thread->isolate(); 713 return this == thread->isolate();
710 } 714 }
711 #endif // DEBUG 715 #endif // DEBUG
712 716
713 717
(...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after
1710 if (deoptimized_code.IsNull()) { 1714 if (deoptimized_code.IsNull()) {
1711 // Not tracking deoptimized code. 1715 // Not tracking deoptimized code.
1712 return; 1716 return;
1713 } 1717 }
1714 // TODO(johnmccutchan): Scan this array and the isolate's profile before 1718 // TODO(johnmccutchan): Scan this array and the isolate's profile before
1715 // old space GC and remove the keep_code flag. 1719 // old space GC and remove the keep_code flag.
1716 deoptimized_code.Add(code); 1720 deoptimized_code.Add(code);
1717 } 1721 }
1718 1722
1719 1723
1724 void Isolate::WakePauseEventHandler(Dart_Isolate isolate) {
1725 Isolate* iso = reinterpret_cast<Isolate*>(isolate);
1726 MonitorLocker ml(iso->pause_loop_monitor_);
1727 ml.Notify();
1728 }
1729
1730
1731 void Isolate::PauseEventHandler() {
1732 // We are stealing a pause event (like a breakpoint) from the
1733 // embedder. We don't know what kind of thread we are on -- it
1734 // could be from our thread pool or it could be a thread from the
1735 // embedder. Sit on the current thread handling service events
1736 // until we are told to resume.
1737 if (pause_loop_monitor_ == NULL) {
1738 pause_loop_monitor_ = new Monitor();
1739 }
1740 Dart_EnterScope();
1741 MonitorLocker ml(pause_loop_monitor_);
1742
1743 Dart_MessageNotifyCallback saved_notify_callback =
1744 message_notify_callback();
1745 set_message_notify_callback(Isolate::WakePauseEventHandler);
1746
1747 bool resume = false;
1748 while (true) {
1749 // Handle all available vm service messages, up to a resume
1750 // request.
1751 while (!resume && Dart_HasServiceMessages()) {
1752 pause_loop_monitor_->Exit();
1753 resume = Dart_HandleServiceMessages();
1754 pause_loop_monitor_->Enter();
1755 }
1756 if (resume) {
1757 break;
1758 }
1759
1760 // Wait for more service messages.
1761 Monitor::WaitResult res = ml.Wait();
1762 ASSERT(res == Monitor::kNotified);
1763 }
1764 set_message_notify_callback(saved_notify_callback);
1765 Dart_ExitScope();
1766 }
1767
1768
1720 void Isolate::VisitIsolates(IsolateVisitor* visitor) { 1769 void Isolate::VisitIsolates(IsolateVisitor* visitor) {
1721 if (visitor == NULL) { 1770 if (visitor == NULL) {
1722 return; 1771 return;
1723 } 1772 }
1724 MonitorLocker ml(isolates_list_monitor_); 1773 MonitorLocker ml(isolates_list_monitor_);
1725 Isolate* current = isolates_list_head_; 1774 Isolate* current = isolates_list_head_;
1726 while (current) { 1775 while (current) {
1727 visitor->VisitIsolate(current); 1776 visitor->VisitIsolate(current);
1728 current = current->next_; 1777 current = current->next_;
1729 } 1778 }
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
1971 serialized_message_, serialized_message_len_); 2020 serialized_message_, serialized_message_len_);
1972 } 2021 }
1973 2022
1974 2023
1975 void IsolateSpawnState::Cleanup() { 2024 void IsolateSpawnState::Cleanup() {
1976 SwitchIsolateScope switch_scope(I); 2025 SwitchIsolateScope switch_scope(I);
1977 Dart::ShutdownIsolate(); 2026 Dart::ShutdownIsolate();
1978 } 2027 }
1979 2028
1980 } // namespace dart 2029 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/isolate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698