Timeline API fixes for Flutter

API changes:

- Remove isolate specific Timeline APIs.
- Remove Dart_EmbedderTimelineGetTimeline callback.
- Add Dart_TimelineEvent so that arbitrary trace events can be added.

Internal changes:

- Remove isolate specific streams which were never used or controllable from outside the VM.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1811613002 .
This commit is contained in:
John McCutchan 2016-03-16 12:18:46 -07:00
parent 4ad0bac4c7
commit c65114b6b4
21 changed files with 252 additions and 384 deletions

View file

@ -902,37 +902,26 @@ DART_EXPORT int64_t Dart_TimelineGetMicros();
#define DART_TIMELINE_STREAM_GC (1 << 5)
/** Timeline stream for isolate events */
#define DART_TIMELINE_STREAM_ISOLATE (1 << 6)
/** Timeline stream for VM events */
#define DART_TIMELINE_STREAM_VM (1 << 7)
/** Enable all timeline stream recording for an isolate */
/** All timeline streams */
#define DART_TIMELINE_STREAM_ALL (DART_TIMELINE_STREAM_API | \
DART_TIMELINE_STREAM_COMPILER | \
DART_TIMELINE_STREAM_DART | \
DART_TIMELINE_STREAM_DEBUGGER | \
DART_TIMELINE_STREAM_EMBEDDER | \
DART_TIMELINE_STREAM_GC | \
DART_TIMELINE_STREAM_ISOLATE)
DART_TIMELINE_STREAM_ISOLATE | \
DART_TIMELINE_STREAM_VM)
/** Disable all timeline stream recording */
#define DART_TIMELINE_STREAM_DISABLE 0
/**
* Start recording timeline events for the current isolate.
*
* \param stream_mask A bitmask of streams that should be recorded.
*
* NOTE: Calling with 0 disables recording of all streams.
*/
DART_EXPORT void Dart_TimelineSetRecordedStreams(int64_t stream_mask);
/**
* Start recording timeline events for the entire VM (including all isolates).
*
* NOTE: When enabled, the global flag, will override the per-isolate flag.
*
* \param stream_mask A bitmask of streams that should be recorded.
*
* NOTE: Calling with 0 disables recording of all streams.
@ -977,20 +966,6 @@ typedef void (*Dart_StreamConsumer)(
intptr_t buffer_length,
void* stream_callback_data);
/**
* Get the timeline for the current isolate in trace-event format
*
* \param consumer A Dart_StreamConsumer.
* \param user_data User data passed into consumer.
*
* NOTE: The trace-event format is documented here: https://goo.gl/hDZw5M
*
* \return True if a stream was output.
*/
DART_EXPORT bool Dart_TimelineGetTrace(Dart_StreamConsumer consumer,
void* user_data);
/**
* Get the timeline for entire VM (including all isolates).
*
@ -1007,8 +982,34 @@ DART_EXPORT bool Dart_TimelineGetTrace(Dart_StreamConsumer consumer,
DART_EXPORT bool Dart_GlobalTimelineGetTrace(Dart_StreamConsumer consumer,
void* user_data);
typedef enum {
Dart_Timeline_Event_Begin, // Phase = 'B'.
Dart_Timeline_Event_End, // Phase = 'E'.
Dart_Timeline_Event_Instant, // Phase = 'i'.
Dart_Timeline_Event_Duration, // Phase = 'X'.
} Dart_Timeline_Event_Type;
/**
* Add a duration timeline event to the embedder stream for the current isolate.
* Add a timeline event to the embedder stream.
*
* \param label The name of the evnet.
* \param timestamp0 The first timestamp of the event.
* \param timestamp1_or_async_id The second timestamp of the event or
* the async id.
* \param argument_count The number of argument names and values.
* \param argument_names An array of names of the arguments.
* \param argument_values An array of values of the arguments.
*/
DART_EXPORT void Dart_TimelineEvent(const char* label,
int64_t timestamp0,
int64_t timestamp1_or_async_id,
Dart_Timeline_Event_Type type,
intptr_t argument_count,
const char** argument_names,
const char** argument_values);
/**
* Add a duration timeline event to the embedder stream.
*
* \param label The name of the event.
* \param start_micros The start of the duration (in microseconds)
@ -1016,112 +1017,81 @@ DART_EXPORT bool Dart_GlobalTimelineGetTrace(Dart_StreamConsumer consumer,
*
* NOTE: All timestamps should be acquired from Dart_TimelineGetMicros.
*/
DART_EXPORT Dart_Handle Dart_TimelineDuration(const char* label,
int64_t start_micros,
int64_t end_micros);
DART_EXPORT void Dart_TimelineDuration(const char* label,
int64_t start_micros,
int64_t end_micros);
/**
* Add an instant timeline event to the embedder stream for the current isolate.
* Add an instant timeline event to the embedder stream.
*
* \param label The name of event.
*
* NOTE: All timestamps should be acquired from Dart_TimelineGetMicros.
*/
DART_EXPORT Dart_Handle Dart_TimelineInstant(const char* label);
DART_EXPORT void Dart_TimelineInstant(const char* label);
/**
* Adds an asynchronous begin timeline event to the embedder stream for the
* current isolate.
* Adds an asynchronous begin timeline event to the embedder stream.
*
* \param label The name of event.
*
* \return Returns an asynchronous id that must be passed to
* Dart_TimelineAsyncInstant and Dart_TimelineAsyncEnd. If the asynchronous
* id is less than 0 the event was not added to the timeline and subsequent
* calls to Dart_TimelineAsyncInstant and Dart_TimelineAsyncEnd will become
* no-ops.
* \param async_id Pointer that receives the asynchronous id for this async
* operation. If it is less than 0 the event was not added to the timeline.
*
* NOTE: All timestamps should be acquired from Dart_TimelineGetMicros.
*/
DART_EXPORT Dart_Handle Dart_TimelineAsyncBegin(const char* label,
int64_t* async_id);
DART_EXPORT void Dart_TimelineAsyncBegin(const char* label,
int64_t* async_id);
/**
* Adds an asynchronous instant timeline event to the embedder stream for the
* current isolate.
* Adds an asynchronous instant timeline event to the embedder stream.
*
* \param label The name of event.
*
* \return Returns an asynchronous id that must be passed to
* Dart_TimelineAsyncInstant and Dart_TimelineAsyncEnd.
* \param async_id the asynchronous id received by Dart_TimelineAsyncBegin.
*
* NOTE: All timestamps should be acquired from Dart_TimelineGetMicros.
*/
DART_EXPORT Dart_Handle Dart_TimelineAsyncInstant(const char* label,
int64_t async_id);
DART_EXPORT void Dart_TimelineAsyncInstant(const char* label,
int64_t async_id);
/**
* Adds an asynchronous end timeline event to the embedder stream for the
* current isolate.
* Adds an asynchronous end timeline event to the embedder stream.
*
* \param label The name of event.
*
* \return Returns an asynchronous id that must be passed to
* Dart_TimelineAsyncInstant and Dart_TimelineAsyncEnd.
* \param async_id the asynchronous id received by Dart_TimelineAsyncBegin.
*
* NOTE: All timestamps should be acquired from Dart_TimelineGetMicros.
*/
DART_EXPORT Dart_Handle Dart_TimelineAsyncEnd(const char* label,
int64_t async_id);
DART_EXPORT void Dart_TimelineAsyncEnd(const char* label,
int64_t async_id);
/**
* Called by the VM to let the embedder know when to start recording into their
* own timeline implementation. Can be called from any thread.
* Called by the VM to let the embedder know when to start recording into the
* timeline. Can be called from any thread.
*/
typedef void (*Dart_EmbedderTimelineStartRecording)();
/**
* Called by the VM to let the embedder know when to stop recording into their
* own timeline implementation. Can be called from any thread.
* Called by the VM to let the embedder know when to stop recording into the
* timeline. Can be called from any thread.
*/
typedef void (*Dart_EmbedderTimelineStopRecording)();
/**
* Called by the VM to request data from the embedder's private timeline
* implementation. Can be called from any thread and must complete
* synchronously.
*
* \param stream_consumer The embedder must only call the stream_consumer with
* the Dart_StreamConsumer_kData state. See Dart_StreamConsumer above.
* \param user_data
*
* \return Returns true on success.
*
*/
typedef bool (*Dart_EmbedderTimelineGetTimeline)(
Dart_StreamConsumer stream_consumer,
void* user_data);
/**
* Sets the embedder timeline callbacks. These callbacks are used by the VM
* to notify the embedder of timeline recording state changes and to request
* data from the embedder.
* to notify the embedder of timeline recording state changes.
*
* \param start_recording See Dart_EmbedderTimelineStartRecording.
* \param stop_recording See Dart_EmbedderTimelineStopRecording.
* \param get_timeline See Dart_EmbedderTimelineGetTimeline.
*
* NOTE: To avoid races, this should be called before Dart_Initialize.
*/
DART_EXPORT void Dart_SetEmbedderTimelineCallbacks(
Dart_EmbedderTimelineStartRecording start_recording,
Dart_EmbedderTimelineStopRecording stop_recording,
Dart_EmbedderTimelineGetTimeline get_timeline);
Dart_EmbedderTimelineStopRecording stop_recording);
#endif // INCLUDE_DART_TOOLS_API_H_

