File tree Expand file tree Collapse file tree 1 file changed +29
-1
lines changed Expand file tree Collapse file tree 1 file changed +29
-1
lines changed Original file line number Diff line number Diff line change 2929
3030#include " ../inc/llvm/ELF.h"
3131
32+ #if defined(HOST_AMD64)
33+ #include < x86intrin.h>
34+ #endif
35+
3236SET_DEFAULT_DEBUG_CHANNEL (MISC);
3337
3438namespace
@@ -37,6 +41,7 @@ namespace
3741 {
3842 JIT_DUMP_MAGIC = 0x4A695444 ,
3943 JIT_DUMP_VERSION = 1 ,
44+ JITDUMP_FLAGS_ARCH_TIMESTAMP = 1 << 0 ,
4045
4146#if defined(HOST_X86)
4247 ELF_MACHINE = EM_386,
@@ -61,13 +66,36 @@ namespace
6166 JIT_CODE_LOAD = 0 ,
6267 };
6368
69+ static bool UseArchTimeStamp ()
70+ {
71+ static bool initialized = false ;
72+ static bool useArchTimestamp = false ;
73+
74+ if (!initialized)
75+ {
76+ #if defined(HOST_AMD64)
77+ const char * archTimestamp = getenv (" JITDUMP_USE_ARCH_TIMESTAMP" );
78+ useArchTimestamp = (archTimestamp != nullptr && strcmp (archTimestamp, " 1" ) == 0 );
79+ #endif
80+ initialized = true ;
81+ }
82+
83+ return useArchTimestamp;
84+ }
85+
6486 static uint64_t GetTimeStampNS ()
6587 {
88+ #if defined(HOST_AMD64)
89+ if (UseArchTimeStamp ()) {
90+ return static_cast <uint64_t >(__rdtsc ());
91+ }
92+ #endif
6693 LARGE_INTEGER result;
6794 QueryPerformanceCounter (&result);
6895 return result.QuadPart ;
6996 }
7097
98+
7199 struct FileHeader
72100 {
73101 FileHeader () :
@@ -78,7 +106,7 @@ namespace
78106 pad1 (0 ),
79107 pid (getpid()),
80108 timestamp (GetTimeStampNS()),
81- flags (0 )
109+ flags (UseArchTimeStamp() ? JITDUMP_FLAGS_ARCH_TIMESTAMP : 0 )
82110 {}
83111
84112 uint32_t magic;
You can’t perform that action at this time.
0 commit comments