Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Jitted Code Dropping Feature implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
sergign60 committed Mar 27, 2017
1 parent 48e2448 commit b4d51a5
Show file tree
Hide file tree
Showing 16 changed files with 786 additions and 20 deletions.
3 changes: 3 additions & 0 deletions src/debug/daccess/fntableaccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ typedef struct _FakeHpRealCodeHdr
LPVOID phdrJitGCInfo; // changed from BYTE*
#if defined (FEATURE_GDBJIT)
LPVOID pCalledMethods;
#endif
#if defined(FEATURE_JIT_DROPPING)
LPVOID phdrHeapList;
#endif
LPVOID hdrMDesc; // changed from MethodDesc*
DWORD nUnwindInfos;
Expand Down
7 changes: 7 additions & 0 deletions src/inc/clrconfigvalues.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ RETAIL_CONFIG_DWORD_INFO(EXTERNAL_FinalizeOnShutdown, W("FinalizeOnShutdown"), D
// ARM
//
RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_ARMEnabled, W("ARMEnabled"), (DWORD)0, "Set it to 1 to enable ARM")
RETAIL_CONFIG_DWORD_INFO(INTERNAL_JitDropEnabled, W("JitDropEnabled"), (DWORD)0, "Set it to 1 to enable Jit Dropping")
RETAIL_CONFIG_DWORD_INFO(INTERNAL_JitDropMemThreshold, W("JitDropMemThreshold"), (DWORD)0, "Dropping jits when code heap usage is larger than this (in bytes)")
RETAIL_CONFIG_DWORD_INFO(INTERNAL_JitDropMethodSizeThreshold, W("JitDropMethodSizeThreshold"), (DWORD)0, "Dropping jit for methods whose native code size larger than this (in bytes)")
RETAIL_CONFIG_DWORD_INFO(INTERNAL_JitDropMaxLevel, W("JitDropMaxLevel"), (DWORD)0, "Dropping jits for all methods as it possible")
RETAIL_CONFIG_DWORD_INFO(INTERNAL_JitDropPrintStat, W("JitDropPrintStat"), (DWORD)0, "Print statistics about Jit Dropping")
RETAIL_CONFIG_DWORD_INFO(INTERNAL_JitDropMinVal, W("JitDropMinVal"), (DWORD)0, "Dropping jit if the value of the inner counter greater than this value (for debugging purpose only)")
RETAIL_CONFIG_DWORD_INFO(INTERNAL_JitDropMaxVal, W("JitDropMaxVal"), (DWORD)0xffffffff, "Dropping jit the value of the inner counter less then this value (for debuggin purpose only)")

//
// Assembly Loader
Expand Down
6 changes: 3 additions & 3 deletions src/inc/loaderheap.h
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ class UnlockedLoaderHeap
#endif

protected:
void *UnlockedAllocMemForCode_NoThrow(size_t dwHeaderSize, size_t dwCodeSize, DWORD dwCodeAlignment);
void *UnlockedAllocMemForCode_NoThrow(size_t dwHeaderSize, size_t dwCodeSize, DWORD dwCodeAlignment, bool updateAllocPtr = true);

void UnlockedSetReservedRegion(BYTE* dwReservedRegionAddress, SIZE_T dwReservedRegionSize, BOOL fReleaseMemory);
};
Expand Down Expand Up @@ -835,10 +835,10 @@ class ExplicitControlLoaderHeap : public UnlockedLoaderHeap


public:
void *AllocMemForCode_NoThrow(size_t dwHeaderSize, size_t dwCodeSize, DWORD dwCodeAlignment)
void *AllocMemForCode_NoThrow(size_t dwHeaderSize, size_t dwCodeSize, DWORD dwCodeAlignment, bool updateAllocPtr = true)
{
WRAPPER_NO_CONTRACT;
return UnlockedAllocMemForCode_NoThrow(dwHeaderSize, dwCodeSize, dwCodeAlignment);
return UnlockedAllocMemForCode_NoThrow(dwHeaderSize, dwCodeSize, dwCodeAlignment, updateAllocPtr);
}

void SetReservedRegion(BYTE* dwReservedRegionAddress, SIZE_T dwReservedRegionSize, BOOL fReleaseMemory)
Expand Down
6 changes: 5 additions & 1 deletion src/jit/codegencommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3213,7 +3213,11 @@ void CodeGen::genGenerateCode(void** codePtr, ULONG* nativeSizeOfCode)
}
#endif // EMIT_TRACK_STACK_DEPTH

*nativeSizeOfCode = codeSize;
if (nativeSizeOfCode != nullptr)
{
*nativeSizeOfCode = codeSize;
}

compiler->info.compNativeCodeSize = (UNATIVE_OFFSET)codeSize;

// printf("%6u bytes of code generated for %s.%s\n", codeSize, compiler->info.compFullName);
Expand Down
5 changes: 3 additions & 2 deletions src/utilcode/loaderheap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1720,7 +1720,7 @@ void *UnlockedLoaderHeap::UnlockedAllocAlignedMem(size_t dwRequestedSize,



void *UnlockedLoaderHeap::UnlockedAllocMemForCode_NoThrow(size_t dwHeaderSize, size_t dwCodeSize, DWORD dwCodeAlignment)
void *UnlockedLoaderHeap::UnlockedAllocMemForCode_NoThrow(size_t dwHeaderSize, size_t dwCodeSize, DWORD dwCodeAlignment, bool updateAllocPtr)
{
CONTRACT(void*)
{
Expand Down Expand Up @@ -1758,7 +1758,8 @@ void *UnlockedLoaderHeap::UnlockedAllocMemForCode_NoThrow(size_t dwHeaderSize, s

BYTE *pResult = (BYTE *)ALIGN_UP(m_pAllocPtr + dwHeaderSize, dwCodeAlignment);
EtwAllocRequest(this, pResult, (pResult + dwCodeSize) - m_pAllocPtr);
m_pAllocPtr = pResult + dwCodeSize;
if (updateAllocPtr)
m_pAllocPtr = pResult + dwCodeSize;

RETURN pResult;
}
Expand Down
4 changes: 4 additions & 0 deletions src/vm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ if(FEATURE_GDBJIT)
add_definitions(-DFEATURE_GDBJIT)
endif(FEATURE_GDBJIT)

if(FEATURE_JIT_DROPPING)
add_definitions(-DFEATURE_JIT_DROPPING)
endif(FEATURE_JIT_DROPPING)

set(VM_SOURCES_DAC_AND_WKS_COMMON
appdomain.cpp
array.cpp
Expand Down
Loading

0 comments on commit b4d51a5

Please sign in to comment.