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

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

Issue 2981173002: Remove the debugger_ field from Isolate in a PRODUCT build (Closed)
Patch Set: Created 3 years, 5 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
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 "include/dart_native_api.h" 8 #include "include/dart_native_api.h"
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "platform/text_buffer.h" 10 #include "platform/text_buffer.h"
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 priority == Isolate::kBeforeNextEventAction /* at_head */); 337 priority == Isolate::kBeforeNextEventAction /* at_head */);
338 } 338 }
339 break; 339 break;
340 } 340 }
341 case Isolate::kInterruptMsg: { 341 case Isolate::kInterruptMsg: {
342 // [ OOB, kInterruptMsg, pause capability ] 342 // [ OOB, kInterruptMsg, pause capability ]
343 if (message.Length() != 3) return Error::null(); 343 if (message.Length() != 3) return Error::null();
344 Object& obj = Object::Handle(zone, message.At(2)); 344 Object& obj = Object::Handle(zone, message.At(2));
345 if (!I->VerifyPauseCapability(obj)) return Error::null(); 345 if (!I->VerifyPauseCapability(obj)) return Error::null();
346 346
347 #if !defined(PRODUCT)
347 // If we are already paused, don't pause again. 348 // If we are already paused, don't pause again.
348 if (FLAG_support_debugger && (I->debugger()->PauseEvent() == NULL)) { 349 if (FLAG_support_debugger && (I->debugger()->PauseEvent() == NULL)) {
349 return I->debugger()->PauseInterrupted(); 350 return I->debugger()->PauseInterrupted();
350 } 351 }
352 #endif
351 break; 353 break;
352 } 354 }
353 355
354 case Isolate::kAddExitMsg: 356 case Isolate::kAddExitMsg:
355 case Isolate::kDelExitMsg: 357 case Isolate::kDelExitMsg:
356 case Isolate::kAddErrorMsg: 358 case Isolate::kAddErrorMsg:
357 case Isolate::kDelErrorMsg: { 359 case Isolate::kDelErrorMsg: {
358 // [ OOB, msg, listener port ] 360 // [ OOB, msg, listener port ]
359 if (message.Length() < 3) return Error::null(); 361 if (message.Length() < 3) return Error::null();
360 const Object& obj = Object::Handle(zone, message.At(2)); 362 const Object& obj = Object::Handle(zone, message.At(2));
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 // whether errors are fatal for the current isolate. 657 // whether errors are fatal for the current isolate.
656 return StoreError(T, result); 658 return StoreError(T, result);
657 } else { 659 } else {
658 bool has_listener = I->NotifyErrorListeners(exc_str, stacktrace_str); 660 bool has_listener = I->NotifyErrorListeners(exc_str, stacktrace_str);
659 if (I->ErrorsFatal()) { 661 if (I->ErrorsFatal()) {
660 if (has_listener) { 662 if (has_listener) {
661 T->clear_sticky_error(); 663 T->clear_sticky_error();
662 } else { 664 } else {
663 T->set_sticky_error(result); 665 T->set_sticky_error(result);
664 } 666 }
667 #if !defined(PRODUCT)
665 // Notify the debugger about specific unhandled exceptions which are 668 // Notify the debugger about specific unhandled exceptions which are
666 // withheld when being thrown. Do this after setting the sticky error 669 // withheld when being thrown. Do this after setting the sticky error
667 // so the isolate has an error set when paused with the unhandled 670 // so the isolate has an error set when paused with the unhandled
668 // exception. 671 // exception.
669 if (result.IsUnhandledException()) { 672 if (result.IsUnhandledException()) {
670 const UnhandledException& error = UnhandledException::Cast(result); 673 const UnhandledException& error = UnhandledException::Cast(result);
671 RawInstance* exception = error.exception(); 674 RawInstance* exception = error.exception();
672 if ((exception == I->object_store()->out_of_memory()) || 675 if ((exception == I->object_store()->out_of_memory()) ||
673 (exception == I->object_store()->stack_overflow())) { 676 (exception == I->object_store()->stack_overflow())) {
674 // We didn't notify the debugger when the stack was full. Do it now. 677 // We didn't notify the debugger when the stack was full. Do it now.
675 if (FLAG_support_debugger) { 678 if (FLAG_support_debugger) {
676 I->debugger()->PauseException(Instance::Handle(exception)); 679 I->debugger()->PauseException(Instance::Handle(exception));
677 } 680 }
678 } 681 }
679 } 682 }
683 #endif // !defined(PRODUCT)
680 return kError; 684 return kError;
681 } 685 }
682 } 686 }
683 return kOK; 687 return kOK;
684 } 688 }
685 689
686 void Isolate::FlagsInitialize(Dart_IsolateFlags* api_flags) { 690 void Isolate::FlagsInitialize(Dart_IsolateFlags* api_flags) {
687 api_flags->version = DART_FLAGS_CURRENT_VERSION; 691 api_flags->version = DART_FLAGS_CURRENT_VERSION;
688 #define INIT_FROM_FLAG(name, isolate_flag, flag) api_flags->isolate_flag = flag; 692 #define INIT_FROM_FLAG(name, isolate_flag, flag) api_flags->isolate_flag = flag;
689 ISOLATE_FLAG_LIST(INIT_FROM_FLAG) 693 ISOLATE_FLAG_LIST(INIT_FROM_FLAG)
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 start_time_micros_(OS::GetCurrentMonotonicMicros()), 752 start_time_micros_(OS::GetCurrentMonotonicMicros()),
749 main_port_(0), 753 main_port_(0),
750 origin_id_(0), 754 origin_id_(0),
751 pause_capability_(0), 755 pause_capability_(0),
752 terminate_capability_(0), 756 terminate_capability_(0),
753 errors_fatal_(true), 757 errors_fatal_(true),
754 init_callback_data_(NULL), 758 init_callback_data_(NULL),
755 environment_callback_(NULL), 759 environment_callback_(NULL),
756 library_tag_handler_(NULL), 760 library_tag_handler_(NULL),
757 api_state_(NULL), 761 api_state_(NULL),
762 #if !defined(PRODUCT)
758 debugger_(NULL), 763 debugger_(NULL),
764 #endif
759 resume_request_(false), 765 resume_request_(false),
760 last_resume_timestamp_(OS::GetCurrentTimeMillis()), 766 last_resume_timestamp_(OS::GetCurrentTimeMillis()),
761 random_(), 767 random_(),
762 simulator_(NULL), 768 simulator_(NULL),
763 mutex_(new Mutex()), 769 mutex_(new Mutex()),
764 symbols_mutex_(new Mutex()), 770 symbols_mutex_(new Mutex()),
765 type_canonicalization_mutex_(new Mutex()), 771 type_canonicalization_mutex_(new Mutex()),
766 constant_canonicalization_mutex_(new Mutex()), 772 constant_canonicalization_mutex_(new Mutex()),
767 megamorphic_lookup_mutex_(new Mutex()), 773 megamorphic_lookup_mutex_(new Mutex()),
768 message_handler_(NULL), 774 message_handler_(NULL),
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 #if defined(DEBUG) 919 #if defined(DEBUG)
914 // Verify that we are never reusing a live origin id. 920 // Verify that we are never reusing a live origin id.
915 VerifyOriginId id_verifier(result->main_port()); 921 VerifyOriginId id_verifier(result->main_port());
916 Isolate::VisitIsolates(&id_verifier); 922 Isolate::VisitIsolates(&id_verifier);
917 #endif 923 #endif
918 result->set_origin_id(result->main_port()); 924 result->set_origin_id(result->main_port());
919 result->set_pause_capability(result->random()->NextUInt64()); 925 result->set_pause_capability(result->random()->NextUInt64());
920 result->set_terminate_capability(result->random()->NextUInt64()); 926 result->set_terminate_capability(result->random()->NextUInt64());
921 927
922 result->BuildName(name_prefix); 928 result->BuildName(name_prefix);
929 #if !defined(PRODUCT)
923 if (FLAG_support_debugger) { 930 if (FLAG_support_debugger) {
924 result->debugger_ = new Debugger(); 931 result->debugger_ = new Debugger();
925 result->debugger_->Initialize(result); 932 result->debugger_->Initialize(result);
926 } 933 }
934 #endif
927 if (FLAG_trace_isolates) { 935 if (FLAG_trace_isolates) {
928 if (name_prefix == NULL || strcmp(name_prefix, "vm-isolate") != 0) { 936 if (name_prefix == NULL || strcmp(name_prefix, "vm-isolate") != 0) {
929 OS::Print( 937 OS::Print(
930 "[+] Starting isolate:\n" 938 "[+] Starting isolate:\n"
931 "\tisolate: %s\n", 939 "\tisolate: %s\n",
932 result->name()); 940 result->name());
933 } 941 }
934 } 942 }
935 943
936 #ifndef PRODUCT 944 #ifndef PRODUCT
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 void Isolate::set_debugger_name(const char* name) { 982 void Isolate::set_debugger_name(const char* name) {
975 free(debugger_name_); 983 free(debugger_name_);
976 debugger_name_ = strdup(name); 984 debugger_name_ = strdup(name);
977 } 985 }
978 986
979 int64_t Isolate::UptimeMicros() const { 987 int64_t Isolate::UptimeMicros() const {
980 return OS::GetCurrentMonotonicMicros() - start_time_micros_; 988 return OS::GetCurrentMonotonicMicros() - start_time_micros_;
981 } 989 }
982 990
983 bool Isolate::IsPaused() const { 991 bool Isolate::IsPaused() const {
992 #if defined(PRODUCT)
993 return false;
994 #else
984 return (debugger_ != NULL) && (debugger_->PauseEvent() != NULL); 995 return (debugger_ != NULL) && (debugger_->PauseEvent() != NULL);
996 #endif
985 } 997 }
986 998
987 RawError* Isolate::PausePostRequest() { 999 RawError* Isolate::PausePostRequest() {
1000 #if !defined(PRODUCT)
988 if (!FLAG_support_debugger) { 1001 if (!FLAG_support_debugger) {
989 return Error::null(); 1002 return Error::null();
990 } 1003 }
991 if (debugger_ == NULL) { 1004 if (debugger_ == NULL) {
992 return Error::null(); 1005 return Error::null();
993 } 1006 }
994 ASSERT(!IsPaused()); 1007 ASSERT(!IsPaused());
995 const Error& error = Error::Handle(debugger_->PausePostRequest()); 1008 const Error& error = Error::Handle(debugger_->PausePostRequest());
996 if (!error.IsNull()) { 1009 if (!error.IsNull()) {
997 if (Thread::Current()->top_exit_frame_info() == 0) { 1010 if (Thread::Current()->top_exit_frame_info() == 0) {
998 return error.raw(); 1011 return error.raw();
999 } else { 1012 } else {
1000 Exceptions::PropagateError(error); 1013 Exceptions::PropagateError(error);
1001 UNREACHABLE(); 1014 UNREACHABLE();
1002 } 1015 }
1003 } 1016 }
1017 #endif
1004 return Error::null(); 1018 return Error::null();
1005 } 1019 }
1006 1020
1007 void Isolate::BuildName(const char* name_prefix) { 1021 void Isolate::BuildName(const char* name_prefix) {
1008 ASSERT(name_ == NULL); 1022 ASSERT(name_ == NULL);
1009 if (name_prefix == NULL) { 1023 if (name_prefix == NULL) {
1010 name_prefix = "isolate"; 1024 name_prefix = "isolate";
1011 } 1025 }
1012 set_debugger_name(name_prefix); 1026 set_debugger_name(name_prefix);
1013 if (ServiceIsolate::NameEquals(name_prefix)) { 1027 if (ServiceIsolate::NameEquals(name_prefix)) {
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
1377 ASSERT(result.IsFunction()); 1391 ASSERT(result.IsFunction());
1378 Function& func = Function::Handle(thread->zone()); 1392 Function& func = Function::Handle(thread->zone());
1379 func ^= result.raw(); 1393 func ^= result.raw();
1380 1394
1381 // TODO(turnidge): Currently we need a way to force a one-time 1395 // TODO(turnidge): Currently we need a way to force a one-time
1382 // breakpoint for all spawned isolates to support isolate 1396 // breakpoint for all spawned isolates to support isolate
1383 // debugging. Remove this once the vmservice becomes the standard 1397 // debugging. Remove this once the vmservice becomes the standard
1384 // way to debug. Set the breakpoint on the static function instead 1398 // way to debug. Set the breakpoint on the static function instead
1385 // of its implicit closure function because that latter is merely 1399 // of its implicit closure function because that latter is merely
1386 // a dispatcher that is marked as undebuggable. 1400 // a dispatcher that is marked as undebuggable.
1401 #if !defined(PRODUCT)
1387 if (FLAG_support_debugger && FLAG_break_at_isolate_spawn) { 1402 if (FLAG_support_debugger && FLAG_break_at_isolate_spawn) {
1388 isolate->debugger()->OneTimeBreakAtEntry(func); 1403 isolate->debugger()->OneTimeBreakAtEntry(func);
1389 } 1404 }
1405 #endif
1390 1406
1391 func = func.ImplicitClosureFunction(); 1407 func = func.ImplicitClosureFunction();
1392 1408
1393 const Array& capabilities = Array::Handle(Array::New(2)); 1409 const Array& capabilities = Array::Handle(Array::New(2));
1394 Capability& capability = Capability::Handle(); 1410 Capability& capability = Capability::Handle();
1395 capability = Capability::New(isolate->pause_capability()); 1411 capability = Capability::New(isolate->pause_capability());
1396 capabilities.SetAt(0, capability); 1412 capabilities.SetAt(0, capability);
1397 // Check whether this isolate should be started in paused state. 1413 // Check whether this isolate should be started in paused state.
1398 if (state->paused()) { 1414 if (state->paused()) {
1399 bool added = isolate->AddResumeCapability(capability); 1415 bool added = isolate->AddResumeCapability(capability);
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1556 1572
1557 // Notify exit listeners that this isolate is shutting down. 1573 // Notify exit listeners that this isolate is shutting down.
1558 if (object_store() != NULL) { 1574 if (object_store() != NULL) {
1559 const Error& error = Error::Handle(thread->sticky_error()); 1575 const Error& error = Error::Handle(thread->sticky_error());
1560 if (error.IsNull() || !error.IsUnwindError() || 1576 if (error.IsNull() || !error.IsUnwindError() ||
1561 UnwindError::Cast(error).is_user_initiated()) { 1577 UnwindError::Cast(error).is_user_initiated()) {
1562 NotifyExitListeners(); 1578 NotifyExitListeners();
1563 } 1579 }
1564 } 1580 }
1565 1581
1582 #if !defined(PRODUCT)
1566 // Clean up debugger resources. 1583 // Clean up debugger resources.
1567 if (FLAG_support_debugger) { 1584 if (FLAG_support_debugger) {
1568 debugger()->Shutdown(); 1585 debugger()->Shutdown();
1569 } 1586 }
1587 #endif
1570 1588
1571 // Close all the ports owned by this isolate. 1589 // Close all the ports owned by this isolate.
1572 PortMap::ClosePorts(message_handler()); 1590 PortMap::ClosePorts(message_handler());
1573 1591
1574 // Fail fast if anybody tries to post any more messages to this isolate. 1592 // Fail fast if anybody tries to post any more messages to this isolate.
1575 delete message_handler(); 1593 delete message_handler();
1576 set_message_handler(NULL); 1594 set_message_handler(NULL);
1577 if (FLAG_support_timeline) { 1595 if (FLAG_support_timeline) {
1578 // Before analyzing the isolate's timeline blocks- reclaim all cached 1596 // Before analyzing the isolate's timeline blocks- reclaim all cached
1579 // blocks. 1597 // blocks.
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1776 // Visit the registered service extension handlers. 1794 // Visit the registered service extension handlers.
1777 visitor->VisitPointer( 1795 visitor->VisitPointer(
1778 reinterpret_cast<RawObject**>(&registered_service_extension_handlers_)); 1796 reinterpret_cast<RawObject**>(&registered_service_extension_handlers_));
1779 1797
1780 // Visit the boxed_field_list_. 1798 // Visit the boxed_field_list_.
1781 // 'boxed_field_list_' access via mutator and background compilation threads 1799 // 'boxed_field_list_' access via mutator and background compilation threads
1782 // is guarded with a monitor. This means that we can visit it only 1800 // is guarded with a monitor. This means that we can visit it only
1783 // when at safepoint or the field_list_mutex_ lock has been taken. 1801 // when at safepoint or the field_list_mutex_ lock has been taken.
1784 visitor->VisitPointer(reinterpret_cast<RawObject**>(&boxed_field_list_)); 1802 visitor->VisitPointer(reinterpret_cast<RawObject**>(&boxed_field_list_));
1785 1803
1804 #if !defined(PRODUCT)
1786 // Visit objects in the debugger. 1805 // Visit objects in the debugger.
1787 if (FLAG_support_debugger) { 1806 if (FLAG_support_debugger) {
1788 debugger()->VisitObjectPointers(visitor); 1807 debugger()->VisitObjectPointers(visitor);
1789 } 1808 }
1790 1809
1791 #if !defined(PRODUCT)
1792 // Visit objects that are being used for isolate reload. 1810 // Visit objects that are being used for isolate reload.
1793 if (reload_context() != NULL) { 1811 if (reload_context() != NULL) {
1794 reload_context()->VisitObjectPointers(visitor); 1812 reload_context()->VisitObjectPointers(visitor);
1795 } 1813 }
1796 if (ServiceIsolate::IsServiceIsolate(this)) { 1814 if (ServiceIsolate::IsServiceIsolate(this)) {
1797 ServiceIsolate::VisitObjectPointers(visitor); 1815 ServiceIsolate::VisitObjectPointers(visitor);
1798 } 1816 }
1799 #endif // !defined(PRODUCT) 1817 #endif // !defined(PRODUCT)
1800 1818
1801 #if !defined(DART_PRECOMPILED_RUNTIME) 1819 #if !defined(DART_PRECOMPILED_RUNTIME)
(...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after
2833 void IsolateSpawnState::DecrementSpawnCount() { 2851 void IsolateSpawnState::DecrementSpawnCount() {
2834 ASSERT(spawn_count_monitor_ != NULL); 2852 ASSERT(spawn_count_monitor_ != NULL);
2835 ASSERT(spawn_count_ != NULL); 2853 ASSERT(spawn_count_ != NULL);
2836 MonitorLocker ml(spawn_count_monitor_); 2854 MonitorLocker ml(spawn_count_monitor_);
2837 ASSERT(*spawn_count_ > 0); 2855 ASSERT(*spawn_count_ > 0);
2838 *spawn_count_ = *spawn_count_ - 1; 2856 *spawn_count_ = *spawn_count_ - 1;
2839 ml.Notify(); 2857 ml.Notify();
2840 } 2858 }
2841 2859
2842 } // namespace dart 2860 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/isolate.h ('k') | runtime/vm/object.cc » ('j') | runtime/vm/object.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698