Files
sdk/runtime/vm/timeline_macos.cc
T
Vyacheslav Egorov 967deb8db4 Revert "[vm, timeline] Fix compilation failed below macOS 10.14"
This reverts commit 156ef76535.

Reason for revert: broke compilation on buildbots

Original change's description:
> [vm, timeline] Fix compilation failed below macOS 10.14
> 
> signpost.h exists in macOS 10.14 or above, so compilation failed below macOS 10.14
> 
> Change-Id: I97c4d6652f8330d3fc150186e41067c80c3b56f2
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151101
> Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>

TBR=vegorov@google.com,3630cn@sina.com

Change-Id: I04cd72a0c16a9e1d32d1735abf0fe42d35d240e1
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151380
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2020-06-16 07:53:36 +00:00

83 lines
2.6 KiB
C++

// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#include "vm/globals.h"
#if defined(HOST_OS_MACOS) && defined(SUPPORT_TIMELINE)
#include <os/signpost.h>
#include "vm/log.h"
#include "vm/timeline.h"
namespace dart {
// Only available on iOS 12.0, macOS 10.14 or above
TimelineEventMacosRecorder::TimelineEventMacosRecorder()
: TimelineEventPlatformRecorder() {}
TimelineEventMacosRecorder::~TimelineEventMacosRecorder() {}
void TimelineEventMacosRecorder::OnEvent(TimelineEvent* event) {
if (event == NULL) {
return;
}
os_log_t log = event->stream_->macos_log();
if (!os_signpost_enabled(log)) {
return;
}
const char* label = event->label();
uint8_t _Alignas(16) buffer[64];
buffer[0] = 0;
switch (event->event_type()) {
case TimelineEvent::kInstant: {
_os_signpost_emit_with_name_impl(&__dso_handle, log, OS_SIGNPOST_EVENT,
OS_SIGNPOST_ID_EXCLUSIVE, label, "",
buffer, sizeof(buffer));
break;
}
case TimelineEvent::kBegin: {
_os_signpost_emit_with_name_impl(
&__dso_handle, log, OS_SIGNPOST_INTERVAL_BEGIN,
OS_SIGNPOST_ID_EXCLUSIVE, label, "", buffer, sizeof(buffer));
break;
}
case TimelineEvent::kEnd: {
_os_signpost_emit_with_name_impl(
&__dso_handle, log, OS_SIGNPOST_INTERVAL_END,
OS_SIGNPOST_ID_EXCLUSIVE, label, "", buffer, sizeof(buffer));
break;
}
case TimelineEvent::kAsyncBegin: {
_os_signpost_emit_with_name_impl(
&__dso_handle, log, OS_SIGNPOST_INTERVAL_BEGIN, event->AsyncId(),
label, "", buffer, sizeof(buffer));
break;
}
case TimelineEvent::kAsyncEnd: {
_os_signpost_emit_with_name_impl(
&__dso_handle, log, OS_SIGNPOST_INTERVAL_END, event->AsyncId(), label,
"", buffer, sizeof(buffer));
break;
}
case TimelineEvent::kCounter: {
const char* fmt = "%s";
Utils::SNPrint(reinterpret_cast<char*>(buffer), sizeof(buffer), fmt,
event->arguments()[0].value);
_os_signpost_emit_with_name_impl(&__dso_handle, log, OS_SIGNPOST_EVENT,
event->AsyncId(), label, fmt, buffer,
sizeof(buffer));
break;
}
default:
break;
}
}
} // namespace dart
#endif // defined(HOST_OS_MACOS) && defined(SUPPORT_TIMELINE)