|
16 | 16 | //
|
17 | 17 |
|
18 | 18 | #import <AsyncDisplayKit/ASAvailability.h>
|
| 19 | +#import <Foundation/Foundation.h> |
19 | 20 |
|
20 |
| -#pragma once |
| 21 | +/// The signposts we use. Signposts are grouped by color. The SystemTrace.tracetemplate file |
| 22 | +/// should be kept up-to-date with these values. |
| 23 | +typedef NS_ENUM(uint32_t, ASSignpostName) { |
| 24 | + // Collection/Table (Blue) |
| 25 | + ASSignpostDataControllerBatch = 300, // Alloc/layout nodes before collection update. |
| 26 | + ASSignpostRangeControllerUpdate, // Ranges update pass. |
| 27 | + ASSignpostCollectionUpdate, // Entire update process, from -endUpdates to [super perform…] |
21 | 28 |
|
| 29 | + // Rendering (Green) |
| 30 | + ASSignpostLayerDisplay = 325, // Client display callout. |
| 31 | + ASSignpostRunLoopQueueBatch, // One batch of ASRunLoopQueue. |
| 32 | + |
| 33 | + // Layout (Purple) |
| 34 | + ASSignpostCalculateLayout = 350, // Start of calculateLayoutThatFits to end. Max 1 per thread. |
| 35 | + |
| 36 | + // Misc (Orange) |
| 37 | + ASSignpostDeallocQueueDrain = 375, // One chunk of dealloc queue work. arg0 is count. |
| 38 | + ASSignpostCATransactionLayout, // The CA transaction commit layout phase. |
| 39 | + ASSignpostCATransactionCommit // The CA transaction commit post-layout phase. |
| 40 | +}; |
| 41 | + |
| 42 | +typedef NS_ENUM(uintptr_t, ASSignpostColor) { |
| 43 | + ASSignpostColorBlue, |
| 44 | + ASSignpostColorGreen, |
| 45 | + ASSignpostColorPurple, |
| 46 | + ASSignpostColorOrange, |
| 47 | + ASSignpostColorRed, |
| 48 | + ASSignpostColorDefault |
| 49 | +}; |
| 50 | + |
| 51 | +static inline ASSignpostColor ASSignpostGetColor(ASSignpostName name, ASSignpostColor colorPref) { |
| 52 | + if (colorPref == ASSignpostColorDefault) { |
| 53 | + return (ASSignpostColor)((name / 25) % 4); |
| 54 | + } else { |
| 55 | + return colorPref; |
| 56 | + } |
| 57 | +} |
22 | 58 |
|
23 | 59 | #define ASMultiplexImageNodeLogDebug(...)
|
24 | 60 | #define ASMultiplexImageNodeCLogDebug(...)
|
25 | 61 |
|
26 | 62 | #define ASMultiplexImageNodeLogError(...)
|
27 | 63 | #define ASMultiplexImageNodeCLogError(...)
|
28 | 64 |
|
29 |
| -// Note: `<sys/kdebug_signpost.h>` only exists in Xcode 8 and later. |
30 |
| -#if defined(PROFILE) && __has_include(<sys/kdebug_signpost.h>) |
| 65 | +#define AS_KDEBUG_ENABLE defined(PROFILE) && __has_include(<sys/kdebug_signpost.h>) |
| 66 | + |
| 67 | +#if AS_KDEBUG_ENABLE |
31 | 68 |
|
32 | 69 | #import <sys/kdebug_signpost.h>
|
33 | 70 |
|
|
45 | 82 | #define APPSDBG_CODE(SubClass,code) KDBG_CODE(DBG_APPS, SubClass, code)
|
46 | 83 | #endif
|
47 | 84 |
|
48 |
| -#define ASProfilingSignpost(x) \ |
49 |
| - AS_AT_LEAST_IOS10 ? kdebug_signpost(x, 0, 0, 0, (uint32_t)(x % 4)) \ |
50 |
| - : syscall(SYS_kdebug_trace, APPSDBG_CODE(DBG_MACH_CHUD, x) | DBG_FUNC_NONE, 0, 0, 0, (uint32_t)(x % 4)); |
| 85 | +// Currently we'll reserve arg3. |
| 86 | +#define ASSignpost(name, identifier, arg2, color) \ |
| 87 | + AS_AT_LEAST_IOS10 ? kdebug_signpost(name, (uintptr_t)identifier, (uintptr_t)arg2, 0, ASSignpostGetColor(name, color)) \ |
| 88 | + : syscall(SYS_kdebug_trace, APPSDBG_CODE(DBG_MACH_CHUD, name) | DBG_FUNC_NONE, (uintptr_t)identifier, (uintptr_t)arg2, 0, ASSignpostGetColor(name, color)); |
| 89 | + |
| 90 | +#define ASSignpostStartCustom(name, identifier, arg2) \ |
| 91 | + AS_AT_LEAST_IOS10 ? kdebug_signpost_start(name, (uintptr_t)identifier, (uintptr_t)arg2, 0, 0) \ |
| 92 | + : syscall(SYS_kdebug_trace, APPSDBG_CODE(DBG_MACH_CHUD, name) | DBG_FUNC_START, (uintptr_t)identifier, (uintptr_t)arg2, 0, 0); |
| 93 | +#define ASSignpostStart(name) ASSignpostStartCustom(name, self, 0) |
51 | 94 |
|
52 |
| -#define ASProfilingSignpostStart(x, y) \ |
53 |
| - AS_AT_LEAST_IOS10 ? kdebug_signpost_start((uint32_t)x, (uintptr_t)y, 0, 0, (uint32_t)(x % 4)) \ |
54 |
| - : syscall(SYS_kdebug_trace, APPSDBG_CODE(DBG_MACH_CHUD, x) | DBG_FUNC_START, (uintptr_t)y, 0, 0, (uint32_t)(x % 4)); |
| 95 | +#define ASSignpostEndCustom(name, identifier, arg2, color) \ |
| 96 | + AS_AT_LEAST_IOS10 ? kdebug_signpost_end(name, (uintptr_t)identifier, (uintptr_t)arg2, 0, ASSignpostGetColor(name, color)) \ |
| 97 | + : syscall(SYS_kdebug_trace, APPSDBG_CODE(DBG_MACH_CHUD, name) | DBG_FUNC_END, (uintptr_t)identifier, (uintptr_t)arg2, 0, ASSignpostGetColor(name, color)); |
| 98 | +#define ASSignpostEnd(name) ASSignpostEndCustom(name, self, 0, ASSignpostColorDefault) |
55 | 99 |
|
56 |
| -#define ASProfilingSignpostEnd(x, y) \ |
57 |
| - AS_AT_LEAST_IOS10 ? kdebug_signpost_end((uint32_t)x, (uintptr_t)y, 0, 0, (uint32_t)(x % 4)) \ |
58 |
| - : syscall(SYS_kdebug_trace, APPSDBG_CODE(DBG_MACH_CHUD, x) | DBG_FUNC_END, (uintptr_t)y, 0, 0, (uint32_t)(x % 4)); |
59 | 100 | #else
|
60 | 101 |
|
61 |
| -#define ASProfilingSignpost(x) |
62 |
| -#define ASProfilingSignpostStart(x, y) |
63 |
| -#define ASProfilingSignpostEnd(x, y) |
| 102 | +#define ASSignpost(name, identifier, arg2, color) |
| 103 | +#define ASSignpostStartCustom(name, identifier, arg2) |
| 104 | +#define ASSignpostStart(name) |
| 105 | +#define ASSignpostEndCustom(name, identifier, arg2, color) |
| 106 | +#define ASSignpostEnd(name) |
64 | 107 |
|
65 | 108 | #endif
|
0 commit comments