[ VM ] Remove requirement for presence of current isolate for
Dart_ServiceSendDataEvent Fixes https://github.com/dart-lang/sdk/issues/44720 Fixed: 44720 TEST=Existing dart:io tests Change-Id: I003a339a91dca84dafc39c44ba804ecf3f6f84ae Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/190303 Commit-Queue: Ben Konyi <bkonyi@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
committed by
commit-bot@chromium.org
parent
0471644ac9
commit
dbbd71cd75
@@ -99,8 +99,12 @@ void FUNCTION_NAME(Builtin_PrintString)(Dart_NativeArguments args) {
|
||||
if (ShouldCaptureStdout()) {
|
||||
// For now we report print output on the Stdout stream.
|
||||
uint8_t newline[] = {'\n'};
|
||||
Dart_ServiceSendDataEvent("Stdout", "WriteEvent", chars, length);
|
||||
Dart_ServiceSendDataEvent("Stdout", "WriteEvent", newline, sizeof(newline));
|
||||
const char* res =
|
||||
Dart_ServiceSendDataEvent("Stdout", "WriteEvent", chars, length);
|
||||
ASSERT(res == nullptr);
|
||||
res = Dart_ServiceSendDataEvent("Stdout", "WriteEvent", newline,
|
||||
sizeof(newline));
|
||||
ASSERT(res == nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -71,15 +71,17 @@ bool File::WriteFully(const void* buffer, int64_t num_bytes) {
|
||||
}
|
||||
if (capture_stdout || capture_stderr) {
|
||||
intptr_t fd = GetFD();
|
||||
const char* result = nullptr;
|
||||
if ((fd == STDOUT_FILENO) && capture_stdout) {
|
||||
Dart_ServiceSendDataEvent("Stdout", "WriteEvent",
|
||||
reinterpret_cast<const uint8_t*>(buffer),
|
||||
num_bytes);
|
||||
result = Dart_ServiceSendDataEvent(
|
||||
"Stdout", "WriteEvent", reinterpret_cast<const uint8_t*>(buffer),
|
||||
num_bytes);
|
||||
} else if ((fd == STDERR_FILENO) && capture_stderr) {
|
||||
Dart_ServiceSendDataEvent("Stderr", "WriteEvent",
|
||||
reinterpret_cast<const uint8_t*>(buffer),
|
||||
num_bytes);
|
||||
result = Dart_ServiceSendDataEvent(
|
||||
"Stderr", "WriteEvent", reinterpret_cast<const uint8_t*>(buffer),
|
||||
num_bytes);
|
||||
}
|
||||
ASSERT(result == nullptr);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -260,13 +260,13 @@ DART_EXPORT void Dart_SetNativeServiceStreamCallback(
|
||||
*
|
||||
* \param bytes_length The length of the byte array.
|
||||
*
|
||||
* \return Success if the arguments are well formed. Otherwise, returns an
|
||||
* error handle.
|
||||
* \return NULL if the arguments are well formed. Otherwise, returns an
|
||||
* error string. The caller is responsible for freeing the error message.
|
||||
*/
|
||||
DART_EXPORT Dart_Handle Dart_ServiceSendDataEvent(const char* stream_id,
|
||||
const char* event_kind,
|
||||
const uint8_t* bytes,
|
||||
intptr_t bytes_length);
|
||||
DART_EXPORT char* Dart_ServiceSendDataEvent(const char* stream_id,
|
||||
const char* event_kind,
|
||||
const uint8_t* bytes,
|
||||
intptr_t bytes_length);
|
||||
|
||||
/**
|
||||
* Usage statistics for a space/generation at a particular moment in time.
|
||||
|
||||
+17
-13
@@ -6278,29 +6278,33 @@ DART_EXPORT void Dart_SetNativeServiceStreamCallback(
|
||||
#endif
|
||||
}
|
||||
|
||||
DART_EXPORT Dart_Handle Dart_ServiceSendDataEvent(const char* stream_id,
|
||||
const char* event_kind,
|
||||
const uint8_t* bytes,
|
||||
intptr_t bytes_length) {
|
||||
DART_EXPORT char* Dart_ServiceSendDataEvent(const char* stream_id,
|
||||
const char* event_kind,
|
||||
const uint8_t* bytes,
|
||||
intptr_t bytes_length) {
|
||||
#if !defined(PRODUCT)
|
||||
DARTSCOPE(Thread::Current());
|
||||
Isolate* I = T->isolate();
|
||||
if (stream_id == NULL) {
|
||||
RETURN_NULL_ERROR(stream_id);
|
||||
return Utils::StrDup(
|
||||
"Dart_ServiceSendDataEvent expects argument 'stream_id' to be "
|
||||
"non-null.");
|
||||
}
|
||||
if (event_kind == NULL) {
|
||||
RETURN_NULL_ERROR(event_kind);
|
||||
return Utils::StrDup(
|
||||
"Dart_ServiceSendDataEvent expects argument 'event_kind' to be "
|
||||
"non-null.");
|
||||
}
|
||||
if (bytes == NULL) {
|
||||
RETURN_NULL_ERROR(bytes);
|
||||
return Utils::StrDup(
|
||||
"Dart_ServiceSendDataEvent expects argument 'bytes' to be non-null.");
|
||||
}
|
||||
if (bytes_length < 0) {
|
||||
return Api::NewError("%s expects argument 'bytes_length' to be >= 0.",
|
||||
CURRENT_FUNC);
|
||||
return Utils::StrDup(
|
||||
"Dart_ServiceSendDataEvent expects argument 'bytes_length' to be >= "
|
||||
"0.");
|
||||
}
|
||||
Service::SendEmbedderEvent(I, stream_id, event_kind, bytes, bytes_length);
|
||||
Service::SendEmbedderEvent(stream_id, event_kind, bytes, bytes_length);
|
||||
#endif
|
||||
return Api::Success();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DART_EXPORT void Dart_SetGCEventCallback(Dart_GCEventCallback callback) {
|
||||
|
||||
@@ -4309,12 +4309,11 @@ void Service::SendInspectEvent(Isolate* isolate, const Object& inspectee) {
|
||||
Service::HandleEvent(&event);
|
||||
}
|
||||
|
||||
void Service::SendEmbedderEvent(Isolate* isolate,
|
||||
const char* stream_id,
|
||||
void Service::SendEmbedderEvent(const char* stream_id,
|
||||
const char* event_kind,
|
||||
const uint8_t* bytes,
|
||||
intptr_t bytes_len) {
|
||||
ServiceEvent event(isolate, ServiceEvent::kEmbedder);
|
||||
ServiceEvent event(ServiceEvent::kEmbedder);
|
||||
event.set_embedder_kind(event_kind);
|
||||
event.set_embedder_stream_id(stream_id);
|
||||
event.set_bytes(bytes, bytes_len);
|
||||
|
||||
@@ -125,8 +125,7 @@ class Service : public AllStatic {
|
||||
static void SendEchoEvent(Isolate* isolate, const char* text);
|
||||
static void SendInspectEvent(Isolate* isolate, const Object& inspectee);
|
||||
|
||||
static void SendEmbedderEvent(Isolate* isolate,
|
||||
const char* stream_id,
|
||||
static void SendEmbedderEvent(const char* stream_id,
|
||||
const char* event_kind,
|
||||
const uint8_t* bytes,
|
||||
intptr_t bytes_len);
|
||||
|
||||
Reference in New Issue
Block a user