View file

@ -53,7 +53,7 @@ DEFINE_NATIVE_ENTRY(Timeline_reportTaskEvent, 6) {
return Object::null();
}
TimelineEvent* event = isolate->GetDartStream()->StartEvent();
TimelineEvent* event = Timeline::GetDartStream()->StartEvent();
if (event == NULL) {
// Stream was turned off.
return Object::null();
@ -118,7 +118,7 @@ DEFINE_NATIVE_ENTRY(Timeline_reportCompleteEvent, 5) {
return Object::null();
}
TimelineEvent* event = isolate->GetDartStream()->StartEvent();
TimelineEvent* event = Timeline::GetDartStream()->StartEvent();
if (event == NULL) {
// Stream was turned off.
return Object::null();
@ -163,7 +163,7 @@ DEFINE_NATIVE_ENTRY(Timeline_reportInstantEvent, 4) {
return Object::null();
}
TimelineEvent* event = isolate->GetDartStream()->StartEvent();
TimelineEvent* event = Timeline::GetDartStream()->StartEvent();
if (event == NULL) {
// Stream was turned off.
return Object::null();

View file

@ -40,6 +40,7 @@
#include "vm/symbols.h"
#include "vm/tags.h"
#include "vm/thread_registry.h"
#include "vm/timeline.h"
#include "vm/timer.h"
namespace dart {
@ -278,7 +279,7 @@ RawError* Compiler::CompileClass(const Class& cls) {
NOT_IN_PRODUCT(
VMTagScope tagScope(thread, VMTag::kCompileClassTagId);
TimelineDurationScope tds(thread,
thread->isolate()->GetCompilerStream(),
Timeline::GetCompilerStream(),
"CompileClass");
if (tds.enabled()) {
tds.SetNumArguments(1);
@ -582,7 +583,7 @@ bool CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) {
bool is_compiled = false;
Zone* const zone = thread()->zone();
NOT_IN_PRODUCT(
TimelineStream* compiler_timeline = isolate()->GetCompilerStream());
TimelineStream* compiler_timeline = Timeline::GetCompilerStream());
CSTAT_TIMER_SCOPE(thread(), codegen_timer);
HANDLESCOPE(thread());

View file

@ -29,6 +29,7 @@
#include "vm/symbols.h"
#include "vm/thread_interrupter.h"
#include "vm/thread_pool.h"
#include "vm/timeline.h"
#include "vm/virtual_memory.h"
#include "vm/zone.h"
@ -391,7 +392,9 @@ RawError* Dart::InitializeIsolate(const uint8_t* snapshot_buffer, void* data) {
Thread* T = Thread::Current();
Isolate* I = T->isolate();
NOT_IN_PRODUCT(
TimelineDurationScope tds(T, I->GetIsolateStream(), "InitializeIsolate");
TimelineDurationScope tds(T,
Timeline::GetIsolateStream(),
"InitializeIsolate");
tds.SetNumArguments(1);
tds.CopyArgument(0, "isolateName", I->name());
)
@ -400,7 +403,7 @@ RawError* Dart::InitializeIsolate(const uint8_t* snapshot_buffer, void* data) {
HandleScope handle_scope(T);
{
NOT_IN_PRODUCT(TimelineDurationScope tds(T,
I->GetIsolateStream(), "ObjectStore::Init"));
Timeline::GetIsolateStream(), "ObjectStore::Init"));
ObjectStore::Init(I);
}
@ -411,7 +414,7 @@ RawError* Dart::InitializeIsolate(const uint8_t* snapshot_buffer, void* data) {
if (snapshot_buffer != NULL) {
// Read the snapshot and setup the initial state.
NOT_IN_PRODUCT(TimelineDurationScope tds(T,
I->GetIsolateStream(), "IsolateSnapshotReader"));
Timeline::GetIsolateStream(), "IsolateSnapshotReader"));
// TODO(turnidge): Remove once length is not part of the snapshot.
const Snapshot* snapshot = Snapshot::SetupFromBuffer(snapshot_buffer);
if (snapshot == NULL) {
@ -449,7 +452,7 @@ RawError* Dart::InitializeIsolate(const uint8_t* snapshot_buffer, void* data) {
{
NOT_IN_PRODUCT(TimelineDurationScope tds(T,
I->GetIsolateStream(), "StubCode::Init"));
Timeline::GetIsolateStream(), "StubCode::Init"));
StubCode::Init(I);
}

View file

@ -78,12 +78,12 @@ const char* CanonicalFunction(const char* func) {
#ifndef PRODUCT
#define API_TIMELINE_DURATION \
TimelineDurationScope tds(Thread::Current(), \
Timeline::GetVMApiStream(), \
Timeline::GetAPIStream(), \
CURRENT_FUNC)
#define API_TIMELINE_BEGIN_END \
TimelineBeginEndScope tbes(Thread::Current(), \
Timeline::GetVMApiStream(), \
Timeline::GetAPIStream(), \
CURRENT_FUNC)
#else
#define API_TIMELINE_DURATION do { } while (false)
@ -5775,31 +5775,7 @@ DART_EXPORT int64_t Dart_TimelineGetMicros() {
}
DART_EXPORT void Dart_TimelineSetRecordedStreams(int64_t stream_mask) {
if (!FLAG_support_timeline) {
return;
}
Isolate* isolate = Isolate::Current();
CHECK_ISOLATE(isolate);
isolate->GetAPIStream()->set_enabled(
(stream_mask & DART_TIMELINE_STREAM_API) != 0);
isolate->GetCompilerStream()->set_enabled(
(stream_mask & DART_TIMELINE_STREAM_COMPILER) != 0);
isolate->GetDartStream()->set_enabled(
(stream_mask & DART_TIMELINE_STREAM_DART) != 0);
isolate->GetDebuggerStream()->set_enabled(
(stream_mask & DART_TIMELINE_STREAM_DEBUGGER) != 0);
isolate->GetEmbedderStream()->set_enabled(
(stream_mask & DART_TIMELINE_STREAM_EMBEDDER) != 0);
isolate->GetGCStream()->set_enabled(
(stream_mask & DART_TIMELINE_STREAM_GC) != 0);
isolate->GetIsolateStream()->set_enabled(
(stream_mask & DART_TIMELINE_STREAM_ISOLATE) != 0);
}
DART_EXPORT void Dart_GlobalTimelineSetRecordedStreams(int64_t stream_mask) {
// Per isolate overrides.
if (!FLAG_support_timeline) {
return;
}
@ -5815,6 +5791,8 @@ DART_EXPORT void Dart_GlobalTimelineSetRecordedStreams(int64_t stream_mask) {
const bool gc_enabled = (stream_mask & DART_TIMELINE_STREAM_GC) != 0;
const bool isolate_enabled =
(stream_mask & DART_TIMELINE_STREAM_ISOLATE) != 0;
const bool vm_enabled =
(stream_mask & DART_TIMELINE_STREAM_VM) != 0;
Timeline::SetStreamAPIEnabled(api_enabled);
Timeline::SetStreamCompilerEnabled(compiler_enabled);
Timeline::SetStreamDartEnabled(dart_enabled);
@ -5822,10 +5800,7 @@ DART_EXPORT void Dart_GlobalTimelineSetRecordedStreams(int64_t stream_mask) {
Timeline::SetStreamEmbedderEnabled(embedder_enabled);
Timeline::SetStreamGCEnabled(gc_enabled);
Timeline::SetStreamIsolateEnabled(isolate_enabled);
// VM wide.
const bool vm_enabled =
(stream_mask & DART_TIMELINE_STREAM_VM) != 0;
Timeline::GetVMStream()->set_enabled(vm_enabled);
Timeline::SetStreamVMEnabled(vm_enabled);
}
@ -5924,44 +5899,14 @@ static bool StreamTraceEvents(Dart_StreamConsumer consumer,
}
DART_EXPORT bool Dart_TimelineGetTrace(Dart_StreamConsumer consumer,
void* user_data) {
if (!FLAG_support_timeline) {
return false;
}
Isolate* isolate = Isolate::Current();
CHECK_ISOLATE(isolate);
if (consumer == NULL) {
return false;
}
TimelineEventRecorder* timeline_recorder = Timeline::recorder();
if (timeline_recorder == NULL) {
// Nothing has been recorded.
return false;
}
Thread* T = Thread::Current();
StackZone zone(T);
Timeline::ReclaimCachedBlocksFromThreads();
JSONStream js;
IsolateTimelineEventFilter filter(isolate->main_port());
timeline_recorder->PrintTraceEvent(&js, &filter);
StartStreamToConsumer(consumer, user_data, "timeline");
bool success = StreamTraceEvents(consumer, user_data, &js);
FinishStreamToConsumer(consumer, user_data, "timeline");
return success;
}
DART_EXPORT void Dart_SetEmbedderTimelineCallbacks(
Dart_EmbedderTimelineStartRecording start_recording,
Dart_EmbedderTimelineStopRecording stop_recording,
Dart_EmbedderTimelineGetTimeline get_timeline) {
Dart_EmbedderTimelineStopRecording stop_recording) {
if (!FLAG_support_timeline) {
return;
}
Timeline::set_start_recording_cb(start_recording);
Timeline::set_stop_recording_cb(stop_recording);
Timeline::set_get_timeline_cb(get_timeline);
}
@ -5996,67 +5941,105 @@ DART_EXPORT bool Dart_GlobalTimelineGetTrace(Dart_StreamConsumer consumer,
}
DART_EXPORT Dart_Handle Dart_TimelineDuration(const char* label,
int64_t start_micros,
int64_t end_micros) {
DART_EXPORT void Dart_TimelineEvent(const char* label,
int64_t timestamp0,
int64_t timestamp1,
Dart_Timeline_Event_Type type,
intptr_t argument_count,
const char** argument_names,
const char** argument_values) {
if (!FLAG_support_timeline) {
return Api::Success();
return;
}
Isolate* isolate = Isolate::Current();
CHECK_ISOLATE(isolate);
if (label == NULL) {
RETURN_NULL_ERROR(label);
if (type < Dart_Timeline_Event_Begin) {
return;
}
if (type > Dart_Timeline_Event_Duration) {
return;
}
TimelineStream* stream = Timeline::GetEmbedderStream();
ASSERT(stream != NULL);
TimelineEvent* event = stream->StartEvent();
if (event == NULL) {
return;
}
switch (type) {
case Dart_Timeline_Event_Begin:
event->Begin(label, timestamp0);
break;
case Dart_Timeline_Event_End:
event->End(label, timestamp0);
break;
case Dart_Timeline_Event_Instant:
event->Instant(label, timestamp0);
break;
case Dart_Timeline_Event_Duration:
event->Duration(label, timestamp0, timestamp1);
break;
default:
FATAL("Unknown Dart_Timeline_Event_Type");
}
event->SetNumArguments(argument_count);
for (intptr_t i = 0; i < argument_count; i++) {
event->CopyArgument(i, argument_names[i], argument_values[i]);
}
event->Complete();
}
DART_EXPORT void Dart_TimelineDuration(const char* label,
int64_t start_micros,
int64_t end_micros) {
if (!FLAG_support_timeline) {
return;
}
if (start_micros > end_micros) {
const char* msg = "%s: start_micros must be <= end_micros";
return Api::NewError(msg, CURRENT_FUNC);
FATAL1("%s: start_micros must be <= end_micros", CURRENT_FUNC);
}
TimelineStream* stream = isolate->GetEmbedderStream();
if (label == NULL) {
return;
}
TimelineStream* stream = Timeline::GetEmbedderStream();
ASSERT(stream != NULL);
TimelineEvent* event = stream->StartEvent();
if (event != NULL) {
event->Duration(label, start_micros, end_micros);
event->Complete();
}
return Api::Success();
}
DART_EXPORT Dart_Handle Dart_TimelineInstant(const char* label) {
DART_EXPORT void Dart_TimelineInstant(const char* label) {
if (!FLAG_support_timeline) {
return Api::Success();
return;
}
Isolate* isolate = Isolate::Current();
CHECK_ISOLATE(isolate);
if (label == NULL) {
RETURN_NULL_ERROR(label);
return;
}
TimelineStream* stream = isolate->GetEmbedderStream();
TimelineStream* stream = Timeline::GetEmbedderStream();
ASSERT(stream != NULL);
TimelineEvent* event = stream->StartEvent();
if (event != NULL) {
event->Instant(label);
event->Complete();
}
return Api::Success();
return;
}
DART_EXPORT Dart_Handle Dart_TimelineAsyncBegin(const char* label,
int64_t* async_id) {
DART_EXPORT void Dart_TimelineAsyncBegin(const char* label,
int64_t* async_id) {
if (!FLAG_support_timeline) {
return Api::Success();
return;
}
Isolate* isolate = Isolate::Current();
CHECK_ISOLATE(isolate);
if (label == NULL) {
RETURN_NULL_ERROR(label);
return;
}
if (async_id == NULL) {
RETURN_NULL_ERROR(async_id);
return;
}
*async_id = -1;
TimelineStream* stream = isolate->GetEmbedderStream();
TimelineStream* stream = Timeline::GetEmbedderStream();
ASSERT(stream != NULL);
TimelineEvent* event = stream->StartEvent();
if (event != NULL) {
@ -6066,55 +6049,51 @@ DART_EXPORT Dart_Handle Dart_TimelineAsyncBegin(const char* label,
event->AsyncBegin(label, *async_id);
event->Complete();
}
return Api::Success();
return;
}
DART_EXPORT Dart_Handle Dart_TimelineAsyncInstant(const char* label,
int64_t async_id) {
DART_EXPORT void Dart_TimelineAsyncInstant(const char* label,
int64_t async_id) {
if (!FLAG_support_timeline) {
return Api::Success();
return;
}
if (async_id < 0) {
return Api::Success();
return;
}
Isolate* isolate = Isolate::Current();
CHECK_ISOLATE(isolate);
if (label == NULL) {
RETURN_NULL_ERROR(label);
return;
}
TimelineStream* stream = isolate->GetEmbedderStream();
TimelineStream* stream = Timeline::GetEmbedderStream();
ASSERT(stream != NULL);
TimelineEvent* event = stream->StartEvent();
if (event != NULL) {
event->AsyncInstant(label, async_id);
event->Complete();
}
return Api::Success();
return;
}
DART_EXPORT Dart_Handle Dart_TimelineAsyncEnd(const char* label,
int64_t async_id) {
DART_EXPORT void Dart_TimelineAsyncEnd(const char* label,
int64_t async_id) {
if (!FLAG_support_timeline) {
return Api::Success();
return;
}
if (async_id < 0) {
return Api::Success();
return;
}
Isolate* isolate = Isolate::Current();
CHECK_ISOLATE(isolate);
if (label == NULL) {
RETURN_NULL_ERROR(label);
return;
}
TimelineStream* stream = isolate->GetEmbedderStream();
TimelineStream* stream = Timeline::GetEmbedderStream();
ASSERT(stream != NULL);
TimelineEvent* event = stream->StartEvent();
if (event != NULL) {
event->AsyncEnd(label, async_id);
event->Complete();
}
return Api::Success();
return;
}
// The precompiler is included in dart_bootstrap and dart_noopt, and

View file

@ -14,6 +14,7 @@
#include "vm/dart_api_impl.h"
#include "vm/dart_api_state.h"
#include "vm/lockers.h"
#include "vm/timeline.h"
#include "vm/unit_test.h"
#include "vm/verifier.h"
@ -9190,7 +9191,7 @@ TEST_CASE(StringFromExternalTypedData) {
TEST_CASE(Timeline_Dart_TimelineDuration) {
Isolate* isolate = Isolate::Current();
// Grab embedder stream.
TimelineStream* stream = isolate->GetEmbedderStream();
TimelineStream* stream = Timeline::GetEmbedderStream();
// Make sure it is enabled.
stream->set_enabled(true);
// Add a duration event.
@ -9208,7 +9209,7 @@ TEST_CASE(Timeline_Dart_TimelineDuration) {
TEST_CASE(Timeline_Dart_TimelineInstant) {
Isolate* isolate = Isolate::Current();
// Grab embedder stream.
TimelineStream* stream = isolate->GetEmbedderStream();
TimelineStream* stream = Timeline::GetEmbedderStream();
// Make sure it is enabled.
stream->set_enabled(true);
Dart_TimelineInstant("testInstantEvent");
@ -9223,9 +9224,8 @@ TEST_CASE(Timeline_Dart_TimelineInstant) {
TEST_CASE(Timeline_Dart_TimelineAsyncDisabled) {
Isolate* isolate = Isolate::Current();
// Grab embedder stream.
TimelineStream* stream = isolate->GetEmbedderStream();
TimelineStream* stream = Timeline::GetEmbedderStream();
// Make sure it is disabled.
stream->set_enabled(false);
int64_t async_id = -1;
@ -9247,7 +9247,7 @@ TEST_CASE(Timeline_Dart_TimelineAsyncDisabled) {
TEST_CASE(Timeline_Dart_TimelineAsync) {
Isolate* isolate = Isolate::Current();
// Grab embedder stream.
TimelineStream* stream = isolate->GetEmbedderStream();
TimelineStream* stream = Timeline::GetEmbedderStream();
// Make sure it is enabled.
stream->set_enabled(true);
int64_t async_id = -1;
@ -9315,7 +9315,7 @@ TEST_CASE(Timeline_Dart_TimelineGetTrace) {
bool success = false;
// Enable recording of all streams.
Dart_TimelineSetRecordedStreams(DART_TIMELINE_STREAM_ALL);
Dart_GlobalTimelineSetRecordedStreams(DART_TIMELINE_STREAM_ALL);
// Invoke main, which will be compiled resulting in a compiler event in
// the timeline.
@ -9327,7 +9327,7 @@ TEST_CASE(Timeline_Dart_TimelineGetTrace) {
// Grab the trace.
AppendData data;
success = Dart_TimelineGetTrace(AppendStreamConsumer, &data);
success = Dart_GlobalTimelineGetTrace(AppendStreamConsumer, &data);
EXPECT(success);
buffer = reinterpret_cast<char*>(data.buffer);
buffer_length = data.buffer_length;
@ -9367,7 +9367,7 @@ TEST_CASE(Timeline_Dart_TimelineGetTraceOnlyDartEvents) {
bool success = false;
// Enable recording of the Dart stream.
Dart_TimelineSetRecordedStreams(DART_TIMELINE_STREAM_DART);
Dart_GlobalTimelineSetRecordedStreams(DART_TIMELINE_STREAM_DART);
// Invoke main, which will add a new timeline event from Dart.
Dart_Handle result = Dart_Invoke(lib,
@ -9380,7 +9380,7 @@ TEST_CASE(Timeline_Dart_TimelineGetTraceOnlyDartEvents) {
AppendData data;
data.buffer = NULL;
data.buffer_length = 0;
success = Dart_TimelineGetTrace(AppendStreamConsumer, &data);
success = Dart_GlobalTimelineGetTrace(AppendStreamConsumer, &data);
EXPECT(success);
buffer = reinterpret_cast<char*>(data.buffer);
buffer_length = data.buffer_length;
@ -9419,7 +9419,7 @@ TEST_CASE(Timeline_Dart_TimelineGetTraceWithDartEvents) {
bool success = false;
// Enable recording of all streams.
Dart_TimelineSetRecordedStreams(DART_TIMELINE_STREAM_ALL);
Dart_GlobalTimelineSetRecordedStreams(DART_TIMELINE_STREAM_ALL);
// Invoke main, which will be compiled resulting in a compiler event in
// the timeline.
@ -9431,7 +9431,7 @@ TEST_CASE(Timeline_Dart_TimelineGetTraceWithDartEvents) {
// Grab the trace.
AppendData data;
success = Dart_TimelineGetTrace(AppendStreamConsumer, &data);
success = Dart_GlobalTimelineGetTrace(AppendStreamConsumer, &data);
EXPECT(success);
buffer = reinterpret_cast<char*>(data.buffer);
buffer_length = data.buffer_length;
@ -9480,7 +9480,7 @@ TEST_CASE(Timeline_Dart_TimelineGetTraceGlobalOverride) {
// Grab the trace.
AppendData data;
success = Dart_TimelineGetTrace(AppendStreamConsumer, &data);
success = Dart_GlobalTimelineGetTrace(AppendStreamConsumer, &data);
EXPECT(success);
buffer = reinterpret_cast<char*>(data.buffer);
buffer_length = data.buffer_length;
@ -9503,6 +9503,16 @@ TEST_CASE(Timeline_Dart_TimelineGetTraceGlobalOverride) {
}
static const char* arg_names[] = {
"arg0"
};
static const char* arg_values[] = {
"value0"
};
TEST_CASE(Timeline_Dart_GlobalTimelineGetTrace) {
const char* kScriptChars =
"bar() => 'z';\n"
@ -9520,6 +9530,17 @@ TEST_CASE(Timeline_Dart_GlobalTimelineGetTrace) {
lib = TestCase::LoadTestScript(kScriptChars, NULL);
}
{
// Add something to the embedder stream.
Dart_TimelineEvent("TRACE_EVENT",
Dart_TimelineGetMicros(),
0,
Dart_Timeline_Event_Begin,
1,
&arg_names[0],
&arg_values[0]);
}
// Invoke main, which will be compiled resulting in a compiler event in
// the timeline.
Dart_Handle result = Dart_Invoke(lib,
@ -9559,6 +9580,9 @@ TEST_CASE(Timeline_Dart_GlobalTimelineGetTrace) {
EXPECT_SUBSTRING("\"name\":\"CompileFunction\"", buffer);
EXPECT_SUBSTRING("\"function\":\"::_main\"", buffer);
EXPECT_NOTSUBSTRING("\"function\":\"::_bar\"", buffer);
EXPECT_SUBSTRING("TRACE_EVENT", buffer);
EXPECT_SUBSTRING("arg0", buffer);
EXPECT_SUBSTRING("value0", buffer);
// Free buffer allocated by AppendStreamConsumer
free(data.buffer);
@ -9786,7 +9810,7 @@ static void StopRecording() {
TEST_CASE(Timeline_Dart_EmbedderTimelineStartStopRecording) {
Dart_SetEmbedderTimelineCallbacks(StartRecording, StopRecording, NULL);
Dart_SetEmbedderTimelineCallbacks(StartRecording, StopRecording);
EXPECT(!start_called);
EXPECT(!stop_called);
@ -9803,37 +9827,6 @@ TEST_CASE(Timeline_Dart_EmbedderTimelineStartStopRecording) {
EXPECT(stop_called);
}
static bool GetTimeline(Dart_StreamConsumer stream_consumer,
void* user_data) {
ASSERT(stream_consumer != NULL);
ASSERT(user_data != NULL);
const char* test_string = "HELLO FROM EMBEDDER";
stream_consumer(Dart_StreamConsumer_kData,
"embedder.timeline",
reinterpret_cast<const uint8_t*>(test_string),
strlen(test_string),
user_data);
return true;
}
TEST_CASE(Timeline_Dart_EmbedderTimelineGetTimeline) {
Dart_SetEmbedderTimelineCallbacks(NULL, NULL, GetTimeline);
Dart_GlobalTimelineSetRecordedStreams(DART_TIMELINE_STREAM_EMBEDDER);
Dart_TimelineDuration("testDurationEvent", 0, 1);
AppendData data;
bool success = Dart_GlobalTimelineGetTrace(AppendStreamConsumer, &data);
EXPECT(success);
EXPECT_SUBSTRING("}},HELLO FROM EMBEDDER",
data.buffer);
// Free buffer allocated by AppendStreamConsumer
free(data.buffer);
}
#endif // !PRODUCT
} // namespace dart

View file

@ -27,6 +27,7 @@
#include "vm/stub_code.h"
#include "vm/symbols.h"
#include "vm/thread_interrupter.h"
#include "vm/timeline.h"
#include "vm/token_position.h"
#include "vm/visitor.h"
@ -2558,7 +2559,7 @@ void Debugger::Pause(DebuggerEvent* event) {
Thread* thread = Thread::Current();
DisableThreadInterruptsScope dtis(thread);
TimelineDurationScope tds(thread,
isolate_->GetDebuggerStream(),
Timeline::GetDebuggerStream(),
"Debugger Pause");
InvokeEventHandler(event);
}

View file

@ -139,8 +139,7 @@ DeoptContext::~DeoptContext() {
deferred_objects_ = NULL;
deferred_objects_count_ = 0;
if (FLAG_support_timeline && (deopt_start_micros_ != 0)) {
Isolate* isolate = Isolate::Current();
TimelineStream* compiler_stream = isolate->GetCompilerStream();
TimelineStream* compiler_stream = Timeline::GetCompilerStream();
ASSERT(compiler_stream != NULL);
if (compiler_stream->Enabled()) {
// Allocate all Dart objects needed before calling StartEvent,

View file

@ -255,7 +255,7 @@ bool FlowGraphCompiler::IsPotentialUnboxedField(const Field& field) {
void FlowGraphCompiler::InitCompiler() {
#ifndef PRODUCT
TimelineDurationScope tds(thread(),
isolate()->GetCompilerStream(),
Timeline::GetCompilerStream(),
"InitCompiler");
#endif // !PRODUCT
pc_descriptors_list_ = new(zone()) DescriptorList(64);

View file

@ -8,6 +8,7 @@
#include "vm/bit_vector.h"
#include "vm/il_printer.h"
#include "vm/regexp_assembler.h"
#include "vm/timeline.h"
namespace dart {
@ -20,8 +21,7 @@ DECLARE_FLAG(bool, propagate_types);
void FlowGraphTypePropagator::Propagate(FlowGraph* flow_graph) {
#ifndef PRODUCT
Thread* thread = flow_graph->thread();
Isolate* const isolate = flow_graph->isolate();
TimelineStream* compiler_timeline = isolate->GetCompilerStream();
TimelineStream* compiler_timeline = Timeline::GetCompilerStream();
TimelineDurationScope tds2(thread,
compiler_timeline,
"FlowGraphTypePropagator");

View file

@ -369,7 +369,7 @@ void Heap::CollectNewSpaceGarbage(Thread* thread,
VMTagScope tagScope(thread, VMTag::kGCNewSpaceTagId);
#ifndef PRODUCT
TimelineDurationScope tds(thread,
isolate()->GetGCStream(),
Timeline::GetGCStream(),
"CollectNewGeneration");
#endif // !PRODUCT
UpdateClassHeapStatsBeforeGC(kNew);
@ -396,7 +396,7 @@ void Heap::CollectOldSpaceGarbage(Thread* thread,
VMTagScope tagScope(thread, VMTag::kGCOldSpaceTagId);
#ifndef PRODUCT
TimelineDurationScope tds(thread,
isolate()->GetGCStream(),
Timeline::GetGCStream(),
"CollectOldGeneration");
#endif // !PRODUCT
UpdateClassHeapStatsBeforeGC(kOld);

View file

@ -451,7 +451,9 @@ MessageHandler::MessageStatus IsolateMessageHandler::HandleMessage(
Zone* zone = stack_zone.GetZone();
HandleScope handle_scope(thread);
#ifndef PRODUCT
TimelineDurationScope tds(thread, I->GetIsolateStream(), "HandleMessage");
TimelineDurationScope tds(thread,
Timeline::GetIsolateStream(),
"HandleMessage");
tds.SetNumArguments(1);
tds.CopyArgument(0, "isolateName", I->name());
#endif
@ -903,11 +905,6 @@ Isolate* Isolate::Init(const char* name_prefix,
ISOLATE_METRIC_LIST(ISOLATE_METRIC_INIT);
#undef ISOLATE_METRIC_INIT
#ifndef PRODUCT
// Initialize Timeline streams.
Timeline::SetupIsolateStreams(result);
#endif // !PRODUCT
Heap::Init(result,
is_vm_isolate
? 0 // New gen size 0; VM isolate should only allocate in old.
@ -1126,7 +1123,7 @@ bool Isolate::MakeRunnable() {
}
#ifndef PRODUCT
if (FLAG_support_timeline) {
TimelineStream* stream = GetIsolateStream();
TimelineStream* stream = Timeline::GetIsolateStream();
ASSERT(stream != NULL);
TimelineEvent* event = stream->StartEvent();
if (event != NULL) {

View file

@ -17,7 +17,6 @@
#include "vm/tags.h"
#include "vm/thread.h"
#include "vm/os_thread.h"
#include "vm/timeline.h"
#include "vm/timer.h"
#include "vm/token_position.h"
@ -542,18 +541,6 @@ class Isolate : public BaseIsolate {
ISOLATE_METRIC_LIST(ISOLATE_METRIC_ACCESSOR);
#undef ISOLATE_METRIC_ACCESSOR
#ifndef PRODUCT
#define ISOLATE_TIMELINE_STREAM_ACCESSOR(name, not_used) \
TimelineStream* Get##name##Stream() { return &stream_##name##_; }
ISOLATE_TIMELINE_STREAM_LIST(ISOLATE_TIMELINE_STREAM_ACCESSOR)
#undef ISOLATE_TIMELINE_STREAM_ACCESSOR
#else
#define ISOLATE_TIMELINE_STREAM_ACCESSOR(name, not_used) \
TimelineStream* Get##name##Stream() { return NULL; }
ISOLATE_TIMELINE_STREAM_LIST(ISOLATE_TIMELINE_STREAM_ACCESSOR)
#undef ISOLATE_TIMELINE_STREAM_ACCESSOR
#endif // !PRODUCT
static intptr_t IsolateListLength();
RawGrowableObjectArray* tag_table() const { return tag_table_; }
@ -869,12 +856,6 @@ class Isolate : public BaseIsolate {
ISOLATE_METRIC_LIST(ISOLATE_METRIC_VARIABLE);
#undef ISOLATE_METRIC_VARIABLE
#ifndef PRODUCT
#define ISOLATE_TIMELINE_STREAM_VARIABLE(name, not_used) \
TimelineStream stream_##name##_;
ISOLATE_TIMELINE_STREAM_LIST(ISOLATE_TIMELINE_STREAM_VARIABLE)
#undef ISOLATE_TIMELINE_STREAM_VARIABLE
#endif // !PRODUCT
static Dart_IsolateCreateCallback create_callback_;
static Dart_IsolateShutdownCallback shutdown_callback_;
@ -906,7 +887,6 @@ REUSABLE_HANDLE_LIST(REUSABLE_FRIEND_DECLARATION)
friend class Scavenger; // VisitObjectPointers
friend class ServiceIsolate;
friend class Thread;
friend class Timeline;
friend class IsolateTestHelper;
DISALLOW_COPY_AND_ASSIGN(Isolate);

View file

@ -38,6 +38,7 @@
#include "vm/symbols.h"
#include "vm/tags.h"
#include "vm/thread_registry.h"
#include "vm/timeline.h"
#include "vm/timer.h"
#include "vm/unicode.h"
#include "vm/verified_memory.h"
@ -1104,7 +1105,7 @@ RawError* Object::Init(Isolate* isolate) {
ASSERT(isolate == thread->isolate());
NOT_IN_PRODUCT(
TimelineDurationScope tds(thread,
isolate->GetIsolateStream(),
Timeline::GetIsolateStream(),
"Object::Init");
)

View file

@ -8,6 +8,7 @@
#include "vm/lockers.h"
#include "vm/log.h"
#include "vm/thread_interrupter.h"
#include "vm/timeline.h"
namespace dart {

View file

@ -35,6 +35,7 @@
#include "vm/stack_frame.h"
#include "vm/symbols.h"
#include "vm/tags.h"
#include "vm/timeline.h"
#include "vm/timer.h"
#include "vm/zone.h"
@ -498,7 +499,7 @@ void Parser::ParseCompilationUnit(const Library& library,
VMTagScope tagScope(thread, VMTag::kCompileTopLevelTagId);
#ifndef PRODUCT
TimelineDurationScope tds(thread,
thread->isolate()->GetCompilerStream(),
Timeline::GetCompilerStream(),
"CompileTopLevel");
if (tds.enabled()) {
tds.SetNumArguments(1);
@ -856,7 +857,7 @@ void Parser::ParseClass(const Class& cls) {
const int64_t num_tokes_before = STAT_VALUE(thread, num_tokens_consumed);
#ifndef PRODUCT
TimelineDurationScope tds(thread,
thread->isolate()->GetCompilerStream(),
Timeline::GetCompilerStream(),
"ParseClass");
if (tds.enabled()) {
tds.SetNumArguments(1);
@ -973,7 +974,7 @@ void Parser::ParseFunction(ParsedFunction* parsed_function) {
FLAG_profile_vm);
#ifndef PRODUCT
TimelineDurationScope tds(thread,
thread->isolate()->GetCompilerStream(),
Timeline::GetCompilerStream(),
"ParseFunction");
#endif // !PRODUCT
ASSERT(thread->long_jump_base()->IsSafeToJump());

View file

@ -39,6 +39,7 @@
#include "vm/resolver.h"
#include "vm/symbols.h"
#include "vm/tags.h"
#include "vm/timeline.h"
#include "vm/timer.h"
namespace dart {
@ -1981,7 +1982,7 @@ bool PrecompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) {
bool is_compiled = false;
Zone* const zone = thread()->zone();
#ifndef PRODUCT
TimelineStream* compiler_timeline = isolate()->GetCompilerStream();
TimelineStream* compiler_timeline = Timeline::GetCompilerStream();
#endif // !PRODUCT
CSTAT_TIMER_SCOPE(thread(), codegen_timer);
HANDLESCOPE(thread());

View file

@ -35,6 +35,7 @@
#include "vm/source_report.h"
#include "vm/stack_frame.h"
#include "vm/symbols.h"
#include "vm/timeline.h"
#include "vm/unicode.h"
#include "vm/version.h"
@ -2870,9 +2871,8 @@ static const char* const timeline_streams_enum_names[] = {
"all",
#define DEFINE_NAME(name, unused) \
#name,
ISOLATE_TIMELINE_STREAM_LIST(DEFINE_NAME)
TIMELINE_STREAM_LIST(DEFINE_NAME)
#undef DEFINE_NAME
"VM",
NULL
};
@ -2915,9 +2915,8 @@ static bool SetVMTimelineFlags(Thread* thread, JSONStream* js) {
#define SET_ENABLE_STREAM(name, unused) \
Timeline::SetStream##name##Enabled(HasStream(recorded_streams, #name));
ISOLATE_TIMELINE_STREAM_LIST(SET_ENABLE_STREAM);
TIMELINE_STREAM_LIST(SET_ENABLE_STREAM);
#undef SET_ENABLE_STREAM
Timeline::SetVMStreamEnabled(HasStream(recorded_streams, "VM"));
PrintSuccess(js);

View file

@ -19,6 +19,7 @@
#include "vm/service.h"
#include "vm/symbols.h"
#include "vm/thread_pool.h"
#include "vm/timeline.h"
namespace dart {

View file

@ -138,20 +138,14 @@ void Timeline::InitOnce() {
recorder_ = new TimelineEventRingRecorder();
}
enabled_streams_ = GetEnabledByDefaultTimelineStreams();
vm_stream_.Init("VM", HasStream(enabled_streams_, "VM"), NULL);
vm_api_stream_.Init("API",
HasStream(enabled_streams_, "API"),
&stream_API_enabled_);
// Global overrides.
#define ISOLATE_TIMELINE_STREAM_FLAG_DEFAULT(name, not_used) \
stream_##name##_enabled_ = HasStream(enabled_streams_, #name);
ISOLATE_TIMELINE_STREAM_LIST(ISOLATE_TIMELINE_STREAM_FLAG_DEFAULT)
#undef ISOLATE_TIMELINE_STREAM_FLAG_DEFAULT
}
void Timeline::SetVMStreamEnabled(bool enabled) {
vm_stream_.set_enabled(enabled);
#define TIMELINE_STREAM_FLAG_DEFAULT(name, not_used) \
stream_##name##_enabled_ = HasStream(enabled_streams_, #name); \
stream_##name##_.Init(#name, \
stream_##name##_enabled_, \
&stream_##name##_enabled_);
TIMELINE_STREAM_LIST(TIMELINE_STREAM_FLAG_DEFAULT)
#undef TIMELINE_STREAM_FLAG_DEFAULT
}
@ -177,12 +171,10 @@ void Timeline::Shutdown() {
recorder_->WriteTo(FLAG_timeline_dir);
}
// Disable global streams.
vm_stream_.set_enabled(false);
vm_api_stream_.set_enabled(false);
#define ISOLATE_TIMELINE_STREAM_DISABLE(name, not_used) \
#define TIMELINE_STREAM_DISABLE(name, not_used) \
stream_##name##_enabled_ = false;
ISOLATE_TIMELINE_STREAM_LIST(ISOLATE_TIMELINE_STREAM_DISABLE)
#undef ISOLATE_TIMELINE_STREAM_DISABLE
TIMELINE_STREAM_LIST(TIMELINE_STREAM_DISABLE)
#undef TIMELINE_STREAM_DISABLE
delete recorder_;
recorder_ = NULL;
if (enabled_streams_ != NULL) {
@ -197,30 +189,6 @@ TimelineEventRecorder* Timeline::recorder() {
}
void Timeline::SetupIsolateStreams(Isolate* isolate) {
if (!FLAG_support_timeline) {
return;
}
#define ISOLATE_TIMELINE_STREAM_INIT(name, enabled_by_default) \
isolate->Get##name##Stream()->Init( \
#name, \
(enabled_by_default || HasStream(enabled_streams_, #name)), \
Timeline::Stream##name##EnabledFlag());
ISOLATE_TIMELINE_STREAM_LIST(ISOLATE_TIMELINE_STREAM_INIT);
#undef ISOLATE_TIMELINE_STREAM_INIT
}
TimelineStream* Timeline::GetVMStream() {
return &vm_stream_;
}
TimelineStream* Timeline::GetVMApiStream() {
return &vm_api_stream_;
}
void Timeline::ReclaimCachedBlocksFromThreads() {
TimelineEventRecorder* recorder = Timeline::recorder();
if (recorder == NULL) {
@ -256,9 +224,8 @@ void Timeline::PrintFlagsToJSON(JSONStream* js) {
JSONArray availableStreams(&obj, "availableStreams");
#define ADD_STREAM_NAME(name, not_used) \
availableStreams.AddValue(#name);
ISOLATE_TIMELINE_STREAM_LIST(ADD_STREAM_NAME);
TIMELINE_STREAM_LIST(ADD_STREAM_NAME);
#undef ADD_STREAM_NAME
availableStreams.AddValue("VM");
}
{
JSONArray recordedStreams(&obj, "recordedStreams");
@ -266,11 +233,8 @@ ISOLATE_TIMELINE_STREAM_LIST(ADD_STREAM_NAME);
if (stream_##name##_enabled_) { \
recordedStreams.AddValue(#name); \
}
ISOLATE_TIMELINE_STREAM_LIST(ADD_RECORDED_STREAM_NAME);
TIMELINE_STREAM_LIST(ADD_RECORDED_STREAM_NAME);
#undef ADD_RECORDED_STREAM_NAME
if (vm_stream_.enabled()) {
recordedStreams.AddValue("VM");
}
}
}
@ -286,17 +250,15 @@ void Timeline::Clear() {
TimelineEventRecorder* Timeline::recorder_ = NULL;
TimelineStream Timeline::vm_stream_;
TimelineStream Timeline::vm_api_stream_;
MallocGrowableArray<char*>* Timeline::enabled_streams_ = NULL;
Dart_EmbedderTimelineStartRecording Timeline::start_recording_cb_ = NULL;
Dart_EmbedderTimelineStopRecording Timeline::stop_recording_cb_ = NULL;
Dart_EmbedderTimelineGetTimeline Timeline::get_timeline_cb_ = NULL;
#define ISOLATE_TIMELINE_STREAM_DEFINE_FLAG(name, enabled_by_default) \
bool Timeline::stream_##name##_enabled_ = enabled_by_default;
ISOLATE_TIMELINE_STREAM_LIST(ISOLATE_TIMELINE_STREAM_DEFINE_FLAG)
#undef ISOLATE_TIMELINE_STREAM_DEFINE_FLAG
#define TIMELINE_STREAM_DEFINE(name, enabled_by_default) \
bool Timeline::stream_##name##_enabled_ = enabled_by_default; \
TimelineStream Timeline::stream_##name##_;
TIMELINE_STREAM_LIST(TIMELINE_STREAM_DEFINE)
#undef TIMELINE_STREAM_DEFINE
TimelineEvent::TimelineEvent()
: timestamp0_(0),
@ -1027,14 +989,6 @@ void TimelineEventRecorder::ThreadBlockCompleteEvent(TimelineEvent* event) {
}
void TimelineEventRecorder::PrintEmbedderJSONEvents(JSONStream* events) {
if (Timeline::get_get_timeline_cb() != NULL) {
events->PrintCommaIfNeeded();
Timeline::get_get_timeline_cb()(AppendJSONStreamConsumer, events);
}
}
void TimelineEventRecorder::WriteTo(const char* directory) {
if (!FLAG_support_service) {
return;
@ -1174,7 +1128,6 @@ void TimelineEventRingRecorder::PrintJSON(JSONStream* js,
JSONArray events(&topLevel, "traceEvents");
PrintJSONMeta(&events);
PrintJSONEvents(&events, filter);
PrintEmbedderJSONEvents(js);
}
}
@ -1186,7 +1139,6 @@ void TimelineEventRingRecorder::PrintTraceEvent(JSONStream* js,
}
JSONArray events(js);
PrintJSONEvents(&events, filter);
PrintEmbedderJSONEvents(js);
}
@ -1309,7 +1261,6 @@ void TimelineEventEndlessRecorder::PrintJSON(JSONStream* js,
JSONArray events(&topLevel, "traceEvents");
PrintJSONMeta(&events);
PrintJSONEvents(&events, filter);
PrintEmbedderJSONEvents(js);
}
}
@ -1322,7 +1273,6 @@ void TimelineEventEndlessRecorder::PrintTraceEvent(
}
JSONArray events(js);
PrintJSONEvents(&events, filter);
PrintEmbedderJSONEvents(js);
}

View file

@ -28,7 +28,7 @@ class TimelineStream;
class Zone;
// (name, enabled by default for isolate).
#define ISOLATE_TIMELINE_STREAM_LIST(V) \
#define TIMELINE_STREAM_LIST(V) \
V(API, false) \
V(Compiler, false) \
V(Dart, false) \
@ -36,6 +36,7 @@ class Zone;
V(Embedder, false) \
V(GC, false) \
V(Isolate, false) \
V(VM, false)
class Timeline : public AllStatic {
public:
@ -48,12 +49,6 @@ class Timeline : public AllStatic {
// Access the global recorder. Not thread safe.
static TimelineEventRecorder* recorder();
static void SetupIsolateStreams(Isolate* isolate);
static TimelineStream* GetVMStream();
static TimelineStream* GetVMApiStream();
// Reclaim all |TimelineEventBlocks|s that are cached by threads.
static void ReclaimCachedBlocksFromThreads();
@ -62,7 +57,12 @@ class Timeline : public AllStatic {
// Print information about streams to JSON.
static void PrintFlagsToJSON(JSONStream* json);
#define ISOLATE_TIMELINE_STREAM_FLAGS(name, not_used) \
#define TIMELINE_STREAM_ACCESSOR(name, not_used) \
static TimelineStream* Get##name##Stream() { return &stream_##name##_; }
TIMELINE_STREAM_LIST(TIMELINE_STREAM_ACCESSOR)
#undef TIMELINE_STREAM_ACCESSOR
#define TIMELINE_STREAM_FLAGS(name, not_used) \
static const bool* Stream##name##EnabledFlag() { \
return &stream_##name##_enabled_; \
} \
@ -70,9 +70,8 @@ class Timeline : public AllStatic {
StreamStateChange(#name, stream_##name##_enabled_, enabled); \
stream_##name##_enabled_ = enabled; \
}
ISOLATE_TIMELINE_STREAM_LIST(ISOLATE_TIMELINE_STREAM_FLAGS)
#undef ISOLATE_TIMELINE_STREAM_FLAGS
static void SetVMStreamEnabled(bool enabled);
TIMELINE_STREAM_LIST(TIMELINE_STREAM_FLAGS)
#undef TIMELINE_STREAM_FLAGS
static void set_start_recording_cb(
Dart_EmbedderTimelineStartRecording start_recording_cb) {
@ -92,29 +91,18 @@ class Timeline : public AllStatic {
return stop_recording_cb_;
}
static void set_get_timeline_cb(
Dart_EmbedderTimelineGetTimeline get_timeline_cb) {
get_timeline_cb_ = get_timeline_cb;
}
static Dart_EmbedderTimelineGetTimeline get_get_timeline_cb() {
return get_timeline_cb_;
}
private:
static void StreamStateChange(const char* stream_name, bool prev, bool curr);
static TimelineEventRecorder* recorder_;
static TimelineStream vm_stream_;
static TimelineStream vm_api_stream_;
static MallocGrowableArray<char*>* enabled_streams_;
static Dart_EmbedderTimelineStartRecording start_recording_cb_;
static Dart_EmbedderTimelineStopRecording stop_recording_cb_;
static Dart_EmbedderTimelineGetTimeline get_timeline_cb_;
#define ISOLATE_TIMELINE_STREAM_DECLARE_FLAG(name, not_used) \
static bool stream_##name##_enabled_;
ISOLATE_TIMELINE_STREAM_LIST(ISOLATE_TIMELINE_STREAM_DECLARE_FLAG)
#undef ISOLATE_TIMELINE_STREAM_DECLARE_FLAG
#define TIMELINE_STREAM_DECLARE(name, not_used) \
static bool stream_##name##_enabled_; \
static TimelineStream stream_##name##_;
TIMELINE_STREAM_LIST(TIMELINE_STREAM_DECLARE)
#undef TIMELINE_STREAM_DECLARE
friend class TimelineRecorderOverride;
friend class ReclaimBlocksIsolateVisitor;
@ -222,6 +210,10 @@ class TimelineEvent {
return thread_;
}
void set_thread(ThreadId tid) {
thread_ = tid;
}
Dart_Port isolate_id() const {
return isolate_id_;
}
@ -386,7 +378,7 @@ class TimelineStream {
#ifndef PRODUCT
#define TIMELINE_FUNCTION_COMPILATION_DURATION(thread, suffix, function) \
TimelineDurationScope tds(thread, \
thread->isolate()->GetCompilerStream(), \
Timeline::GetCompilerStream(), \
"Compile" suffix); \
if (tds.enabled()) { \
tds.SetNumArguments(1); \
@ -678,7 +670,6 @@ class TimelineEventRecorder {
void PrintJSONMeta(JSONArray* array) const;
TimelineEvent* ThreadBlockStartEvent();
void ThreadBlockCompleteEvent(TimelineEvent* event);
void PrintEmbedderJSONEvents(JSONStream* events);
Mutex lock_;
uintptr_t async_id_;