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

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

Issue 2146713004: More changes to use #ifndef PRODUCT ... #endif explicitly instead of relying on compiler magic. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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
« no previous file with comments | « runtime/vm/isolate.h ('k') | runtime/vm/metrics.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) 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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 200
201 201
202 class IsolateMessageHandler : public MessageHandler { 202 class IsolateMessageHandler : public MessageHandler {
203 public: 203 public:
204 explicit IsolateMessageHandler(Isolate* isolate); 204 explicit IsolateMessageHandler(Isolate* isolate);
205 ~IsolateMessageHandler(); 205 ~IsolateMessageHandler();
206 206
207 const char* name() const; 207 const char* name() const;
208 void MessageNotify(Message::Priority priority); 208 void MessageNotify(Message::Priority priority);
209 MessageStatus HandleMessage(Message* message); 209 MessageStatus HandleMessage(Message* message);
210 #ifndef PRODUCT
210 void NotifyPauseOnStart(); 211 void NotifyPauseOnStart();
211 void NotifyPauseOnExit(); 212 void NotifyPauseOnExit();
213 #endif // !PRODUCT
212 214
213 #if defined(DEBUG) 215 #if defined(DEBUG)
214 // Check that it is safe to access this handler. 216 // Check that it is safe to access this handler.
215 void CheckAccess(); 217 void CheckAccess();
216 #endif 218 #endif
217 bool IsCurrentIsolate() const; 219 bool IsCurrentIsolate() const;
218 virtual Isolate* isolate() const { return isolate_; } 220 virtual Isolate* isolate() const { return isolate_; }
219 221
220 private: 222 private:
221 // A result of false indicates that the isolate should terminate the 223 // A result of false indicates that the isolate should terminate the
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 } else { 570 } else {
569 const Object& result = Object::Handle(zone, 571 const Object& result = Object::Handle(zone,
570 DartLibraryCalls::HandleMessage(msg_handler, msg)); 572 DartLibraryCalls::HandleMessage(msg_handler, msg));
571 if (result.IsError()) { 573 if (result.IsError()) {
572 status = ProcessUnhandledException(Error::Cast(result)); 574 status = ProcessUnhandledException(Error::Cast(result));
573 } else { 575 } else {
574 ASSERT(result.IsNull()); 576 ASSERT(result.IsNull());
575 } 577 }
576 } 578 }
577 delete message; 579 delete message;
580 #ifndef PRODUCT
578 if (status == kOK) { 581 if (status == kOK) {
579 const Object& result = 582 const Object& result =
580 Object::Handle(zone, I->InvokePendingServiceExtensionCalls()); 583 Object::Handle(zone, I->InvokePendingServiceExtensionCalls());
581 if (result.IsError()) { 584 if (result.IsError()) {
582 status = ProcessUnhandledException(Error::Cast(result)); 585 status = ProcessUnhandledException(Error::Cast(result));
583 } else { 586 } else {
584 ASSERT(result.IsNull()); 587 ASSERT(result.IsNull());
585 } 588 }
586 } 589 }
590 #endif // !PRODUCT
587 return status; 591 return status;
588 } 592 }
589 593
590 594
595 #ifndef PRODUCT
591 void IsolateMessageHandler::NotifyPauseOnStart() { 596 void IsolateMessageHandler::NotifyPauseOnStart() {
592 if (!FLAG_support_service) { 597 if (!FLAG_support_service) {
593 return; 598 return;
594 } 599 }
595 if (Service::debug_stream.enabled() || FLAG_warn_on_pause_with_no_debugger) { 600 if (Service::debug_stream.enabled() || FLAG_warn_on_pause_with_no_debugger) {
596 StartIsolateScope start_isolate(I); 601 StartIsolateScope start_isolate(I);
597 StackZone zone(T); 602 StackZone zone(T);
598 HandleScope handle_scope(T); 603 HandleScope handle_scope(T);
599 ServiceEvent pause_event(I, ServiceEvent::kPauseStart); 604 ServiceEvent pause_event(I, ServiceEvent::kPauseStart);
600 Service::HandleEvent(&pause_event); 605 Service::HandleEvent(&pause_event);
(...skipping 12 matching lines...) Expand all
613 StartIsolateScope start_isolate(I); 618 StartIsolateScope start_isolate(I);
614 StackZone zone(T); 619 StackZone zone(T);
615 HandleScope handle_scope(T); 620 HandleScope handle_scope(T);
616 ServiceEvent pause_event(I, ServiceEvent::kPauseExit); 621 ServiceEvent pause_event(I, ServiceEvent::kPauseExit);
617 Service::HandleEvent(&pause_event); 622 Service::HandleEvent(&pause_event);
618 } else if (FLAG_trace_service) { 623 } else if (FLAG_trace_service) {
619 OS::Print("vm-service: Dropping event of type PauseExit (%s)\n", 624 OS::Print("vm-service: Dropping event of type PauseExit (%s)\n",
620 I->name()); 625 I->name());
621 } 626 }
622 } 627 }
628 #endif // !PRODUCT
623 629
624 630
625 #if defined(DEBUG) 631 #if defined(DEBUG)
626 void IsolateMessageHandler::CheckAccess() { 632 void IsolateMessageHandler::CheckAccess() {
627 ASSERT(IsCurrentIsolate()); 633 ASSERT(IsCurrentIsolate());
628 } 634 }
629 #endif 635 #endif
630 636
631 637
632 bool IsolateMessageHandler::IsCurrentIsolate() const { 638 bool IsolateMessageHandler::IsCurrentIsolate() const {
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 result->debugger_ = new Debugger(); 959 result->debugger_ = new Debugger();
954 result->debugger_->Initialize(result); 960 result->debugger_->Initialize(result);
955 } 961 }
956 if (FLAG_trace_isolates) { 962 if (FLAG_trace_isolates) {
957 if (name_prefix == NULL || strcmp(name_prefix, "vm-isolate") != 0) { 963 if (name_prefix == NULL || strcmp(name_prefix, "vm-isolate") != 0) {
958 OS::Print("[+] Starting isolate:\n" 964 OS::Print("[+] Starting isolate:\n"
959 "\tisolate: %s\n", result->name()); 965 "\tisolate: %s\n", result->name());
960 } 966 }
961 } 967 }
962 968
969 #ifndef PRODUCT
963 if (FLAG_support_service) { 970 if (FLAG_support_service) {
964 ObjectIdRing::Init(result); 971 ObjectIdRing::Init(result);
965 } 972 }
973 #endif // !PRODUCT
966 974
967 // Add to isolate list. Shutdown and delete the isolate on failure. 975 // Add to isolate list. Shutdown and delete the isolate on failure.
968 if (!AddIsolateToList(result)) { 976 if (!AddIsolateToList(result)) {
969 result->LowLevelShutdown(); 977 result->LowLevelShutdown();
970 Thread::ExitIsolate(); 978 Thread::ExitIsolate();
971 delete result; 979 delete result;
972 return NULL; 980 return NULL;
973 } 981 }
974 982
975 return result; 983 return result;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 reload_context_ = NULL; 1084 reload_context_ = NULL;
1077 } 1085 }
1078 1086
1079 1087
1080 void Isolate::ReloadSources(bool test_mode) { 1088 void Isolate::ReloadSources(bool test_mode) {
1081 ASSERT(!IsReloading()); 1089 ASSERT(!IsReloading());
1082 has_attempted_reload_ = true; 1090 has_attempted_reload_ = true;
1083 reload_context_ = new IsolateReloadContext(this, test_mode); 1091 reload_context_ = new IsolateReloadContext(this, test_mode);
1084 reload_context_->StartReload(); 1092 reload_context_->StartReload();
1085 } 1093 }
1086 1094 #endif // !PRODUCT
1087 #endif
1088 1095
1089 1096
1090 void Isolate::DoneFinalizing() { 1097 void Isolate::DoneFinalizing() {
1091 NOT_IN_PRODUCT( 1098 NOT_IN_PRODUCT(
1092 if (IsReloading()) { 1099 if (IsReloading()) {
1093 reload_context_->FinishReload(); 1100 reload_context_->FinishReload();
1094 if (reload_context_->has_error() && reload_context_->test_mode()) { 1101 if (reload_context_->has_error() && reload_context_->test_mode()) {
1095 // If the reload has an error and we are in test mode keep the reload 1102 // If the reload has an error and we are in test mode keep the reload
1096 // context on the isolate so that it can be used by unit tests. 1103 // context on the isolate so that it can be used by unit tests.
1097 return; 1104 return;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1136 #ifndef PRODUCT 1143 #ifndef PRODUCT
1137 if (FLAG_support_timeline) { 1144 if (FLAG_support_timeline) {
1138 TimelineStream* stream = Timeline::GetIsolateStream(); 1145 TimelineStream* stream = Timeline::GetIsolateStream();
1139 ASSERT(stream != NULL); 1146 ASSERT(stream != NULL);
1140 TimelineEvent* event = stream->StartEvent(); 1147 TimelineEvent* event = stream->StartEvent();
1141 if (event != NULL) { 1148 if (event != NULL) {
1142 event->Instant("Runnable"); 1149 event->Instant("Runnable");
1143 event->Complete(); 1150 event->Complete();
1144 } 1151 }
1145 } 1152 }
1146 #endif // !PRODUCT
1147 if (FLAG_support_service && Service::isolate_stream.enabled()) { 1153 if (FLAG_support_service && Service::isolate_stream.enabled()) {
1148 ServiceEvent runnableEvent(this, ServiceEvent::kIsolateRunnable); 1154 ServiceEvent runnableEvent(this, ServiceEvent::kIsolateRunnable);
1149 Service::HandleEvent(&runnableEvent); 1155 Service::HandleEvent(&runnableEvent);
1150 } 1156 }
1157 #endif // !PRODUCT
1151 return true; 1158 return true;
1152 } 1159 }
1153 1160
1154 1161
1155 bool Isolate::VerifyPauseCapability(const Object& capability) const { 1162 bool Isolate::VerifyPauseCapability(const Object& capability) const {
1156 return !capability.IsNull() && 1163 return !capability.IsNull() &&
1157 capability.IsCapability() && 1164 capability.IsCapability() &&
1158 (pause_capability() == Capability::Cast(capability).Id()); 1165 (pause_capability() == Capability::Cast(capability).Id());
1159 } 1166 }
1160 1167
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after
2095 } 2102 }
2096 const GrowableObjectArray& array = 2103 const GrowableObjectArray& array =
2097 GrowableObjectArray::Handle(boxed_field_list_); 2104 GrowableObjectArray::Handle(boxed_field_list_);
2098 if (array.Length() == 0) { 2105 if (array.Length() == 0) {
2099 return Field::null(); 2106 return Field::null();
2100 } 2107 }
2101 return Field::RawCast(array.RemoveLast()); 2108 return Field::RawCast(array.RemoveLast());
2102 } 2109 }
2103 2110
2104 2111
2112 #ifndef PRODUCT
2105 RawObject* Isolate::InvokePendingServiceExtensionCalls() { 2113 RawObject* Isolate::InvokePendingServiceExtensionCalls() {
2106 if (!FLAG_support_service) { 2114 if (!FLAG_support_service) {
2107 return Object::null(); 2115 return Object::null();
2108 } 2116 }
2109 GrowableObjectArray& calls = 2117 GrowableObjectArray& calls =
2110 GrowableObjectArray::Handle(GetAndClearPendingServiceExtensionCalls()); 2118 GrowableObjectArray::Handle(GetAndClearPendingServiceExtensionCalls());
2111 if (calls.IsNull()) { 2119 if (calls.IsNull()) {
2112 return Object::null(); 2120 return Object::null();
2113 } 2121 }
2114 // Grab run function. 2122 // Grab run function.
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
2275 String& handler_name = String::Handle(); 2283 String& handler_name = String::Handle();
2276 for (intptr_t i = 0; i < handlers.Length(); i += kRegisteredEntrySize) { 2284 for (intptr_t i = 0; i < handlers.Length(); i += kRegisteredEntrySize) {
2277 handler_name ^= handlers.At(i + kRegisteredNameIndex); 2285 handler_name ^= handlers.At(i + kRegisteredNameIndex);
2278 ASSERT(!handler_name.IsNull()); 2286 ASSERT(!handler_name.IsNull());
2279 if (handler_name.Equals(name)) { 2287 if (handler_name.Equals(name)) {
2280 return Instance::RawCast(handlers.At(i + kRegisteredHandlerIndex)); 2288 return Instance::RawCast(handlers.At(i + kRegisteredHandlerIndex));
2281 } 2289 }
2282 } 2290 }
2283 return Instance::null(); 2291 return Instance::null();
2284 } 2292 }
2293 #endif // !PRODUCT
2285 2294
2286 2295
2287 void Isolate::WakePauseEventHandler(Dart_Isolate isolate) { 2296 void Isolate::WakePauseEventHandler(Dart_Isolate isolate) {
2288 Isolate* iso = reinterpret_cast<Isolate*>(isolate); 2297 Isolate* iso = reinterpret_cast<Isolate*>(isolate);
2289 MonitorLocker ml(iso->pause_loop_monitor_); 2298 MonitorLocker ml(iso->pause_loop_monitor_);
2290 ml.Notify(); 2299 ml.Notify();
2291 } 2300 }
2292 2301
2293 2302
2294 void Isolate::PauseEventHandler() { 2303 void Isolate::PauseEventHandler() {
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
2852 void IsolateSpawnState::DecrementSpawnCount() { 2861 void IsolateSpawnState::DecrementSpawnCount() {
2853 ASSERT(spawn_count_monitor_ != NULL); 2862 ASSERT(spawn_count_monitor_ != NULL);
2854 ASSERT(spawn_count_ != NULL); 2863 ASSERT(spawn_count_ != NULL);
2855 MonitorLocker ml(spawn_count_monitor_); 2864 MonitorLocker ml(spawn_count_monitor_);
2856 ASSERT(*spawn_count_ > 0); 2865 ASSERT(*spawn_count_ > 0);
2857 *spawn_count_ = *spawn_count_ - 1; 2866 *spawn_count_ = *spawn_count_ - 1;
2858 ml.Notify(); 2867 ml.Notify();
2859 } 2868 }
2860 2869
2861 } // namespace dart 2870 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/isolate.h ('k') | runtime/vm/metrics.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698