diff options
author | dotnet-bot <dotnet-bot@microsoft.com> | 2015-01-30 14:14:42 -0800 |
---|---|---|
committer | dotnet-bot <dotnet-bot@microsoft.com> | 2015-01-30 14:14:42 -0800 |
commit | ef1e2ab328087c61a6878c1e84f4fc5d710aebce (patch) | |
tree | dee1bbb89e9d722e16b0d1485e3cdd1b6c8e2cfa /src/vm/readytoruninfo.h | |
download | coreclr-ef1e2ab328087c61a6878c1e84f4fc5d710aebce.tar.gz coreclr-ef1e2ab328087c61a6878c1e84f4fc5d710aebce.tar.bz2 coreclr-ef1e2ab328087c61a6878c1e84f4fc5d710aebce.zip |
Initial commit to populate CoreCLR repo
[tfs-changeset: 1407945]
Diffstat (limited to 'src/vm/readytoruninfo.h')
-rw-r--r-- | src/vm/readytoruninfo.h | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/src/vm/readytoruninfo.h b/src/vm/readytoruninfo.h new file mode 100644 index 0000000000..8ddebcb735 --- /dev/null +++ b/src/vm/readytoruninfo.h @@ -0,0 +1,131 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// +// =========================================================================== +// File: ReadyToRunInfo.h +// + +// +// Runtime support for Ready to Run +// =========================================================================== + +#ifndef _READYTORUNINFO_H_ +#define _READYTORUNINFO_H_ + +#include "nativeformatreader.h" + +typedef DPTR(struct READYTORUN_SECTION) PTR_READYTORUN_SECTION; + +typedef DPTR(class ReadyToRunInfo) PTR_ReadyToRunInfo; +class ReadyToRunInfo +{ + friend class ReadyToRunJitManager; + + PTR_Module m_pModule; + + PTR_PEImageLayout m_pLayout; + PTR_READYTORUN_HEADER m_pHeader; + + PTR_RUNTIME_FUNCTION m_pRuntimeFunctions; + DWORD m_nRuntimeFunctions; + + PTR_CORCOMPILE_IMPORT_SECTION m_pImportSections; + DWORD m_nImportSections; + + NativeFormat::NativeReader m_nativeReader; + NativeFormat::NativeArray m_methodDefEntryPoints; + + Crst m_Crst; + PtrHashMap m_entryPointToMethodDescMap; + + ReadyToRunInfo(Module * pModule, PEImageLayout * pLayout, READYTORUN_HEADER * pHeader); + +public: + static BOOL IsReadyToRunEnabled(); + + static PTR_ReadyToRunInfo Initialize(Module * pModule, AllocMemTracker *pamTracker); + + PCODE GetEntryPoint(MethodDesc * pMD, BOOL fFixups = TRUE); + + MethodDesc * GetMethodDescForEntryPoint(PCODE entryPoint); + + BOOL SkipTypeValidation() + { + LIMITED_METHOD_CONTRACT; + return m_pHeader->Flags & READYTORUN_FLAG_SKIP_TYPE_VALIDATION; + } + + PTR_PEImageLayout GetImage() + { + LIMITED_METHOD_CONTRACT; + return m_pLayout; + } + + IMAGE_DATA_DIRECTORY * FindSection(DWORD type); + + PTR_CORCOMPILE_IMPORT_SECTION GetImportSections(COUNT_T * pCount) + { + LIMITED_METHOD_CONTRACT; + *pCount = m_nImportSections; + return m_pImportSections; + } + + PTR_CORCOMPILE_IMPORT_SECTION GetImportSectionFromIndex(COUNT_T index) + { + LIMITED_METHOD_CONTRACT; + _ASSERTE(index < m_nImportSections); + return m_pImportSections + index; + } + + PTR_CORCOMPILE_IMPORT_SECTION GetImportSectionForRVA(RVA rva) + { + LIMITED_METHOD_CONTRACT; + + PTR_CORCOMPILE_IMPORT_SECTION pEnd = m_pImportSections + m_nImportSections; + for (PTR_CORCOMPILE_IMPORT_SECTION pSection = m_pImportSections; pSection < pEnd; pSection++) + { + if (rva >= VAL32(pSection->Section.VirtualAddress) && rva < VAL32(pSection->Section.VirtualAddress) + VAL32(pSection->Section.Size)) + return pSection; + } + + return NULL; + } + + PTR_BYTE GetDebugInfo(PTR_RUNTIME_FUNCTION pRuntimeFunction); + + class MethodIterator + { + ReadyToRunInfo * m_pInfo; + int m_methodDefIndex; + + public: + MethodIterator(ReadyToRunInfo * pInfo) + : m_pInfo(pInfo), m_methodDefIndex(-1) + { + } + + BOOL Next(); + + MethodDesc * GetMethodDesc(); + PCODE GetMethodStartAddress(); + }; + + static DWORD GetFieldBaseOffset(MethodTable * pMT); +}; + +class DynamicHelpers +{ +public: + static PCODE CreateHelper(LoaderAllocator * pAllocator, TADDR arg, PCODE target); + static PCODE CreateHelperWithArg(LoaderAllocator * pAllocator, TADDR arg, PCODE target); + static PCODE CreateHelper(LoaderAllocator * pAllocator, TADDR arg, TADDR arg2, PCODE target); + static PCODE CreateHelperArgMove(LoaderAllocator * pAllocator, TADDR arg, PCODE target); + static PCODE CreateReturn(LoaderAllocator * pAllocator); + static PCODE CreateReturnConst(LoaderAllocator * pAllocator, TADDR arg); + static PCODE CreateReturnIndirConst(LoaderAllocator * pAllocator, TADDR arg, INT8 offset); + static PCODE CreateHelperWithTwoArgs(LoaderAllocator * pAllocator, TADDR arg, PCODE target); + static PCODE CreateHelperWithTwoArgs(LoaderAllocator * pAllocator, TADDR arg, TADDR arg2, PCODE target); +}; + +#endif // _READYTORUNINFO_H_ |