| 1 |
/** |
| 2 |
Compilation time tracing, -ftime-trace. |
| 3 |
|
| 4 |
The time trace profile is output in the Chrome Trace Event Format, described |
| 5 |
here: https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview |
| 6 |
|
| 7 |
This file is originally from LDC (the LLVM D compiler). |
| 8 |
|
| 9 |
Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved |
| 10 |
Authors: Johan Engelen, Max Haughton, Dennis Korpel |
| 11 |
License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) |
| 12 |
Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/timetrace.d, common/_timetrace.d) |
| 13 |
Documentation: https://dlang.org/phobos/dmd_common_timetrace.html |
| 14 |
Coverage: https://codecov.io/gh/dlang/dmd/src/master/compiler/src/dmd/timetrace.d |
| 15 |
*/ |
| 16 |
module dmd.timetrace; |
| 17 |
|
| 18 |
import dmd.dsymbol; |
| 19 |
import dmd.expression; |
| 20 |
|
| 21 |
/** |
| 22 |
* Start a new time trace event |
| 23 |
* |
| 24 |
* Details of the event will be passed as delegates to `timeTraceEndEvent` so |
| 25 |
* they're only generated when the event is actually written. |
| 26 |
* |
| 27 |
* Params: |
| 28 |
* eventType = what compilation stage the event belongs to |
| 29 |
* (redundant with the eventType of `timeTraceEndEvent` but used by GDC) |
| 30 |
*/ |
| 31 |
extern (C++) |
| 32 |
void timeTraceBeginEvent(TimeTraceEventType eventType) |
| 33 |
{ |
| 34 |
} |
| 35 |
|
| 36 |
/** |
| 37 |
* End a time tracing event, optionally updating the event name and details |
| 38 |
* with a delegate. Delegates are used to prevent spending time on string |
| 39 |
* generation when an event is too small to be generated anyway. |
| 40 |
* |
| 41 |
* Params: |
| 42 |
* eventType = what compilation stage the event belongs to |
| 43 |
* sym = Dsymbol which was analyzed, used to generate 'name' and 'detail' |
| 44 |
* e = Expression which was analyzed, used to generate 'name' and 'detail' |
| 45 |
* detail = custom lazy string for 'detail' of event |
| 46 |
*/ |
| 47 |
extern (C++) |
| 48 |
void timeTraceEndEvent(TimeTraceEventType eventType) |
| 49 |
{ |
| 50 |
} |
| 51 |
|
| 52 |
/// ditto |
| 53 |
void timeTraceEndEvent(TimeTraceEventType eventType, Dsymbol sym, scope const(char)[] delegate() detail = null) |
| 54 |
{ |
| 55 |
return timeTraceEndEvent(eventType); |
| 56 |
} |
| 57 |
|
| 58 |
/// ditto |
| 59 |
extern (C++) |
| 60 |
void timeTraceEndEvent(TimeTraceEventType eventType, Expression e) |
| 61 |
{ |
| 62 |
return timeTraceEndEvent(eventType); |
| 63 |
} |
| 64 |
|
| 65 |
/// Identifies which compilation stage the event is associated to |
| 66 |
enum TimeTraceEventType |
| 67 |
{ |
| 68 |
generic, |
| 69 |
parseGeneral, |
| 70 |
parse, |
| 71 |
semaGeneral, |
| 72 |
sema1Import, |
| 73 |
sema1Module, |
| 74 |
sema2, |
| 75 |
sema3, |
| 76 |
ctfe, |
| 77 |
ctfeCall, |
| 78 |
codegenGlobal, |
| 79 |
codegenModule, |
| 80 |
codegenFunction, |
| 81 |
link, |
| 82 |
} |