Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
timeline.cc
Go to the documentation of this file.
1// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
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.
4
6
7#include "include/dart_api.h"
8
9#include "vm/native_entry.h"
10#include "vm/object.h"
11#include "vm/os.h"
12#include "vm/timeline.h"
13
14namespace dart {
15
16// Native implementations for the dart:developer library.
17
18DEFINE_NATIVE_ENTRY(Timeline_isDartStreamEnabled, 0, 0) {
19#if defined(SUPPORT_TIMELINE)
20 if (Timeline::GetDartStream()->enabled()) {
21 return Bool::True().ptr();
22 }
23#endif
24 return Bool::False().ptr();
25}
26
27DEFINE_NATIVE_ENTRY(Timeline_getNextTaskId, 0, 0) {
28#if !defined(SUPPORT_TIMELINE)
29 return Integer::New(0);
30#else
31 return Integer::New(thread->GetNextTaskId());
32#endif
33}
34
35DEFINE_NATIVE_ENTRY(Timeline_getTraceClock, 0, 0) {
37}
38
39DEFINE_NATIVE_ENTRY(Timeline_reportTaskEvent, 0, 5) {
40#if defined(SUPPORT_TIMELINE)
41 GET_NON_NULL_NATIVE_ARGUMENT(Integer, id, arguments->NativeArgAt(0));
42 GET_NON_NULL_NATIVE_ARGUMENT(Integer, flow_id, arguments->NativeArgAt(1));
43 GET_NON_NULL_NATIVE_ARGUMENT(Smi, type, arguments->NativeArgAt(2));
44 GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(3));
45 GET_NON_NULL_NATIVE_ARGUMENT(String, args, arguments->NativeArgAt(4));
46
47 TimelineEventRecorder* recorder = Timeline::recorder();
48 if (recorder == nullptr) {
49 return Object::null();
50 }
51
52 TimelineEvent* event = Timeline::GetDartStream()->StartEvent();
53 if (event == nullptr) {
54 // Stream was turned off.
55 return Object::null();
56 }
57
58 std::unique_ptr<const int64_t[]> flow_ids;
59 if (flow_id.AsInt64Value() != TimelineEvent::kNoFlowId) {
60 int64_t* flow_ids_internal = new int64_t[1];
61 flow_ids_internal[0] = flow_id.AsInt64Value();
62 flow_ids = std::unique_ptr<const int64_t[]>(flow_ids_internal);
63 }
64 intptr_t flow_id_count =
65 flow_id.AsInt64Value() == TimelineEvent::kNoFlowId ? 0 : 1;
66 DartTimelineEventHelpers::ReportTaskEvent(
67 event, id.AsInt64Value(), flow_id_count, flow_ids, type.Value(),
68 name.ToMallocCString(), args.ToMallocCString());
69#endif // SUPPORT_TIMELINE
70 return Object::null();
71}
72
73} // namespace dart
static const Bool & False()
Definition object.h:10778
static const Bool & True()
Definition object.h:10776
@ kNew
Definition heap.h:38
static IntegerPtr New(const String &str, Heap::Space space=Heap::kNew)
Definition object.cc:23063
static int64_t GetCurrentMonotonicMicros()
static ObjectPtr null()
Definition object.h:433
ObjectPtr ptr() const
Definition object.h:332
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
FlKeyEvent * event
const char *const name
#define DEFINE_NATIVE_ENTRY(name, type_argument_count, argument_count)
#define GET_NON_NULL_NATIVE_ARGUMENT(type, name, value)