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

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

Issue 1660063002: Remove many features when building product mode (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « runtime/vm/isolate.h ('k') | runtime/vm/json_stream.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) 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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 } 350 }
351 break; 351 break;
352 } 352 }
353 case Isolate::kInterruptMsg: { 353 case Isolate::kInterruptMsg: {
354 // [ OOB, kInterruptMsg, pause capability ] 354 // [ OOB, kInterruptMsg, pause capability ]
355 if (message.Length() != 3) return Error::null(); 355 if (message.Length() != 3) return Error::null();
356 Object& obj = Object::Handle(zone, message.At(2)); 356 Object& obj = Object::Handle(zone, message.At(2));
357 if (!I->VerifyPauseCapability(obj)) return Error::null(); 357 if (!I->VerifyPauseCapability(obj)) return Error::null();
358 358
359 // If we are already paused, don't pause again. 359 // If we are already paused, don't pause again.
360 if (I->debugger()->PauseEvent() == NULL) { 360 if (FLAG_support_debugger && (I->debugger()->PauseEvent() == NULL)) {
361 return I->debugger()->SignalIsolateInterrupted(); 361 return I->debugger()->SignalIsolateInterrupted();
362 } 362 }
363 break; 363 break;
364 } 364 }
365 365
366 case Isolate::kAddExitMsg: 366 case Isolate::kAddExitMsg:
367 case Isolate::kDelExitMsg: 367 case Isolate::kDelExitMsg:
368 case Isolate::kAddErrorMsg: 368 case Isolate::kAddErrorMsg:
369 case Isolate::kDelErrorMsg: { 369 case Isolate::kDelErrorMsg: {
370 // [ OOB, msg, listener port ] 370 // [ OOB, msg, listener port ]
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 // OOB messages are expected to be fixed length arrays where the first 503 // OOB messages are expected to be fixed length arrays where the first
504 // element is a Smi describing the OOB destination. Messages that do not 504 // element is a Smi describing the OOB destination. Messages that do not
505 // confirm to this layout are silently ignored. 505 // confirm to this layout are silently ignored.
506 if (msg.IsArray()) { 506 if (msg.IsArray()) {
507 const Array& oob_msg = Array::Cast(msg); 507 const Array& oob_msg = Array::Cast(msg);
508 if (oob_msg.Length() > 0) { 508 if (oob_msg.Length() > 0) {
509 const Object& oob_tag = Object::Handle(zone, oob_msg.At(0)); 509 const Object& oob_tag = Object::Handle(zone, oob_msg.At(0));
510 if (oob_tag.IsSmi()) { 510 if (oob_tag.IsSmi()) {
511 switch (Smi::Cast(oob_tag).Value()) { 511 switch (Smi::Cast(oob_tag).Value()) {
512 case Message::kServiceOOBMsg: { 512 case Message::kServiceOOBMsg: {
513 Service::HandleIsolateMessage(I, oob_msg); 513 if (FLAG_support_service) {
514 Service::HandleIsolateMessage(I, oob_msg);
515 } else {
516 UNREACHABLE();
517 }
514 break; 518 break;
515 } 519 }
516 case Message::kIsolateLibOOBMsg: { 520 case Message::kIsolateLibOOBMsg: {
517 const Error& error = Error::Handle(HandleLibMessage(oob_msg)); 521 const Error& error = Error::Handle(HandleLibMessage(oob_msg));
518 if (!error.IsNull()) { 522 if (!error.IsNull()) {
519 status = ProcessUnhandledException(error); 523 status = ProcessUnhandledException(error);
520 } 524 }
521 break; 525 break;
522 } 526 }
523 #if defined(DEBUG) 527 #if defined(DEBUG)
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 status = ProcessUnhandledException(Error::Cast(result)); 569 status = ProcessUnhandledException(Error::Cast(result));
566 } else { 570 } else {
567 ASSERT(result.IsNull()); 571 ASSERT(result.IsNull());
568 } 572 }
569 } 573 }
570 return status; 574 return status;
571 } 575 }
572 576
573 577
574 void IsolateMessageHandler::NotifyPauseOnStart() { 578 void IsolateMessageHandler::NotifyPauseOnStart() {
579 if (!FLAG_support_service) {
580 return;
581 }
575 if (Service::debug_stream.enabled() || FLAG_warn_on_pause_with_no_debugger) { 582 if (Service::debug_stream.enabled() || FLAG_warn_on_pause_with_no_debugger) {
576 StartIsolateScope start_isolate(I); 583 StartIsolateScope start_isolate(I);
577 StackZone zone(T); 584 StackZone zone(T);
578 HandleScope handle_scope(T); 585 HandleScope handle_scope(T);
579 ServiceEvent pause_event(I, ServiceEvent::kPauseStart); 586 ServiceEvent pause_event(I, ServiceEvent::kPauseStart);
580 Service::HandleEvent(&pause_event); 587 Service::HandleEvent(&pause_event);
581 } else if (FLAG_trace_service) { 588 } else if (FLAG_trace_service) {
582 OS::Print("vm-service: Dropping event of type PauseStart (%s)\n", 589 OS::Print("vm-service: Dropping event of type PauseStart (%s)\n",
583 I->name()); 590 I->name());
584 } 591 }
585 } 592 }
586 593
587 594
588 void IsolateMessageHandler::NotifyPauseOnExit() { 595 void IsolateMessageHandler::NotifyPauseOnExit() {
596 if (!FLAG_support_service) {
597 return;
598 }
589 if (Service::debug_stream.enabled() || FLAG_warn_on_pause_with_no_debugger) { 599 if (Service::debug_stream.enabled() || FLAG_warn_on_pause_with_no_debugger) {
590 StartIsolateScope start_isolate(I); 600 StartIsolateScope start_isolate(I);
591 StackZone zone(T); 601 StackZone zone(T);
592 HandleScope handle_scope(T); 602 HandleScope handle_scope(T);
593 ServiceEvent pause_event(I, ServiceEvent::kPauseExit); 603 ServiceEvent pause_event(I, ServiceEvent::kPauseExit);
594 Service::HandleEvent(&pause_event); 604 Service::HandleEvent(&pause_event);
595 } else if (FLAG_trace_service) { 605 } else if (FLAG_trace_service) {
596 OS::Print("vm-service: Dropping event of type PauseExit (%s)\n", 606 OS::Print("vm-service: Dropping event of type PauseExit (%s)\n",
597 I->name()); 607 I->name());
598 } 608 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 MessageHandler::MessageStatus IsolateMessageHandler::ProcessUnhandledException( 641 MessageHandler::MessageStatus IsolateMessageHandler::ProcessUnhandledException(
632 const Error& result) { 642 const Error& result) {
633 // Notify the debugger about specific unhandled exceptions which are withheld 643 // Notify the debugger about specific unhandled exceptions which are withheld
634 // when being thrown. 644 // when being thrown.
635 if (result.IsUnhandledException()) { 645 if (result.IsUnhandledException()) {
636 const UnhandledException& error = UnhandledException::Cast(result); 646 const UnhandledException& error = UnhandledException::Cast(result);
637 RawInstance* exception = error.exception(); 647 RawInstance* exception = error.exception();
638 if ((exception == I->object_store()->out_of_memory()) || 648 if ((exception == I->object_store()->out_of_memory()) ||
639 (exception == I->object_store()->stack_overflow())) { 649 (exception == I->object_store()->stack_overflow())) {
640 // We didn't notify the debugger when the stack was full. Do it now. 650 // We didn't notify the debugger when the stack was full. Do it now.
641 I->debugger()->SignalExceptionThrown(Instance::Handle(exception)); 651 if (FLAG_support_debugger) {
652 I->debugger()->SignalExceptionThrown(Instance::Handle(exception));
653 }
642 } 654 }
643 } 655 }
644 656
645 // Generate the error and stacktrace strings for the error message. 657 // Generate the error and stacktrace strings for the error message.
646 String& exc_str = String::Handle(T->zone()); 658 String& exc_str = String::Handle(T->zone());
647 String& stacktrace_str = String::Handle(T->zone()); 659 String& stacktrace_str = String::Handle(T->zone());
648 if (result.IsUnhandledException()) { 660 if (result.IsUnhandledException()) {
649 Zone* zone = T->zone(); 661 Zone* zone = T->zone();
650 const UnhandledException& uhe = UnhandledException::Cast(result); 662 const UnhandledException& uhe = UnhandledException::Cast(result);
651 const Instance& exception = Instance::Handle(zone, uhe.exception()); 663 const Instance& exception = Instance::Handle(zone, uhe.exception());
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 #undef REUSABLE_HANDLE_SCOPE_INIT 828 #undef REUSABLE_HANDLE_SCOPE_INIT
817 #undef REUSABLE_HANDLE_INITIALIZERS 829 #undef REUSABLE_HANDLE_INITIALIZERS
818 830
819 Isolate::~Isolate() { 831 Isolate::~Isolate() {
820 free(name_); 832 free(name_);
821 free(debugger_name_); 833 free(debugger_name_);
822 delete store_buffer_; 834 delete store_buffer_;
823 delete heap_; 835 delete heap_;
824 delete object_store_; 836 delete object_store_;
825 delete api_state_; 837 delete api_state_;
826 delete debugger_; 838 if (FLAG_support_debugger) {
839 delete debugger_;
840 }
827 #if defined(USING_SIMULATOR) 841 #if defined(USING_SIMULATOR)
828 delete simulator_; 842 delete simulator_;
829 #endif 843 #endif
830 delete mutex_; 844 delete mutex_;
831 mutex_ = NULL; // Fail fast if interrupts are scheduled on a dead isolate. 845 mutex_ = NULL; // Fail fast if interrupts are scheduled on a dead isolate.
832 delete message_handler_; 846 delete message_handler_;
833 message_handler_ = NULL; // Fail fast if we send messages to a dead isolate. 847 message_handler_ = NULL; // Fail fast if we send messages to a dead isolate.
834 ASSERT(deopt_context_ == NULL); // No deopt in progress when isolate deleted. 848 ASSERT(deopt_context_ == NULL); // No deopt in progress when isolate deleted.
835 delete spawn_state_; 849 delete spawn_state_;
836 delete object_id_ring_; 850 if (FLAG_support_service) {
851 delete object_id_ring_;
852 }
837 object_id_ring_ = NULL; 853 object_id_ring_ = NULL;
838 delete pause_loop_monitor_; 854 delete pause_loop_monitor_;
839 pause_loop_monitor_ = NULL; 855 pause_loop_monitor_ = NULL;
840 ASSERT(spawn_count_ == 0); 856 ASSERT(spawn_count_ == 0);
841 delete spawn_count_monitor_; 857 delete spawn_count_monitor_;
842 if (compiler_stats_ != NULL) { 858 if (compiler_stats_ != NULL) {
843 delete compiler_stats_; 859 delete compiler_stats_;
844 compiler_stats_ = NULL; 860 compiler_stats_ = NULL;
845 } 861 }
846 delete safepoint_handler_; 862 delete safepoint_handler_;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 #if defined(DEBUG) 922 #if defined(DEBUG)
907 // Verify that we are never reusing a live origin id. 923 // Verify that we are never reusing a live origin id.
908 VerifyOriginId id_verifier(result->main_port()); 924 VerifyOriginId id_verifier(result->main_port());
909 Isolate::VisitIsolates(&id_verifier); 925 Isolate::VisitIsolates(&id_verifier);
910 #endif 926 #endif
911 result->set_origin_id(result->main_port()); 927 result->set_origin_id(result->main_port());
912 result->set_pause_capability(result->random()->NextUInt64()); 928 result->set_pause_capability(result->random()->NextUInt64());
913 result->set_terminate_capability(result->random()->NextUInt64()); 929 result->set_terminate_capability(result->random()->NextUInt64());
914 930
915 result->BuildName(name_prefix); 931 result->BuildName(name_prefix);
916 result->debugger_ = new Debugger(); 932 if (FLAG_support_debugger) {
917 result->debugger_->Initialize(result); 933 result->debugger_ = new Debugger();
934 result->debugger_->Initialize(result);
935 }
918 if (FLAG_trace_isolates) { 936 if (FLAG_trace_isolates) {
919 if (name_prefix == NULL || strcmp(name_prefix, "vm-isolate") != 0) { 937 if (name_prefix == NULL || strcmp(name_prefix, "vm-isolate") != 0) {
920 OS::Print("[+] Starting isolate:\n" 938 OS::Print("[+] Starting isolate:\n"
921 "\tisolate: %s\n", result->name()); 939 "\tisolate: %s\n", result->name());
922 } 940 }
923 } 941 }
924 942
925 result->compiler_stats_ = new CompilerStats(result); 943 result->compiler_stats_ = new CompilerStats(result);
926 if (FLAG_compiler_benchmark) { 944 if (FLAG_compiler_benchmark) {
927 result->compiler_stats_->EnableBenchmark(); 945 result->compiler_stats_->EnableBenchmark();
928 } 946 }
929 947
930 ObjectIdRing::Init(result); 948 if (FLAG_support_service) {
949 ObjectIdRing::Init(result);
950 }
931 951
932 // Add to isolate list. Shutdown and delete the isolate on failure. 952 // Add to isolate list. Shutdown and delete the isolate on failure.
933 if (!AddIsolateToList(result)) { 953 if (!AddIsolateToList(result)) {
934 result->LowLevelShutdown(); 954 result->LowLevelShutdown();
935 Thread::ExitIsolate(); 955 Thread::ExitIsolate();
936 delete result; 956 delete result;
937 return NULL; 957 return NULL;
938 } 958 }
939 959
940 return result; 960 return result;
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 1081
1062 MutexLocker ml(mutex_); 1082 MutexLocker ml(mutex_);
1063 // Check if we are in a valid state to make the isolate runnable. 1083 // Check if we are in a valid state to make the isolate runnable.
1064 if (is_runnable() == true) { 1084 if (is_runnable() == true) {
1065 return false; // Already runnable. 1085 return false; // Already runnable.
1066 } 1086 }
1067 // Set the isolate as runnable and if we are being spawned schedule 1087 // Set the isolate as runnable and if we are being spawned schedule
1068 // isolate on thread pool for execution. 1088 // isolate on thread pool for execution.
1069 ASSERT(object_store()->root_library() != Library::null()); 1089 ASSERT(object_store()->root_library() != Library::null());
1070 set_is_runnable(true); 1090 set_is_runnable(true);
1071 if (!ServiceIsolate::IsServiceIsolate(this)) { 1091 if (FLAG_support_debugger && !ServiceIsolate::IsServiceIsolate(this)) {
1072 if (FLAG_pause_isolates_on_unhandled_exceptions) { 1092 if (FLAG_pause_isolates_on_unhandled_exceptions) {
1073 debugger()->SetExceptionPauseInfo(kPauseOnUnhandledExceptions); 1093 debugger()->SetExceptionPauseInfo(kPauseOnUnhandledExceptions);
1074 } 1094 }
1075 } 1095 }
1076 IsolateSpawnState* state = spawn_state(); 1096 IsolateSpawnState* state = spawn_state();
1077 if (state != NULL) { 1097 if (state != NULL) {
1078 ASSERT(this == state->isolate()); 1098 ASSERT(this == state->isolate());
1079 Run(); 1099 Run();
1080 } 1100 }
1081 TimelineStream* stream = GetIsolateStream(); 1101 TimelineStream* stream = GetIsolateStream();
1082 ASSERT(stream != NULL); 1102 ASSERT(stream != NULL);
1083 TimelineEvent* event = stream->StartEvent(); 1103 TimelineEvent* event = stream->StartEvent();
1084 if (event != NULL) { 1104 if (event != NULL) {
1085 event->Instant("Runnable"); 1105 event->Instant("Runnable");
1086 event->Complete(); 1106 event->Complete();
1087 } 1107 }
1088 if (Service::isolate_stream.enabled()) { 1108 if (FLAG_support_service && Service::isolate_stream.enabled()) {
1089 ServiceEvent runnableEvent(this, ServiceEvent::kIsolateRunnable); 1109 ServiceEvent runnableEvent(this, ServiceEvent::kIsolateRunnable);
1090 Service::HandleEvent(&runnableEvent); 1110 Service::HandleEvent(&runnableEvent);
1091 } 1111 }
1092 return true; 1112 return true;
1093 } 1113 }
1094 1114
1095 1115
1096 bool Isolate::VerifyPauseCapability(const Object& capability) const { 1116 bool Isolate::VerifyPauseCapability(const Object& capability) const {
1097 return !capability.IsNull() && 1117 return !capability.IsNull() &&
1098 capability.IsCapability() && 1118 capability.IsCapability() &&
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
1350 ASSERT(result.IsFunction()); 1370 ASSERT(result.IsFunction());
1351 Function& func = Function::Handle(thread->zone()); 1371 Function& func = Function::Handle(thread->zone());
1352 func ^= result.raw(); 1372 func ^= result.raw();
1353 1373
1354 // TODO(turnidge): Currently we need a way to force a one-time 1374 // TODO(turnidge): Currently we need a way to force a one-time
1355 // breakpoint for all spawned isolates to support isolate 1375 // breakpoint for all spawned isolates to support isolate
1356 // debugging. Remove this once the vmservice becomes the standard 1376 // debugging. Remove this once the vmservice becomes the standard
1357 // way to debug. Set the breakpoint on the static function instead 1377 // way to debug. Set the breakpoint on the static function instead
1358 // of its implicit closure function because that latter is merely 1378 // of its implicit closure function because that latter is merely
1359 // a dispatcher that is marked as undebuggable. 1379 // a dispatcher that is marked as undebuggable.
1360 if (FLAG_break_at_isolate_spawn) { 1380 if (FLAG_support_debugger && FLAG_break_at_isolate_spawn) {
1361 isolate->debugger()->OneTimeBreakAtEntry(func); 1381 isolate->debugger()->OneTimeBreakAtEntry(func);
1362 } 1382 }
1363 1383
1364 func = func.ImplicitClosureFunction(); 1384 func = func.ImplicitClosureFunction();
1365 1385
1366 const Array& capabilities = Array::Handle(Array::New(2)); 1386 const Array& capabilities = Array::Handle(Array::New(2));
1367 Capability& capability = Capability::Handle(); 1387 Capability& capability = Capability::Handle();
1368 capability = Capability::New(isolate->pause_capability()); 1388 capability = Capability::New(isolate->pause_capability());
1369 capabilities.SetAt(0, capability); 1389 capabilities.SetAt(0, capability);
1370 // Check whether this isolate should be started in paused state. 1390 // Check whether this isolate should be started in paused state.
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
1571 if (object_store() != NULL) { 1591 if (object_store() != NULL) {
1572 const Error& error = Error::Handle(object_store()->sticky_error()); 1592 const Error& error = Error::Handle(object_store()->sticky_error());
1573 if (error.IsNull() || 1593 if (error.IsNull() ||
1574 !error.IsUnwindError() || 1594 !error.IsUnwindError() ||
1575 UnwindError::Cast(error).is_user_initiated()) { 1595 UnwindError::Cast(error).is_user_initiated()) {
1576 NotifyExitListeners(); 1596 NotifyExitListeners();
1577 } 1597 }
1578 } 1598 }
1579 1599
1580 // Clean up debugger resources. 1600 // Clean up debugger resources.
1581 debugger()->Shutdown(); 1601 if (FLAG_support_debugger) {
1602 debugger()->Shutdown();
1603 }
1604
1582 1605
1583 // Close all the ports owned by this isolate. 1606 // Close all the ports owned by this isolate.
1584 PortMap::ClosePorts(message_handler()); 1607 PortMap::ClosePorts(message_handler());
1585 1608
1586 // Fail fast if anybody tries to post any more messsages to this isolate. 1609 // Fail fast if anybody tries to post any more messsages to this isolate.
1587 delete message_handler(); 1610 delete message_handler();
1588 set_message_handler(NULL); 1611 set_message_handler(NULL);
1589 1612
1590 // Before analyzing the isolate's timeline blocks- reclaim all cached blocks. 1613 // Before analyzing the isolate's timeline blocks- reclaim all cached blocks.
1591 Timeline::ReclaimCachedBlocksFromThreads(); 1614 Timeline::ReclaimCachedBlocksFromThreads();
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1747 1770
1748 // Visit the pending service extension calls. 1771 // Visit the pending service extension calls.
1749 visitor->VisitPointer( 1772 visitor->VisitPointer(
1750 reinterpret_cast<RawObject**>(&pending_service_extension_calls_)); 1773 reinterpret_cast<RawObject**>(&pending_service_extension_calls_));
1751 1774
1752 // Visit the registered service extension handlers. 1775 // Visit the registered service extension handlers.
1753 visitor->VisitPointer( 1776 visitor->VisitPointer(
1754 reinterpret_cast<RawObject**>(&registered_service_extension_handlers_)); 1777 reinterpret_cast<RawObject**>(&registered_service_extension_handlers_));
1755 1778
1756 // Visit objects in the debugger. 1779 // Visit objects in the debugger.
1757 debugger()->VisitObjectPointers(visitor); 1780 if (FLAG_support_debugger) {
1781 debugger()->VisitObjectPointers(visitor);
1782 }
1758 1783
1759 // Visit objects that are being used for deoptimization. 1784 // Visit objects that are being used for deoptimization.
1760 if (deopt_context() != NULL) { 1785 if (deopt_context() != NULL) {
1761 deopt_context()->VisitObjectPointers(visitor); 1786 deopt_context()->VisitObjectPointers(visitor);
1762 } 1787 }
1763 1788
1764 // Visit objects in all threads (e.g., Dart stack, handles in zones). 1789 // Visit objects in all threads (e.g., Dart stack, handles in zones).
1765 thread_registry()->VisitObjectPointers(visitor, validate_frames); 1790 thread_registry()->VisitObjectPointers(visitor, validate_frames);
1766 } 1791 }
1767 1792
(...skipping 19 matching lines...) Expand all
1787 case kPauseOnUnhandledExceptions: 1812 case kPauseOnUnhandledExceptions:
1788 return "Unhandled"; 1813 return "Unhandled";
1789 default: 1814 default:
1790 UNIMPLEMENTED(); 1815 UNIMPLEMENTED();
1791 return NULL; 1816 return NULL;
1792 } 1817 }
1793 } 1818 }
1794 1819
1795 1820
1796 void Isolate::PrintJSON(JSONStream* stream, bool ref) { 1821 void Isolate::PrintJSON(JSONStream* stream, bool ref) {
1822 if (!FLAG_support_service) {
1823 return;
1824 }
1797 JSONObject jsobj(stream); 1825 JSONObject jsobj(stream);
1798 jsobj.AddProperty("type", (ref ? "@Isolate" : "Isolate")); 1826 jsobj.AddProperty("type", (ref ? "@Isolate" : "Isolate"));
1799 jsobj.AddFixedServiceId("isolates/%" Pd64 "", 1827 jsobj.AddFixedServiceId("isolates/%" Pd64 "",
1800 static_cast<int64_t>(main_port())); 1828 static_cast<int64_t>(main_port()));
1801 1829
1802 jsobj.AddProperty("name", debugger_name()); 1830 jsobj.AddProperty("name", debugger_name());
1803 jsobj.AddPropertyF("number", "%" Pd64 "", 1831 jsobj.AddPropertyF("number", "%" Pd64 "",
1804 static_cast<int64_t>(main_port())); 1832 static_cast<int64_t>(main_port()));
1805 if (ref) { 1833 if (ref) {
1806 return; 1834 return;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1945 } 1973 }
1946 1974
1947 1975
1948 void Isolate::set_registered_service_extension_handlers( 1976 void Isolate::set_registered_service_extension_handlers(
1949 const GrowableObjectArray& value) { 1977 const GrowableObjectArray& value) {
1950 registered_service_extension_handlers_ = value.raw(); 1978 registered_service_extension_handlers_ = value.raw();
1951 } 1979 }
1952 1980
1953 1981
1954 RawObject* Isolate::InvokePendingServiceExtensionCalls() { 1982 RawObject* Isolate::InvokePendingServiceExtensionCalls() {
1983 if (!FLAG_support_service) {
1984 return Object::null();
1985 }
1955 GrowableObjectArray& calls = 1986 GrowableObjectArray& calls =
1956 GrowableObjectArray::Handle(GetAndClearPendingServiceExtensionCalls()); 1987 GrowableObjectArray::Handle(GetAndClearPendingServiceExtensionCalls());
1957 if (calls.IsNull()) { 1988 if (calls.IsNull()) {
1958 return Object::null(); 1989 return Object::null();
1959 } 1990 }
1960 // Grab run function. 1991 // Grab run function.
1961 const Library& developer_lib = Library::Handle(Library::DeveloperLibrary()); 1992 const Library& developer_lib = Library::Handle(Library::DeveloperLibrary());
1962 ASSERT(!developer_lib.IsNull()); 1993 ASSERT(!developer_lib.IsNull());
1963 const Function& run_extension = Function::Handle( 1994 const Function& run_extension = Function::Handle(
1964 developer_lib.LookupLocalFunction(Symbols::_runExtension())); 1995 developer_lib.LookupLocalFunction(Symbols::_runExtension()));
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
2052 calls.Add(id); 2083 calls.Add(id);
2053 } 2084 }
2054 2085
2055 2086
2056 // This function is written in C++ and not Dart because we must do this 2087 // This function is written in C++ and not Dart because we must do this
2057 // operation atomically in the face of random OOB messages. Do not port 2088 // operation atomically in the face of random OOB messages. Do not port
2058 // to Dart code unless you can ensure that the operations will can be 2089 // to Dart code unless you can ensure that the operations will can be
2059 // done atomically. 2090 // done atomically.
2060 void Isolate::RegisterServiceExtensionHandler(const String& name, 2091 void Isolate::RegisterServiceExtensionHandler(const String& name,
2061 const Instance& closure) { 2092 const Instance& closure) {
2093 if (!FLAG_support_service) {
2094 return;
2095 }
2062 GrowableObjectArray& handlers = 2096 GrowableObjectArray& handlers =
2063 GrowableObjectArray::Handle(registered_service_extension_handlers()); 2097 GrowableObjectArray::Handle(registered_service_extension_handlers());
2064 if (handlers.IsNull()) { 2098 if (handlers.IsNull()) {
2065 handlers ^= GrowableObjectArray::New(Heap::kOld); 2099 handlers ^= GrowableObjectArray::New(Heap::kOld);
2066 set_registered_service_extension_handlers(handlers); 2100 set_registered_service_extension_handlers(handlers);
2067 } 2101 }
2068 #if defined(DEBUG) 2102 #if defined(DEBUG)
2069 { 2103 {
2070 // Sanity check. 2104 // Sanity check.
2071 const Instance& existing_handler = 2105 const Instance& existing_handler =
(...skipping 12 matching lines...) Expand all
2084 Service::HandleEvent(&event); 2118 Service::HandleEvent(&event);
2085 } 2119 }
2086 } 2120 }
2087 2121
2088 2122
2089 // This function is written in C++ and not Dart because we must do this 2123 // This function is written in C++ and not Dart because we must do this
2090 // operation atomically in the face of random OOB messages. Do not port 2124 // operation atomically in the face of random OOB messages. Do not port
2091 // to Dart code unless you can ensure that the operations will can be 2125 // to Dart code unless you can ensure that the operations will can be
2092 // done atomically. 2126 // done atomically.
2093 RawInstance* Isolate::LookupServiceExtensionHandler(const String& name) { 2127 RawInstance* Isolate::LookupServiceExtensionHandler(const String& name) {
2128 if (!FLAG_support_service) {
2129 return Instance::null();
2130 }
2094 const GrowableObjectArray& handlers = 2131 const GrowableObjectArray& handlers =
2095 GrowableObjectArray::Handle(registered_service_extension_handlers()); 2132 GrowableObjectArray::Handle(registered_service_extension_handlers());
2096 if (handlers.IsNull()) { 2133 if (handlers.IsNull()) {
2097 return Instance::null(); 2134 return Instance::null();
2098 } 2135 }
2099 String& handler_name = String::Handle(); 2136 String& handler_name = String::Handle();
2100 for (intptr_t i = 0; i < handlers.Length(); i += kRegisteredEntrySize) { 2137 for (intptr_t i = 0; i < handlers.Length(); i += kRegisteredEntrySize) {
2101 handler_name ^= handlers.At(i + kRegisteredNameIndex); 2138 handler_name ^= handlers.At(i + kRegisteredNameIndex);
2102 ASSERT(!handler_name.IsNull()); 2139 ASSERT(!handler_name.IsNull());
2103 if (handler_name.Equals(name)) { 2140 if (handler_name.Equals(name)) {
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
2630 void IsolateSpawnState::DecrementSpawnCount() { 2667 void IsolateSpawnState::DecrementSpawnCount() {
2631 ASSERT(spawn_count_monitor_ != NULL); 2668 ASSERT(spawn_count_monitor_ != NULL);
2632 ASSERT(spawn_count_ != NULL); 2669 ASSERT(spawn_count_ != NULL);
2633 MonitorLocker ml(spawn_count_monitor_); 2670 MonitorLocker ml(spawn_count_monitor_);
2634 ASSERT(*spawn_count_ > 0); 2671 ASSERT(*spawn_count_ > 0);
2635 *spawn_count_ = *spawn_count_ - 1; 2672 *spawn_count_ = *spawn_count_ - 1;
2636 ml.Notify(); 2673 ml.Notify();
2637 } 2674 }
2638 2675
2639 } // namespace dart 2676 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/isolate.h ('k') | runtime/vm/json_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698