Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "include/dart_api.h" | 5 #include "include/dart_api.h" |
| 6 #include "include/dart_mirrors_api.h" | 6 #include "include/dart_mirrors_api.h" |
| 7 #include "include/dart_native_api.h" | 7 #include "include/dart_native_api.h" |
| 8 | 8 |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 #include "lib/stacktrace.h" | 10 #include "lib/stacktrace.h" |
| (...skipping 5522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5533 Dart_Handle state = Api::CheckAndFinalizePendingClasses(T); | 5533 Dart_Handle state = Api::CheckAndFinalizePendingClasses(T); |
| 5534 if (::Dart_IsError(state)) { | 5534 if (::Dart_IsError(state)) { |
| 5535 return state; | 5535 return state; |
| 5536 } | 5536 } |
| 5537 | 5537 |
| 5538 // Now that the newly loaded classes are finalized, notify the debugger | 5538 // Now that the newly loaded classes are finalized, notify the debugger |
| 5539 // that new code has been loaded. If there are latent breakpoints in | 5539 // that new code has been loaded. If there are latent breakpoints in |
| 5540 // the new code, the debugger convert them to unresolved source breakpoints. | 5540 // the new code, the debugger convert them to unresolved source breakpoints. |
| 5541 // The code that completes the futures (invoked below) may call into the | 5541 // The code that completes the futures (invoked below) may call into the |
| 5542 // newly loaded code and trigger one of these breakpoints. | 5542 // newly loaded code and trigger one of these breakpoints. |
| 5543 #ifndef PRODUCT | |
| 5543 I->debugger()->NotifyDoneLoading(); | 5544 I->debugger()->NotifyDoneLoading(); |
|
rmacnak
2016/02/04 21:26:41
+ FLAG_support_debugger
| |
| 5545 #endif // !PRODUCT | |
| 5544 | 5546 |
| 5545 if (FLAG_enable_mirrors) { | 5547 if (FLAG_enable_mirrors) { |
| 5546 // Notify mirrors that MirrorSystem.libraries needs to be recomputed. | 5548 // Notify mirrors that MirrorSystem.libraries needs to be recomputed. |
| 5547 const Library& libmirrors = Library::Handle(Z, Library::MirrorsLibrary()); | 5549 const Library& libmirrors = Library::Handle(Z, Library::MirrorsLibrary()); |
| 5548 const Field& dirty_bit = Field::Handle(Z, | 5550 const Field& dirty_bit = Field::Handle(Z, |
| 5549 libmirrors.LookupLocalField(String::Handle(String::New("dirty")))); | 5551 libmirrors.LookupLocalField(String::Handle(String::New("dirty")))); |
| 5550 ASSERT(!dirty_bit.IsNull() && dirty_bit.is_static()); | 5552 ASSERT(!dirty_bit.IsNull() && dirty_bit.is_static()); |
| 5551 dirty_bit.SetStaticValue(Bool::True()); | 5553 dirty_bit.SetStaticValue(Bool::True()); |
| 5552 } | 5554 } |
| 5553 | 5555 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5641 | 5643 |
| 5642 DART_EXPORT Dart_Port Dart_ServiceWaitForLoadPort() { | 5644 DART_EXPORT Dart_Port Dart_ServiceWaitForLoadPort() { |
| 5643 return ServiceIsolate::WaitForLoadPort(); | 5645 return ServiceIsolate::WaitForLoadPort(); |
| 5644 } | 5646 } |
| 5645 | 5647 |
| 5646 | 5648 |
| 5647 DART_EXPORT void Dart_RegisterIsolateServiceRequestCallback( | 5649 DART_EXPORT void Dart_RegisterIsolateServiceRequestCallback( |
| 5648 const char* name, | 5650 const char* name, |
| 5649 Dart_ServiceRequestCallback callback, | 5651 Dart_ServiceRequestCallback callback, |
| 5650 void* user_data) { | 5652 void* user_data) { |
| 5653 #ifndef PRODUCT | |
| 5651 Service::RegisterIsolateEmbedderCallback(name, callback, user_data); | 5654 Service::RegisterIsolateEmbedderCallback(name, callback, user_data); |
| 5655 #endif // !PRODUCT | |
| 5652 } | 5656 } |
| 5653 | 5657 |
| 5654 | 5658 |
| 5655 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( | 5659 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( |
| 5656 const char* name, | 5660 const char* name, |
| 5657 Dart_ServiceRequestCallback callback, | 5661 Dart_ServiceRequestCallback callback, |
| 5658 void* user_data) { | 5662 void* user_data) { |
| 5663 #ifndef PRODUCT | |
| 5659 Service::RegisterRootEmbedderCallback(name, callback, user_data); | 5664 Service::RegisterRootEmbedderCallback(name, callback, user_data); |
| 5665 #endif // !PRODUCT | |
| 5660 } | 5666 } |
| 5661 | 5667 |
| 5662 | 5668 |
| 5663 DART_EXPORT Dart_Handle Dart_SetServiceStreamCallbacks( | 5669 DART_EXPORT Dart_Handle Dart_SetServiceStreamCallbacks( |
| 5664 Dart_ServiceStreamListenCallback listen_callback, | 5670 Dart_ServiceStreamListenCallback listen_callback, |
| 5665 Dart_ServiceStreamCancelCallback cancel_callback) { | 5671 Dart_ServiceStreamCancelCallback cancel_callback) { |
| 5672 #ifdef PRODUCT | |
| 5673 return Api::Success(); | |
|
rmacnak
2016/02/04 21:26:41
Should we expect the embedder to also behave a bit
Cutch
2016/02/04 22:12:52
I'm trying to allow 'disabled' API calls to become
| |
| 5674 #else | |
| 5666 if (listen_callback != NULL) { | 5675 if (listen_callback != NULL) { |
| 5667 if (Service::stream_listen_callback() != NULL) { | 5676 if (Service::stream_listen_callback() != NULL) { |
| 5668 return Api::NewError( | 5677 return Api::NewError( |
| 5669 "%s permits only one listen callback to be registered, please " | 5678 "%s permits only one listen callback to be registered, please " |
| 5670 "remove the existing callback and then add this callback", | 5679 "remove the existing callback and then add this callback", |
| 5671 CURRENT_FUNC); | 5680 CURRENT_FUNC); |
| 5672 } | 5681 } |
| 5673 } else { | 5682 } else { |
| 5674 if (Service::stream_listen_callback() == NULL) { | 5683 if (Service::stream_listen_callback() == NULL) { |
| 5675 return Api::NewError( | 5684 return Api::NewError( |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 5686 } | 5695 } |
| 5687 } else { | 5696 } else { |
| 5688 if (Service::stream_cancel_callback() == NULL) { | 5697 if (Service::stream_cancel_callback() == NULL) { |
| 5689 return Api::NewError( | 5698 return Api::NewError( |
| 5690 "%s expects 'cancel_callback' to be present in the callback set.", | 5699 "%s expects 'cancel_callback' to be present in the callback set.", |
| 5691 CURRENT_FUNC); | 5700 CURRENT_FUNC); |
| 5692 } | 5701 } |
| 5693 } | 5702 } |
| 5694 Service::SetEmbedderStreamCallbacks(listen_callback, cancel_callback); | 5703 Service::SetEmbedderStreamCallbacks(listen_callback, cancel_callback); |
| 5695 return Api::Success(); | 5704 return Api::Success(); |
| 5705 #endif // PRODUCT | |
| 5696 } | 5706 } |
| 5697 | 5707 |
| 5698 | 5708 |
| 5699 DART_EXPORT Dart_Handle Dart_ServiceSendDataEvent(const char* stream_id, | 5709 DART_EXPORT Dart_Handle Dart_ServiceSendDataEvent(const char* stream_id, |
| 5700 const char* event_kind, | 5710 const char* event_kind, |
| 5701 const uint8_t* bytes, | 5711 const uint8_t* bytes, |
| 5702 intptr_t bytes_length) { | 5712 intptr_t bytes_length) { |
| 5713 #ifdef PRODUCT | |
| 5714 return Api::Success(); | |
| 5715 #else | |
| 5703 DARTSCOPE(Thread::Current()); | 5716 DARTSCOPE(Thread::Current()); |
| 5704 Isolate* I = T->isolate(); | 5717 Isolate* I = T->isolate(); |
| 5705 if (stream_id == NULL) { | 5718 if (stream_id == NULL) { |
| 5706 RETURN_NULL_ERROR(stream_id); | 5719 RETURN_NULL_ERROR(stream_id); |
| 5707 } | 5720 } |
| 5708 if (event_kind == NULL) { | 5721 if (event_kind == NULL) { |
| 5709 RETURN_NULL_ERROR(event_kind); | 5722 RETURN_NULL_ERROR(event_kind); |
| 5710 } | 5723 } |
| 5711 if (bytes == NULL) { | 5724 if (bytes == NULL) { |
| 5712 RETURN_NULL_ERROR(bytes); | 5725 RETURN_NULL_ERROR(bytes); |
| 5713 } | 5726 } |
| 5714 if (bytes_length < 0) { | 5727 if (bytes_length < 0) { |
| 5715 return Api::NewError("%s expects argument 'bytes_length' to be >= 0.", | 5728 return Api::NewError("%s expects argument 'bytes_length' to be >= 0.", |
| 5716 CURRENT_FUNC); | 5729 CURRENT_FUNC); |
| 5717 } | 5730 } |
| 5718 Service::SendEmbedderEvent(I, stream_id, event_kind, | 5731 Service::SendEmbedderEvent(I, stream_id, event_kind, |
| 5719 bytes, bytes_length); | 5732 bytes, bytes_length); |
| 5720 return Api::Success(); | 5733 return Api::Success(); |
| 5734 #endif // PRODUCT | |
| 5721 } | 5735 } |
| 5722 | 5736 |
| 5723 | 5737 |
| 5724 DART_EXPORT int64_t Dart_TimelineGetMicros() { | 5738 DART_EXPORT int64_t Dart_TimelineGetMicros() { |
| 5725 return OS::GetCurrentMonotonicMicros(); | 5739 return OS::GetCurrentMonotonicMicros(); |
| 5726 } | 5740 } |
| 5727 | 5741 |
| 5728 | 5742 |
| 5729 DART_EXPORT void Dart_TimelineSetRecordedStreams(int64_t stream_mask) { | 5743 DART_EXPORT void Dart_TimelineSetRecordedStreams(int64_t stream_mask) { |
| 5730 Isolate* isolate = Isolate::Current(); | 5744 Isolate* isolate = Isolate::Current(); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5868 free(output); | 5882 free(output); |
| 5869 | 5883 |
| 5870 // Finish the stream. | 5884 // Finish the stream. |
| 5871 FinishStreamToConsumer(consumer, user_data, "timeline"); | 5885 FinishStreamToConsumer(consumer, user_data, "timeline"); |
| 5872 return true; | 5886 return true; |
| 5873 } | 5887 } |
| 5874 | 5888 |
| 5875 | 5889 |
| 5876 DART_EXPORT bool Dart_TimelineGetTrace(Dart_StreamConsumer consumer, | 5890 DART_EXPORT bool Dart_TimelineGetTrace(Dart_StreamConsumer consumer, |
| 5877 void* user_data) { | 5891 void* user_data) { |
| 5892 if (!FLAG_support_timeline) { | |
| 5893 return false; | |
| 5894 } | |
| 5878 Isolate* isolate = Isolate::Current(); | 5895 Isolate* isolate = Isolate::Current(); |
| 5879 CHECK_ISOLATE(isolate); | 5896 CHECK_ISOLATE(isolate); |
| 5880 if (consumer == NULL) { | 5897 if (consumer == NULL) { |
| 5881 return false; | 5898 return false; |
| 5882 } | 5899 } |
| 5883 TimelineEventRecorder* timeline_recorder = Timeline::recorder(); | 5900 TimelineEventRecorder* timeline_recorder = Timeline::recorder(); |
| 5884 if (timeline_recorder == NULL) { | 5901 if (timeline_recorder == NULL) { |
| 5885 // Nothing has been recorded. | 5902 // Nothing has been recorded. |
| 5886 return false; | 5903 return false; |
| 5887 } | 5904 } |
| 5888 Thread* T = Thread::Current(); | 5905 Thread* T = Thread::Current(); |
| 5889 StackZone zone(T); | 5906 StackZone zone(T); |
| 5890 Timeline::ReclaimCachedBlocksFromThreads(); | 5907 Timeline::ReclaimCachedBlocksFromThreads(); |
| 5891 JSONStream js; | 5908 JSONStream js; |
| 5892 IsolateTimelineEventFilter filter(isolate->main_port()); | 5909 IsolateTimelineEventFilter filter(isolate->main_port()); |
| 5893 timeline_recorder->PrintTraceEvent(&js, &filter); | 5910 timeline_recorder->PrintTraceEvent(&js, &filter); |
| 5894 return StreamTraceEvents(consumer, user_data, &js); | 5911 return StreamTraceEvents(consumer, user_data, &js); |
| 5895 } | 5912 } |
| 5896 | 5913 |
| 5897 | 5914 |
| 5898 DART_EXPORT bool Dart_GlobalTimelineGetTrace(Dart_StreamConsumer consumer, | 5915 DART_EXPORT bool Dart_GlobalTimelineGetTrace(Dart_StreamConsumer consumer, |
| 5899 void* user_data) { | 5916 void* user_data) { |
| 5917 if (!FLAG_support_timeline) { | |
| 5918 return false; | |
| 5919 } | |
| 5900 // To support various embedders, it must be possible to call this function | 5920 // To support various embedders, it must be possible to call this function |
| 5901 // from a thread for which we have not entered an Isolate and set up a Thread | 5921 // from a thread for which we have not entered an Isolate and set up a Thread |
| 5902 // TLS object. Therefore, a Zone may not be available, a StackZone cannot be | 5922 // TLS object. Therefore, a Zone may not be available, a StackZone cannot be |
| 5903 // created, and no ZoneAllocated objects can be allocated. | 5923 // created, and no ZoneAllocated objects can be allocated. |
| 5904 if (consumer == NULL) { | 5924 if (consumer == NULL) { |
| 5905 return false; | 5925 return false; |
| 5906 } | 5926 } |
| 5907 TimelineEventRecorder* timeline_recorder = Timeline::recorder(); | 5927 TimelineEventRecorder* timeline_recorder = Timeline::recorder(); |
| 5908 if (timeline_recorder == NULL) { | 5928 if (timeline_recorder == NULL) { |
| 5909 // Nothing has been recorded. | 5929 // Nothing has been recorded. |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6120 return Api::Success(); | 6140 return Api::Success(); |
| 6121 } | 6141 } |
| 6122 #endif // DART_PRECOMPILER | 6142 #endif // DART_PRECOMPILER |
| 6123 | 6143 |
| 6124 | 6144 |
| 6125 DART_EXPORT bool Dart_IsRunningPrecompiledCode() { | 6145 DART_EXPORT bool Dart_IsRunningPrecompiledCode() { |
| 6126 return Dart::IsRunningPrecompiledCode(); | 6146 return Dart::IsRunningPrecompiledCode(); |
| 6127 } | 6147 } |
| 6128 | 6148 |
| 6129 } // namespace dart | 6149 } // namespace dart |
| OLD | NEW |