Skip to content

Commit

Permalink
[MERGE #1221 @digitalinfinity] Fix linux build break
Browse files Browse the repository at this point in the history
Merge pull request #1221 from digitalinfinity:vtune_fnix

- Add VTune profiling code to Linux build
- Wrap JIT specific part of the profiler under ENABLE_NATIVE_CODEGEN
  • Loading branch information
digitalinfinity committed Jun 30, 2016
2 parents fc4409d + 0ffbcef commit dc7e814
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/Runtime/Base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ add_library (Chakra.Runtime.Base STATIC
ThreadContextTlsEntry.cpp
ThreadServiceWrapperBase.cpp
Utf8SourceInfo.cpp
VTuneChakraProfile.cpp
# WindowsFoundationAdapter.cpp
# WindowsGlobalizationAdapter.cpp
)
Expand Down
8 changes: 8 additions & 0 deletions lib/Runtime/Base/VTuneChakraProfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,30 @@ bool VTuneChakraProfile::isJitProfilingActive = false;
//
void VTuneChakraProfile::Register()
{
#if ENABLE_NATIVE_CODEGEN
isJitProfilingActive = (iJIT_IsProfilingActive() == iJIT_SAMPLING_ON);
#endif
}

//
// Unregister and notify VTune that even sampling is done.
//
void VTuneChakraProfile::UnRegister()
{
#if ENABLE_NATIVE_CODEGEN
if(isJitProfilingActive)
{
iJIT_NotifyEvent(iJVM_EVENT_TYPE_SHUTDOWN, NULL);
}
#endif
}

//
// Log JIT method native load event to VTune
//
void VTuneChakraProfile::LogMethodNativeLoadEvent(Js::FunctionBody* body, Js::FunctionEntryPointInfo* entryPoint)
{
#if ENABLE_NATIVE_CODEGEN
if (isJitProfilingActive)
{
iJIT_Method_Load methodInfo;
Expand Down Expand Up @@ -105,13 +110,15 @@ void VTuneChakraProfile::LogMethodNativeLoadEvent(Js::FunctionBody* body, Js::Fu
HeapDeleteArray(length, utf8MethodName);
}
}
#endif
}

//
// Log loop body load event to VTune
//
void VTuneChakraProfile::LogLoopBodyLoadEvent(Js::FunctionBody* body, Js::LoopHeader* loopHeader, Js::LoopEntryPointInfo* entryPoint, uint16 loopNumber)
{
#if ENABLE_NATIVE_CODEGEN
if (isJitProfilingActive)
{
iJIT_Method_Load methodInfo;
Expand Down Expand Up @@ -144,6 +151,7 @@ void VTuneChakraProfile::LogLoopBodyLoadEvent(Js::FunctionBody* body, Js::LoopHe
HeapDeleteArray(length, utf8MethodName);
}
}
#endif
}

//
Expand Down
2 changes: 1 addition & 1 deletion lib/Runtime/Base/VTuneChakraProfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class VTuneChakraProfile
static void Register();
static void UnRegister();

static void LogMethodNativeLoadEvent(Js::FunctionBody* body, Js::FunctionEntryPointInfo* entryPoint);
static void LogMethodNativeLoadEvent(Js::FunctionBody* body, Js::FunctionEntryPointInfo* entryPoint);
static void LogLoopBodyLoadEvent(Js::FunctionBody* body, Js::LoopHeader* loopHeader, Js::LoopEntryPointInfo* entryPoint, uint16 loopNumber);

static const utf8char_t DynamicCode[];
Expand Down

0 comments on commit dc7e814

Please sign in to comment.