diff --git a/src/coreclr/classlibnative/bcltype/arraynative.cpp b/src/coreclr/classlibnative/bcltype/arraynative.cpp index 284573d219eb2..738d3f9a76b15 100644 --- a/src/coreclr/classlibnative/bcltype/arraynative.cpp +++ b/src/coreclr/classlibnative/bcltype/arraynative.cpp @@ -1081,9 +1081,6 @@ FCIMPL2_IV(void, ArrayNative::InitializeArray, ArrayBase* pArrayRef, FCALLRuntim if (!pField->IsRVA()) COMPlusThrow(kArgumentException); - // Report the RVA field to the logger. - g_IBCLogger.LogRVADataAccess(pField); - // Note that we do not check that the field is actually in the PE file that is initializing // the array. Basically the data being published is can be accessed by anyone with the proper // permissions (C# marks these as assembly visibility, and thus are protected from outside @@ -1161,9 +1158,6 @@ FCIMPL3_VVI(void*, ArrayNative::GetSpanDataFrom, FCALLRuntimeFieldHandle structF DWORD totalSize = pField->LoadSize(); DWORD targetTypeSize = targetTypeHandle.GetSize(); - // Report the RVA field to the logger. - g_IBCLogger.LogRVADataAccess(pField); - data = pField->GetStaticAddressHandle(NULL); _ASSERTE(data != NULL); _ASSERTE(count != NULL); diff --git a/src/coreclr/inc/corbbtprof.h b/src/coreclr/inc/corbbtprof.h deleted file mode 100644 index 78df6c6a79bda..0000000000000 --- a/src/coreclr/inc/corbbtprof.h +++ /dev/null @@ -1,596 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*****************************************************************************\ -* * -* CorBBTProf.h - File format for profile data * -* * -* Version 1.0 * -******************************************************************************* -* * -* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY * -* KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE * -* IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR * -* PURPOSE. * -* * -\*****************************************************************************/ - -#ifndef _COR_BBTPROF_H_ -#define _COR_BBTPROF_H_ - -#include -#include - -const CorTokenType ibcExternalNamespace = CorTokenType(0x61000000); -const CorTokenType ibcExternalType = CorTokenType(0x62000000); -const CorTokenType ibcExternalSignature = CorTokenType(0x63000000); -const CorTokenType ibcExternalMethod = CorTokenType(0x64000000); -const CorTokenType ibcTypeSpec = CorTokenType(0x68000000); -const CorTokenType ibcMethodSpec = CorTokenType(0x69000000); - -typedef mdToken idExternalNamespace; // External Namespace token in the IBC data -typedef mdToken idExternalType; // External Type token in the IBC data -typedef mdToken idExternalSignature; // External Signature token in the IBC data -typedef mdToken idExternalMethod; // External Method token in the IBC data -typedef mdToken idTypeSpec; // TypeSpec token in the IBC data -typedef mdToken idMethodSpec; // MethodSpec token in the IBC data - -#define idExternalNamespaceNil ((idExternalNamespace) ibcExternalNamespace) -#define idExternalTypeNil ((idExternalType) ibcExternalType) -#define idExternalSignatureNil ((idExternalSignature) ibcExternalSignature) -#define idExternalMethodNil ((idExternalMethod) ibcExternalMethod) -#define idTypeSpecNil ((idTypeSpec) ibcTypeSpec) -#define idMethodSpecNil ((idMethodSpec) ibcMethodSpec) - -// -// File format: -// -// CORBBTPROF_FILE_HEADER -// CORBBTPROF_SECTION_TABLE_HEADER -// CORBBTPROF_SECTION_TABLE_ENTRY -// ... (can be multiple entries) -// -// Method block counts section: -// CORBBTPROF_METHOD_BLOCK_COUNTS_SECTION_HEADER -// CORBBTPROF_METHOD_HEADER -// CORBBTPROF_BLOCK_DATA -// ... (can be multiple method header/block data entries) -// -// Method load order section: -// CORBBTPROF_TOKEN_LIST_SECTION_HEADER -// ... (list of tokens) -// -// Type token usage information -// CORBBTPROF_TOKEN_LIST_SECTION_HEADER -// ... (list of tokens) -// - -// MethodDef token usage information -// CORBBTPROF_TOKEN_LIST_SECTION_HEADER -// ... (list of tokens) -// - -// RIDs to not use slim headers section -// CORBBTPROF_TOKEN_LIST_SECTION_HEADER -// ... (list of tokens) -// - -// Metadata hints to re-order some tables -// Instantiated TypeSPecs to re-order EEClasses -// -// The header for the profile data file. -// ... (list of CORBBTPROF_BLOB_ENTRY) -// terminated by null - -struct CORBBTPROF_FILE_HEADER -{ - DWORD HeaderSize; - DWORD Magic; - DWORD Version; - GUID MVID; -}; - -// Optional in V1 and V2. Usually present in V2. Must be present in V3. -struct CORBBTPROF_FILE_OPTIONAL_HEADER -{ - DWORD Size; // Including the size field - DWORD MinorVersion; - DWORD FileFlags; // Only in V3 or later - // future fields -}; - -enum CORBBTPROF_FILE_FLAGS -{ - CORBBTPROF_FILE_FLAG_MINIFIED = 1, - CORBBTPROF_FILE_FLAG_PARTIAL_NGEN = 2 -}; - -enum -{ - CORBBTPROF_V0_VERSION = 0, - CORBBTPROF_V1_VERSION = 1, - CORBBTPROF_V2_VERSION = 2, - CORBBTPROF_V3_VERSION = 3, - CORBBTPROF_CURRENT_VERSION = CORBBTPROF_V2_VERSION, // V3 is opt-in - CORBBTPROF_MAGIC = 0xb1d0f11e, - CORBBTPROF_END_TOKEN = 0xb4356f98 -}; - -// -// The profile data can be mapped anywhere in memory. So instead of using pointers, -// to denote sections, we will instead use offsets from the beginning of the file. -// - -struct Section -{ - DWORD Offset; - DWORD Size; -}; - -// -// Section types, where various sections contains different types of profile data. -// - -#define CORBBTPROF_TOKEN_MAX_NUM_FLAGS 32 - -enum TypeProfilingDataFlags -{ - // Important: update toolbox\ibcmerge\ibcmerge.cs if you change these - ReadMethodTable = 0, // 0x00001 - ReadEEClass = 1, // 0x00002 - WriteEEClass = 2, // 0x00004 -// ReadStoredEnumData = 3, // 0x00008 // obsolete - ReadFieldDescs = 4, // 0x00010 - ReadCCtorInfo = 5, // 0x00020 - ReadClassHashTable = 6, // 0x00040 - ReadDispatchMap = 7, // 0x00080 - ReadDispatchTable = 8, // 0x00100 - ReadMethodTableWriteableData = 9, // 0x00200 -// ReadFieldMarshalers = 10, // 0x00400 // obsolete -// WriteDispatchTable = 11, // 0x00800 // obsolete -// WriteMethodTable = 12, // 0x01000 // obsolete - WriteMethodTableWriteableData = 13, // 0x02000 - ReadTypeDesc = 14, // 0x04000 - WriteTypeDesc = 15, // 0x08000 - ReadTypeHashTable = 16, // 0x10000 -// WriteTypeHashTable = 17, // 0x20000 // obsolete -// ReadDictionary = 18, // 0x40000 // obsolete -// WriteDictionary = 19, // 0x80000 // obsolete - ReadNonVirtualSlots = 20, // 0x100000 -}; - -enum MethodProfilingDataFlags -{ - // Important: update toolbox\ibcmerge\ibcmerge.cs if you change these - ReadMethodCode = 0, // 0x00001 // Also means the method was executed - ReadMethodDesc = 1, // 0x00002 - RunOnceMethod = 2, // 0x00004 - RunNeverMethod = 3, // 0x00008 -// MethodStoredDataAccess = 4, // 0x00010 // obsolete - WriteMethodDesc = 5, // 0x00020 -// ReadFCallHash = 6, // 0x00040 // obsolete - ReadGCInfo = 7, // 0x00080 - CommonReadGCInfo = 8, // 0x00100 -// ReadMethodDefRidMap = 9, // 0x00200 // obsolete - ReadCerMethodList = 10, // 0x00400 - ReadMethodPrecode = 11, // 0x00800 - WriteMethodPrecode = 12, // 0x01000 - ExcludeHotMethodCode = 13, // 0x02000 // Hot method should be excluded from the ReadyToRun image - ExcludeColdMethodCode = 14, // 0x04000 // Cold method should be excluded from the ReadyToRun image - DisableInlining = 15, // 0x08000 // Disable inlining of this method in optimized AOT native code -}; - -enum GeneralProfilingDataFlags -{ - // Important: update ibcmerge.cs if you change these - // ZapImage.h depends on 0xFFFFFFFF being an invalid flag value. If this - // changes, update ReadFlagWithMemory in that file. - // Important: make sure these don't collide with TypeProfilingDataFlags or MethodProfilingDataFlags - // These grow downward from CORBBTPROF_TOKEN_MAX_NUM_FLAGS-1 to minimize the chance of collision - ProfilingFlags_MetaData = 31, // 0x800... - CommonMetaData = 30, // 0x400... - RidMap = 29, // 0x200... - RVAFieldData = 28, // 0x100... - ProfilingFlags_MetaDataSearch = 27, // 0x080... -}; - -enum BlobType -{ - /* IMPORTANT: Keep the first four enums together in the same order and at - the very beginning of this enum. See MetaModelPub.h for the order */ - MetadataStringPool = 0, - MetadataGuidPool = 1, - MetadataBlobPool = 2, - MetadataUserStringPool = 3, - - FirstMetadataPool = 0, - LastMetadataPool = 3, - - // SectionFormat only supports tokens, which have to already exist in the module. - // For instantiated parameterized types, there may be no corresponding token - // in the module, if a dependent module caused the type to be instantiated. - // For such instantiated types, we save a blob/signature to identify the type. - // - ParamTypeSpec = 4, // Instantiated Type Signature - ParamMethodSpec = 5, // Instantiated Method Signature - ExternalNamespaceDef = 6, // External Namespace Token Definition - ExternalTypeDef = 7, // External Type Token Definition - ExternalSignatureDef = 8, // External Signature Definition - ExternalMethodDef = 9, // External Method Token Definition - - IllegalBlob = 10, // Failed to allocate the blob - - EndOfBlobStream = -1 -}; - -enum SectionFormat -{ - // Important: update ibcmerge.cs if you change these - ScenarioInfo = 0, - MethodBlockCounts = 1, // Basic-block counts. Cold blocks will be placed in the cold-code section - BlobStream = 2, // metadata access, inst-type-spec and inst-method-spec blobs - - FirstTokenFlagSection = 3, - - ModuleProfilingData = FirstTokenFlagSection + (mdtModule >> 24), - TypeRefProfilingData = FirstTokenFlagSection + (mdtTypeRef >> 24), - TypeProfilingData = FirstTokenFlagSection + (mdtTypeDef >> 24), - FieldDefProfilingData = FirstTokenFlagSection + (mdtFieldDef >> 24), - MethodProfilingData = FirstTokenFlagSection + (mdtMethodDef >> 24), - ParamDefProfilingData = FirstTokenFlagSection + (mdtParamDef >> 24), - InterfaceImplProfilingData = FirstTokenFlagSection + (mdtInterfaceImpl >> 24), - MemberRefProfilingData = FirstTokenFlagSection + (mdtMemberRef >> 24), - CustomAttributeProfilingData = FirstTokenFlagSection + (mdtCustomAttribute >> 24), - PermissionProfilingData = FirstTokenFlagSection + (mdtPermission >> 24), - SignatureProfilingData = FirstTokenFlagSection + (mdtSignature >> 24), - EventProfilingData = FirstTokenFlagSection + (mdtEvent >> 24), - PropertyProfilingData = FirstTokenFlagSection + (mdtProperty >> 24), - ModuleRefProfilingData = FirstTokenFlagSection + (mdtModuleRef >> 24), - TypeSpecProfilingData = FirstTokenFlagSection + (mdtTypeSpec >> 24), - AssemblyProfilingData = FirstTokenFlagSection + (mdtAssembly >> 24), - AssemblyRefProfilingData = FirstTokenFlagSection + (mdtAssemblyRef >> 24), - FileProfilingData = FirstTokenFlagSection + (mdtFile >> 24), - ExportedTypeProfilingData = FirstTokenFlagSection + (mdtExportedType >> 24), - ManifestResourceProfilingData = FirstTokenFlagSection + (mdtManifestResource >> 24), - GenericParamProfilingData = FirstTokenFlagSection + (mdtGenericParam >> 24), - MethodSpecProfilingData = FirstTokenFlagSection + (mdtMethodSpec >> 24), - GenericParamConstraintProfilingData = FirstTokenFlagSection + (mdtGenericParamConstraint >> 24), - - StringPoolProfilingData, - GuidPoolProfilingData, - BlobPoolProfilingData, - UserStringPoolProfilingData, - - FirstMetadataPoolSection = StringPoolProfilingData, - LastMetadataPoolSection = UserStringPoolProfilingData, - LastTokenFlagSection = LastMetadataPoolSection, - - IbcTypeSpecSection, - IbcMethodSpecSection, - - GenericTypeProfilingData = 63, // Deprecated with V2 IBC data - SectionFormatCount = 64, // 0x40 - - SectionFormatInvalid = -1 -}; - -#include - -struct CORBBTPROF_SECTION_TABLE_ENTRY -{ - SectionFormat FormatID; - Section Data; -}; - -struct CORBBTPROF_SECTION_TABLE_HEADER -{ - DWORD NumEntries; - CORBBTPROF_SECTION_TABLE_ENTRY Entries[0]; -}; - -// -// ScenarioInfo section -// - -struct CORBBTPROF_SCENARIO_RUN -{ - FILETIME runTime; // the FILETIME when the scenario was cnt - GUID mvid; // The GUID of this assembly when the scenario was run (useful for incremental ibcdata) - DWORD cCmdLine; // the count of WCHAR's in the cmdLine for this run of the scenario - DWORD cSystemInfo; // the count of WCHAR's in the systemInfo string for this run of the scenario - WCHAR cmdLine[0]; // the command line used, the array is 'cName' in length -// WCHAR systemInfo[]; // the system information, the array is 'cSystemInfo' in length - - DWORD sizeofCmdLine() - { - return (cCmdLine * (DWORD)sizeof(WCHAR)); - } - - DWORD sizeofSystemInfo() - { - return (cSystemInfo * (DWORD)sizeof(WCHAR)); - } - - DWORD Size() - { - return (DWORD)sizeof(CORBBTPROF_SCENARIO_RUN) + sizeofCmdLine() + sizeofSystemInfo(); - } - - CORBBTPROF_SCENARIO_RUN* GetNextRun() - { - return reinterpret_cast< CORBBTPROF_SCENARIO_RUN* >( - reinterpret_cast< PBYTE >( this + 1 ) + Size() ); - } -}; - -struct CORBBTPROF_SCENARIO_INFO -{ - DWORD ordinal; // the id number for this scenario - DWORD mask; // the one-bit mask use to identify this scenario - DWORD priority; // the priority of this scenario - DWORD numRuns; // the number of times this scenario was run - DWORD cName; // the count of WCHAR's in name[] - WCHAR name[0]; // the name of this scenario, the array is 'cName' in length -// CORBBTPROF_SCENARIO_RUN run[]; // the array is 'numRuns' in length - - DWORD sizeofName() - { - return (DWORD) (cName * sizeof(WCHAR)); - } - - DWORD Size() - { - return (DWORD) sizeof(CORBBTPROF_SCENARIO_INFO) + sizeofName() + sizeofRuns(); - } - - CORBBTPROF_SCENARIO_RUN* GetScenarioRun() - { - return reinterpret_cast< CORBBTPROF_SCENARIO_RUN* >( - reinterpret_cast< PBYTE >( this ) + (DWORD)sizeof(CORBBTPROF_SCENARIO_INFO) + sizeofName()); - } - - DWORD sizeofRuns() - { - DWORD sum = 0; - if (numRuns > 0) - { - DWORD cnt = 1; - CORBBTPROF_SCENARIO_RUN* pRun = GetScenarioRun(); - do - { - sum += pRun->Size(); - if (cnt == numRuns) - break; - cnt++; - pRun = pRun->GetNextRun(); - } - while (true); - } - return sum; - } -}; - -struct CORBBTPROF_SCENARIO_HEADER -{ - DWORD size; // Size to skip to get to the next CORBBTPROF_SCENARIO_HEADER - CORBBTPROF_SCENARIO_INFO scenario; - - DWORD Size() - { - return (DWORD) sizeof(CORBBTPROF_SCENARIO_HEADER) + scenario.sizeofName() + scenario.sizeofRuns(); - } -}; - -struct CORBBTPROF_SCENARIO_INFO_SECTION_HEADER -{ - DWORD TotalNumRuns; - DWORD NumScenarios; -// CORBBTPROF_SCENARIO_HEADER scenario[0]; // array is 'NumScenarios' in length -}; - -// -// MethodBlockCounts section -// - -struct CORBBTPROF_METHOD_BLOCK_COUNTS_SECTION_HEADER_V1 -{ - DWORD NumMethods; - DWORD NumRuns; -}; - -struct CORBBTPROF_METHOD_BLOCK_COUNTS_SECTION_HEADER -{ - DWORD NumMethods; -}; - -struct CORBBTPROF_BLOCK_DATA // This struct is also defined by: ICorJitInfo.BlockCounts -{ - UINT32 ILOffset; - UINT32 ExecutionCount; -}; - -struct CORBBTPROF_METHOD_DETAIL_HEADER -{ - DWORD size; // Size to skip to get to the next CORBBTPROF_METHOD_DETAIL_HEADER at this level - DWORD kind; // Identifier that specifies what kind this CORBBTPROF_METHOD_DETAIL_HEADER actually represents - - size_t Size() - { - return size; - } -}; - -// -// This struct records the basic block execution counts for a method -// -struct CORBBTPROF_METHOD_INFO -{ - DWORD token; // token for this method - DWORD ILSize; // IL size for this method - DWORD cBlock; // count for block[] - CORBBTPROF_BLOCK_DATA block[0]; // actually 'cBlock' in length - - size_t Size() - { - return sizeof(CORBBTPROF_METHOD_INFO) + sizeofBlock(); - } - - size_t sizeofBlock() - { - return cBlock * sizeof(CORBBTPROF_BLOCK_DATA); - } -}; - -struct CORBBTPROF_METHOD_HEADER_V1 -{ - DWORD HeaderSize; - mdToken MethodToken; - DWORD Size; -}; - -struct CORBBTPROF_METHOD_HEADER -{ - DWORD size; // Size to skip to get to the next CORBBTPROF_METHOD_HEADER - DWORD cDetail; // the count of CORBBTPROF_METHOD_DETAIL_HEADER records that follow this record - CORBBTPROF_METHOD_INFO method; // Basic block execution counts for a method - // ... followed by 'cDetail' occurrences of CORBBTPROF_METHOD_DETAIL_HEADER - - size_t Size() - { - return sizeof(CORBBTPROF_METHOD_HEADER) + method.sizeofBlock(); - } -}; - - -struct CORBBTPROF_TOKEN_LIST_SECTION_HEADER -{ - DWORD NumTokens; -}; - -struct CORBBTPROF_TOKEN_LIST_ENTRY_V1 -{ - mdToken token; - DWORD flags; -}; - -struct CORBBTPROF_TOKEN_INFO // Was CORBBTPROF_TOKEN_LIST_ENTRY -{ - mdToken token; - DWORD flags; - DWORD scenarios; // Could use UINT64 instead - - CORBBTPROF_TOKEN_INFO() - : token(0) - , flags(0) - , scenarios(0) - {} - - CORBBTPROF_TOKEN_INFO( mdToken t, DWORD f = 0, DWORD s = 0) - : token(t) - , flags(f) - , scenarios(s) - {} - - CORBBTPROF_TOKEN_INFO( CORBBTPROF_TOKEN_INFO const & right ) - : token(right.token) - , flags(right.flags) - , scenarios(right.scenarios) - {} - - CORBBTPROF_TOKEN_INFO operator=( CORBBTPROF_TOKEN_INFO const & right ) - { - token = right.token; - flags = right.flags; - scenarios = right.scenarios; - return *this; - } - - bool operator<( CORBBTPROF_TOKEN_INFO const & right ) const - { - return token < right.token; - } -}; - -struct CORBBTPROF_BLOB_ENTRY_V1 -{ - BlobType blobType; - DWORD flags; - DWORD cBuffer; - BYTE pBuffer[0]; // actually 'cBuffer' in length - - CORBBTPROF_BLOB_ENTRY_V1 * GetNextEntry() - { - return reinterpret_cast< CORBBTPROF_BLOB_ENTRY_V1* >( - reinterpret_cast< PBYTE >( this + 1 ) + cBuffer ); - } -}; - -struct CORBBTPROF_BLOB_ENTRY -{ - DWORD size; - BlobType type; - mdToken token; // The code:CORBBTPROF_BLOB_ENTRY.token field is not a real meta-data token - // but a look-alike that IBCMerge makes to represent blob entry - - bool TypeIsValid() - { - return (type >= MetadataStringPool) && (type < IllegalBlob); - } - - CORBBTPROF_BLOB_ENTRY * GetNextEntry() - { - return reinterpret_cast< CORBBTPROF_BLOB_ENTRY* >( - reinterpret_cast< PBYTE >( this ) + size); - } -}; - -struct CORBBTPROF_BLOB_PARAM_SIG_ENTRY -{ - CORBBTPROF_BLOB_ENTRY blob; - DWORD cSig; - COR_SIGNATURE sig[0]; // actually 'cSig' in length -}; - -struct CORBBTPROF_BLOB_NAMESPACE_DEF_ENTRY -{ - CORBBTPROF_BLOB_ENTRY blob; - DWORD cName; - CHAR name[0]; // actually cName in length -}; - -struct CORBBTPROF_BLOB_TYPE_DEF_ENTRY -{ - CORBBTPROF_BLOB_ENTRY blob; - mdToken assemblyRefToken; - mdToken nestedClassToken; - mdToken nameSpaceToken; - DWORD cName; - CHAR name[0]; // actually cName in length -}; - -struct CORBBTPROF_BLOB_SIGNATURE_DEF_ENTRY -{ - CORBBTPROF_BLOB_ENTRY blob; - DWORD cSig; - COR_SIGNATURE sig[0]; // actually 'cSig' in length -}; - -struct CORBBTPROF_BLOB_METHOD_DEF_ENTRY -{ - CORBBTPROF_BLOB_ENTRY blob; - mdToken nestedClassToken; - mdToken signatureToken; - DWORD cName; - CHAR name[0]; // actually cName in length -}; - -struct CORBBTPROF_BLOB_POOL_ENTRY -{ - CORBBTPROF_BLOB_ENTRY blob; - DWORD cBuffer; - BYTE buffer[0]; // actually 'cBuffer' in length -}; - -#include - -#endif /* COR_BBTPROF_H_ */ diff --git a/src/coreclr/inc/corcompile.h b/src/coreclr/inc/corcompile.h index fda3120309442..c7aaac1a210fc 100644 --- a/src/coreclr/inc/corcompile.h +++ b/src/coreclr/inc/corcompile.h @@ -11,8 +11,6 @@ * * * * \*****************************************************************************/ -// See code:CorProfileData for information on Hot Cold splitting using profile data. - #ifndef _COR_COMPILE_H_ #define _COR_COMPILE_H_ @@ -24,7 +22,6 @@ #include #include #include -#include #include typedef DPTR(struct CORCOMPILE_EXCEPTION_LOOKUP_TABLE) @@ -55,9 +52,6 @@ typedef DPTR(RUNTIME_FUNCTION) PTR_RUNTIME_FUNCTION; #endif // TARGET_X86 - -typedef DPTR(struct CORCOMPILE_METHOD_PROFILE_LIST) - PTR_CORCOMPILE_METHOD_PROFILE_LIST; typedef DPTR(struct CORCOMPILE_RUNTIME_DLL_INFO) PTR_CORCOMPILE_RUNTIME_DLL_INFO; typedef DPTR(struct COR_ILMETHOD) PTR_COR_ILMETHOD; @@ -290,167 +284,6 @@ struct CORCOMPILE_EXCEPTION_CLAUSE }; }; - -/*********************************************************************************/ -// The layout of this struct is required to be -// a 'next' pointer followed by a CORBBTPROF_METHOD_HEADER -// -struct CORCOMPILE_METHOD_PROFILE_LIST -{ - CORCOMPILE_METHOD_PROFILE_LIST * next; -// CORBBTPROF_METHOD_HEADER info; - - CORBBTPROF_METHOD_HEADER * GetInfo() - { return (CORBBTPROF_METHOD_HEADER *) (this+1); } -}; - -class CorProfileData -{ -public: - CorProfileData(void * rawProfileData); // really of type ZapImage::ProfileDataSection* - - struct CORBBTPROF_TOKEN_INFO * GetTokenFlagsData(SectionFormat section) - { - return this->profilingTokenFlagsData[section].data; - } - - DWORD GetTokenFlagsCount(SectionFormat section) - { - return this->profilingTokenFlagsData[section].count; - } - - CORBBTPROF_BLOB_ENTRY * GetBlobStream() - { - return this->blobStream; - } - - // - // Token lookup methods - // - ULONG GetTypeProfilingFlagsOfToken(mdToken token) - { - _ASSERTE(TypeFromToken(token) == mdtTypeDef); - return GetProfilingFlagsOfToken(token); - } - - CORBBTPROF_BLOB_PARAM_SIG_ENTRY *GetBlobSigEntry(mdToken token) - { - _ASSERTE((TypeFromToken(token) == ibcTypeSpec) || (TypeFromToken(token) == ibcMethodSpec)); - - CORBBTPROF_BLOB_ENTRY * pBlobEntry = GetBlobEntry(token); - if (pBlobEntry == NULL) - return NULL; - - _ASSERTE(pBlobEntry->token == token); - _ASSERTE((pBlobEntry->type == ParamTypeSpec) || (pBlobEntry->type == ParamMethodSpec)); - - return (CORBBTPROF_BLOB_PARAM_SIG_ENTRY *) pBlobEntry; - } - - CORBBTPROF_BLOB_NAMESPACE_DEF_ENTRY *GetBlobExternalNamespaceDef(mdToken token) - { - _ASSERTE(TypeFromToken(token) == ibcExternalNamespace); - - CORBBTPROF_BLOB_ENTRY * pBlobEntry = GetBlobEntry(token); - if (pBlobEntry == NULL) - return NULL; - - _ASSERTE(pBlobEntry->token == token); - _ASSERTE(pBlobEntry->type == ExternalNamespaceDef); - - return (CORBBTPROF_BLOB_NAMESPACE_DEF_ENTRY *) pBlobEntry; - } - - CORBBTPROF_BLOB_TYPE_DEF_ENTRY *GetBlobExternalTypeDef(mdToken token) - { - _ASSERTE(TypeFromToken(token) == ibcExternalType); - - CORBBTPROF_BLOB_ENTRY * pBlobEntry = GetBlobEntry(token); - if (pBlobEntry == NULL) - return NULL; - - _ASSERTE(pBlobEntry->token == token); - _ASSERTE(pBlobEntry->type == ExternalTypeDef); - - return (CORBBTPROF_BLOB_TYPE_DEF_ENTRY *) pBlobEntry; - } - - CORBBTPROF_BLOB_SIGNATURE_DEF_ENTRY *GetBlobExternalSignatureDef(mdToken token) - { - _ASSERTE(TypeFromToken(token) == ibcExternalSignature); - - CORBBTPROF_BLOB_ENTRY * pBlobEntry = GetBlobEntry(token); - if (pBlobEntry == NULL) - return NULL; - - _ASSERTE(pBlobEntry->token == token); - _ASSERTE(pBlobEntry->type == ExternalSignatureDef); - - return (CORBBTPROF_BLOB_SIGNATURE_DEF_ENTRY *) pBlobEntry; - } - - CORBBTPROF_BLOB_METHOD_DEF_ENTRY *GetBlobExternalMethodDef(mdToken token) - { - _ASSERTE(TypeFromToken(token) == ibcExternalMethod); - - CORBBTPROF_BLOB_ENTRY * pBlobEntry = GetBlobEntry(token); - if (pBlobEntry == NULL) - return NULL; - - _ASSERTE(pBlobEntry->token == token); - _ASSERTE(pBlobEntry->type == ExternalMethodDef); - - return (CORBBTPROF_BLOB_METHOD_DEF_ENTRY *) pBlobEntry; - } - -private: - ULONG GetProfilingFlagsOfToken(mdToken token) - { - SectionFormat section = (SectionFormat)((TypeFromToken(token) >> 24) + FirstTokenFlagSection); - - CORBBTPROF_TOKEN_INFO *profilingData = this->profilingTokenFlagsData[section].data; - DWORD cProfilingData = this->profilingTokenFlagsData[section].count; - - if (profilingData != NULL) - { - for (DWORD i = 0; i < cProfilingData; i++) - { - if (profilingData[i].token == token) - return profilingData[i].flags; - } - } - return 0; - } - - CORBBTPROF_BLOB_ENTRY *GetBlobEntry(idTypeSpec token) - { - CORBBTPROF_BLOB_ENTRY * pBlobEntry = this->GetBlobStream(); - if (pBlobEntry == NULL) - return NULL; - - while (pBlobEntry->TypeIsValid()) - { - if (pBlobEntry->token == token) - { - return pBlobEntry; - } - pBlobEntry = pBlobEntry->GetNextEntry(); - } - - return NULL; - } - -private: - struct - { - struct CORBBTPROF_TOKEN_INFO *data; - DWORD count; - } - profilingTokenFlagsData[SectionFormatCount]; - - CORBBTPROF_BLOB_ENTRY* blobStream; -}; - /*********************************************************************************/ // When NGEN install /Profile is run, the ZapProfilingHandleImport fixup table contains // these 5 values per MethodDesc diff --git a/src/coreclr/inc/mdcommon.h b/src/coreclr/inc/mdcommon.h index eeeb32fc72829..e1c816d5dc898 100644 --- a/src/coreclr/inc/mdcommon.h +++ b/src/coreclr/inc/mdcommon.h @@ -37,7 +37,6 @@ enum MAPPINGTYPE #define COMPRESSED_MODEL_STREAM_A "#~" #define ENC_MODEL_STREAM_A "#-" #define MINIMAL_MD_STREAM_A "#JTD" -#define HOT_MODEL_STREAM_A "#!" #ifdef FEATURE_METADATA_EMIT_PORTABLE_PDB #define PDB_STREAM_A "#Pdb" #endif // FEATURE_METADATA_EMIT_PORTABLE_PDB @@ -50,7 +49,6 @@ enum MAPPINGTYPE #define COMPRESSED_MODEL_STREAM W("#~") #define ENC_MODEL_STREAM W("#-") #define MINIMAL_MD_STREAM W("#JTD") -#define HOT_MODEL_STREAM W("#!") #ifdef FEATURE_METADATA_EMIT_PORTABLE_PDB #define PDB_STREAM W("#Pdb") #endif // FEATURE_METADATA_EMIT_PORTABLE_PDB diff --git a/src/coreclr/inc/metadata.h b/src/coreclr/inc/metadata.h index cf69f3a909999..85da85f96f542 100644 --- a/src/coreclr/inc/metadata.h +++ b/src/coreclr/inc/metadata.h @@ -15,7 +15,6 @@ #include "ex.h" -class CorProfileData; class IMetaModelCommon; class MDInternalRW; class UTSemReadWrite; diff --git a/src/coreclr/inc/stgpool.h b/src/coreclr/inc/stgpool.h index 04cab2283365b..b80d7c6c9a1fb 100644 --- a/src/coreclr/inc/stgpool.h +++ b/src/coreclr/inc/stgpool.h @@ -49,7 +49,6 @@ const int DFT_CODE_HEAP_SIZE = 8192; class StgStringPool; class StgBlobPool; class StgCodePool; -class CorProfileData; // Perform binary search on index table. // diff --git a/src/coreclr/md/compiler/regmeta.cpp b/src/coreclr/md/compiler/regmeta.cpp index b181ba0fa3a5f..252792975738a 100644 --- a/src/coreclr/md/compiler/regmeta.cpp +++ b/src/coreclr/md/compiler/regmeta.cpp @@ -67,7 +67,6 @@ RegMeta::RegMeta() : m_SetAPICaller(EXTERNAL_CALLER), m_ModuleType(ValidatorModuleTypeInvalid), m_bKeepKnownCa(false), - m_pCorProfileData(NULL), m_ReorderingOptions(NoReordering) #ifdef FEATURE_METADATA_RELEASE_MEMORY_ON_REOPEN , m_safeToDeleteStgdb(true) diff --git a/src/coreclr/md/compiler/regmeta.h b/src/coreclr/md/compiler/regmeta.h index ce768e99ccc54..83df906cf84f0 100644 --- a/src/coreclr/md/compiler/regmeta.h +++ b/src/coreclr/md/compiler/regmeta.h @@ -2059,8 +2059,6 @@ class RegMeta : bool m_bKeepKnownCa; // Should all known CA's be kept? - CorProfileData *m_pCorProfileData; - MetaDataReorderingOptions m_ReorderingOptions; #ifdef FEATURE_METADATA_RELEASE_MEMORY_ON_REOPEN diff --git a/src/coreclr/md/compiler/regmeta_emit.cpp b/src/coreclr/md/compiler/regmeta_emit.cpp index 5433d35409f62..ed57397560c25 100644 --- a/src/coreclr/md/compiler/regmeta_emit.cpp +++ b/src/coreclr/md/compiler/regmeta_emit.cpp @@ -172,7 +172,7 @@ HRESULT RegMeta::_SaveToStream( // S_OK or error. HRESULT hr=S_OK; IfFailGo(PreSave()); - IfFailGo( m_pStgdb->SaveToStream(pIStream, m_ReorderingOptions, m_pCorProfileData) ); + IfFailGo( m_pStgdb->SaveToStream(pIStream, m_ReorderingOptions) ); // Reset m_bSaveOptimized, this is to handle the incremental and ENC // scenerios where one may do multiple saves. @@ -281,7 +281,7 @@ STDMETHODIMP RegMeta::GetSaveSize( // S_OK or error. IfFailGo(PreSave()); - hr = m_pStgdb->GetSaveSize(fSave, (UINT32 *)pdwSaveSize, m_ReorderingOptions, m_pCorProfileData); + hr = m_pStgdb->GetSaveSize(fSave, (UINT32 *)pdwSaveSize, m_ReorderingOptions); ErrExit: STOP_MD_PERF(GetSaveSize); @@ -792,7 +792,7 @@ HRESULT RegMeta::PreSave() // Return code. m_bSaveOptimized = true; // call get save size to trigger the PreSaveXXX on MetaModelRW class. - IfFailGo(m_pStgdb->m_MiniMd.PreSave(m_ReorderingOptions, m_pCorProfileData)); + IfFailGo(m_pStgdb->m_MiniMd.PreSave(m_ReorderingOptions)); ErrExit: m_bRemap = bRemapOld; diff --git a/src/coreclr/md/enc/liteweightstgdbrw.cpp b/src/coreclr/md/enc/liteweightstgdbrw.cpp index 236c051706cd5..7ae079d3a8a64 100644 --- a/src/coreclr/md/enc/liteweightstgdbrw.cpp +++ b/src/coreclr/md/enc/liteweightstgdbrw.cpp @@ -527,8 +527,7 @@ __checkReturn HRESULT CLiteWeightStgdbRW::GetSaveSize(// S_OK or error. CorSaveSize fSave, // Quick or accurate? UINT32 *pcbSaveSize, // Put the size here. - MetaDataReorderingOptions reorderingOptions, - CorProfileData *pProfileData) // Profile data for working set optimization + MetaDataReorderingOptions reorderingOptions) { HRESULT hr = S_OK; // A result. UINT32 cbTotal = 0; // The total size. @@ -593,40 +592,13 @@ HRESULT CLiteWeightStgdbRW::GetSaveSize(// S_OK or error. if (reorderingOptions & ReArrangeStringPool) { - if (pProfileData != NULL) - { - UINT32 cbHotSize = 0; // Size of pool data. - UINT32 cbStream; // Size of just the stream. - DWORD bCompressed; // Will the stream be compressed data? - - // Ask the metadata to size its hot data. - IfFailGo(m_MiniMd.GetSaveSize(fSave, &cbHotSize, &bCompressed, reorderingOptions, pProfileData)); - cbStream = cbHotSize; - m_bSaveCompressed = bCompressed; - - if (cbHotSize != 0) - { - // Add this item to the save list. - IfFailGo(AddStreamToList(cbHotSize, HOT_MODEL_STREAM)); - - // Ask the storage system to add stream fixed overhead. - IfFailGo(TiggerStorage::GetStreamSaveSize(HOT_MODEL_STREAM, cbHotSize, &cbHotSize)); - - // Log the size info. - LOG((LF_METADATA, LL_INFO10, "Metadata: GetSaveSize for %ls: %d data, %d total.\n", - HOT_MODEL_STREAM, cbStream, cbHotSize)); - - cbTotal += cbHotSize; - } - } - // get string pool save size IfFailGo(GetPoolSaveSize(STRING_POOL_STREAM, MDPoolStrings, &cbSize)); cbTotal += cbSize; } // Query the MiniMd for its size. - IfFailGo(GetTablesSaveSize(fSave, &cbSize, reorderingOptions, pProfileData)); + IfFailGo(GetTablesSaveSize(fSave, &cbSize, reorderingOptions)); cbTotal += cbSize; // Get the pools' sizes. @@ -744,8 +716,7 @@ __checkReturn HRESULT CLiteWeightStgdbRW::GetTablesSaveSize( CorSaveSize fSave, UINT32 *pcbSaveSize, - MetaDataReorderingOptions reorderingOptions, - CorProfileData *pProfileData) // Add pool data to this value. + MetaDataReorderingOptions reorderingOptions) { UINT32 cbSize = 0; // Size of pool data. UINT32 cbHotSize = 0; // Size of pool data. @@ -756,31 +727,6 @@ HRESULT CLiteWeightStgdbRW::GetTablesSaveSize( *pcbSaveSize = 0; - if( !(reorderingOptions & ReArrangeStringPool) ) - { - if (pProfileData != NULL) - { - // Ask the metadata to size its hot data. - IfFailGo(m_MiniMd.GetSaveSize(fSave, &cbHotSize, &bCompressed, reorderingOptions, pProfileData)); - cbStream = cbHotSize; - m_bSaveCompressed = bCompressed; - - if (cbHotSize != 0) - { - szName = HOT_MODEL_STREAM; - - // Add this item to the save list. - IfFailGo(AddStreamToList(cbHotSize, szName)); - - // Ask the storage system to add stream fixed overhead. - IfFailGo(TiggerStorage::GetStreamSaveSize(szName, cbHotSize, &cbHotSize)); - - // Log the size info. - LOG((LF_METADATA, LL_INFO10, "Metadata: GetSaveSize for %ls: %d data, %d total.\n", - szName, cbStream, cbHotSize)); - } - } - } // Ask the metadata to size its data. IfFailGo(m_MiniMd.GetSaveSize(fSave, &cbSize, &bCompressed)); cbStream = cbSize; @@ -834,8 +780,7 @@ HRESULT CLiteWeightStgdbRW::AddStreamToList( __checkReturn HRESULT CLiteWeightStgdbRW::SaveToStream( IStream *pIStream, - MetaDataReorderingOptions reorderingOptions, - CorProfileData *pProfileData) + MetaDataReorderingOptions reorderingOptions) { HRESULT hr = S_OK; // A result. StgIO *pStgIO = 0; @@ -856,7 +801,7 @@ HRESULT CLiteWeightStgdbRW::SaveToStream( IfFailGo(pStorage->Init(pStgIO, ov.m_RuntimeVersion)); // Save worker will do tables, pools. - IfFailGo(SaveToStorage(pStorage, reorderingOptions, pProfileData)); + IfFailGo(SaveToStorage(pStorage, reorderingOptions)); ErrExit: if (pStgIO != NULL) @@ -871,8 +816,7 @@ HRESULT CLiteWeightStgdbRW::SaveToStream( __checkReturn HRESULT CLiteWeightStgdbRW::SaveToStorage( TiggerStorage *pStorage, - MetaDataReorderingOptions reorderingOptions, - CorProfileData *pProfileData) + MetaDataReorderingOptions reorderingOptions) { HRESULT hr; // A result. LPCWSTR szName; // Name of the tables stream. @@ -901,28 +845,6 @@ HRESULT CLiteWeightStgdbRW::SaveToStorage( pIStreamTbl = 0; } - if (pProfileData != NULL) - { - DWORD bCompressed; - UINT32 cbHotSize; - // Will the stream be compressed data? - - // Only create this additional stream if it will be non-empty - IfFailGo(m_MiniMd.GetSaveSize(cssAccurate, &cbHotSize, &bCompressed, reorderingOptions, pProfileData)); - - if (cbHotSize > 0) - { - // Create a stream and save the hot tables. - szName = HOT_MODEL_STREAM; - IfFailGo(pStorage->CreateStream(szName, - STGM_DIRECT | STGM_READWRITE | STGM_SHARE_EXCLUSIVE, - 0, 0, &pIStreamTbl)); - IfFailGo(m_MiniMd.SaveTablesToStream(pIStreamTbl, reorderingOptions, pProfileData)); - pIStreamTbl->Release(); - pIStreamTbl = 0; - } - } - if (reorderingOptions & ReArrangeStringPool) { // Save the string pool before the tables when we do not have the string pool cache @@ -934,7 +856,7 @@ HRESULT CLiteWeightStgdbRW::SaveToStorage( IfFailGo(pStorage->CreateStream(szName, STGM_DIRECT | STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &pIStreamTbl)); - IfFailGo(m_MiniMd.SaveTablesToStream(pIStreamTbl, NoReordering, NULL)); + IfFailGo(m_MiniMd.SaveTablesToStream(pIStreamTbl, NoReordering)); pIStreamTbl->Release(); pIStreamTbl = 0; diff --git a/src/coreclr/md/enc/metamodelrw.cpp b/src/coreclr/md/enc/metamodelrw.cpp index ee8ded44bf062..0bf150e44e49d 100644 --- a/src/coreclr/md/enc/metamodelrw.cpp +++ b/src/coreclr/md/enc/metamodelrw.cpp @@ -1964,8 +1964,7 @@ CMiniMdRW::GetFullSaveSize( CorSaveSize fSave, // [IN] cssAccurate or cssQuick. UINT32 *pcbSaveSize, // [OUT] Put the size here. DWORD *pbSaveCompressed, // [OUT] Will the saved data be fully compressed? - MetaDataReorderingOptions reorderingOptions, // [IN] Metadata reordering options - CorProfileData *pProfileData) // [IN] Optional IBC profile data for working set optimization + MetaDataReorderingOptions reorderingOptions) // [IN] Metadata reordering options { HRESULT hr = S_OK; CMiniTableDef sTempTable; // Definition for a temporary table. @@ -1977,7 +1976,6 @@ CMiniMdRW::GetFullSaveSize( int i; // Loop control. _ASSERTE(m_bPreSaveDone); - _ASSERTE(pProfileData == NULL); // Determine if the stream is "fully compressed", ie no pointer tables. *pbSaveCompressed = true; @@ -2021,14 +2019,9 @@ CMiniMdRW::GetFullSaveSize( Schema.m_heaps &= ~CMiniMdSchema::HEAP_GUID_4; } - cbTotal = 0; - // schema isn't saved for the hot metadata - if (pProfileData == NULL) - { - cbTotal = Schema.SaveTo(SchemaBuf); - if ( (cbAlign = Align4(cbTotal) - cbTotal) != 0) - cbTotal += cbAlign; - } + cbTotal = Schema.SaveTo(SchemaBuf); + if ( (cbAlign = Align4(cbTotal) - cbTotal) != 0) + cbTotal += cbAlign; // For each table... ULONG ixTbl; @@ -2061,13 +2054,9 @@ CMiniMdRW::GetFullSaveSize( if (cbAlign < 2) cbAlign += 4; cbTotal += cbAlign; + m_cbSaveSize = cbTotal; - if (pProfileData == NULL) - { - m_cbSaveSize = cbTotal; - } - - LOG((LOGMD, "CMiniMdRW::GetFullSaveSize: Total %ssize = %d\n", pProfileData ? "hot " : "", cbTotal)); + LOG((LOGMD, "CMiniMdRW::GetFullSaveSize: Total size = %d\n", cbTotal)); *pcbSaveSize = cbTotal; @@ -2155,8 +2144,7 @@ CMiniMdRW::GetSaveSize( CorSaveSize fSave, // [IN] cssAccurate or cssQuick. UINT32 *pcbSaveSize, // [OUT] Put the size here. DWORD *pbSaveCompressed, // [OUT] Will the saved data be fully compressed? - MetaDataReorderingOptions reorderingOptions, // [IN] Optional metadata reordering options - CorProfileData *pProfileData) // [IN] Optional IBC profile data for working set optimization + MetaDataReorderingOptions reorderingOptions) // [IN] Optional metadata reordering options { HRESULT hr; @@ -2166,12 +2154,12 @@ CMiniMdRW::GetSaveSize( switch (m_OptionValue.m_UpdateMode & MDUpdateMask) { case MDUpdateFull: - hr = GetFullSaveSize(fSave, pcbSaveSize, pbSaveCompressed, reorderingOptions, pProfileData); + hr = GetFullSaveSize(fSave, pcbSaveSize, pbSaveCompressed, reorderingOptions); break; case MDUpdateIncremental: case MDUpdateExtension: case MDUpdateENC: - hr = GetFullSaveSize(fSave, pcbSaveSize, pbSaveCompressed, NoReordering, pProfileData); + hr = GetFullSaveSize(fSave, pcbSaveSize, pbSaveCompressed, NoReordering); // never save compressed if it is incremental compilation. *pbSaveCompressed = false; break; @@ -3069,8 +3057,7 @@ CMiniMdRW::PreSaveEnc() __checkReturn HRESULT CMiniMdRW::PreSave( - MetaDataReorderingOptions reorderingOptions, - CorProfileData *pProfileData) + MetaDataReorderingOptions reorderingOptions) { HRESULT hr = S_OK; @@ -3131,8 +3118,7 @@ __checkReturn HRESULT CMiniMdRW::SaveFullTablesToStream( IStream *pIStream, - MetaDataReorderingOptions reorderingOptions, - CorProfileData *pProfileData) + MetaDataReorderingOptions reorderingOptions) { HRESULT hr; CMiniTableDef sTempTable; // Definition for a temporary table. @@ -3143,8 +3129,6 @@ CMiniMdRW::SaveFullTablesToStream( UINT32 cbTotal; // Bytes written. static const unsigned char zeros[8] = {0}; // For padding and alignment. - _ASSERTE(pProfileData == NULL); - // Write the header. CMiniMdSchema Schema = m_Schema; IfFailGo(m_StringHeap.GetAlignedSize(&cbTable)); @@ -3176,15 +3160,11 @@ CMiniMdRW::SaveFullTablesToStream( Schema.m_heaps &= ~CMiniMdSchema::HEAP_BLOB_4; } - cbTotal = 0; - if (pProfileData == NULL) - { - cbTotal = Schema.SaveTo(SchemaBuf); - IfFailGo(pIStream->Write(SchemaBuf, cbTotal, 0)); - if ( (cbAlign = Align4(cbTotal) - cbTotal) != 0) - IfFailGo(pIStream->Write(&hr, cbAlign, 0)); - cbTotal += cbAlign; - } + cbTotal = Schema.SaveTo(SchemaBuf); + IfFailGo(pIStream->Write(SchemaBuf, cbTotal, 0)); + if ( (cbAlign = Align4(cbTotal) - cbTotal) != 0) + IfFailGo(pIStream->Write(&hr, cbAlign, 0)); + cbTotal += cbAlign; ULONG headerOffset[TBL_COUNT]; _ASSERTE(m_TblCount <= TBL_COUNT); @@ -3270,7 +3250,7 @@ CMiniMdRW::SaveFullTablesToStream( cbAlign += 4; IfFailGo(pIStream->Write(zeros, cbAlign, 0)); cbTotal += cbAlign; - _ASSERTE((m_cbSaveSize == 0) || (m_cbSaveSize == cbTotal) || (pProfileData != NULL)); + _ASSERTE((m_cbSaveSize == 0) || (m_cbSaveSize == cbTotal)); ErrExit: return hr; @@ -3389,8 +3369,7 @@ __checkReturn HRESULT CMiniMdRW::SaveTablesToStream( IStream *pIStream, // The stream. - MetaDataReorderingOptions reorderingOptions, - CorProfileData *pProfileData) + MetaDataReorderingOptions reorderingOptions) { HRESULT hr; @@ -3403,7 +3382,7 @@ CMiniMdRW::SaveTablesToStream( case MDUpdateIncremental: case MDUpdateExtension: case MDUpdateENC: - hr = SaveFullTablesToStream(pIStream, reorderingOptions, pProfileData); + hr = SaveFullTablesToStream(pIStream, reorderingOptions); break; case MDUpdateDelta: hr = SaveENCTablesToStream(pIStream); diff --git a/src/coreclr/md/inc/liteweightstgdb.h b/src/coreclr/md/inc/liteweightstgdb.h index 649b3d9036c75..72e566201cb9e 100644 --- a/src/coreclr/md/inc/liteweightstgdb.h +++ b/src/coreclr/md/inc/liteweightstgdb.h @@ -129,14 +129,12 @@ class CLiteWeightStgdbRW : public CLiteWeightStgdb HRESULT GetSaveSize( CorSaveSize fSize, UINT32 *pcbSaveSize, - MetaDataReorderingOptions reorderingOptions = NoReordering, - CorProfileData *pProfileData = NULL); // optional IBC profile data for working set optimization + MetaDataReorderingOptions reorderingOptions = NoReordering); __checkReturn HRESULT SaveToStream( IStream *pIStream, // Stream to which to write - MetaDataReorderingOptions reorderingOptions = NoReordering, - CorProfileData *pProfileData = NULL); // optional IBC profile data for working set optimization + MetaDataReorderingOptions reorderingOptions = NoReordering); __checkReturn HRESULT Save( @@ -213,8 +211,7 @@ class CLiteWeightStgdbRW : public CLiteWeightStgdb HRESULT GetTablesSaveSize( CorSaveSize fSave, UINT32 *pcbSaveSize, - MetaDataReorderingOptions reorderingOptions, - CorProfileData *pProfileData = NULL); // Add pool data to this value. + MetaDataReorderingOptions reorderingOptions); __checkReturn HRESULT AddStreamToList( @@ -224,8 +221,7 @@ class CLiteWeightStgdbRW : public CLiteWeightStgdb __checkReturn HRESULT SaveToStorage( TiggerStorage *pStorage, - MetaDataReorderingOptions reorderingOptions = NoReordering, - CorProfileData *pProfileData = NULL); + MetaDataReorderingOptions reorderingOptions = NoReordering); __checkReturn HRESULT SavePool(LPCWSTR szName, TiggerStorage *pStorage, int iPool); diff --git a/src/coreclr/md/inc/metamodelrw.h b/src/coreclr/md/inc/metamodelrw.h index 2cabfc200a2de..13432d9155e8f 100644 --- a/src/coreclr/md/inc/metamodelrw.h +++ b/src/coreclr/md/inc/metamodelrw.h @@ -201,7 +201,6 @@ typedef CMetaDataHashBase CLookUpHash; class MDTOKENMAP; class MDInternalRW; -class CorProfileData; class UTSemReadWrite; template class CLiteWeightStgdb; @@ -247,14 +246,13 @@ class CMiniMdRW : public CMiniMdTemplate CorSaveSize fSave, UINT32 *pcbSize, DWORD *pbCompressed, - MetaDataReorderingOptions reorderingOptions = NoReordering, - CorProfileData *pProfileData = NULL); + MetaDataReorderingOptions reorderingOptions = NoReordering); int IsPoolEmpty(int iPool); __checkReturn HRESULT GetPoolSaveSize(int iPool, UINT32 *pcbSize); __checkReturn - HRESULT SaveTablesToStream(IStream *pIStream, MetaDataReorderingOptions reorderingOptions, CorProfileData *pProfileData); + HRESULT SaveTablesToStream(IStream *pIStream, MetaDataReorderingOptions reorderingOptions); __checkReturn HRESULT SavePoolToStream(int iPool, IStream *pIStream); __checkReturn @@ -1012,7 +1010,7 @@ class CMiniMdRW : public CMiniMdTemplate FORCEINLINE int IsPreSaveDone() { return m_bPreSaveDone; } protected: - __checkReturn HRESULT PreSave(MetaDataReorderingOptions reorderingOptions=NoReordering, CorProfileData *pProfileData=NULL); + __checkReturn HRESULT PreSave(MetaDataReorderingOptions reorderingOptions=NoReordering); __checkReturn HRESULT PostSave(); __checkReturn HRESULT PreSaveFull(); @@ -1029,18 +1027,16 @@ class CMiniMdRW : public CMiniMdTemplate CorSaveSize fSave, UINT32 *pcbSize, DWORD *pbCompressed, - MetaDataReorderingOptions reorderingOptions = NoReordering, - CorProfileData *pProfileData = NULL); + MetaDataReorderingOptions reorderingOptions = NoReordering); __checkReturn HRESULT GetENCSaveSize(UINT32 *pcbSize); __checkReturn HRESULT GetHotPoolsSaveSize( UINT32 *pcbSize, - MetaDataReorderingOptions reorderingOptions, - CorProfileData *pProfileData); + MetaDataReorderingOptions reorderingOptions); __checkReturn - HRESULT SaveFullTablesToStream(IStream *pIStream, MetaDataReorderingOptions reorderingOptions=NoReordering, CorProfileData *pProfileData = NULL ); + HRESULT SaveFullTablesToStream(IStream *pIStream, MetaDataReorderingOptions reorderingOptions=NoReordering); __checkReturn HRESULT SaveENCTablesToStream(IStream *pIStream); diff --git a/src/coreclr/md/runtime/liteweightstgdb.cpp b/src/coreclr/md/runtime/liteweightstgdb.cpp index 02015b3dac5d8..b38e9e5833d1b 100644 --- a/src/coreclr/md/runtime/liteweightstgdb.cpp +++ b/src/coreclr/md/runtime/liteweightstgdb.cpp @@ -154,12 +154,6 @@ CLiteWeightStgdb::InitOnMem( bFoundMd = true; } - // Found the hot meta data stream - else if (strcmp(pStream->GetName(), HOT_MODEL_STREAM_A) == 0) - { - Debug_ReportError("MetaData hot stream is peresent, but ngen is not supported."); - // Ignore the stream - } // Pick off the next stream if there is one. pStream = pNext; cbStreamBuffer = (ULONG)((LPBYTE)pData + cbData - (LPBYTE)pNext); diff --git a/src/coreclr/nativeaot/Runtime/eventtrace.cpp b/src/coreclr/nativeaot/Runtime/eventtrace.cpp index 55138d7fec089..f9f3979454daa 100644 --- a/src/coreclr/nativeaot/Runtime/eventtrace.cpp +++ b/src/coreclr/nativeaot/Runtime/eventtrace.cpp @@ -6444,11 +6444,6 @@ void ETW::EnumerationLog::EnumerationHelper(Module* moduleFilter, BaseDomain* do GC_TRIGGERS; } CONTRACTL_END; - // Disable IBC logging during ETW enumeration since we call a lot of functionality - // that does logging and causes problems in the shutdown path due to critical - // section access for IBC logging - IBCLoggingDisabler disableLogging; - // See code:#TableLockHolder ReJitManager::TableLockHolder lkRejitMgrSharedDomain(SharedDomain::GetDomain()->GetReJitManager()); diff --git a/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/ReferenceSource/callhelpers.cpp b/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/ReferenceSource/callhelpers.cpp index ae37523742b05..9fae31422a502 100644 --- a/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/ReferenceSource/callhelpers.cpp +++ b/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/ReferenceSource/callhelpers.cpp @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. /* * CallHelpers.CPP: helpers to call managed code - * + * */ @@ -28,12 +28,12 @@ void AssertMulticoreJitAllowedModule(PCODE pTarget) } CONTRACTL_END; - MethodDesc* pMethod = Entry2MethodDesc(pTarget, NULL); + MethodDesc* pMethod = Entry2MethodDesc(pTarget, NULL); Module * pModule = pMethod->GetModule_NoLogging(); #if defined(FEATURE_APPX_BINDER) - + // For Appx process, allow certain modules to load on background thread if (AppX::IsAppXProcess()) { @@ -89,7 +89,7 @@ void CallDescrWorkerWithHandler( } -#if !defined(_WIN64) && defined(_DEBUG) +#if !defined(_WIN64) && defined(_DEBUG) //******************************************************************************* // assembly code, in i386/asmhelpers.asm @@ -103,7 +103,7 @@ void CallDescrWorker(CallDescrData * pCallDescrData) // unwind the C++ handler before branching to the catch clause in managed code. That essentially causes an // out-of-order destruction of the contract object, resulting in very odd crashes later. // -#if 0 +#if 0 CONTRACTL { THROWS; GC_TRIGGERS; @@ -189,7 +189,7 @@ void DispatchCallDebuggerWrapper( // Helper for VM->managed calls with simple signatures. void * DispatchCallSimple( SIZE_T *pSrc, - DWORD numStackSlotsToCopy, + DWORD numStackSlotsToCopy, PCODE pTargetAddress, DWORD dwDispatchCallSimpleFlags) { @@ -201,7 +201,7 @@ void * DispatchCallSimple( } CONTRACTL_END; -#ifdef DEBUGGING_SUPPORTED +#ifdef DEBUGGING_SUPPORTED if (CORDebuggerTraceCall()) g_pDebugInterface->TraceCall((const BYTE *)pTargetAddress); #endif // DEBUGGING_SUPPORTED @@ -261,7 +261,7 @@ void DispatchCall( } CONTRACTL_END; -#ifdef DEBUGGING_SUPPORTED +#ifdef DEBUGGING_SUPPORTED if (CORDebuggerTraceCall()) g_pDebugInterface->TraceCall((const BYTE *)pCallDescrData->pTarget); #endif // DEBUGGING_SUPPORTED @@ -320,7 +320,7 @@ void FillInRegTypeMap(int argOffset, CorElementType typ, BYTE * pMap) // right for each arg. if (regArgNum < NUM_ARGUMENT_REGISTERS) - { + { pMap[regArgNum] = typ; } } @@ -342,8 +342,8 @@ ARG_SLOT MethodDescCallSite::CallTargetWorker(const ARG_SLOT *pArguments) // // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING // - // This method needs to have a GC_TRIGGERS contract because it - // calls managed code. However, IT MAY NOT TRIGGER A GC ITSELF + // This method needs to have a GC_TRIGGERS contract because it + // calls managed code. However, IT MAY NOT TRIGGER A GC ITSELF // because the argument array is not protected and may contain gc // refs. // @@ -361,7 +361,7 @@ ARG_SLOT MethodDescCallSite::CallTargetWorker(const ARG_SLOT *pArguments) #ifdef FEATURE_COMINTEROP // If we're an exe, then we must either be initializing the first AD, or have already setup the main thread's // COM apartment state. - // If you hit this assert, then you likely introduced code during startup that could inadvertently + // If you hit this assert, then you likely introduced code during startup that could inadvertently // initialize the COM apartment state of the main thread before we set it based on the user attribute. PRECONDITION(g_fInExecuteMainMethod ? (g_fMainThreadApartmentStateSet || g_fInitializingInitialAD) : TRUE); #endif // FEATURE_COMINTEROP @@ -375,7 +375,7 @@ ARG_SLOT MethodDescCallSite::CallTargetWorker(const ARG_SLOT *pArguments) // // @todo: In an ideal world, we would require each of those sites to do the override rather than disabling // the assert broadly here. However, by limiting the override to mscorlib methods, we should still be able - // to effectively enforce the more general rule about loader recursion. + // to effectively enforce the more general rule about loader recursion. MAYBE_OVERRIDE_TYPE_LOAD_LEVEL_LIMIT(CLASS_LOADED, m_pMD->GetModule()->IsSystem()); LPBYTE pTransitionBlock; @@ -391,17 +391,14 @@ ARG_SLOT MethodDescCallSite::CallTargetWorker(const ARG_SLOT *pArguments) { // - // the incoming argument array is not gc-protected, so we + // the incoming argument array is not gc-protected, so we // may not trigger a GC before we actually call managed code // GCX_FORBID(); - // Record this call if required - g_IBCLogger.LogMethodDescAccess(m_pMD); - - // + // // All types must already be loaded. This macro also sets up a FAULT_FORBID region which is - // also required for critical calls since we cannot inject any failure points between the + // also required for critical calls since we cannot inject any failure points between the // caller of MethodDesc::CallDescr and the actual transition to managed code. // ENABLE_FORBID_GC_LOADER_USE_IN_THIS_SCOPE(); @@ -492,7 +489,7 @@ ARG_SLOT MethodDescCallSite::CallTargetWorker(const ARG_SLOT *pArguments) } #ifdef FEATURE_HFA #ifdef FEATURE_INTERPRETER - // Something is necessary for HFA's, but what's below (in the FEATURE_INTERPRETER ifdef) + // Something is necessary for HFA's, but what's below (in the FEATURE_INTERPRETER ifdef) // doesn't seem to do the proper test. It fires, // incorrectly, for a one-word struct that *doesn't* have a ret buff. So we'll try this, instead: // We're here because it doesn't have a ret buff. If it would, except that the struct being returned @@ -642,7 +639,7 @@ ARG_SLOT MethodDescCallSite::CallTargetWorker(const ARG_SLOT *pArguments) } } #endif // !defined(_WIN64) && BIGENDIAN - + return retval; } diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs index b079d34525e11..a657279bfd1b1 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs @@ -475,8 +475,6 @@ private void PublishCode() _methodCodeNode.InitializeLocalTypes(localTypes); #endif - - PublishProfileData(); } private void PublishROData() @@ -496,8 +494,6 @@ private void PublishROData() _roDataBlob.InitializeData(objectData); } - partial void PublishProfileData(); - private MethodDesc MethodBeingCompiled { get @@ -570,7 +566,6 @@ private void CompileMethodCleanup() _lastException = null; #if READYTORUN - _profileDataNode = null; _inlinedMethods = new ArrayBuilder(); _actualInstructionSetSupported = default(InstructionSetFlags); _actualInstructionSetUnsupported = default(InstructionSetFlags); @@ -3628,7 +3623,7 @@ private void recordRelocation(void* location, void* locationRW, void* target, us #if READYTORUN case BlockType.BBCounts: - relocTarget = _profileDataNode; + relocTarget = null; break; #endif diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/ProfileDataNode.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/ProfileDataNode.cs deleted file mode 100644 index 0a4b2b89120d0..0000000000000 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/ProfileDataNode.cs +++ /dev/null @@ -1,133 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Reflection.Metadata.Ecma335; -using ILCompiler.DependencyAnalysisFramework; -using Internal.Text; -using Internal.TypeSystem; -using Internal.TypeSystem.Ecma; - -namespace ILCompiler.DependencyAnalysis.ReadyToRun -{ - public class ProfileDataNode : EmbeddedObjectNode, ISymbolDefinitionNode - { - MethodWithGCInfo _methodNode; - private byte[] _profileData; - private int _ilSize; - private int _blockCount; - private TargetDetails _targetDetails; - - public ProfileDataNode(MethodWithGCInfo methodNode, TargetDetails targetDetails) - { - _methodNode = methodNode; - _targetDetails = targetDetails; - } - - public void SetProfileData(int ilSize, int blockCount, byte[] data) - { - Debug.Assert(_profileData == null); // This function should not be called twice on the same object - - _profileData = data; - _ilSize = ilSize; - _blockCount = blockCount; - } - - public override bool StaticDependenciesAreComputed => _profileData != null; - - public override int ClassCode => 274394286; - - private int OffsetFromStartOfObjectToSymbol - { - get - { - int offset = 0 - // sizeof(CORCOMPILE_METHOD_PROFILE_LIST) - + _targetDetails.PointerSize // (CORCOMPILE_METHOD_PROFILE_LIST::next) - // sizeof(CORBBTPROF_METHOD_HEADER) - + sizeof(int) // (CORBBTPROF_METHOD_HEADER::size) - + sizeof(int) // (CORBBTPROF_METHOD_HEADER::cDetail) - // Next field is a CORBBT_METHOD_INFO struct (CORBBTPROF_METHOD_HEADER::method) - + sizeof(int) // (CORBBT_METHOD_INFO::token) - + sizeof(int) // (CORBBT_METHOD_INFO::ILSize) - + sizeof(int); // (CORBBT_METHOD_INFO::cBlock) - // At this offset lies the block counts - return offset; - } - } - - int ISymbolDefinitionNode.Offset - { - get - { - // At this offset lies the block counts - return OffsetFromStartOfObjectToSymbol + OffsetFromBeginningOfArray; - } - } - - int ISymbolNode.Offset => 0; - - public void AppendMangledName(NameMangler nameMangler, Utf8StringBuilder sb) - { - sb.Append("ProfileDataNode->"); - _methodNode.AppendMangledName(nameMangler, sb); - } - - protected override void OnMarked(NodeFactory factory) - { - factory.ProfileDataSection.AddEmbeddedObject(this); - } - - public override void EncodeData(ref ObjectDataBuilder dataBuilder, NodeFactory factory, bool relocsOnly) - { - ProfileDataNode nextElementInList = ((ProfileDataSectionNode)ContainingNode).NextElementToEncode; - if (nextElementInList != null) - dataBuilder.EmitPointerReloc(nextElementInList, -OffsetFromStartOfObjectToSymbol); - else - dataBuilder.EmitZeroPointer(); - - if (relocsOnly) - { - return; - } - - EcmaMethod ecmaMethod = (EcmaMethod)_methodNode.Method.GetTypicalMethodDefinition(); - int startOffset = dataBuilder.CountBytes; - var reservation = dataBuilder.ReserveInt(); - - dataBuilder.EmitInt(0); // CORBBTPROF_METHOD_HEADER::cDetail - dataBuilder.EmitInt(ecmaMethod.MetadataReader.GetToken(ecmaMethod.Handle)); // CORBBT_METHOD_INFO::token - dataBuilder.EmitInt(_ilSize); // CORBBT_METHOD_INFO::ILSize - dataBuilder.EmitInt(_blockCount); // CORBBT_METHOD_INFO::cBlock - int sizeOfCORBBTPROF_METHOD_HEADER = dataBuilder.CountBytes - startOffset; - - Debug.Assert(sizeOfCORBBTPROF_METHOD_HEADER == (OffsetFromStartOfObjectToSymbol - _targetDetails.PointerSize)); - dataBuilder.EmitInt(reservation, sizeOfCORBBTPROF_METHOD_HEADER + _profileData.Length); - - dataBuilder.EmitBytes(_profileData); - - while ((dataBuilder.CountBytes & (dataBuilder.TargetPointerSize - 1)) != 0) - dataBuilder.EmitByte(0); - } - - protected override string GetName(NodeFactory context) - { - Utf8StringBuilder sb = new Utf8StringBuilder(); - sb.Append("ProfileDataNode->"); - _methodNode.AppendMangledName(context.NameMangler, sb); - return sb.ToString(); - } - - public override IEnumerable GetStaticDependencies(NodeFactory context) - { - return Array.Empty(); - } - - public override int CompareToImpl(ISortableNode other, CompilerComparer comparer) - { - return comparer.Compare(_methodNode, ((ProfileDataNode)other)._methodNode); - } - } -} diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/ProfileDataSectionNode.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/ProfileDataSectionNode.cs deleted file mode 100644 index 2046fb1fb428d..0000000000000 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/ProfileDataSectionNode.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Internal.Text; - -namespace ILCompiler.DependencyAnalysis.ReadyToRun -{ - public class ProfileDataSectionNode : ArrayOfEmbeddedDataNode - { - public ProfileDataSectionNode() - : base("ProfileDataSectionNode_Begin", "ProfileDataSectionNode_End", new EmbeddedObjectNodeComparer(CompilerComparer.Instance)) - { - } - - public override int ClassCode => 576050264; - - public override ObjectNodeSection Section => ObjectNodeSection.DataSection; - - public override bool StaticDependenciesAreComputed => true; - - public override bool IsShareable => false; - } -} diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRunCodegenNodeFactory.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRunCodegenNodeFactory.cs index 8ae0b41d24b67..81b4c8e981efc 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRunCodegenNodeFactory.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRunCodegenNodeFactory.cs @@ -256,7 +256,7 @@ private void CreateNodeCaches() { return new DelayLoadHelperMethodImport( this, - DispatchImports, + DispatchImports, ReadyToRunHelper.DelayLoad_Helper_Obj, key.Method, useVirtualCall: false, @@ -301,11 +301,6 @@ private void CreateNodeCaches() { return new CopiedManagedResourcesNode(module); }); - - _profileDataCountsNodes = new NodeCache(method => - { - return new ProfileDataNode(method, Target); - }); } public int CompilationCurrentPhase { get; private set; } @@ -326,7 +321,6 @@ private void CreateNodeCaches() public RuntimeFunctionsGCInfoNode RuntimeFunctionsGCInfo; - public ProfileDataSectionNode ProfileDataSection; public DelayLoadMethodCallThunkNodeRange DelayLoadMethodCallThunks; public InstanceEntryPointTableNode InstanceEntryPointTable; @@ -533,7 +527,7 @@ public VirtualResolutionFixupSignatureFixupKey(ReadyToRunFixupKind fixupKind, Me public bool Equals(VirtualResolutionFixupSignatureFixupKey other) { - return FixupKind == other.FixupKind && DeclMethod.Equals(other.DeclMethod) && ImplType == other.ImplType && + return FixupKind == other.FixupKind && DeclMethod.Equals(other.DeclMethod) && ImplType == other.ImplType && ((ImplMethod == null && other.ImplMethod == null) || (ImplMethod != null && ImplMethod.Equals(other.ImplMethod))); } @@ -618,9 +612,6 @@ public void AttachToDependencyGraph(DependencyAnalyzerBase graph) RuntimeFunctionsGCInfo = new RuntimeFunctionsGCInfoNode(); graph.AddRoot(RuntimeFunctionsGCInfo, "GC info is always generated"); - ProfileDataSection = new ProfileDataSectionNode(); - Header.Add(Internal.Runtime.ReadyToRunSectionType.ProfileDataInfo, ProfileDataSection, ProfileDataSection.StartSymbol); - DelayLoadMethodCallThunks = new DelayLoadMethodCallThunkNodeRange(); Header.Add(Internal.Runtime.ReadyToRunSectionType.DelayLoadMethodCallThunks, DelayLoadMethodCallThunks, DelayLoadMethodCallThunks); @@ -932,12 +923,5 @@ public CopiedManagedResourcesNode CopiedManagedResources(EcmaModule module) { return _copiedManagedResources.GetOrAdd(module); } - - private NodeCache _profileDataCountsNodes; - - public ProfileDataNode ProfileData(MethodWithGCInfo method) - { - return _profileDataCountsNodes.GetOrAdd(method); - } } } diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilationBuilder.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilationBuilder.cs index 357946bb4870c..03a583173545c 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilationBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilationBuilder.cs @@ -23,7 +23,6 @@ public sealed class ReadyToRunCodegenCompilationBuilder : CompilationBuilder private readonly IEnumerable _inputFiles; private readonly string _compositeRootPath; - private bool _ibcTuning; private bool _generateMapFile; private bool _generateMapCsvFile; private bool _generatePdbFile; @@ -111,12 +110,6 @@ public ReadyToRunCodegenCompilationBuilder UseJitPath(string jitPath) return this; } - public ReadyToRunCodegenCompilationBuilder UseIbcTuning(bool ibcTuning) - { - _ibcTuning = ibcTuning; - return this; - } - public ReadyToRunCodegenCompilationBuilder UseProfileData(ProfileDataManager profileData) { _profileData = profileData; @@ -280,9 +273,6 @@ public override ICompilation ToCompilation() break; } - if (_ibcTuning) - corJitFlags.Add(CorJitFlag.CORJIT_FLAG_BBINSTR); - if (!_isJitInitialized) { JitConfigProvider.Initialize(_context.Target, corJitFlags, _ryujitOptions, _jitPath); diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj index 3655d355f0c67..f779f573e766b 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj @@ -165,8 +165,6 @@ - - diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs index 02ef56fab2a3c..2b09cadceebb0 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs @@ -2439,16 +2439,6 @@ private void expandRawHandleIntrinsic(ref CORINFO_RESOLVED_TOKEN pResolvedToken, } private byte[] _bbCounts; - private ProfileDataNode _profileDataNode; - - partial void PublishProfileData() - { - if (_profileDataNode != null) - { - MethodIL methodIL = _compilation.GetMethodIL(MethodBeingCompiled); - _profileDataNode.SetProfileData(methodIL.GetILBytes().Length, _bbCounts.Length / sizeof(BlockCounts), _bbCounts); - } - } partial void findKnownBBCountBlock(ref BlockType blockType, void* location, ref int offset) { @@ -2516,10 +2506,6 @@ private unsafe HRESULT allocPgoInstrumentationBySchema(CORINFO_METHOD_STRUCT_* f blockCounts[iSchema].ILOffset = (uint)pSchema[iSchema].ILOffset; } - if (_profileDataNode == null) - { - _profileDataNode = _compilation.NodeFactory.ProfileData(_methodCodeNode); - } return 0; } diff --git a/src/coreclr/tools/aot/crossgen2/CommandLineOptions.cs b/src/coreclr/tools/aot/crossgen2/CommandLineOptions.cs index 0c431a2986396..9e0a4ba945916 100644 --- a/src/coreclr/tools/aot/crossgen2/CommandLineOptions.cs +++ b/src/coreclr/tools/aot/crossgen2/CommandLineOptions.cs @@ -48,7 +48,6 @@ internal class CommandLineOptions public string JitPath; public string SystemModule; public bool WaitForDebugger; - public bool Tuning; public bool Partial; public bool Resilient; public bool Map; @@ -133,7 +132,6 @@ public CommandLineOptions(string[] args) syntax.DefineOption("compile-no-methods", ref CompileNoMethods, SR.CompileNoMethodsOption); syntax.DefineOption("out-near-input", ref OutNearInput, SR.OutNearInputOption); syntax.DefineOption("single-file-compilation", ref SingleFileCompilation, SR.SingleFileCompilationOption); - syntax.DefineOption("tuning", ref Tuning, SR.TuningImageOption); syntax.DefineOption("partial", ref Partial, SR.PartialImageOption); syntax.DefineOption("compilebubblegenerics", ref CompileBubbleGenerics, SR.BubbleGenericsOption); syntax.DefineOption("embed-pgo-data", ref EmbedPgoData, SR.EmbedPgoDataOption); diff --git a/src/coreclr/tools/aot/crossgen2/Program.cs b/src/coreclr/tools/aot/crossgen2/Program.cs index be2b6b5d09b09..3302cf5be433b 100644 --- a/src/coreclr/tools/aot/crossgen2/Program.cs +++ b/src/coreclr/tools/aot/crossgen2/Program.cs @@ -737,7 +737,6 @@ private void RunSingleCompilation(Dictionary inFilePaths, Instru DependencyTrackingLevel.None : (_commandLineOptions.GenerateFullDgmlLog ? DependencyTrackingLevel.All : DependencyTrackingLevel.First); builder - .UseIbcTuning(_commandLineOptions.Tuning) .UseMapFile(_commandLineOptions.Map) .UseMapCsvFile(_commandLineOptions.MapCsv) .UsePdbFile(_commandLineOptions.Pdb, _commandLineOptions.PdbPath) diff --git a/src/coreclr/tools/aot/crossgen2/Properties/Resources.resx b/src/coreclr/tools/aot/crossgen2/Properties/Resources.resx index 04ef03c237af9..e5deb22319cdc 100644 --- a/src/coreclr/tools/aot/crossgen2/Properties/Resources.resx +++ b/src/coreclr/tools/aot/crossgen2/Properties/Resources.resx @@ -1,17 +1,17 @@  - @@ -273,9 +273,6 @@ Target OS is not supported - - Generate IBC tuning image - Both method name and type name are required parameters for single method mode diff --git a/src/coreclr/utilcode/pedecoder.cpp b/src/coreclr/utilcode/pedecoder.cpp index 671233cc41117..7e72b1bc88de4 100644 --- a/src/coreclr/utilcode/pedecoder.cpp +++ b/src/coreclr/utilcode/pedecoder.cpp @@ -1125,9 +1125,6 @@ CHECK PEDecoder::CheckCorHeader() const for(namelen=0; (namelen<32)&&(pSS->rcName[namelen]!=0); namelen++); CHECK((0 < namelen)&&(namelen < 32)); - // Forbid HOT_MODEL_STREAM - CHECK(strcmp(pSS->rcName, HOT_MODEL_STREAM_A) != 0); - pcMD = dac_cast(NextStorageStream(pSS)); ctMD -= (COUNT_T)(pcMD - dac_cast(pSS)); diff --git a/src/coreclr/vm/CMakeLists.txt b/src/coreclr/vm/CMakeLists.txt index b8351536752ac..8c0b03342d016 100644 --- a/src/coreclr/vm/CMakeLists.txt +++ b/src/coreclr/vm/CMakeLists.txt @@ -333,7 +333,6 @@ set(VM_SOURCES_WKS genanalysis.cpp genmeth.cpp hosting.cpp - ibclogger.cpp ilmarshalers.cpp interopconverter.cpp interoputil.cpp @@ -436,7 +435,6 @@ set(VM_HEADERS_WKS gcenv.ee.h gcenv.os.h gchelpers.h - ibclogger.h ilmarshalers.h interopconverter.h interoputil.h diff --git a/src/coreclr/vm/appdomain.cpp b/src/coreclr/vm/appdomain.cpp index c0741f5c50ee6..efcf7dd2d25dd 100644 --- a/src/coreclr/vm/appdomain.cpp +++ b/src/coreclr/vm/appdomain.cpp @@ -1758,8 +1758,6 @@ StackWalkAction SystemDomain::CallersMethodCallbackWithStackMark(CrawlFrame* pCf // MethodInfo, Type or Delegate (and depending on which invoke overload is // being used, several different reflection classes may be involved). - g_IBCLogger.LogMethodDescAccess(pFunc); - if (SystemDomain::IsReflectionInvocationMethod(pFunc)) return SWA_CONTINUE; diff --git a/src/coreclr/vm/callhelpers.cpp b/src/coreclr/vm/callhelpers.cpp index c0cf4cdb46aea..da342a1b1f01b 100644 --- a/src/coreclr/vm/callhelpers.cpp +++ b/src/coreclr/vm/callhelpers.cpp @@ -305,9 +305,6 @@ void MethodDescCallSite::CallTargetWorker(const ARG_SLOT *pArguments, ARG_SLOT * // GCX_FORBID(); - // Record this call if required - g_IBCLogger.LogMethodDescAccess(m_pMD); - // // All types must already be loaded. This macro also sets up a FAULT_FORBID region which is // also required for critical calls since we cannot inject any failure points between the diff --git a/src/coreclr/vm/ceeload.cpp b/src/coreclr/vm/ceeload.cpp index 56616d3db9c4a..a6a863d70af82 100644 --- a/src/coreclr/vm/ceeload.cpp +++ b/src/coreclr/vm/ceeload.cpp @@ -352,35 +352,6 @@ Module::Module(Assembly *pAssembly, mdFile moduleRef, PEAssembly *pPEAssembly) pPEAssembly->AddRef(); } -void Module::InitializeForProfiling() -{ - CONTRACTL - { - INSTANCE_CHECK; - THROWS; - GC_TRIGGERS; - MODE_PREEMPTIVE; - PRECONDITION(IsReadyToRun()); - } - CONTRACTL_END; - - COUNT_T cbProfileList = 0; - - m_nativeImageProfiling = FALSE; - -#ifdef FEATURE_READYTORUN - // We already setup the m_methodProfileList in the ReadyToRunInfo constructor - if (m_methodProfileList != nullptr) - { - ReadyToRunInfo * pInfo = GetReadyToRunInfo(); - PEImageLayout * pImage = pInfo->GetImage(); - - // Enable profiling if the ZapBBInstr value says to - m_nativeImageProfiling = GetAssembly()->IsInstrumented(); - } -#endif -} - BOOL Module::IsPersistedObject(void *address) { LIMITED_METHOD_CONTRACT; @@ -535,11 +506,6 @@ void Module::Initialize(AllocMemTracker *pamTracker, LPCWSTR szName) // Prepare statics that are known at module load time AllocateStatics(pamTracker); - if (IsReadyToRun()) - { - InitializeForProfiling(); - } - if (m_AssemblyRefByNameTable == NULL) { Module::CreateAssemblyRefByNameTable(pamTracker); @@ -2155,9 +2121,6 @@ void Module::FreeClassTables() FastInterlockOr(&m_dwTransientFlags, CLASSES_FREED); - // disable ibc here because it can cause errors during the destruction of classes - IBCLoggingDisabler disableLogging; - #if _DEBUG DebugLogRidMapOccupancy(); #endif @@ -2250,22 +2213,6 @@ void Module::StartUnload() } #endif // PROFILING_SUPPORTED - if (g_IBCLogger.InstrEnabled()) - { - Thread * pThread = GetThread(); - ThreadLocalIBCInfo* pInfo = pThread->GetIBCInfo(); - - // Acquire the Crst lock before creating the IBCLoggingDisabler object. - // Only one thread at a time can be processing an IBC logging event. - CrstHolder lock(IBCLogger::GetSync()); - { - IBCLoggingDisabler disableLogging( pInfo ); // runs IBCLoggingDisabler::DisableLogging - - // Write out the method profile data - /*hr=*/WriteMethodProfileDataLogFile(true); - } - } - SetBeingUnloaded(); } @@ -3520,8 +3467,6 @@ TypeHandle Module::LookupTypeRef(mdTypeRef token) _ASSERTE(TypeFromToken(token) == mdtTypeRef); - g_IBCLogger.LogRidMapAccess( MakePair( this, token ) ); - TypeHandle entry = TypeHandle::FromTAddr(dac_cast(m_TypeRefToMethodTableMap.GetElement(RidFromToken(token)))); if (entry.IsNull()) @@ -4769,2122 +4714,120 @@ BOOL Module::FixupNativeEntry(CORCOMPILE_IMPORT_SECTION* pSection, SIZE_T fixupI return TRUE; } -// -// Profile data management -// +static LPCWSTR s_pCommandLine = NULL; -ICorJitInfo::BlockCounts * Module::AllocateMethodBlockCounts(mdToken _token, DWORD _count, DWORD _ILSize) +// Retrieve the full command line for the current process. +LPCWSTR GetManagedCommandLine() { - CONTRACT (ICorJitInfo::BlockCounts*) - { - INSTANCE_CHECK; - THROWS; - GC_NOTRIGGER; - MODE_ANY; - INJECT_FAULT(CONTRACT_RETURN NULL;); - POSTCONDITION(CheckPointer(RETVAL, NULL_OK)); - } - CONTRACT_END; - - _ASSERTE(_ILSize != 0); - - DWORD listSize = sizeof(CORCOMPILE_METHOD_PROFILE_LIST); - DWORD headerSize = sizeof(CORBBTPROF_METHOD_HEADER); - DWORD blockSize = _count * sizeof(CORBBTPROF_BLOCK_DATA); - DWORD totalSize = listSize + headerSize + blockSize; - - BYTE * memory = (BYTE *) (void *) this->m_pAssembly->GetLowFrequencyHeap()->AllocMem(S_SIZE_T(totalSize)); - - CORCOMPILE_METHOD_PROFILE_LIST * methodProfileList = (CORCOMPILE_METHOD_PROFILE_LIST *) (memory + 0); - CORBBTPROF_METHOD_HEADER * methodProfileData = (CORBBTPROF_METHOD_HEADER *) (memory + listSize); - - // Note: Memory allocated on the LowFrequencyHeap is zero filled - - methodProfileData->size = headerSize + blockSize; - methodProfileData->method.token = _token; - methodProfileData->method.ILSize = _ILSize; - methodProfileData->method.cBlock = _count; - - _ASSERTE(methodProfileData->size == methodProfileData->Size()); - - // Link it to the per module list of profile data buffers - - methodProfileList->next = m_methodProfileList; - m_methodProfileList = methodProfileList; - - RETURN ((ICorJitInfo::BlockCounts *) &methodProfileData->method.block[0]); + LIMITED_METHOD_CONTRACT; + return s_pCommandLine; } -HANDLE Module::OpenMethodProfileDataLogFile(GUID mvid) +LPCWSTR GetCommandLineForDiagnostics() { - CONTRACTL - { - INSTANCE_CHECK; - THROWS; - GC_NOTRIGGER; - MODE_ANY; - } - CONTRACTL_END; - - HANDLE profileDataFile = INVALID_HANDLE_VALUE; - - SString path; - LPCWSTR assemblyPath = m_pPEAssembly->GetPath(); - LPCWSTR ibcDir = g_pConfig->GetZapBBInstrDir(); // should we put the ibc data into a particular directory? - if (ibcDir == 0) { - path.Set(assemblyPath); // no, then put it beside the IL dll - } - else { - LPCWSTR assemblyFileName = wcsrchr(assemblyPath, DIRECTORY_SEPARATOR_CHAR_W); - if (assemblyFileName) - assemblyFileName++; // skip past the \ char - else - assemblyFileName = assemblyPath; + // Get the managed command line. + LPCWSTR pCmdLine = GetManagedCommandLine(); - path.Set(ibcDir); // yes, put it in the directory, named with the assembly name. - path.Append(DIRECTORY_SEPARATOR_CHAR_W); - path.Append(assemblyFileName); + // Checkout https://github.com/dotnet/coreclr/pull/24433 for more information about this fall back. + if (pCmdLine == nullptr) + { + // Use the result from GetCommandLineW() instead + pCmdLine = GetCommandLineW(); } - SString::Iterator ext = path.End(); // remove the extension - if (path.FindBack(ext, '.')) - path.Truncate(ext); - path.Append(W(".ibc")); // replace with .ibc extension - - profileDataFile = WszCreateFile(path, GENERIC_READ | GENERIC_WRITE, 0, NULL, - OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, - NULL); + return pCmdLine; +} - if (profileDataFile == INVALID_HANDLE_VALUE) COMPlusThrowWin32(); +void Append_Next_Item(LPWSTR* ppCursor, SIZE_T* pRemainingLen, LPCWSTR pItem, bool addSpace) +{ + // read the writeback args and setup pCursor and remainingLen + LPWSTR pCursor = *ppCursor; + SIZE_T remainingLen = *pRemainingLen; - DWORD count; - CORBBTPROF_FILE_HEADER fileHeader; + // Calculate the length of pItem + SIZE_T itemLen = wcslen(pItem); - SetFilePointer(profileDataFile, 0, NULL, FILE_BEGIN); - BOOL result = ReadFile(profileDataFile, &fileHeader, sizeof(fileHeader), &count, NULL); - if (result && - (count == sizeof(fileHeader)) && - (fileHeader.HeaderSize == sizeof(CORBBTPROF_FILE_HEADER)) && - (fileHeader.Magic == CORBBTPROF_MAGIC) && - (fileHeader.Version == CORBBTPROF_CURRENT_VERSION) && - (fileHeader.MVID == mvid)) - { - // - // The existing file was from the same assembly version - just append to it. - // + // Append pItem at pCursor + wcscpy_s(pCursor, remainingLen, pItem); + pCursor += itemLen; + remainingLen -= itemLen; - SetFilePointer(profileDataFile, 0, NULL, FILE_END); - } - else + // Also append a space after pItem, if requested + if (addSpace) { - // - // Either this is a new file, or it's from a previous version. Replace the contents. - // - - SetFilePointer(profileDataFile, 0, NULL, FILE_BEGIN); + // Append a space at pCursor + wcscpy_s(pCursor, remainingLen, W(" ")); + pCursor += 1; + remainingLen -= 1; } - return profileDataFile; + // writeback and update ppCursor and pRemainingLen + *ppCursor = pCursor; + *pRemainingLen = remainingLen; } -// Note that this method cleans up the profile buffers, so it's crucial that -// no managed code in the module is allowed to run once this method has -// been called! - -class ProfileMap +void SaveManagedCommandLine(LPCWSTR pwzAssemblyPath, int argc, LPCWSTR *argv) { -public: - SIZE_T getCurrentOffset() {WRAPPER_NO_CONTRACT; return buffer.Size();} - - void * getOffsetPtr(SIZE_T offset) - { - LIMITED_METHOD_CONTRACT; - _ASSERTE(offset <= buffer.Size()); - return ((void *) (((char *) buffer.Ptr()) + offset)); - } - - void *Allocate(SIZE_T size) + CONTRACTL { - CONTRACT(void *) - { - INSTANCE_CHECK; - THROWS; - GC_NOTRIGGER; - MODE_ANY; - INJECT_FAULT(CONTRACT_RETURN NULL;); - POSTCONDITION(CheckPointer(RETVAL, NULL_OK)); - } - CONTRACT_END; - - SIZE_T oldSize = buffer.Size(); - buffer.ReSizeThrows(oldSize + size); - RETURN getOffsetPtr(oldSize); + NOTHROW; + GC_NOTRIGGER; + MODE_ANY; } + CONTRACTL_END; -private: - CQuickBytes buffer; -}; + // Get the command line. + LPCWSTR osCommandLine = GetCommandLineW(); -class ProfileEmitter -{ -public: +#ifndef TARGET_UNIX + // On Windows, osCommandLine contains the executable and all arguments. + s_pCommandLine = osCommandLine; +#else + // On UNIX, the PAL doesn't have the command line arguments, so we must build the command line. + // osCommandLine contains the full path to the executable. + SIZE_T commandLineLen = (wcslen(osCommandLine) + 1); - ProfileEmitter() - { - LIMITED_METHOD_CONTRACT; - pSectionList = NULL; - } + // We will append pwzAssemblyPath to the 'corerun' osCommandLine + commandLineLen += (wcslen(pwzAssemblyPath) + 1); - ~ProfileEmitter() + for (int i = 0; i < argc; i++) { - WRAPPER_NO_CONTRACT; - while (pSectionList) - { - SectionList *temp = pSectionList->next; - delete pSectionList; - pSectionList = temp; - } + commandLineLen += (wcslen(argv[i]) + 1); } + commandLineLen++; // Add 1 for the null-termination - ProfileMap *EmitNewSection(SectionFormat format) - { - WRAPPER_NO_CONTRACT; - SectionList *s = new SectionList(); - - s->format = format; - s->next = pSectionList; - pSectionList = s; - - return &s->profileMap; - } + // Allocate a new string for the command line. + LPWSTR pNewCommandLine = new WCHAR[commandLineLen]; + SIZE_T remainingLen = commandLineLen; + LPWSTR pCursor = pNewCommandLine; - // - // Serialize the profile sections into pMap - // + Append_Next_Item(&pCursor, &remainingLen, osCommandLine, true); + Append_Next_Item(&pCursor, &remainingLen, pwzAssemblyPath, (argc > 0)); - void Serialize(ProfileMap *profileMap, GUID mvid) + for (int i = 0; i < argc; i++) { - CONTRACTL - { - INSTANCE_CHECK; - THROWS; - GC_NOTRIGGER; - MODE_ANY; - INJECT_FAULT(COMPlusThrowOM()); - } - CONTRACTL_END; - - // - // Allocate the file header - // - { - CORBBTPROF_FILE_HEADER *fileHeader; - fileHeader = (CORBBTPROF_FILE_HEADER *) profileMap->Allocate(sizeof(CORBBTPROF_FILE_HEADER)); - - fileHeader->HeaderSize = sizeof(CORBBTPROF_FILE_HEADER); - fileHeader->Magic = CORBBTPROF_MAGIC; - fileHeader->Version = CORBBTPROF_CURRENT_VERSION; - fileHeader->MVID = mvid; - } - - // - // Count the number of sections - // - ULONG32 numSections = 0; - for (SectionList *p = pSectionList; p; p = p->next) - { - numSections++; - } - - // - // Allocate the section table - // - SIZE_T tableEntryOffset; - { - CORBBTPROF_SECTION_TABLE_HEADER *tableHeader; - tableHeader = (CORBBTPROF_SECTION_TABLE_HEADER *) - profileMap->Allocate(sizeof(CORBBTPROF_SECTION_TABLE_HEADER)); - - tableHeader->NumEntries = numSections; - tableEntryOffset = profileMap->getCurrentOffset(); - - CORBBTPROF_SECTION_TABLE_ENTRY *tableEntry; - tableEntry = (CORBBTPROF_SECTION_TABLE_ENTRY *) - profileMap->Allocate(sizeof(CORBBTPROF_SECTION_TABLE_ENTRY) * numSections); - } - - // - // Allocate the data sections - // - { - ULONG secCount = 0; - for (SectionList *pSec = pSectionList; pSec; pSec = pSec->next, secCount++) - { - SIZE_T offset = profileMap->getCurrentOffset(); - _ASSERTE((offset & 0x3) == 0); - _ASSERTE(offset <= MAXDWORD); - - SIZE_T actualSize = pSec->profileMap.getCurrentOffset(); - SIZE_T alignUpSize = AlignUp(actualSize, sizeof(DWORD)); - _ASSERTE(alignUpSize <= MAXDWORD); - - profileMap->Allocate(alignUpSize); - - memcpy(profileMap->getOffsetPtr(offset), pSec->profileMap.getOffsetPtr(0), actualSize); - if (alignUpSize > actualSize) - { - memset(((BYTE*)profileMap->getOffsetPtr(offset))+actualSize, 0, (alignUpSize - actualSize)); - } - - CORBBTPROF_SECTION_TABLE_ENTRY *tableEntry; - tableEntry = (CORBBTPROF_SECTION_TABLE_ENTRY *) profileMap->getOffsetPtr(tableEntryOffset); - tableEntry += secCount; - tableEntry->FormatID = pSec->format; - tableEntry->Data.Offset = (DWORD)offset; - tableEntry->Data.Size = (DWORD)alignUpSize; - } - } - - // - // Allocate the end token marker - // - { - ULONG *endToken; - endToken = (ULONG *) profileMap->Allocate(sizeof(ULONG)); - - *endToken = CORBBTPROF_END_TOKEN; - } + bool moreArgs = (i < (argc-1)); + Append_Next_Item(&pCursor, &remainingLen, argv[i], moreArgs); } -private: - struct SectionList - { - SectionFormat format; - ProfileMap profileMap; - SectionList *next; - }; - SectionList * pSectionList; -}; - - -/*static*/ idTypeSpec TypeSpecBlobEntry::s_lastTypeSpecToken = idTypeSpecNil; -/*static*/ idMethodSpec MethodSpecBlobEntry::s_lastMethodSpecToken = idMethodSpecNil; -/*static*/ idExternalNamespace ExternalNamespaceBlobEntry::s_lastExternalNamespaceToken = idExternalNamespaceNil; -/*static*/ idExternalType ExternalTypeBlobEntry::s_lastExternalTypeToken = idExternalTypeNil; -/*static*/ idExternalSignature ExternalSignatureBlobEntry::s_lastExternalSignatureToken = idExternalSignatureNil; -/*static*/ idExternalMethod ExternalMethodBlobEntry::s_lastExternalMethodToken = idExternalMethodNil; - - -inline static size_t HashCombine(size_t h1, size_t h2) -{ - LIMITED_METHOD_CONTRACT; - - size_t result = (h1 * 129) ^ h2; - return result; -} - -bool TypeSpecBlobEntry::IsEqual(const ProfilingBlobEntry * other) const -{ - WRAPPER_NO_CONTRACT; - - if (this->kind() != other->kind()) - return false; - - const TypeSpecBlobEntry * other2 = static_cast(other); - - if (this->cbSig() != other2->cbSig()) - return false; - - PCCOR_SIGNATURE p1 = this->pSig(); - PCCOR_SIGNATURE p2 = other2->pSig(); - - for (DWORD i=0; (i < this->cbSig()); i++) - if (p1[i] != p2[i]) - return false; - - return true; + s_pCommandLine = pNewCommandLine; +#endif } -size_t TypeSpecBlobEntry::Hash() const +void Module::SetIsIJWFixedUp() { - WRAPPER_NO_CONTRACT; - - size_t hashValue = HashInit(); - - PCCOR_SIGNATURE p1 = pSig(); - for (DWORD i=0; (i < cbSig()); i++) - hashValue = HashCombine(hashValue, p1[i]); - - return hashValue; + LIMITED_METHOD_CONTRACT; + FastInterlockOr(&m_dwTransientFlags, IS_IJW_FIXED_UP); } +#endif // !DACCESS_COMPILE -TypeSpecBlobEntry::TypeSpecBlobEntry(DWORD _cbSig, PCCOR_SIGNATURE _pSig) +#ifndef DACCESS_COMPILE +void Module::SetBeingUnloaded() { - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - PRECONDITION(_cbSig > 0); - PRECONDITION(CheckPointer(_pSig)); - } - CONTRACTL_END; - - m_token = idTypeSpecNil; - m_flags = 0; - m_cbSig = 0; - - COR_SIGNATURE * pNewSig = (COR_SIGNATURE *) new (nothrow) BYTE[_cbSig]; - if (pNewSig != NULL) - { - m_flags = 0; - m_cbSig = _cbSig; - memcpy(pNewSig, _pSig, _cbSig); - } - m_pSig = const_cast(pNewSig); + LIMITED_METHOD_CONTRACT; + FastInterlockOr((ULONG*)&m_dwTransientFlags, IS_BEING_UNLOADED); } -/* static */ const TypeSpecBlobEntry * TypeSpecBlobEntry::FindOrAdd(PTR_Module pModule, - DWORD _cbSig, - PCCOR_SIGNATURE _pSig) -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - if ((_cbSig == 0) || (_pSig == NULL)) - return NULL; - - TypeSpecBlobEntry sEntry(_cbSig, _pSig); - - const ProfilingBlobEntry * pEntry = pModule->GetProfilingBlobTable()->Lookup(&sEntry); - if (pEntry == NULL) - { - // - // Not Found, add a new type spec profiling blob entry - // - TypeSpecBlobEntry * newEntry = new (nothrow) TypeSpecBlobEntry(_cbSig, _pSig); - if (newEntry == NULL) - return NULL; - - newEntry->newToken(); // Assign a new ibc type spec token - CONTRACT_VIOLATION(ThrowsViolation); - pModule->GetProfilingBlobTable()->Add(newEntry); - pEntry = newEntry; - } - - // - // Return the type spec entry that we found or the new one that we just created - // - _ASSERTE(pEntry->kind() == ParamTypeSpec); - return static_cast(pEntry); -} - -bool MethodSpecBlobEntry::IsEqual(const ProfilingBlobEntry * other) const -{ - WRAPPER_NO_CONTRACT; - - if (this->kind() != other->kind()) - return false; - - const MethodSpecBlobEntry * other2 = static_cast(other); - - if (this->cbSig() != other2->cbSig()) - return false; - - PCCOR_SIGNATURE p1 = this->pSig(); - PCCOR_SIGNATURE p2 = other2->pSig(); - - for (DWORD i=0; (i < this->cbSig()); i++) - if (p1[i] != p2[i]) - return false; - - return true; -} - -size_t MethodSpecBlobEntry::Hash() const -{ - WRAPPER_NO_CONTRACT; - - size_t hashValue = HashInit(); - - PCCOR_SIGNATURE p1 = pSig(); - for (DWORD i=0; (i < cbSig()); i++) - hashValue = HashCombine(hashValue, p1[i]); - - return hashValue; -} - -MethodSpecBlobEntry::MethodSpecBlobEntry(DWORD _cbSig, PCCOR_SIGNATURE _pSig) -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - PRECONDITION(_cbSig > 0); - PRECONDITION(CheckPointer(_pSig)); - } - CONTRACTL_END; - - m_token = idMethodSpecNil; - m_flags = 0; - m_cbSig = 0; - - COR_SIGNATURE * pNewSig = (COR_SIGNATURE *) new (nothrow) BYTE[_cbSig]; - if (pNewSig != NULL) - { - m_flags = 0; - m_cbSig = _cbSig; - memcpy(pNewSig, _pSig, _cbSig); - } - m_pSig = const_cast(pNewSig); -} - -/* static */ const MethodSpecBlobEntry * MethodSpecBlobEntry::FindOrAdd(PTR_Module pModule, - DWORD _cbSig, - PCCOR_SIGNATURE _pSig) -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - if ((_cbSig == 0) || (_pSig == NULL)) - return NULL; - - MethodSpecBlobEntry sEntry(_cbSig, _pSig); - - const ProfilingBlobEntry * pEntry = pModule->GetProfilingBlobTable()->Lookup(&sEntry); - if (pEntry == NULL) - { - // - // Not Found, add a new method spec profiling blob entry - // - MethodSpecBlobEntry * newEntry = new (nothrow) MethodSpecBlobEntry(_cbSig, _pSig); - if (newEntry == NULL) - return NULL; - - newEntry->newToken(); // Assign a new ibc method spec token - CONTRACT_VIOLATION(ThrowsViolation); - pModule->GetProfilingBlobTable()->Add(newEntry); - pEntry = newEntry; - } - - // - // Return the method spec entry that we found or the new one that we just created - // - _ASSERTE(pEntry->kind() == ParamMethodSpec); - return static_cast(pEntry); -} - -bool ExternalNamespaceBlobEntry::IsEqual(const ProfilingBlobEntry * other) const -{ - WRAPPER_NO_CONTRACT; - - if (this->kind() != other->kind()) - return false; - - const ExternalNamespaceBlobEntry * other2 = static_cast(other); - - if (this->cbName() != other2->cbName()) - return false; - - LPCSTR p1 = this->pName(); - LPCSTR p2 = other2->pName(); - - for (DWORD i=0; (i < this->cbName()); i++) - if (p1[i] != p2[i]) - return false; - - return true; -} - -size_t ExternalNamespaceBlobEntry::Hash() const -{ - WRAPPER_NO_CONTRACT; - - size_t hashValue = HashInit(); - - LPCSTR p1 = pName(); - for (DWORD i=0; (i < cbName()); i++) - hashValue = HashCombine(hashValue, p1[i]); - - return hashValue; -} - -ExternalNamespaceBlobEntry::ExternalNamespaceBlobEntry(LPCSTR _pName) -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - PRECONDITION(CheckPointer(_pName)); - } - CONTRACTL_END; - - m_token = idExternalNamespaceNil; - m_cbName = 0; - m_pName = NULL; - - DWORD _cbName = (DWORD) strlen(_pName) + 1; - LPSTR * pName = (LPSTR *) new (nothrow) CHAR[_cbName]; - if (pName != NULL) - { - m_cbName = _cbName; - memcpy(pName, _pName, _cbName); - m_pName = (LPCSTR) pName; - } -} - -/* static */ const ExternalNamespaceBlobEntry * ExternalNamespaceBlobEntry::FindOrAdd(PTR_Module pModule, LPCSTR _pName) -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - if ((_pName == NULL) || (::strlen(_pName) == 0)) - return NULL; - - ExternalNamespaceBlobEntry sEntry(_pName); - - const ProfilingBlobEntry * pEntry = pModule->GetProfilingBlobTable()->Lookup(&sEntry); - if (pEntry == NULL) - { - // - // Not Found, add a new external namespace blob entry - // - ExternalNamespaceBlobEntry * newEntry = new (nothrow) ExternalNamespaceBlobEntry(_pName); - if (newEntry == NULL) - return NULL; - - newEntry->newToken(); // Assign a new ibc external namespace token - CONTRACT_VIOLATION(ThrowsViolation); - pModule->GetProfilingBlobTable()->Add(newEntry); - pEntry = newEntry; - } - - // - // Return the external namespace entry that we found or the new one that we just created - // - _ASSERTE(pEntry->kind() == ExternalNamespaceDef); - return static_cast(pEntry); -} - -bool ExternalTypeBlobEntry::IsEqual(const ProfilingBlobEntry * other) const -{ - WRAPPER_NO_CONTRACT; - - if (this->kind() != other->kind()) - return false; - - const ExternalTypeBlobEntry * other2 = static_cast(other); - - if (this->assemblyRef() != other2->assemblyRef()) - return false; - - if (this->nestedClass() != other2->nestedClass()) - return false; - - if (this->nameSpace() != other2->nameSpace()) - return false; - - if (this->cbName() != other2->cbName()) - return false; - - LPCSTR p1 = this->pName(); - LPCSTR p2 = other2->pName(); - - for (DWORD i=0; (i < this->cbName()); i++) - if (p1[i] != p2[i]) - return false; - - return true; -} - -size_t ExternalTypeBlobEntry::Hash() const -{ - WRAPPER_NO_CONTRACT; - - size_t hashValue = HashInit(); - - hashValue = HashCombine(hashValue, assemblyRef()); - hashValue = HashCombine(hashValue, nestedClass()); - hashValue = HashCombine(hashValue, nameSpace()); - - LPCSTR p1 = pName(); - - for (DWORD i=0; (i < cbName()); i++) - hashValue = HashCombine(hashValue, p1[i]); - - return hashValue; -} - -ExternalTypeBlobEntry::ExternalTypeBlobEntry(mdToken _assemblyRef, - mdToken _nestedClass, - mdToken _nameSpace, - LPCSTR _pName) -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - PRECONDITION(CheckPointer(_pName)); - } - CONTRACTL_END; - - m_token = idExternalTypeNil; - m_assemblyRef = mdAssemblyRefNil; - m_nestedClass = idExternalTypeNil; - m_nameSpace = idExternalNamespaceNil; - m_cbName = 0; - m_pName = NULL; - - DWORD _cbName = (DWORD) strlen(_pName) + 1; - LPSTR * pName = (LPSTR *) new (nothrow) CHAR[_cbName]; - if (pName != NULL) - { - m_assemblyRef = _assemblyRef; - m_nestedClass = _nestedClass; - m_nameSpace = _nameSpace; - m_cbName = _cbName; - memcpy(pName, _pName, _cbName); - m_pName = (LPCSTR) pName; - } -} - -/* static */ const ExternalTypeBlobEntry * ExternalTypeBlobEntry::FindOrAdd(PTR_Module pModule, - mdToken _assemblyRef, - mdToken _nestedClass, - mdToken _nameSpace, - LPCSTR _pName) -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - if ((_pName == NULL) || (::strlen(_pName) == 0)) - return NULL; - - ExternalTypeBlobEntry sEntry(_assemblyRef, _nestedClass, _nameSpace, _pName); - - const ProfilingBlobEntry * pEntry = pModule->GetProfilingBlobTable()->Lookup(&sEntry); - if (pEntry == NULL) - { - // - // Not Found, add a new external type blob entry - // - ExternalTypeBlobEntry * newEntry = new (nothrow) ExternalTypeBlobEntry(_assemblyRef, _nestedClass, _nameSpace, _pName); - if (newEntry == NULL) - return NULL; - - newEntry->newToken(); // Assign a new ibc external type token - CONTRACT_VIOLATION(ThrowsViolation); - pModule->GetProfilingBlobTable()->Add(newEntry); - pEntry = newEntry; - } - - // - // Return the external type entry that we found or the new one that we just created - // - _ASSERTE(pEntry->kind() == ExternalTypeDef); - return static_cast(pEntry); -} - -bool ExternalSignatureBlobEntry::IsEqual(const ProfilingBlobEntry * other) const -{ - WRAPPER_NO_CONTRACT; - - if (this->kind() != other->kind()) - return false; - - const ExternalSignatureBlobEntry * other2 = static_cast(other); - - if (this->cbSig() != other2->cbSig()) - return false; - - PCCOR_SIGNATURE p1 = this->pSig(); - PCCOR_SIGNATURE p2 = other2->pSig(); - - for (DWORD i=0; (i < this->cbSig()); i++) - if (p1[i] != p2[i]) - return false; - - return true; -} - -size_t ExternalSignatureBlobEntry::Hash() const -{ - WRAPPER_NO_CONTRACT; - - size_t hashValue = HashInit(); - - hashValue = HashCombine(hashValue, cbSig()); - - PCCOR_SIGNATURE p1 = pSig(); - - for (DWORD i=0; (i < cbSig()); i++) - hashValue = HashCombine(hashValue, p1[i]); - - return hashValue; -} - -ExternalSignatureBlobEntry::ExternalSignatureBlobEntry(DWORD _cbSig, PCCOR_SIGNATURE _pSig) -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - PRECONDITION(_cbSig > 0); - PRECONDITION(CheckPointer(_pSig)); - } - CONTRACTL_END; - - m_token = idExternalSignatureNil; - m_cbSig = 0; - - COR_SIGNATURE * pNewSig = (COR_SIGNATURE *) new (nothrow) BYTE[_cbSig]; - if (pNewSig != NULL) - { - m_cbSig = _cbSig; - memcpy(pNewSig, _pSig, _cbSig); - } - m_pSig = const_cast(pNewSig); -} - -/* static */ const ExternalSignatureBlobEntry * ExternalSignatureBlobEntry::FindOrAdd(PTR_Module pModule, - DWORD _cbSig, - PCCOR_SIGNATURE _pSig) -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - if ((_cbSig == 0) || (_pSig == NULL)) - return NULL; - - ExternalSignatureBlobEntry sEntry(_cbSig, _pSig); - - const ProfilingBlobEntry * pEntry = pModule->GetProfilingBlobTable()->Lookup(&sEntry); - if (pEntry == NULL) - { - // - // Not Found, add a new external signature blob entry - // - ExternalSignatureBlobEntry * newEntry = new (nothrow) ExternalSignatureBlobEntry(_cbSig, _pSig); - if (newEntry == NULL) - return NULL; - - newEntry->newToken(); // Assign a new ibc external signature token - CONTRACT_VIOLATION(ThrowsViolation); - pModule->GetProfilingBlobTable()->Add(newEntry); - pEntry = newEntry; - } - - // - // Return the external signature entry that we found or the new one that we just created - // - _ASSERTE(pEntry->kind() == ExternalSignatureDef); - return static_cast(pEntry); -} - -bool ExternalMethodBlobEntry::IsEqual(const ProfilingBlobEntry * other) const -{ - WRAPPER_NO_CONTRACT; - - if (this->kind() != other->kind()) - return false; - - const ExternalMethodBlobEntry * other2 = static_cast(other); - - if (this->nestedClass() != other2->nestedClass()) - return false; - - if (this->signature() != other2->signature()) - return false; - - if (this->cbName() != other2->cbName()) - return false; - - LPCSTR p1 = this->pName(); - LPCSTR p2 = other2->pName(); - - for (DWORD i=0; (i < this->cbName()); i++) - if (p1[i] != p2[i]) - return false; - - return true; -} - -size_t ExternalMethodBlobEntry::Hash() const -{ - WRAPPER_NO_CONTRACT; - - size_t hashValue = HashInit(); - - hashValue = HashCombine(hashValue, nestedClass()); - hashValue = HashCombine(hashValue, signature()); - - LPCSTR p1 = pName(); - - for (DWORD i=0; (i < cbName()); i++) - hashValue = HashCombine(hashValue, p1[i]); - - return hashValue; -} - -ExternalMethodBlobEntry::ExternalMethodBlobEntry(mdToken _nestedClass, - mdToken _signature, - LPCSTR _pName) -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - PRECONDITION(CheckPointer(_pName)); - } - CONTRACTL_END; - - m_token = idExternalMethodNil; - m_nestedClass = idExternalTypeNil; - m_signature = idExternalSignatureNil; - m_cbName = 0; - - DWORD _cbName = (DWORD) strlen(_pName) + 1; - LPSTR * pName = (LPSTR *) new (nothrow) CHAR[_cbName]; - if (pName != NULL) - { - m_nestedClass = _nestedClass; - m_signature = _signature; - m_cbName = _cbName; - memcpy(pName, _pName, _cbName); - m_pName = (LPSTR) pName; - } - } - -/* static */ const ExternalMethodBlobEntry * ExternalMethodBlobEntry::FindOrAdd( - PTR_Module pModule, - mdToken _nestedClass, - mdToken _signature, - LPCSTR _pName) -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - PRECONDITION(CheckPointer(_pName)); - } - CONTRACTL_END; - - if ((_pName == NULL) || (::strlen(_pName) == 0)) - return NULL; - - ExternalMethodBlobEntry sEntry(_nestedClass, _signature, _pName); - - const ProfilingBlobEntry * pEntry = pModule->GetProfilingBlobTable()->Lookup(&sEntry); - if (pEntry == NULL) - { - // - // Not Found, add a new external type blob entry - // - ExternalMethodBlobEntry * newEntry; - newEntry = new (nothrow) ExternalMethodBlobEntry(_nestedClass, _signature, _pName); - if (newEntry == NULL) - return NULL; - - newEntry->newToken(); // Assign a new ibc external method token - CONTRACT_VIOLATION(ThrowsViolation); - pModule->GetProfilingBlobTable()->Add(newEntry); - pEntry = newEntry; - } - - // - // Return the external method entry that we found or the new one that we just created - // - _ASSERTE(pEntry->kind() == ExternalMethodDef); - return static_cast(pEntry); -} - -static bool GetBasename(LPCWSTR _src, _Out_writes_z_(dstlen) LPWSTR _dst, int dstlen) -{ - LIMITED_METHOD_CONTRACT; - LPCWSTR src = _src; - LPWSTR dst = _dst; - - if ((src == NULL) || (dstlen <= 0)) - return false; - - bool inQuotes = false; - LPWSTR dstLast = dst + (dstlen - 1); - while (dst < dstLast) - { - WCHAR wch = *src++; - if (wch == W('"')) - { - inQuotes = !inQuotes; - continue; - } - - if (wch == 0) - break; - - *dst++ = wch; - - if (!inQuotes) - { - if ((wch == W('\\')) || (wch == W(':'))) - { - dst = _dst; - } - else if (wch == W(' ')) - { - dst--; - break; - } - } - } - *dst++ = 0; - return true; -} - -static LPCWSTR s_pCommandLine = NULL; - -// Retrieve the full command line for the current process. -LPCWSTR GetManagedCommandLine() -{ - LIMITED_METHOD_CONTRACT; - return s_pCommandLine; -} - -LPCWSTR GetCommandLineForDiagnostics() -{ - // Get the managed command line. - LPCWSTR pCmdLine = GetManagedCommandLine(); - - // Checkout https://github.com/dotnet/coreclr/pull/24433 for more information about this fall back. - if (pCmdLine == nullptr) - { - // Use the result from GetCommandLineW() instead - pCmdLine = GetCommandLineW(); - } - - return pCmdLine; -} - -void Append_Next_Item(LPWSTR* ppCursor, SIZE_T* pRemainingLen, LPCWSTR pItem, bool addSpace) -{ - // read the writeback args and setup pCursor and remainingLen - LPWSTR pCursor = *ppCursor; - SIZE_T remainingLen = *pRemainingLen; - - // Calculate the length of pItem - SIZE_T itemLen = wcslen(pItem); - - // Append pItem at pCursor - wcscpy_s(pCursor, remainingLen, pItem); - pCursor += itemLen; - remainingLen -= itemLen; - - // Also append a space after pItem, if requested - if (addSpace) - { - // Append a space at pCursor - wcscpy_s(pCursor, remainingLen, W(" ")); - pCursor += 1; - remainingLen -= 1; - } - - // writeback and update ppCursor and pRemainingLen - *ppCursor = pCursor; - *pRemainingLen = remainingLen; -} - -void SaveManagedCommandLine(LPCWSTR pwzAssemblyPath, int argc, LPCWSTR *argv) -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - MODE_ANY; - } - CONTRACTL_END; - - // Get the command line. - LPCWSTR osCommandLine = GetCommandLineW(); - -#ifndef TARGET_UNIX - // On Windows, osCommandLine contains the executable and all arguments. - s_pCommandLine = osCommandLine; -#else - // On UNIX, the PAL doesn't have the command line arguments, so we must build the command line. - // osCommandLine contains the full path to the executable. - SIZE_T commandLineLen = (wcslen(osCommandLine) + 1); - - // We will append pwzAssemblyPath to the 'corerun' osCommandLine - commandLineLen += (wcslen(pwzAssemblyPath) + 1); - - for (int i = 0; i < argc; i++) - { - commandLineLen += (wcslen(argv[i]) + 1); - } - commandLineLen++; // Add 1 for the null-termination - - // Allocate a new string for the command line. - LPWSTR pNewCommandLine = new WCHAR[commandLineLen]; - SIZE_T remainingLen = commandLineLen; - LPWSTR pCursor = pNewCommandLine; - - Append_Next_Item(&pCursor, &remainingLen, osCommandLine, true); - Append_Next_Item(&pCursor, &remainingLen, pwzAssemblyPath, (argc > 0)); - - for (int i = 0; i < argc; i++) - { - bool moreArgs = (i < (argc-1)); - Append_Next_Item(&pCursor, &remainingLen, argv[i], moreArgs); - } - - s_pCommandLine = pNewCommandLine; -#endif -} - -static void ProfileDataAllocateScenarioInfo(ProfileEmitter * pEmitter, LPCSTR scopeName, GUID* pMvid) -{ - CONTRACTL - { - THROWS; - GC_NOTRIGGER; - MODE_ANY; - INJECT_FAULT(COMPlusThrowOM()); - } - CONTRACTL_END; - - ProfileMap *profileMap = pEmitter->EmitNewSection(ScenarioInfo); - - // - // Allocate and initialize the scenario info section - // - { - CORBBTPROF_SCENARIO_INFO_SECTION_HEADER *siHeader; - siHeader = (CORBBTPROF_SCENARIO_INFO_SECTION_HEADER *) profileMap->Allocate(sizeof(CORBBTPROF_SCENARIO_INFO_SECTION_HEADER)); - - siHeader->NumScenarios = 1; - siHeader->TotalNumRuns = 1; - } - - // - // Allocate and initialize the scenario header section - // - { - // Get the managed command line. - LPCWSTR pCmdLine = GetCommandLineForDiagnostics(); - - S_SIZE_T cCmdLine = S_SIZE_T(wcslen(pCmdLine)); - cCmdLine += 1; - if (cCmdLine.IsOverflow()) - { - ThrowHR(COR_E_OVERFLOW); - } - - LPCWSTR pSystemInfo = W(""); - S_SIZE_T cSystemInfo = S_SIZE_T(wcslen(pSystemInfo)); - cSystemInfo += 1; - if (cSystemInfo.IsOverflow()) - { - ThrowHR(COR_E_OVERFLOW); - } - - FILETIME runTime, unused1, unused2, unused3; - GetProcessTimes(GetCurrentProcess(), &runTime, &unused1, &unused2, &unused3); - - WCHAR scenarioName[256]; - GetBasename(pCmdLine, &scenarioName[0], 256); - - LPCWSTR pName = &scenarioName[0]; - S_SIZE_T cName = S_SIZE_T(wcslen(pName)); - cName += 1; - if (cName.IsOverflow()) - { - ThrowHR(COR_E_OVERFLOW); - } - - S_SIZE_T sizeHeader = S_SIZE_T(sizeof(CORBBTPROF_SCENARIO_HEADER)); - sizeHeader += cName * S_SIZE_T(sizeof(WCHAR)); - if (sizeHeader.IsOverflow()) - { - ThrowHR(COR_E_OVERFLOW); - } - - S_SIZE_T sizeRun = S_SIZE_T(sizeof(CORBBTPROF_SCENARIO_RUN)); - sizeRun += cCmdLine * S_SIZE_T(sizeof(WCHAR)); - sizeRun += cSystemInfo * S_SIZE_T(sizeof(WCHAR)); - if (sizeRun.IsOverflow()) - { - ThrowHR(COR_E_OVERFLOW); - } - - // - // Allocate the Scenario Header struct - // - SIZE_T sHeaderOffset; - { - CORBBTPROF_SCENARIO_HEADER *sHeader; - S_SIZE_T sHeaderSize = sizeHeader + sizeRun; - if (sHeaderSize.IsOverflow()) - { - ThrowHR(COR_E_OVERFLOW); - } - - sHeaderOffset = profileMap->getCurrentOffset(); - sHeader = (CORBBTPROF_SCENARIO_HEADER *) profileMap->Allocate(sizeHeader.Value()); - - _ASSERTE(sHeaderSize.Value() <= MAXDWORD); - _ASSERTE(cName.Value() <= MAXDWORD); - sHeader->size = (DWORD)sHeaderSize.Value(); - sHeader->scenario.ordinal = 1; - sHeader->scenario.mask = 1; - sHeader->scenario.priority = 0; - sHeader->scenario.numRuns = 1; - sHeader->scenario.cName = (DWORD)cName.Value(); - wcscpy_s(sHeader->scenario.name, cName.Value(), pName); - } - - // - // Allocate the Scenario Run struct - // - { - CORBBTPROF_SCENARIO_RUN *sRun; - sRun = (CORBBTPROF_SCENARIO_RUN *) profileMap->Allocate(sizeRun.Value()); - - _ASSERTE(cCmdLine.Value() <= MAXDWORD); - _ASSERTE(cSystemInfo.Value() <= MAXDWORD); - sRun->runTime = runTime; - sRun->mvid = *pMvid; - sRun->cCmdLine = (DWORD)cCmdLine.Value(); - sRun->cSystemInfo = (DWORD)cSystemInfo.Value(); - wcscpy_s(sRun->cmdLine, cCmdLine.Value(), pCmdLine); - wcscpy_s(sRun->cmdLine+cCmdLine.Value(), cSystemInfo.Value(), pSystemInfo); - } -#ifdef _DEBUG - { - CORBBTPROF_SCENARIO_HEADER * sHeader; - sHeader = (CORBBTPROF_SCENARIO_HEADER *) profileMap->getOffsetPtr(sHeaderOffset); - _ASSERTE(sHeader->size == sHeader->Size()); - } -#endif - } -} - -static void ProfileDataAllocateMethodBlockCounts(ProfileEmitter * pEmitter, CORCOMPILE_METHOD_PROFILE_LIST * pMethodProfileListHead) -{ - CONTRACTL - { - THROWS; - GC_NOTRIGGER; - MODE_ANY; - INJECT_FAULT(COMPlusThrowOM()); - } - CONTRACTL_END; - - ProfileMap *profileMap = pEmitter->EmitNewSection(MethodBlockCounts); - - // - // Allocate and initialize the method block count section - // - SIZE_T mbcHeaderOffset; - { - CORBBTPROF_METHOD_BLOCK_COUNTS_SECTION_HEADER *mbcHeader; - mbcHeaderOffset = profileMap->getCurrentOffset(); - mbcHeader = (CORBBTPROF_METHOD_BLOCK_COUNTS_SECTION_HEADER *) - profileMap->Allocate(sizeof(CORBBTPROF_METHOD_BLOCK_COUNTS_SECTION_HEADER)); - mbcHeader->NumMethods = 0; // This gets filled in later - } - - ULONG numMethods = 0; // We count the number of methods that were executed - - for (CORCOMPILE_METHOD_PROFILE_LIST * methodProfileList = pMethodProfileListHead; - methodProfileList; - methodProfileList = methodProfileList->next) - { - CORBBTPROF_METHOD_HEADER * pInfo = methodProfileList->GetInfo(); - - _ASSERTE(pInfo->size == pInfo->Size()); - - // - // We set methodWasExecuted based upon the ExecutionCount of the very first block - // - bool methodWasExecuted = (pInfo->method.block[0].ExecutionCount > 0); - - // - // If the method was not executed then we don't need to output this methods block counts - // - SIZE_T methodHeaderOffset; - if (methodWasExecuted) - { - DWORD profileDataSize = pInfo->size; - methodHeaderOffset = profileMap->getCurrentOffset(); - CORBBTPROF_METHOD_HEADER *methodHeader = (CORBBTPROF_METHOD_HEADER *) profileMap->Allocate(profileDataSize); - memcpy(methodHeader, pInfo, profileDataSize); - numMethods++; - } - - // Reset all of the basic block counts to zero - for (UINT32 i=0; (i < pInfo->method.cBlock); i++ ) - { - // - // If methodWasExecuted is false then every block's ExecutionCount should also be zero - // - _ASSERTE(methodWasExecuted || (pInfo->method.block[i].ExecutionCount == 0)); - - pInfo->method.block[i].ExecutionCount = 0; - } - } - - { - CORBBTPROF_METHOD_BLOCK_COUNTS_SECTION_HEADER *mbcHeader; - // We have to refetch the mbcHeader as calls to Allocate will resize and thus move the mbcHeader - mbcHeader = (CORBBTPROF_METHOD_BLOCK_COUNTS_SECTION_HEADER *) profileMap->getOffsetPtr(mbcHeaderOffset); - mbcHeader->NumMethods = numMethods; - } -} - -/*static*/ void Module::ProfileDataAllocateTokenLists(ProfileEmitter * pEmitter, Module::TokenProfileData* pTokenProfileData) -{ - CONTRACTL - { - THROWS; - GC_NOTRIGGER; - MODE_ANY; - INJECT_FAULT(COMPlusThrowOM()); - } - CONTRACTL_END; - - // - // Allocate and initialize the token list sections - // - if (pTokenProfileData) - { - for (int format = 0; format < (int)SectionFormatCount; format++) - { - CQuickArray *pTokenArray = &(pTokenProfileData->m_formats[format].tokenArray); - - if (pTokenArray->Size() != 0) - { - ProfileMap * profileMap = pEmitter->EmitNewSection((SectionFormat) format); - - CORBBTPROF_TOKEN_LIST_SECTION_HEADER *header; - header = (CORBBTPROF_TOKEN_LIST_SECTION_HEADER *) - profileMap->Allocate(sizeof(CORBBTPROF_TOKEN_LIST_SECTION_HEADER) + - pTokenArray->Size() * sizeof(CORBBTPROF_TOKEN_INFO)); - - _ASSERTE(pTokenArray->Size() <= MAXDWORD); - header->NumTokens = (DWORD)pTokenArray->Size(); - memcpy( (header + 1), &((*pTokenArray)[0]), pTokenArray->Size() * sizeof(CORBBTPROF_TOKEN_INFO)); - - // Reset the collected tokens - for (unsigned i = 0; i < CORBBTPROF_TOKEN_MAX_NUM_FLAGS; i++) - { - pTokenProfileData->m_formats[format].tokenBitmaps[i].Reset(); - } - pTokenProfileData->m_formats[format].tokenArray.ReSizeNoThrow(0); - } - } - } -} - -static void ProfileDataAllocateTokenDefinitions(ProfileEmitter * pEmitter, Module * pModule) -{ - CONTRACTL - { - THROWS; - GC_NOTRIGGER; - MODE_ANY; - INJECT_FAULT(COMPlusThrowOM()); - } - CONTRACTL_END; - - // - // Allocate and initialize the ibc token definition section (aka the Blob stream) - // - ProfileMap * profileMap = pEmitter->EmitNewSection(BlobStream); - - // Compute the size of the metadata section: - // It is the sum of all of the Metadata Profile pool entries - // plus the sum of all of the Param signature entries - // - size_t totalSize = 0; - - for (ProfilingBlobTable::Iterator cur = pModule->GetProfilingBlobTable()->Begin(), - end = pModule->GetProfilingBlobTable()->End(); - (cur != end); - cur++) - { - const ProfilingBlobEntry * pEntry = *cur; - size_t blobElementSize = pEntry->varSize(); - switch (pEntry->kind()) { - case ParamTypeSpec: - case ParamMethodSpec: - blobElementSize += sizeof(CORBBTPROF_BLOB_PARAM_SIG_ENTRY); - break; - - case ExternalNamespaceDef: - blobElementSize += sizeof(CORBBTPROF_BLOB_NAMESPACE_DEF_ENTRY); - break; - - case ExternalTypeDef: - blobElementSize += sizeof(CORBBTPROF_BLOB_TYPE_DEF_ENTRY); - break; - - case ExternalSignatureDef: - blobElementSize += sizeof(CORBBTPROF_BLOB_SIGNATURE_DEF_ENTRY); - break; - - case ExternalMethodDef: - blobElementSize += sizeof(CORBBTPROF_BLOB_METHOD_DEF_ENTRY); - break; - - default: - _ASSERTE(!"Unexpected blob type"); - break; - } - totalSize += blobElementSize; - } - - profileMap->Allocate(totalSize); - - size_t currentPos = 0; - - // Traverse each element and record it - size_t blobElementSize = 0; - for (ProfilingBlobTable::Iterator cur = pModule->GetProfilingBlobTable()->Begin(), - end = pModule->GetProfilingBlobTable()->End(); - (cur != end); - cur++, currentPos += blobElementSize) - { - const ProfilingBlobEntry * pEntry = *cur; - blobElementSize = pEntry->varSize(); - void *profileData = profileMap->getOffsetPtr(currentPos); - - switch (pEntry->kind()) { - case ParamTypeSpec: - { - CORBBTPROF_BLOB_PARAM_SIG_ENTRY * bProfileData = (CORBBTPROF_BLOB_PARAM_SIG_ENTRY*) profileData; - const TypeSpecBlobEntry * typeSpecBlobEntry = static_cast(pEntry); - - blobElementSize += sizeof(CORBBTPROF_BLOB_PARAM_SIG_ENTRY); - bProfileData->blob.size = static_cast(blobElementSize); - bProfileData->blob.type = typeSpecBlobEntry->kind(); - bProfileData->blob.token = typeSpecBlobEntry->token(); - _ASSERTE(typeSpecBlobEntry->cbSig() > 0); - bProfileData->cSig = typeSpecBlobEntry->cbSig(); - memcpy(&bProfileData->sig[0], typeSpecBlobEntry->pSig(), typeSpecBlobEntry->cbSig()); - break; - } - - case ParamMethodSpec: - { - CORBBTPROF_BLOB_PARAM_SIG_ENTRY * bProfileData = (CORBBTPROF_BLOB_PARAM_SIG_ENTRY*) profileData; - const MethodSpecBlobEntry * methodSpecBlobEntry = static_cast(pEntry); - - blobElementSize += sizeof(CORBBTPROF_BLOB_PARAM_SIG_ENTRY); - bProfileData->blob.size = static_cast(blobElementSize); - bProfileData->blob.type = methodSpecBlobEntry->kind(); - bProfileData->blob.token = methodSpecBlobEntry->token(); - _ASSERTE(methodSpecBlobEntry->cbSig() > 0); - bProfileData->cSig = methodSpecBlobEntry->cbSig(); - memcpy(&bProfileData->sig[0], methodSpecBlobEntry->pSig(), methodSpecBlobEntry->cbSig()); - break; - } - - case ExternalNamespaceDef: - { - CORBBTPROF_BLOB_NAMESPACE_DEF_ENTRY * bProfileData = (CORBBTPROF_BLOB_NAMESPACE_DEF_ENTRY*) profileData; - const ExternalNamespaceBlobEntry * namespaceBlobEntry = static_cast(pEntry); - - blobElementSize += sizeof(CORBBTPROF_BLOB_NAMESPACE_DEF_ENTRY); - bProfileData->blob.size = static_cast(blobElementSize); - bProfileData->blob.type = namespaceBlobEntry->kind(); - bProfileData->blob.token = namespaceBlobEntry->token(); - _ASSERTE(namespaceBlobEntry->cbName() > 0); - bProfileData->cName = namespaceBlobEntry->cbName(); - memcpy(&bProfileData->name[0], namespaceBlobEntry->pName(), namespaceBlobEntry->cbName()); - break; - } - - case ExternalTypeDef: - { - CORBBTPROF_BLOB_TYPE_DEF_ENTRY * bProfileData = (CORBBTPROF_BLOB_TYPE_DEF_ENTRY*) profileData; - const ExternalTypeBlobEntry * typeBlobEntry = static_cast(pEntry); - - blobElementSize += sizeof(CORBBTPROF_BLOB_TYPE_DEF_ENTRY); - bProfileData->blob.size = static_cast(blobElementSize); - bProfileData->blob.type = typeBlobEntry->kind(); - bProfileData->blob.token = typeBlobEntry->token(); - bProfileData->assemblyRefToken = typeBlobEntry->assemblyRef(); - bProfileData->nestedClassToken = typeBlobEntry->nestedClass(); - bProfileData->nameSpaceToken = typeBlobEntry->nameSpace(); - _ASSERTE(typeBlobEntry->cbName() > 0); - bProfileData->cName = typeBlobEntry->cbName(); - memcpy(&bProfileData->name[0], typeBlobEntry->pName(), typeBlobEntry->cbName()); - break; - } - - case ExternalSignatureDef: - { - CORBBTPROF_BLOB_SIGNATURE_DEF_ENTRY * bProfileData = (CORBBTPROF_BLOB_SIGNATURE_DEF_ENTRY*) profileData; - const ExternalSignatureBlobEntry * signatureBlobEntry = static_cast(pEntry); - - blobElementSize += sizeof(CORBBTPROF_BLOB_SIGNATURE_DEF_ENTRY); - bProfileData->blob.size = static_cast(blobElementSize); - bProfileData->blob.type = signatureBlobEntry->kind(); - bProfileData->blob.token = signatureBlobEntry->token(); - _ASSERTE(signatureBlobEntry->cbSig() > 0); - bProfileData->cSig = signatureBlobEntry->cbSig(); - memcpy(&bProfileData->sig[0], signatureBlobEntry->pSig(), signatureBlobEntry->cbSig()); - break; - } - - case ExternalMethodDef: - { - CORBBTPROF_BLOB_METHOD_DEF_ENTRY * bProfileData = (CORBBTPROF_BLOB_METHOD_DEF_ENTRY*) profileData; - const ExternalMethodBlobEntry * methodBlobEntry = static_cast(pEntry); - - blobElementSize += sizeof(CORBBTPROF_BLOB_METHOD_DEF_ENTRY); - bProfileData->blob.size = static_cast(blobElementSize); - bProfileData->blob.type = methodBlobEntry->kind(); - bProfileData->blob.token = methodBlobEntry->token(); - bProfileData->nestedClassToken = methodBlobEntry->nestedClass(); - bProfileData->signatureToken = methodBlobEntry->signature(); - _ASSERTE(methodBlobEntry->cbName() > 0); - bProfileData->cName = methodBlobEntry->cbName(); - memcpy(&bProfileData->name[0], methodBlobEntry->pName(), methodBlobEntry->cbName()); - break; - } - - default: - _ASSERTE(!"Unexpected blob type"); - break; - } - } - - _ASSERTE(currentPos == totalSize); - - // Emit a terminating entry with type EndOfBlobStream to mark the end - DWORD mdElementSize = sizeof(CORBBTPROF_BLOB_ENTRY); - void *profileData = profileMap->Allocate(mdElementSize); - memset(profileData, 0, mdElementSize); - - CORBBTPROF_BLOB_ENTRY* mdProfileData = (CORBBTPROF_BLOB_ENTRY*) profileData; - mdProfileData->type = EndOfBlobStream; - mdProfileData->size = sizeof(CORBBTPROF_BLOB_ENTRY); -} - -// Responsible for writing out the profile data if the COMPlus_BBInstr -// environment variable is set. This is called when the module is unloaded -// (usually at shutdown). -HRESULT Module::WriteMethodProfileDataLogFile(bool cleanup) -{ - CONTRACTL - { - INSTANCE_CHECK; - NOTHROW; - GC_TRIGGERS; - MODE_ANY; - INJECT_FAULT(return E_OUTOFMEMORY;); - } - CONTRACTL_END; - - HRESULT hr = S_OK; - - EX_TRY - { - if (GetAssembly()->IsInstrumented() && (m_pProfilingBlobTable != NULL) && (m_tokenProfileData != NULL)) - { - NewHolder pEmitter(new ProfileEmitter()); - - // Get this ahead of time - metadata access may be logged, which will - // take the m_tokenProfileData->crst, which we take a couple lines below - LPCSTR pszName; - GUID mvid; - IfFailThrow(GetMDImport()->GetScopeProps(&pszName, &mvid)); - - CrstHolder ch(&m_tokenProfileData->crst); - - // - // Create the scenario info section - // - ProfileDataAllocateScenarioInfo(pEmitter, pszName, &mvid); - - // - // Create the method block count section - // - ProfileDataAllocateMethodBlockCounts(pEmitter, m_methodProfileList); - - // - // Create the token list sections - // - ProfileDataAllocateTokenLists(pEmitter, m_tokenProfileData); - - // - // Create the ibc token definition section (aka the Blob stream) - // - ProfileDataAllocateTokenDefinitions(pEmitter, this); - - // - // Now store the profile data in the ibc file - // - ProfileMap profileImage; - pEmitter->Serialize(&profileImage, mvid); - - HandleHolder profileDataFile(OpenMethodProfileDataLogFile(mvid)); - - ULONG count; - _ASSERTE(profileImage.getCurrentOffset() <= MAXDWORD); - BOOL result = WriteFile(profileDataFile, profileImage.getOffsetPtr(0), (DWORD)profileImage.getCurrentOffset(), &count, NULL); - if (!result || (count != profileImage.getCurrentOffset())) - { - DWORD lasterror = GetLastError(); - _ASSERTE(!"Error writing ibc profile data to file"); - hr = HRESULT_FROM_WIN32(lasterror); - } - } - - if (cleanup) - { - DeleteProfilingData(); - } - } - EX_CATCH - { - hr = E_FAIL; - } - EX_END_CATCH(SwallowAllExceptions) - - return hr; -} - - -/* static */ -void Module::WriteAllModuleProfileData(bool cleanup) -{ - CONTRACTL - { - NOTHROW; - GC_TRIGGERS; - MODE_ANY; - } - CONTRACTL_END; - - // Iterate over all the app domains; for each one iterator over its - // assemblies; for each one iterate over its modules. - EX_TRY - { - AppDomainIterator appDomainIterator(FALSE); - while(appDomainIterator.Next()) - { - AppDomain * appDomain = appDomainIterator.GetDomain(); - AppDomain::AssemblyIterator assemblyIterator = appDomain->IterateAssembliesEx( - (AssemblyIterationFlags)(kIncludeLoaded | kIncludeExecution)); - CollectibleAssemblyHolder pDomainAssembly; - - while (assemblyIterator.Next(pDomainAssembly.This())) - { - pDomainAssembly->GetModule()->WriteMethodProfileDataLogFile(cleanup); - } - } - } - EX_CATCH - { } - EX_END_CATCH(SwallowAllExceptions); -} - -PTR_ProfilingBlobTable Module::GetProfilingBlobTable() -{ - LIMITED_METHOD_CONTRACT; - return m_pProfilingBlobTable; -} - -void Module::CreateProfilingData() -{ - TokenProfileData *tpd = TokenProfileData::CreateNoThrow(); - - PVOID pv = InterlockedCompareExchangeT(&m_tokenProfileData, tpd, NULL); - if (pv != NULL) - { - delete tpd; - } - - PTR_ProfilingBlobTable ppbt = new (nothrow) ProfilingBlobTable(); - - if (ppbt != NULL) - { - pv = InterlockedCompareExchangeT(&m_pProfilingBlobTable, ppbt, NULL); - if (pv != NULL) - { - delete ppbt; - } - } -} - -void Module::DeleteProfilingData() -{ - if (m_pProfilingBlobTable != NULL) - { - for (ProfilingBlobTable::Iterator cur = m_pProfilingBlobTable->Begin(), - end = m_pProfilingBlobTable->End(); - (cur != end); - cur++) - { - const ProfilingBlobEntry * pCurrentEntry = *cur; - delete pCurrentEntry; - } - delete m_pProfilingBlobTable; - m_pProfilingBlobTable = NULL; - } - - if (m_tokenProfileData != NULL) - { - delete m_tokenProfileData; - m_tokenProfileData = NULL; - } - - // the metadataProfileData is free'ed in destructor of the corresponding MetaDataTracker -} - -void Module::SetIsIJWFixedUp() -{ - LIMITED_METHOD_CONTRACT; - FastInterlockOr(&m_dwTransientFlags, IS_IJW_FIXED_UP); -} - -/* static */ -Module::TokenProfileData *Module::TokenProfileData::CreateNoThrow(void) -{ - STATIC_CONTRACT_NOTHROW; - - TokenProfileData *tpd = NULL; - - EX_TRY - { - // - // This constructor calls crst.Init(), which may throw. So putting (nothrow) doesn't - // do what we would want it to. Thus I wrap it here in a TRY/CATCH and revert to NULL - // if it fails. - // - tpd = new TokenProfileData(); - } - EX_CATCH - { - tpd = NULL; - } - EX_END_CATCH(SwallowAllExceptions); - - return tpd; -} - -#endif // !DACCESS_COMPILE - -#ifndef DACCESS_COMPILE -void Module::SetBeingUnloaded() -{ - LIMITED_METHOD_CONTRACT; - FastInterlockOr((ULONG*)&m_dwTransientFlags, IS_BEING_UNLOADED); -} -#endif - -void Module::LogTokenAccess(mdToken token, SectionFormat format, ULONG flagnum) -{ - CONTRACTL - { - INSTANCE_CHECK; - NOTHROW; - GC_NOTRIGGER; - MODE_ANY; - PRECONDITION(g_IBCLogger.InstrEnabled()); - PRECONDITION(flagnum < CORBBTPROF_TOKEN_MAX_NUM_FLAGS); - } - CONTRACTL_END; - -#ifndef DACCESS_COMPILE - - // - // If we are in ngen instrumentation mode, then we should record this token. - // - - if (!m_nativeImageProfiling) - return; - - if (flagnum >= CORBBTPROF_TOKEN_MAX_NUM_FLAGS) - { - return; - } - - mdToken rid = RidFromToken(token); - CorTokenType tkType = (CorTokenType) TypeFromToken(token); - SectionFormat tkKind = (SectionFormat) (tkType >> 24); - - if ((rid == 0) && (tkKind < (SectionFormat) TBL_COUNT)) - return; - - FAULT_NOT_FATAL(); - - _ASSERTE(TypeProfilingData == FirstTokenFlagSection + TBL_TypeDef); - _ASSERTE(MethodProfilingData == FirstTokenFlagSection + TBL_Method); - _ASSERTE(SectionFormatCount >= FirstTokenFlagSection + TBL_COUNT + 4); - - if (!m_tokenProfileData) - { - CreateProfilingData(); - } - - if (!m_tokenProfileData) - { - return; - } - - if (tkKind == (SectionFormat) (ibcTypeSpec >> 24)) - tkKind = IbcTypeSpecSection; - else if (tkKind == (SectionFormat) (ibcMethodSpec >> 24)) - tkKind = IbcMethodSpecSection; - - _ASSERTE(tkKind >= 0); - _ASSERTE(tkKind < SectionFormatCount); - if (tkKind < 0 || tkKind >= SectionFormatCount) - { - return; - } - - CQuickArray * pTokenArray = &m_tokenProfileData->m_formats[format].tokenArray; - RidBitmap * pTokenBitmap = &m_tokenProfileData->m_formats[tkKind].tokenBitmaps[flagnum]; - - // Have we seen this token with this flag already? - if (pTokenBitmap->IsTokenInBitmap(token)) - { - return; - } - - // Insert the token to the bitmap - if (FAILED(pTokenBitmap->InsertToken(token))) - { - return; - } - - ULONG flag = 1 << flagnum; - - // [ToDo] Fix: this is a sequential search and can be very slow - for (unsigned int i = 0; i < pTokenArray->Size(); i++) - { - if ((*pTokenArray)[i].token == token) - { - _ASSERTE(! ((*pTokenArray)[i].flags & flag)); - (*pTokenArray)[i].flags |= flag; - return; - } - } - - if (FAILED(pTokenArray->ReSizeNoThrow(pTokenArray->Size() + 1))) - { - return; - } - - (*pTokenArray)[pTokenArray->Size() - 1].token = token; - (*pTokenArray)[pTokenArray->Size() - 1].flags = flag; - (*pTokenArray)[pTokenArray->Size() - 1].scenarios = 0; - -#endif // !DACCESS_COMPILE -} - -void Module::LogTokenAccess(mdToken token, ULONG flagNum) -{ - WRAPPER_NO_CONTRACT; - SectionFormat format = (SectionFormat)((TypeFromToken(token)>>24) + FirstTokenFlagSection); - if (FirstTokenFlagSection <= format && format < SectionFormatCount) - { - LogTokenAccess(token, format, flagNum); - } -} - -#ifndef DACCESS_COMPILE - -// -// Encoding callbacks -// - -/*static*/ DWORD Module::EncodeModuleHelper(void * pModuleContext, Module *pReferencedModule) -{ - Module* pReferencingModule = (Module *) pModuleContext; - _ASSERTE(pReferencingModule != pReferencedModule); - - Assembly *pReferencingAssembly = pReferencingModule->GetAssembly(); - Assembly *pReferencedAssembly = pReferencedModule->GetAssembly(); - - _ASSERTE(pReferencingAssembly != pReferencedAssembly); - - if (pReferencedAssembly == pReferencingAssembly) - { - return 0; - } - - mdAssemblyRef token = pReferencingModule->FindAssemblyRef(pReferencedAssembly); - - if (IsNilToken(token)) - { - return ENCODE_MODULE_FAILED; - } - - return RidFromToken(token); -} - -/*static*/ void Module::TokenDefinitionHelper(void* pModuleContext, Module *pReferencedModule, DWORD index, mdToken* pToken) -{ - LIMITED_METHOD_CONTRACT; - HRESULT hr; - Module * pReferencingModule = (Module *) pModuleContext; - mdAssemblyRef mdAssemblyRef = TokenFromRid(index, mdtAssemblyRef); - IMDInternalImport * pImport = pReferencedModule->GetMDImport(); - LPCUTF8 szName = NULL; - - if (TypeFromToken(*pToken) == mdtTypeDef) - { - // - // Compute nested type (if any) - // - mdTypeDef mdEnclosingType = idExternalTypeNil; - hr = pImport->GetNestedClassProps(*pToken, &mdEnclosingType); - // If there's not enclosing type, then hr=CLDB_E_RECORD_NOTFOUND and mdEnclosingType is unchanged - _ASSERTE((hr == S_OK) || (hr == CLDB_E_RECORD_NOTFOUND)); - - if (!IsNilToken(mdEnclosingType)) - { - _ASSERT(TypeFromToken(mdEnclosingType) == mdtTypeDef); - TokenDefinitionHelper(pModuleContext, pReferencedModule, index, &mdEnclosingType); - } - _ASSERT(TypeFromToken(mdEnclosingType) == ibcExternalType); - - // - // Compute type name and namespace. - // - LPCUTF8 szNamespace = NULL; - hr = pImport->GetNameOfTypeDef(*pToken, &szName, &szNamespace); - _ASSERTE(hr == S_OK); - - // - // Transform namespace string into ibc external namespace token - // - idExternalNamespace idNamespace = idExternalNamespaceNil; - if (szNamespace != NULL) - { - const ExternalNamespaceBlobEntry * pNamespaceEntry; - pNamespaceEntry = ExternalNamespaceBlobEntry::FindOrAdd(pReferencingModule, szNamespace); - if (pNamespaceEntry != NULL) - { - idNamespace = pNamespaceEntry->token(); - } - } - _ASSERTE(TypeFromToken(idNamespace) == ibcExternalNamespace); - - // - // Transform type name into ibc external type token - // - idExternalType idType = idExternalTypeNil; - _ASSERTE(szName != NULL); - const ExternalTypeBlobEntry * pTypeEntry = NULL; - pTypeEntry = ExternalTypeBlobEntry::FindOrAdd(pReferencingModule, - mdAssemblyRef, - mdEnclosingType, - idNamespace, - szName); - if (pTypeEntry != NULL) - { - idType = pTypeEntry->token(); - } - _ASSERTE(TypeFromToken(idType) == ibcExternalType); - - *pToken = idType; // Remap pToken to our idExternalType token - } - else if (TypeFromToken(*pToken) == mdtMethodDef) - { - // - // Compute nested type (if any) - // - mdTypeDef mdEnclosingType = idExternalTypeNil; - hr = pImport->GetParentToken(*pToken, &mdEnclosingType); - _ASSERTE(!FAILED(hr)); - - if (!IsNilToken(mdEnclosingType)) - { - _ASSERT(TypeFromToken(mdEnclosingType) == mdtTypeDef); - TokenDefinitionHelper(pModuleContext, pReferencedModule, index, &mdEnclosingType); - } - _ASSERT(TypeFromToken(mdEnclosingType) == ibcExternalType); - - // - // Compute the method name and signature - // - PCCOR_SIGNATURE pSig = NULL; - DWORD cbSig = 0; - hr = pImport->GetNameAndSigOfMethodDef(*pToken, &pSig, &cbSig, &szName); - _ASSERTE(hr == S_OK); - - // - // Transform signature into ibc external signature token - // - idExternalSignature idSignature = idExternalSignatureNil; - if (pSig != NULL) - { - const ExternalSignatureBlobEntry * pSignatureEntry; - pSignatureEntry = ExternalSignatureBlobEntry::FindOrAdd(pReferencingModule, cbSig, pSig); - if (pSignatureEntry != NULL) - { - idSignature = pSignatureEntry->token(); - } - } - _ASSERTE(TypeFromToken(idSignature) == ibcExternalSignature); - - // - // Transform method name into ibc external method token - // - idExternalMethod idMethod = idExternalMethodNil; - _ASSERTE(szName != NULL); - const ExternalMethodBlobEntry * pMethodEntry = NULL; - pMethodEntry = ExternalMethodBlobEntry::FindOrAdd(pReferencingModule, - mdEnclosingType, - idSignature, - szName); - if (pMethodEntry != NULL) - { - idMethod = pMethodEntry->token(); - } - _ASSERTE(TypeFromToken(idMethod) == ibcExternalMethod); - - *pToken = idMethod; // Remap pToken to our idMethodSpec token - } - else - { - _ASSERTE(!"Unexpected token type"); - } -} - -idTypeSpec Module::LogInstantiatedType(TypeHandle typeHnd, ULONG flagNum) -{ - CONTRACT(idTypeSpec) - { - NOTHROW; - GC_NOTRIGGER; - MODE_ANY; - PRECONDITION(g_IBCLogger.InstrEnabled()); - PRECONDITION(!typeHnd.HasUnrestoredTypeKey()); - // We want to report the type only in its own loader module as a type's - // MethodTable can only live in its own loader module. - // We can relax this if we allow a (duplicate) MethodTable to live - // in any module (which might be needed for ngen of generics) - } - CONTRACT_END; - - idTypeSpec result = idTypeSpecNil; - - if (m_nativeImageProfiling) - { - CONTRACT_VIOLATION(ThrowsViolation|FaultViolation|GCViolation); - - SigBuilder sigBuilder; - - ZapSig zapSig(this, this, ZapSig::IbcTokens, - Module::EncodeModuleHelper, Module::TokenDefinitionHelper); - BOOL fSuccess = zapSig.GetSignatureForTypeHandle(typeHnd, &sigBuilder); - - // a return value of 0 indicates a failure to create the signature - if (fSuccess) - { - DWORD cbSig; - PCCOR_SIGNATURE pSig = (PCCOR_SIGNATURE)sigBuilder.GetSignature(&cbSig); - - ULONG flag = (1 << flagNum); - TypeSpecBlobEntry * pEntry = const_cast(TypeSpecBlobEntry::FindOrAdd(this, cbSig, pSig)); - if (pEntry != NULL) - { - // Update the flags with any new bits - pEntry->orFlag(flag); - result = pEntry->token(); - } - } - } - _ASSERTE(TypeFromToken(result) == ibcTypeSpec); - - RETURN result; -} - -idMethodSpec Module::LogInstantiatedMethod(const MethodDesc * md, ULONG flagNum) -{ - CONTRACT(idMethodSpec) - { - NOTHROW; - GC_NOTRIGGER; - MODE_ANY; - PRECONDITION( md != NULL ); - } - CONTRACT_END; - - idMethodSpec result = idMethodSpecNil; - - if (m_nativeImageProfiling) - { - CONTRACT_VIOLATION(ThrowsViolation|FaultViolation|GCViolation); - - if (!m_tokenProfileData) - { - CreateProfilingData(); - } - - if (!m_tokenProfileData) - { - return idMethodSpecNil; - } - - // get data - SigBuilder sigBuilder; - - BOOL fSuccess; - fSuccess = ZapSig::EncodeMethod(const_cast(md), this, &sigBuilder, - (LPVOID) this, - (ENCODEMODULE_CALLBACK) Module::EncodeModuleHelper, - (DEFINETOKEN_CALLBACK) Module::TokenDefinitionHelper); - - if (fSuccess) - { - DWORD dataSize; - BYTE * pBlob = (BYTE *)sigBuilder.GetSignature(&dataSize); - - ULONG flag = (1 << flagNum); - MethodSpecBlobEntry * pEntry = const_cast(MethodSpecBlobEntry::FindOrAdd(this, dataSize, pBlob)); - if (pEntry != NULL) - { - // Update the flags with any new bits - pEntry->orFlag(flag); - result = pEntry->token(); - } - } - } - - _ASSERTE(TypeFromToken(result) == ibcMethodSpec); - RETURN result; -} -#endif // DACCESS_COMPILE - -#ifndef DACCESS_COMPILE - // =========================================================================== // ReflectionModule // =========================================================================== @@ -7595,7 +5538,6 @@ FieldDesc *Module::LookupFieldDef(mdFieldDef token) { WRAPPER_NO_CONTRACT; _ASSERTE(TypeFromToken(token) == mdtFieldDef); - g_IBCLogger.LogRidMapAccess( MakePair( this, token ) ); return m_FieldDefToDescMap.GetElement(RidFromToken(token)); } diff --git a/src/coreclr/vm/ceeload.h b/src/coreclr/vm/ceeload.h index d10baac2f775c..86fdb83a1e075 100644 --- a/src/coreclr/vm/ceeload.h +++ b/src/coreclr/vm/ceeload.h @@ -28,7 +28,6 @@ // find anything better (modulo common or vars.hpp) #include "classloadlevel.h" #include "precode.h" -#include "corbbtprof.h" #include "ilstubcache.h" #include "classhash.h" @@ -67,7 +66,6 @@ class AppDomain; class DynamicMethodTable; class CodeVersionManager; class TieredCompilationManager; -class ProfileEmitter; class JITInlineTrackingMap; // Hash table parameter of available classes (name -> module/class) hash @@ -373,267 +371,6 @@ struct VASigCookieBlock VASigCookie m_cookies[kVASigCookieBlockSize]; }; -// For IBC Profiling we collect signature blobs for instantiated types. -// For such instantiated types and methods we create our own ibc token -// -// For instantiated types, there also may be no corresponding type token -// or method token for the instantiated types or method in our module. -// For these cases we create our own ibc token definition that is used -// to refer to these external types and methods. We have to handle -// external nested types and namespaces and method signatures. -// -// ParamTypeSpec = 4, // Instantiated Type Signature -// ParamMethodSpec = 5, // Instantiated Method Signature -// ExternalNamespaceDef = 6, // External Namespace Token Definition -// ExternalTypeDef = 7, // External Type Token Definition -// ExternalSignatureDef = 8, // External Signature Definition -// ExternalMethodDef = 9, // External Method Token Definition -// -// typedef DPTR(class ProfilingBlobEntry) PTR_ProfilingBlobEntry; -class ProfilingBlobEntry -{ -public: - virtual ~ProfilingBlobEntry() { LIMITED_METHOD_CONTRACT; }; - virtual bool IsEqual(const ProfilingBlobEntry * other) const = 0; // Pure Virtual - virtual size_t Hash() const = 0; - virtual BlobType kind() const = 0; - virtual size_t varSize() const = 0; - virtual void newToken() = 0; - mdToken token() const { LIMITED_METHOD_CONTRACT; return m_token; } - -protected: - mdToken m_token; -}; - -class TypeSpecBlobEntry : public ProfilingBlobEntry -{ -public: - TypeSpecBlobEntry(DWORD _cbSig, PCCOR_SIGNATURE _pSig); - - virtual ~TypeSpecBlobEntry() { LIMITED_METHOD_CONTRACT; delete [] m_pSig; } - virtual BlobType kind() const { LIMITED_METHOD_CONTRACT; return ParamTypeSpec; } - virtual size_t varSize() const { LIMITED_METHOD_CONTRACT; return sizeof(COR_SIGNATURE) * m_cbSig; } - virtual void newToken() { LIMITED_METHOD_CONTRACT; m_token = ++s_lastTypeSpecToken; } - DWORD flags() const { LIMITED_METHOD_CONTRACT; return m_flags; } - DWORD cbSig() const { LIMITED_METHOD_CONTRACT; return m_cbSig; } - PCCOR_SIGNATURE pSig() const { LIMITED_METHOD_CONTRACT; return m_pSig; } - void orFlag(DWORD flag) { LIMITED_METHOD_CONTRACT; m_flags |= flag; } - static size_t HashInit() { LIMITED_METHOD_CONTRACT; return 156437; } - - virtual bool IsEqual(const ProfilingBlobEntry * other) const; - virtual size_t Hash() const; - - static const TypeSpecBlobEntry * FindOrAdd(PTR_Module pModule, - DWORD _cbSig, - PCCOR_SIGNATURE _pSig); - -private: - DWORD m_flags; - DWORD m_cbSig; - PCCOR_SIGNATURE m_pSig; - - static idTypeSpec s_lastTypeSpecToken; -}; - -class MethodSpecBlobEntry : public ProfilingBlobEntry -{ -public: - MethodSpecBlobEntry(DWORD _cbSig, PCCOR_SIGNATURE _pSig); - - virtual ~MethodSpecBlobEntry() { LIMITED_METHOD_CONTRACT; delete [] m_pSig; } - virtual BlobType kind() const { LIMITED_METHOD_CONTRACT; return ParamMethodSpec; } - virtual size_t varSize() const { LIMITED_METHOD_CONTRACT; return sizeof(COR_SIGNATURE) * m_cbSig; } - virtual void newToken() { LIMITED_METHOD_CONTRACT; m_token = ++s_lastMethodSpecToken; } - DWORD flags() const { LIMITED_METHOD_CONTRACT; return m_flags; } - DWORD cbSig() const { LIMITED_METHOD_CONTRACT; return m_cbSig; } - PCCOR_SIGNATURE pSig() const { LIMITED_METHOD_CONTRACT; return m_pSig; } - void orFlag(DWORD flag) { LIMITED_METHOD_CONTRACT; m_flags |= flag; } - static size_t HashInit() { LIMITED_METHOD_CONTRACT; return 187751; } - - virtual bool IsEqual(const ProfilingBlobEntry * other) const; - virtual size_t Hash() const; - - static const MethodSpecBlobEntry * FindOrAdd(PTR_Module pModule, - DWORD _cbSig, - PCCOR_SIGNATURE _pSig); - -private: - DWORD m_flags; - DWORD m_cbSig; - PCCOR_SIGNATURE m_pSig; - - static idTypeSpec s_lastMethodSpecToken; -}; - -class ExternalNamespaceBlobEntry : public ProfilingBlobEntry -{ -public: - ExternalNamespaceBlobEntry(LPCSTR _pName); - - virtual ~ExternalNamespaceBlobEntry() { LIMITED_METHOD_CONTRACT; delete [] m_pName; } - virtual BlobType kind() const { LIMITED_METHOD_CONTRACT; return ExternalNamespaceDef; } - virtual size_t varSize() const { LIMITED_METHOD_CONTRACT; return sizeof(CHAR) * m_cbName; } - virtual void newToken() { LIMITED_METHOD_CONTRACT; m_token = ++s_lastExternalNamespaceToken; } - DWORD cbName() const { LIMITED_METHOD_CONTRACT; return m_cbName; } - LPCSTR pName() const { LIMITED_METHOD_CONTRACT; return m_pName; } - static size_t HashInit() { LIMITED_METHOD_CONTRACT; return 225307; } - - virtual bool IsEqual(const ProfilingBlobEntry * other) const; - virtual size_t Hash() const; - - static const ExternalNamespaceBlobEntry * FindOrAdd(PTR_Module pModule, LPCSTR _pName); - -private: - DWORD m_cbName; - LPCSTR m_pName; - - static idExternalNamespace s_lastExternalNamespaceToken; -}; - -class ExternalTypeBlobEntry : public ProfilingBlobEntry -{ -public: - ExternalTypeBlobEntry(mdToken _assemblyRef, mdToken _nestedClass, - mdToken _nameSpace, LPCSTR _pName); - - virtual ~ExternalTypeBlobEntry() { LIMITED_METHOD_CONTRACT; delete [] m_pName; } - virtual BlobType kind() const { LIMITED_METHOD_CONTRACT; return ExternalTypeDef; } - virtual size_t varSize() const { LIMITED_METHOD_CONTRACT; return sizeof(CHAR) * m_cbName; } - virtual void newToken() { LIMITED_METHOD_CONTRACT; m_token = ++s_lastExternalTypeToken; } - mdToken assemblyRef() const { LIMITED_METHOD_CONTRACT; return m_assemblyRef; } - mdToken nestedClass() const { LIMITED_METHOD_CONTRACT; return m_nestedClass; } - mdToken nameSpace() const { LIMITED_METHOD_CONTRACT; return m_nameSpace; } - DWORD cbName() const { LIMITED_METHOD_CONTRACT; return m_cbName; } - LPCSTR pName() const { LIMITED_METHOD_CONTRACT; return m_pName; } - static size_t HashInit() { LIMITED_METHOD_CONTRACT; return 270371; } - - virtual bool IsEqual(const ProfilingBlobEntry * other) const; - virtual size_t Hash() const; - - static const ExternalTypeBlobEntry * FindOrAdd(PTR_Module pModule, - mdToken _assemblyRef, - mdToken _nestedClass, - mdToken _nameSpace, - LPCSTR _pName); - -private: - mdToken m_assemblyRef; - mdToken m_nestedClass; - mdToken m_nameSpace; - DWORD m_cbName; - LPCSTR m_pName; - - static idExternalType s_lastExternalTypeToken; -}; - -class ExternalSignatureBlobEntry : public ProfilingBlobEntry -{ -public: - ExternalSignatureBlobEntry(DWORD _cbSig, PCCOR_SIGNATURE _pSig); - - virtual ~ExternalSignatureBlobEntry() { LIMITED_METHOD_CONTRACT; delete [] m_pSig; } - virtual BlobType kind() const { LIMITED_METHOD_CONTRACT; return ExternalSignatureDef; } - virtual size_t varSize() const { LIMITED_METHOD_CONTRACT; return sizeof(COR_SIGNATURE) * m_cbSig; } - virtual void newToken() { LIMITED_METHOD_CONTRACT; m_token = ++s_lastExternalSignatureToken; } - DWORD cbSig() const { LIMITED_METHOD_CONTRACT; return m_cbSig; } - PCCOR_SIGNATURE pSig() const { LIMITED_METHOD_CONTRACT; return m_pSig; } - static size_t HashInit() { LIMITED_METHOD_CONTRACT; return 324449; } - - virtual bool IsEqual(const ProfilingBlobEntry * other) const; - virtual size_t Hash() const; - - static const ExternalSignatureBlobEntry * FindOrAdd(PTR_Module pModule, - DWORD _cbSig, - PCCOR_SIGNATURE _pSig); - -private: - DWORD m_cbSig; - PCCOR_SIGNATURE m_pSig; - - static idExternalSignature s_lastExternalSignatureToken; -}; - -class ExternalMethodBlobEntry : public ProfilingBlobEntry -{ -public: - ExternalMethodBlobEntry(mdToken _nestedClass, mdToken _signature, LPCSTR _pName); - - virtual ~ExternalMethodBlobEntry() { LIMITED_METHOD_CONTRACT; delete [] m_pName; } - virtual BlobType kind() const { LIMITED_METHOD_CONTRACT; return ExternalMethodDef; } - virtual size_t varSize() const { LIMITED_METHOD_CONTRACT; return sizeof(CHAR) * m_cbName; } - virtual void newToken() { LIMITED_METHOD_CONTRACT; m_token = ++s_lastExternalMethodToken; } - mdToken nestedClass() const { LIMITED_METHOD_CONTRACT; return m_nestedClass; } - mdToken signature() const { LIMITED_METHOD_CONTRACT; return m_signature; } - DWORD cbName() const { LIMITED_METHOD_CONTRACT; return m_cbName; } - LPCSTR pName() const { LIMITED_METHOD_CONTRACT; return m_pName; } - static size_t HashInit() { LIMITED_METHOD_CONTRACT; return 389357; } - - virtual bool IsEqual(const ProfilingBlobEntry * other) const; - virtual size_t Hash() const; - - static const ExternalMethodBlobEntry * FindOrAdd(PTR_Module pModule, - mdToken _nestedClass, - mdToken _signature, - LPCSTR _pName); - -private: - mdToken m_nestedClass; - mdToken m_signature; - DWORD m_cbName; - LPCSTR m_pName; - - static idExternalMethod s_lastExternalMethodToken; -}; - -struct IbcNameHandle -{ - mdToken tkIbcNameSpace; - mdToken tkIbcNestedClass; - - LPCSTR szName; - LPCSTR szNamespace; - mdToken tkEnclosingClass; -}; - -// -// Hashtable of ProfilingBlobEntry * -// -class ProfilingBlobTraits : public NoRemoveSHashTraits > -{ -public: - typedef ProfilingBlobEntry * key_t; - - static key_t GetKey(element_t e) - { - LIMITED_METHOD_CONTRACT; - return e; - } - static BOOL Equals(key_t k1, key_t k2) - { - LIMITED_METHOD_CONTRACT; - return k1->IsEqual(k2); - } - static count_t Hash(key_t k) - { - LIMITED_METHOD_CONTRACT; - return (count_t) k->Hash(); - } - static element_t Null() - { - LIMITED_METHOD_CONTRACT; - return NULL; - } - - static bool IsNull(const element_t &e) - { - LIMITED_METHOD_CONTRACT; - return (e == NULL); - } -}; - -typedef SHash ProfilingBlobTable; -typedef DPTR(ProfilingBlobTable) PTR_ProfilingBlobTable; - // // A Module is the primary unit of code packaging in the runtime. It // corresponds mostly to an OS executable image, although other kinds @@ -1026,54 +763,19 @@ class Module PTR_NativeImage m_pNativeImage; #endif -private: - PTR_ProfilingBlobTable m_pProfilingBlobTable; // While performing IBC instrumenting this hashtable is populated with the External defs - CorProfileData * m_pProfileData; // While ngen-ing with IBC optimizations this contains a link to the IBC data for the assembly - - // Profile information - BOOL m_nativeImageProfiling; - CORCOMPILE_METHOD_PROFILE_LIST *m_methodProfileList; - #if PROFILING_SUPPORTED_DATA +private: DWORD m_dwTypeCount; DWORD m_dwExportedTypeCount; DWORD m_dwCustomAttributeCount; #endif // PROFILING_SUPPORTED_DATA - struct TokenProfileData - { - static TokenProfileData *CreateNoThrow(void); - - TokenProfileData() - // We need a critical section that can be entered in both preemptive and cooperative modes. - // Hopefully this restriction can be removed in the future. - : crst(CrstSaveModuleProfileData, CRST_UNSAFE_ANYMODE) - { - WRAPPER_NO_CONTRACT; - } - - ~TokenProfileData() - { - WRAPPER_NO_CONTRACT; - } - - Crst crst; - - struct Formats - { - CQuickArray tokenArray; - RidBitmap tokenBitmaps[CORBBTPROF_TOKEN_MAX_NUM_FLAGS]; - } m_formats[SectionFormatCount]; - - } *m_tokenProfileData; - protected: void DoInit(AllocMemTracker *pamTracker, LPCWSTR szName); protected: #ifndef DACCESS_COMPILE virtual void Initialize(AllocMemTracker *pamTracker, LPCWSTR szName = NULL); - void InitializeForProfiling(); #endif void AllocateMaps(); @@ -1428,8 +1130,6 @@ class Module BAD_FORMAT_NOTHROW_ASSERT(TypeFromToken(token) == mdtTypeDef); - g_IBCLogger.LogRidMapAccess( MakePair( this, token ) ); - TADDR flags; TypeHandle th = TypeHandle(m_TypeDefToMethodTableMap.GetElementAndFlags(RidFromToken(token), &flags)); @@ -1447,8 +1147,6 @@ class Module BAD_FORMAT_NOTHROW_ASSERT(TypeFromToken(token) == mdtTypeDef); - g_IBCLogger.LogRidMapAccess( MakePair( this, token ) ); - TADDR flags; TypeHandle th = TypeHandle(m_GenericTypeDefToCanonMethodTableMap.GetElementAndFlags(RidFromToken(token), &flags)); @@ -1502,8 +1200,6 @@ class Module _ASSERTE(TypeFromToken(token) == mdtTypeRef); - g_IBCLogger.LogRidMapAccess( MakePair( this, token ) ); - // The TypeRef cache is strictly a lookaside cache. If we get an OOM trying to grow the table, // we cannot abort the load. (This will cause fatal errors during gc promotion.) m_TypeRefToMethodTableMap.TrySetElement(RidFromToken(token), @@ -1565,7 +1261,6 @@ class Module _ASSERTE(TypeFromToken(token) == mdtMemberRef); TADDR pResult = dac_cast(m_pMemberRefToDescHashTable->GetValue(token, pfIsMethod)); - g_IBCLogger.LogRidMapAccess( MakePair( this, token ) ); return pResult; } MethodDesc *LookupMemberRefAsMethod(mdMemberRef token); @@ -1831,24 +1526,6 @@ class Module Module *GetModuleFromIndex(DWORD ix); Module *GetModuleFromIndexIfLoaded(DWORD ix); - ICorJitInfo::BlockCounts * AllocateMethodBlockCounts(mdToken _token, DWORD _size, DWORD _ILSize); - HANDLE OpenMethodProfileDataLogFile(GUID mvid); - static void ProfileDataAllocateTokenLists(ProfileEmitter * pEmitter, TokenProfileData* pTokenProfileData); - HRESULT WriteMethodProfileDataLogFile(bool cleanup); - static void WriteAllModuleProfileData(bool cleanup); - void SetMethodProfileList(CORCOMPILE_METHOD_PROFILE_LIST * value) - { - m_methodProfileList = value; - } - - void CreateProfilingData(); - void DeleteProfilingData(); - - PTR_ProfilingBlobTable GetProfilingBlobTable(); - - void LogTokenAccess(mdToken token, SectionFormat format, ULONG flagNum); - void LogTokenAccess(mdToken token, ULONG flagNum); - BOOL IsReadyToRun() const { LIMITED_METHOD_DAC_CONTRACT; @@ -1887,14 +1564,6 @@ class Module void SetBeingUnloaded(); void StartUnload(); - -public: - idTypeSpec LogInstantiatedType(TypeHandle typeHnd, ULONG flagNum); - idMethodSpec LogInstantiatedMethod(const MethodDesc * md, ULONG flagNum); - - static DWORD EncodeModuleHelper(void* pModuleContext, Module *pReferencedModule); - static void TokenDefinitionHelper(void* pModuleContext, Module *pReferencedModule, DWORD index, mdToken* token); - public: void SetDynamicIL(mdToken token, TADDR blobAddress, BOOL fTemporaryOverride); TADDR GetDynamicIL(mdToken token, BOOL fAllowTemporary); diff --git a/src/coreclr/vm/ceeload.inl b/src/coreclr/vm/ceeload.inl index fee8a8f4fcc33..28923c537418c 100644 --- a/src/coreclr/vm/ceeload.inl +++ b/src/coreclr/vm/ceeload.inl @@ -267,8 +267,6 @@ inline MethodDesc *Module::LookupMethodDef(mdMethodDef token) CONTRACTL_END _ASSERTE(TypeFromToken(token) == mdtMethodDef); - g_IBCLogger.LogRidMapAccess( MakePair( this, token ) ); - return m_MethodDefToDescMap.GetElement(RidFromToken(token)); } @@ -277,7 +275,6 @@ inline MethodDesc *Module::LookupMemberRefAsMethod(mdMemberRef token) LIMITED_METHOD_DAC_CONTRACT; _ASSERTE(TypeFromToken(token) == mdtMemberRef); - g_IBCLogger.LogRidMapAccess( MakePair( this, token ) ); BOOL flags = FALSE; PTR_MemberRef pMemberRef = m_pMemberRefToDescHashTable->GetValue(token, &flags); return flags ? dac_cast(pMemberRef) : NULL; diff --git a/src/coreclr/vm/ceemain.cpp b/src/coreclr/vm/ceemain.cpp index e1c9bddedde34..aa100b2605822 100644 --- a/src/coreclr/vm/ceemain.cpp +++ b/src/coreclr/vm/ceemain.cpp @@ -1238,41 +1238,6 @@ void STDMETHODCALLTYPE EEShutDownHelper(BOOL fIsDllUnloading) PerfMap::Destroy(); #endif - { - // If we're doing basic block profiling, we need to write the log files to disk. - static BOOL fIBCLoggingDone = FALSE; - if (!fIBCLoggingDone) - { - if (g_IBCLogger.InstrEnabled()) - { - Thread * pThread = GetThreadNULLOk(); - ThreadLocalIBCInfo* pInfo = NULL; - - if (pThread != NULL) - { - pInfo = pThread->GetIBCInfo(); - if (pInfo == NULL) - { - CONTRACT_VIOLATION( ThrowsViolation | FaultViolation); - pInfo = new ThreadLocalIBCInfo(); - pThread->SetIBCInfo(pInfo); - } - } - - // Acquire the Crst lock before creating the IBCLoggingDisabler object. - // Only one thread at a time can be processing an IBC logging event. - CrstHolder lock(IBCLogger::GetSync()); - { - IBCLoggingDisabler disableLogging( pInfo ); // runs IBCLoggingDisabler::DisableLogging - - CONTRACT_VIOLATION(GCViolation); - Module::WriteAllModuleProfileData(true); - } - } - fIBCLoggingDone = TRUE; - } - } - ceeInf.JitProcessShutdownWork(); // Do anything JIT-related that needs to happen at shutdown. #ifdef FEATURE_INTERPRETER diff --git a/src/coreclr/vm/class.cpp b/src/coreclr/vm/class.cpp index 3add832d29a72..82a951a340d13 100644 --- a/src/coreclr/vm/class.cpp +++ b/src/coreclr/vm/class.cpp @@ -1794,7 +1794,6 @@ TypeHandle MethodTable::SetupCoClassForInterface() CoClassType = TypeName::GetTypeUsingCASearchRules(ss.GetUnicode(), GetAssembly()); // Cache the coclass type - g_IBCLogger.LogEEClassCOWTableAccess(this); GetClass_NoLogging()->SetCoClassForInterface(CoClassType); } return CoClassType; @@ -2161,7 +2160,6 @@ CorIfaceAttr MethodTable::GetComInterfaceType() } // Cache the interface type - g_IBCLogger.LogEEClassCOWTableAccess(this); GetClass_NoLogging()->SetComInterfaceType(ItfType); return ItfType; diff --git a/src/coreclr/vm/class.h b/src/coreclr/vm/class.h index 9aa6c6994e726..3093feae45bfd 100644 --- a/src/coreclr/vm/class.h +++ b/src/coreclr/vm/class.h @@ -48,7 +48,6 @@ #include "packedfields.inl" #include "array.h" -#define IBCLOG(x) g_IBCLogger.##x VOID DECLSPEC_NORETURN RealCOMPlusThrowHR(HRESULT hr); diff --git a/src/coreclr/vm/classhash.cpp b/src/coreclr/vm/classhash.cpp index 00e61836e7a5d..005a392565731 100644 --- a/src/coreclr/vm/classhash.cpp +++ b/src/coreclr/vm/classhash.cpp @@ -478,11 +478,6 @@ EEClassHashEntry_t *EEClassHashTable::FindItem(LPCUTF8 pszNamespace, LPCUTF8 psz // If (pSearch->pEncloser), we've found a nested class if ((IsNested != FALSE) == (pSearch->GetEncloser() != NULL)) { - if (m_bCaseInsensitive) - g_IBCLogger.LogClassHashTableAccess(dac_cast(pSearch->GetData())); - else - g_IBCLogger.LogClassHashTableAccess(pSearch); - return pSearch; } } diff --git a/src/coreclr/vm/clrtocomcall.cpp b/src/coreclr/vm/clrtocomcall.cpp index 3a7847089b682..d3eb20d440359 100644 --- a/src/coreclr/vm/clrtocomcall.cpp +++ b/src/coreclr/vm/clrtocomcall.cpp @@ -61,17 +61,11 @@ ComPlusCallInfo *ComPlusCall::PopulateComPlusCallMethodDesc(MethodDesc* pMD, DWO MethodTable *pMT = pMD->GetMethodTable(); MethodTable *pItfMT = NULL; - // We are going to use this MethodDesc for a CLR->COM call - g_IBCLogger.LogMethodCodeAccess(pMD); - if (pMD->IsComPlusCall()) { ComPlusCallMethodDesc *pCMD = (ComPlusCallMethodDesc *)pMD; if (pCMD->m_pComPlusCallInfo == NULL) { - // We are going to write the m_pComPlusCallInfo field of the MethodDesc - g_IBCLogger.LogMethodDescWriteAccess(pMD); - LoaderHeap *pHeap = pMD->GetLoaderAllocator()->GetHighFrequencyHeap(); ComPlusCallInfo *pTemp = (ComPlusCallInfo *)(void *)pHeap->AllocMem(S_SIZE_T(sizeof(ComPlusCallInfo))); diff --git a/src/coreclr/vm/clsload.cpp b/src/coreclr/vm/clsload.cpp index c1a5ffb86ecd9..8dc93dd89d9d1 100644 --- a/src/coreclr/vm/clsload.cpp +++ b/src/coreclr/vm/clsload.cpp @@ -957,8 +957,6 @@ TypeHandle ClassLoader::LoadConstructedTypeThrowing(TypeKey *pKey, if (!typeHnd.IsNull()) { existingLoadLevel = typeHnd.GetLoadLevel(); - if (existingLoadLevel >= level) - g_IBCLogger.LogTypeHashTableAccess(&typeHnd); } } @@ -2842,7 +2840,7 @@ TypeHandle ClassLoader::DoIncrementalLoad(TypeKey *pTypeKey, TypeHandle typeHnd, // or at least level CLASS_LOAD_APPROXPARENTS (if creating type for the first time) case CLASS_LOAD_BEGIN : { - IBCLoggerAwareAllocMemTracker amTracker; + AllocMemTracker amTracker; typeHnd = CreateTypeHandleForTypeKey(pTypeKey, &amTracker); CONSISTENCY_CHECK(!typeHnd.IsNull()); TypeHandle published = PublishType(pTypeKey, typeHnd); @@ -3134,8 +3132,6 @@ void ClassLoader::Notify(TypeHandle typeHnd) } #endif //PROFILING_SUPPORTED - g_IBCLogger.LogMethodTableAccess(pMT); - if (pMT->IsTypicalTypeDefinition()) { LOG((LF_CLASSLOADER, LL_INFO100, "Successfully loaded class %s\n", pMT->GetDebugClassName())); diff --git a/src/coreclr/vm/codeman.cpp b/src/coreclr/vm/codeman.cpp index 83bbbd56d0b97..d9fe09a7ae447 100644 --- a/src/coreclr/vm/codeman.cpp +++ b/src/coreclr/vm/codeman.cpp @@ -5787,15 +5787,6 @@ GCInfoToken ReadyToRunJitManager::GetGCInfoToken(const METHODTOKEN& MethodToken) PTR_RUNTIME_FUNCTION pRuntimeFunction = JitTokenToRuntimeFunction(MethodToken); TADDR baseAddress = JitTokenToModuleBase(MethodToken); -#ifndef DACCESS_COMPILE - if (g_IBCLogger.InstrEnabled()) - { - ReadyToRunInfo * pInfo = JitTokenToReadyToRunInfo(MethodToken); - MethodDesc * pMD = pInfo->GetMethodDescForEntryPoint(JitTokenToStartAddress(MethodToken)); - g_IBCLogger.LogMethodGCInfoAccess(pMD); - } -#endif - SIZE_T nUnwindDataSize; PTR_VOID pUnwindData = GetUnwindDataBlob(baseAddress, pRuntimeFunction, &nUnwindDataSize); diff --git a/src/coreclr/vm/codepitchingmanager.cpp b/src/coreclr/vm/codepitchingmanager.cpp index 7ed39f40a5325..6badd9746d44f 100644 --- a/src/coreclr/vm/codepitchingmanager.cpp +++ b/src/coreclr/vm/codepitchingmanager.cpp @@ -341,8 +341,6 @@ void MethodDesc::PitchNativeCode() WRAPPER_NO_CONTRACT; SUPPORTS_DAC; - g_IBCLogger.LogMethodDescAccess(this); - if (!IsPitchable()) return; diff --git a/src/coreclr/vm/comdelegate.cpp b/src/coreclr/vm/comdelegate.cpp index 2c6d268917106..5733fd8478315 100644 --- a/src/coreclr/vm/comdelegate.cpp +++ b/src/coreclr/vm/comdelegate.cpp @@ -832,8 +832,6 @@ Stub* COMDelegate::SetupShuffleThunk(MethodTable * pDelMT, MethodDesc *pTargetMe COMPlusThrowOM(); } - g_IBCLogger.LogEEClassCOWTableAccess(pDelMT); - if (!pTargetMeth->IsStatic() && pTargetMeth->HasRetBuffArg() && IsRetBuffPassedAsFirstArg()) { if (FastInterlockCompareExchangePointer(&pClass->m_pInstRetBuffCallStub, pShuffleThunk, NULL ) != NULL) @@ -1275,7 +1273,6 @@ LPVOID COMDelegate::ConvertToCallback(OBJECTREF pDelegateObj) ExecutableWriterHolder uMThunkMarshInfoWriterHolder(pUMThunkMarshInfo, sizeof(UMThunkMarshInfo)); uMThunkMarshInfoWriterHolder.GetRW()->LoadTimeInit(pInvokeMeth); - g_IBCLogger.LogEEClassCOWTableAccess(pMT); if (FastInterlockCompareExchangePointer(&(pClass->m_pUMThunkMarshInfo), pUMThunkMarshInfo, NULL ) != NULL) @@ -1719,8 +1716,6 @@ FCIMPL3(void, COMDelegate::DelegateConstruct, Object* refThisUNSAFE, Object* tar { if (pMTTarg) { - g_IBCLogger.LogMethodTableAccess(pMTTarg); - // Use the Unboxing stub for value class methods, since the value // class is constructed using the boxed instance. // @@ -2315,8 +2310,6 @@ FCIMPL1(PCODE, COMDelegate::GetMulticastInvoke, Object* refThisIn) pStub = Stub::NewStub(JitILStub(pStubMD)); - g_IBCLogger.LogEEClassCOWTableAccess(pDelegateMT); - InterlockedCompareExchangeT(&delegateEEClass->m_pMultiCastInvokeStub, pStub, NULL); HELPER_METHOD_FRAME_END(); @@ -2368,14 +2361,12 @@ FCIMPL1(PCODE, COMDelegate::GetMulticastInvoke, Object* refThisIn) if (!pWinner) COMPlusThrowOM(); - LOG((LF_CORDB,LL_INFO10000, "Putting a MC stub at 0x%x (code:0x%x)\n", + LOG((LF_CORDB,LL_INFO10000, "Putting a MC stub at 0x%p (code:0x%p)\n", pWinner, (BYTE*)pWinner+sizeof(Stub))); pStub = pWinner; } - g_IBCLogger.LogEEClassCOWTableAccess(pDelegateMT); - // we don't need to do an InterlockedCompareExchange here - the m_pMulticastStubCache->AttemptToSetStub // will make sure all threads racing here will get the same stub, so they'll all store the same value delegateEEClass->m_pMultiCastInvokeStub = pStub; @@ -2447,8 +2438,6 @@ PCODE COMDelegate::GetWrapperInvoke(MethodDesc* pMD) pStub = Stub::NewStub(JitILStub(pStubMD)); - g_IBCLogger.LogEEClassCOWTableAccess(pDelegateMT); - InterlockedCompareExchangeT(&delegateEEClass->m_pWrapperDelegateInvokeStub, pStub, NULL); } diff --git a/src/coreclr/vm/common.h b/src/coreclr/vm/common.h index dd750e91002af..c4bd0ad55d08c 100644 --- a/src/coreclr/vm/common.h +++ b/src/coreclr/vm/common.h @@ -292,7 +292,6 @@ inline void ClrRestoreNonvolatileContext(PCONTEXT ContextRecord) #include "gcenv.interlocked.inl" #include "util.hpp" -#include "ibclogger.h" #include "eepolicy.h" #include "vars.hpp" diff --git a/src/coreclr/vm/dllimport.cpp b/src/coreclr/vm/dllimport.cpp index 75aa9e65308d0..7f2d3cf4c8165 100644 --- a/src/coreclr/vm/dllimport.cpp +++ b/src/coreclr/vm/dllimport.cpp @@ -5449,8 +5449,6 @@ namespace } CONTRACT_END; - g_IBCLogger.LogNDirectCodeAccess(pMD); - RETURN pMD->FindEntryPoint(hMod); } @@ -5776,7 +5774,6 @@ VOID NDirectMethodDesc::SetNDirectTarget(LPVOID pTarget) CONTRACTL_END; NDirectWriteableData* pWriteableData = GetWriteableData(); - g_IBCLogger.LogNDirectCodeAccess(this); pWriteableData->m_pNDirectTarget = pTarget; } diff --git a/src/coreclr/vm/eeconfig.cpp b/src/coreclr/vm/eeconfig.cpp index c68eccdf3618e..87692b656eb01 100644 --- a/src/coreclr/vm/eeconfig.cpp +++ b/src/coreclr/vm/eeconfig.cpp @@ -503,11 +503,7 @@ HRESULT EEConfig::sync() if (szZapBBInstr != NULL) { IfFailRet(CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_ZapBBInstrDir, &szZapBBInstrDir)); - g_IBCLogger.EnableAllInstr(); } - else - g_IBCLogger.DisableAllInstr(); - dwDisableStackwalkCache = CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_DisableStackwalkCache, dwDisableStackwalkCache); diff --git a/src/coreclr/vm/eventtrace.cpp b/src/coreclr/vm/eventtrace.cpp index ebf8d8ee36311..397365c824b96 100644 --- a/src/coreclr/vm/eventtrace.cpp +++ b/src/coreclr/vm/eventtrace.cpp @@ -7448,12 +7448,7 @@ VOID ETW::EnumerationLog::EnumerationHelper(Module *moduleFilter, BaseDomain *do GC_TRIGGERS; } CONTRACTL_END; - // Disable IBC logging during ETW enumeration since we call a lot of functionality - // that does logging and causes problems in the shutdown path due to critical - // section access for IBC logging - IBCLoggingDisabler disableLogging; - - if(moduleFilter) + if (moduleFilter) { // Iterate modules first because their number is usually smaller then the number of methods. // Thus hitting a timeout due to a large number of methods will not affect modules rundown.tf g diff --git a/src/coreclr/vm/field.cpp b/src/coreclr/vm/field.cpp index 31d858814d020..dd472e41cda98 100644 --- a/src/coreclr/vm/field.cpp +++ b/src/coreclr/vm/field.cpp @@ -109,8 +109,6 @@ BOOL FieldDesc::MightHaveName(ULONG nameHashValue) { LIMITED_METHOD_CONTRACT; - g_IBCLogger.LogFieldDescsAccess(this); - // We only have space for a name hash when we are using the packed mb layout if (m_requiresFullMbValue) { @@ -255,8 +253,6 @@ PTR_VOID FieldDesc::GetStaticAddressHandle(PTR_VOID base) } CONTRACTL_END - g_IBCLogger.LogFieldDescsAccess(this); - _ASSERTE(IsStatic()); #ifdef EnC_SUPPORTED if (IsEnCNew()) @@ -471,7 +467,6 @@ PTR_VOID FieldDesc::GetAddress(PTR_VOID o) _ASSERTE(!IsEnCNew()); // when we call this while finding an EnC field via the DAC, // the field desc is for the EnCHelper, not the new EnC field #endif - g_IBCLogger.LogFieldDescsAccess(this); #if defined(EnC_SUPPORTED) && !defined(DACCESS_COMPILE) // EnC added fields aren't at a simple offset like normal fields. @@ -493,8 +488,6 @@ void *FieldDesc::GetInstanceAddress(OBJECTREF o) } CONTRACTL_END; - g_IBCLogger.LogFieldDescsAccess(this); - DWORD dwOffset = m_dwOffset; // GetOffset() #ifdef EnC_SUPPORTED diff --git a/src/coreclr/vm/field.h b/src/coreclr/vm/field.h index 72378df259060..143a9056b537f 100644 --- a/src/coreclr/vm/field.h +++ b/src/coreclr/vm/field.h @@ -194,8 +194,6 @@ class FieldDesc DWORD GetOffsetUnsafe() { LIMITED_METHOD_CONTRACT; - - g_IBCLogger.LogFieldDescsAccess(this); _ASSERTE(m_dwOffset <= FIELD_OFFSET_LAST_REAL_OFFSET); return m_dwOffset; } @@ -203,7 +201,6 @@ class FieldDesc DWORD GetOffset() { LIMITED_METHOD_DAC_CONTRACT; - g_IBCLogger.LogFieldDescsAccess(this); return GetOffset_NoLogging(); } @@ -395,7 +392,6 @@ class FieldDesc PTR_MethodTable GetApproxEnclosingMethodTable() { LIMITED_METHOD_DAC_CONTRACT; - g_IBCLogger.LogFieldDescsAccess(this); return GetApproxEnclosingMethodTable_NoLogging(); } diff --git a/src/coreclr/vm/gchelpers.cpp b/src/coreclr/vm/gchelpers.cpp index 9745d430f29cf..03f930498cb18 100644 --- a/src/coreclr/vm/gchelpers.cpp +++ b/src/coreclr/vm/gchelpers.cpp @@ -369,8 +369,6 @@ OBJECTREF AllocateSzArray(MethodTable* pArrayMT, INT32 cElements, GC_ALLOC_FLAGS MODE_COOPERATIVE; // returns an objref without pinning it => cooperative } CONTRACTL_END; - // IBC Log MethodTable access - g_IBCLogger.LogMethodTableAccess(pArrayMT); SetTypeHandleOnThreadForAlloc(TypeHandle(pArrayMT)); _ASSERTE(pArrayMT->CheckInstanceActivated()); @@ -544,8 +542,6 @@ OBJECTREF AllocateArrayEx(MethodTable *pArrayMT, INT32 *pArgs, DWORD dwNumArgs, } #endif - // IBC Log MethodTable access - g_IBCLogger.LogMethodTableAccess(pArrayMT); SetTypeHandleOnThreadForAlloc(TypeHandle(pArrayMT)); // keep original flags in case the call is recursive (jugged array case) @@ -920,8 +916,6 @@ OBJECTREF AllocateObject(MethodTable *pMT // not set becuase it isn't until near the end of the fcn at which point we can allow // the check. _UNCHECKED_OBJECTREF oref; - - g_IBCLogger.LogMethodTableAccess(pMT); SetTypeHandleOnThreadForAlloc(TypeHandle(pMT)); diff --git a/src/coreclr/vm/generics.cpp b/src/coreclr/vm/generics.cpp index c58ef270e0874..fea2ce22645fd 100644 --- a/src/coreclr/vm/generics.cpp +++ b/src/coreclr/vm/generics.cpp @@ -500,9 +500,6 @@ ClassLoader::CreateTypeHandleForNonCanonicalGenericInstantiation( { pStaticFieldDescs = (FieldDesc*) pamTracker->Track(pAllocator->GetLowFrequencyHeap()->AllocMem(S_SIZE_T(sizeof(FieldDesc)) * S_SIZE_T(pOldMT->GetNumStaticFields()))); FieldDesc* pOldFD = pOldMT->GetGenericsStaticFieldDescs(); - - g_IBCLogger.LogFieldDescsAccess(pOldFD); - for (DWORD i = 0; i < pOldMT->GetNumStaticFields(); i++) { pStaticFieldDescs[i].InitializeFrom(pOldFD[i], pMT); @@ -573,8 +570,6 @@ BOOL CheckInstantiation(Instantiation inst) return TRUE; } - g_IBCLogger.LogTypeMethodTableAccess(&th); - if ( type == ELEMENT_TYPE_BYREF || type == ELEMENT_TYPE_TYPEDBYREF || type == ELEMENT_TYPE_VOID diff --git a/src/coreclr/vm/genmeth.cpp b/src/coreclr/vm/genmeth.cpp index 8237f147c6166..97269a6519e1f 100644 --- a/src/coreclr/vm/genmeth.cpp +++ b/src/coreclr/vm/genmeth.cpp @@ -358,7 +358,7 @@ InstantiatedMethodDesc::NewInstantiatedMethodDesc(MethodTable *pExactMT, TypeHandle *pInstOrPerInstInfo = NULL; DictionaryLayout *pDL = NULL; DWORD infoSize = 0; - IBCLoggerAwareAllocMemTracker amt; + AllocMemTracker amt; if (!methodInst.IsEmpty()) { @@ -857,7 +857,6 @@ MethodDesc::FindOrCreateAssociatedMethodDesc(MethodDesc* pDefMD, if (pResultMD != NULL) { _ASSERTE(pResultMD->GetMethodTable()->IsFullyLoaded()); - g_IBCLogger.LogMethodDescAccess(pResultMD); RETURN(pResultMD); } @@ -894,7 +893,7 @@ MethodDesc::FindOrCreateAssociatedMethodDesc(MethodDesc* pDefMD, FALSE); if (pResultMD == NULL) { - IBCLoggerAwareAllocMemTracker amt; + AllocMemTracker amt; pResultMD = CreateMethodDesc(pAllocator, pRepMT, @@ -972,7 +971,7 @@ MethodDesc::FindOrCreateAssociatedMethodDesc(MethodDesc* pDefMD, _ASSERTE(!pNonUnboxingStub->RequiresInstArg()); _ASSERTE(!pNonUnboxingStub->IsUnboxingStub()); - IBCLoggerAwareAllocMemTracker amt; + AllocMemTracker amt; _ASSERTE(pDefMD->GetClassification() == mcInstantiated); @@ -1052,11 +1051,8 @@ MethodDesc::FindOrCreateAssociatedMethodDesc(MethodDesc* pDefMD, pResultMD == FindTightlyBoundWrappedMethodDesc_DEBUG(pMDescInCanonMT)); if (pResultMD != NULL) - { + { _ASSERTE(pResultMD->GetMethodTable()->IsFullyLoaded()); - - g_IBCLogger.LogMethodDescAccess(pResultMD); - if (allowInstParam || !pResultMD->RequiresInstArg()) { RETURN(pResultMD); diff --git a/src/coreclr/vm/ibclogger.cpp b/src/coreclr/vm/ibclogger.cpp deleted file mode 100644 index 1f193826d64ab..0000000000000 --- a/src/coreclr/vm/ibclogger.cpp +++ /dev/null @@ -1,639 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// IBClogger.CPP -// - -// -// Infrastructure for recording touches of EE data structures -// -// - - -#include "common.h" -#ifdef IBCLOGGER_ENABLED -#include "method.hpp" -#include "corbbtprof.h" -#include "metadatatracker.h" -#include "field.h" -#include "typekey.h" -#include "ibclogger.h" - -//#ifdef _DEBUG -//#define DEBUG_IBCLOGGER -//#endif - -#ifdef DEBUG_IBCLOGGER - -#define DEBUG_PRINTF1(a) printf(a) -#define DEBUG_PRINTF2(a,b) printf(a,b) -#define DEBUG_PRINTF3(a,b,c) printf(a,b,c) -#define DEBUG_PRINTF4(a,b,c,d) printf(a,b,c,d) -#define DEBUG_PRINTF5(a,b,c,d,e) printf(a,b,c,d,e) -#else -#define DEBUG_PRINTF1(a) -#define DEBUG_PRINTF2(a,b) -#define DEBUG_PRINTF3(a,b,c) -#define DEBUG_PRINTF4(a,b,c,d) -#define DEBUG_PRINTF5(a,b,c,d,e) -#endif - -DWORD dwIBCLogCount = 0; -CrstStatic IBCLogger::m_sync; - -#ifdef _DEBUG -/*static*/ unsigned IbcCallback::s_highestId = 0; -#endif - -IBCLoggingDisabler::IBCLoggingDisabler() -{ - m_pInfo = NULL; - m_fDisabled = false; - - if (g_IBCLogger.InstrEnabled()) - { - m_pInfo = GetThread()->GetIBCInfo(); - if (m_pInfo != NULL) - { - m_fDisabled = m_pInfo->DisableLogging(); - } - } -} - -IBCLoggingDisabler::IBCLoggingDisabler(bool ignore) -{ - m_pInfo = NULL; - m_fDisabled = false; - - if (ignore == false) - { - if (g_IBCLogger.InstrEnabled()) - { - m_pInfo = GetThread()->GetIBCInfo(); - if (m_pInfo != NULL) - { - m_fDisabled = m_pInfo->DisableLogging(); - } - } - } -} - -IBCLoggingDisabler::IBCLoggingDisabler(ThreadLocalIBCInfo* pInfo) -{ - LIMITED_METHOD_CONTRACT; - m_pInfo = pInfo; - - if (m_pInfo != NULL) - { - m_fDisabled = m_pInfo->DisableLogging(); - } - else - { - m_fDisabled = false; - } -} - -IBCLoggingDisabler::~IBCLoggingDisabler() -{ - LIMITED_METHOD_CONTRACT; - if (m_fDisabled) - m_pInfo->EnableLogging(); -} - -IBCLoggerAwareAllocMemTracker::~IBCLoggerAwareAllocMemTracker() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - MODE_ANY; - } - CONTRACTL_END; - - if (!m_fReleased) - { - GetThread()->FlushIBCInfo(); - } -} - -IBCLogger::IBCLogger() - : dwInstrEnabled(0) -{ - LIMITED_METHOD_CONTRACT; - m_sync.Init(CrstIbcProfile, CrstFlags(CRST_UNSAFE_ANYMODE | CRST_REENTRANCY | CRST_DEBUGGER_THREAD)); -} - -IBCLogger::~IBCLogger() -{ - WRAPPER_NO_CONTRACT; - - m_sync.Destroy(); -} - -void IBCLogger::LogAccessThreadSafeHelperStatic(const void * p, pfnIBCAccessCallback callback) -{ - WRAPPER_NO_CONTRACT; - /* To make the logging callsite as small as possible keep the part that passes extra */ - /* argument to LogAccessThreadSafeHelper in separate non-inlined function */ - g_IBCLogger.LogAccessThreadSafeHelper(p, callback); -} - -void IBCLogger::LogAccessThreadSafeHelper(const void * p, pfnIBCAccessCallback callback) -{ - WRAPPER_NO_CONTRACT; - CONTRACT_VIOLATION( HostViolation ); - - /* For the Global Class we may see p == NULL */ - if (p == NULL) - return; - - Thread * pThread = GetThreadNULLOk(); - - /* This could be called by the concurrent GC thread*/ - /* where GetThread() returns NULL. In such cases,*/ - /* we want to log data accessed by the GC, but we will just ignore it for now.*/ - if (pThread == NULL) - return; - - ThreadLocalIBCInfo* pInfo = pThread->GetIBCInfo(); - if (pInfo == NULL) - { - CONTRACT_VIOLATION( ThrowsViolation | FaultViolation); - pInfo = new ThreadLocalIBCInfo(); - pThread->SetIBCInfo(pInfo); - } - - // - // During certain events we disable IBC logging. - // This may be to prevent deadlocks or we might - // not want to have IBC logging during these events. - // - if ( !pInfo->IsLoggingDisabled() ) - { - CONTRACT_VIOLATION( ThrowsViolation | TakesLockViolation | FaultViolation); - pInfo->CallbackHelper(p, callback); - } -} - -CrstStatic* IBCLogger::GetSync() -{ - CONTRACTL - { - THROWS; - GC_NOTRIGGER; - MODE_ANY; - } - CONTRACTL_END; - - return &m_sync; -} - -void IBCLogger::DelayedCallbackPtr(pfnIBCAccessCallback callback, const void * pValue1, const void * pValue2 /*=NULL*/) -{ - WRAPPER_NO_CONTRACT; - - ThreadLocalIBCInfo* pInfo = GetThread()->GetIBCInfo(); - - // record that we could not currently resolve this callback - pInfo->SetCallbackFailed(); - - // If we are processing the delayed list then we don't want or need to - // add this pair to the delay list. - if (pInfo->ProcessingDelayedList()) - { - return; - } - - // We could throw an out of memory exception - CONTRACT_VIOLATION( ThrowsViolation ); - - // Get our thread local hashtable - DelayCallbackTable * pTable = pInfo->GetPtrDelayList(); - - // Create IbcCallback in our stack frame to use as a key for the Lookup - IbcCallback key(callback, pValue1, pValue2); - - // Perform lookup of this key in our hashtable - IbcCallback * pEntry = pTable->Lookup(&key); - - // If we already have this pair in our table - // then just return, because we don't need to add a duplicate - if (pEntry != NULL) - { - // Print out a debug message if we are debugging this - DEBUG_PRINTF4("Did not add duplicate delayed ptr callback: pfn=0x%08x, pValue1=0x%8p, pValue2=0x%8p\n", - pEntry->GetPfn(), pEntry->GetValue1(), pEntry->GetValue2()); - return; - } - // Now that we know that we will add a new entry into our hashtable - // We create a new IbcCallback in the heap to use as a persisted key - pEntry = new IbcCallback(callback, pValue1, pValue2); - - // Mark this key as new valid IbcCallback - pEntry->SetValid(); - - // Add the entry into our hashtable. - pTable->Add(pEntry); - - // Print out a debug message if we are debugging this - DEBUG_PRINTF4("Added a new delayed ptr callback: pfn=0x%08x, pValue1=0x%8p, pValue2=0x%8p\n", - key.GetPfn(), key.GetValue1(), key.GetValue2()); -} - -// some of IBC probes never complete successfully at all. -// and there is no point for them to stay in the delay list forever, -// because it significantly slows down the IBC instrumentation. -// c_maxRetries: the maximun number of times the unsuccessful IBC probe is tried -// c_minCount: is the minimum number of entries in the delay list that we -// need before we will call ProcessDelayedCallbacks() -// c_minCountIncr: is the minimum number of entries in the delay list that we -// need to add before we will call ProcessDelayedCallbacks() again -// -static const int c_maxRetries = 10; -static const int c_minCount = 8; -static const int c_minCountIncr = 8; - -ThreadLocalIBCInfo::ThreadLocalIBCInfo() -{ - LIMITED_METHOD_CONTRACT; - - m_fCallbackFailed = false; - m_fProcessingDelayedList = false; - m_fLoggingDisabled = false; - m_iMinCountToProcess = c_minCount; - m_pDelayList = NULL; -} - -ThreadLocalIBCInfo:: ~ThreadLocalIBCInfo() -{ - WRAPPER_NO_CONTRACT; - - if (m_pDelayList != NULL) - { - // We have one last call to the CallbackHelper to - // flush out any remaining items on our delay list - // - // CONTRACT_VIOLATION( ThrowsViolation | TakesLockViolation ); - // CallbackHelper(NULL, NULL); - - DeleteDelayedCallbacks(); - } -} - -void ThreadLocalIBCInfo::DeleteDelayedCallbacks() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - MODE_ANY; - } - CONTRACTL_END; - - for (DelayCallbackTable::Iterator elem = m_pDelayList->Begin(), - end = m_pDelayList->End(); - (elem != end); elem++) - { - IbcCallback * pCallback = const_cast(*elem); - - _ASSERTE(pCallback->IsValid()); - - // free up each of the IbcCallback pointers that we allocated - pCallback->Invalidate(); - delete pCallback; - } - - delete m_pDelayList; - m_pDelayList = NULL; -} - -void ThreadLocalIBCInfo::FlushDelayedCallbacks() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - MODE_ANY; - } - CONTRACTL_END; - - if (m_pDelayList != NULL) - { - CONTRACT_VIOLATION( ThrowsViolation ); - CallbackHelper(NULL, NULL); - - DeleteDelayedCallbacks(); - } -} - -DelayCallbackTable * ThreadLocalIBCInfo::GetPtrDelayList() -{ - CONTRACTL - { - THROWS; - GC_NOTRIGGER; - MODE_ANY; - } - CONTRACTL_END; - - if (m_pDelayList == NULL) - { - m_pDelayList = new DelayCallbackTable; - } - - return m_pDelayList; -} - -int ThreadLocalIBCInfo::ProcessDelayedCallbacks() -{ - CONTRACTL - { - THROWS; - GC_NOTRIGGER; - MODE_ANY; - } - CONTRACTL_END; - - int removedCount = 0; // Our return result - - _ASSERTE(m_pDelayList != NULL); - _ASSERTE(m_fProcessingDelayedList == false); - - m_fProcessingDelayedList = true; - - // Processing Delayed Callback list - DEBUG_PRINTF2("Processing Delayed Callback list: GetCount()=%d\n", m_pDelayList->GetCount()); - - // try callbacks in the list - for (DelayCallbackTable::Iterator elem = m_pDelayList->Begin(), - end = m_pDelayList->End(); - (elem != end); elem++) - { - IbcCallback * pCallback = const_cast(*elem); - - _ASSERTE(pCallback->IsValid()); - - // For each callback that we process we use the - // field m_fCallbackFailed to record wheather we - // failed or succeeded in resolving the callback - // - m_fCallbackFailed = false; - - pCallback->Invoke(); - - if (m_fCallbackFailed == false) - { - // Successfully proccessed a delayed callback - DEBUG_PRINTF5("Successfully processed a delayed callback: pfn=0x%08x, value1=0x%8p, value2=0x%8p, retries=%d\n", - pCallback->GetPfn(), pCallback->GetValue1(), pCallback->GetValue2(), pCallback->GetTryCount()); - - m_pDelayList->Remove(pCallback); - pCallback->Invalidate(); - delete pCallback; - removedCount++; - } - else if (pCallback->IncrementTryCount() > c_maxRetries) - { - // Failed a delayed callback by hitting c_maxRetries - DEBUG_PRINTF4("Failed a delayed callback by hitting c_maxRetries: pfn=0x%08x, value1=0x%8p, value2=0x%8p\n", - pCallback->GetPfn(), pCallback->GetValue1(), pCallback->GetValue2()); - - m_pDelayList->Remove(pCallback); - pCallback->Invalidate(); - delete pCallback; - removedCount++; - } - } - - // Done Processing Delayed Callback list - DEBUG_PRINTF3("Done Processing Delayed Callback list: removed %d items, %d remain\n", - removedCount, m_pDelayList->GetCount()); - - _ASSERTE(m_fProcessingDelayedList == true); - m_fProcessingDelayedList = false; - - return removedCount; -} - -void ThreadLocalIBCInfo::CallbackHelper(const void * p, pfnIBCAccessCallback callback) -{ - CONTRACTL - { - THROWS; - GC_NOTRIGGER; - MODE_ANY; - CAN_TAKE_LOCK; - } - CONTRACTL_END; - - // Acquire the Crst lock before creating the IBCLoggingDisabler object. - // Only one thread at a time can be processing an IBC logging event. - CrstHolder lock(IBCLogger::GetSync()); - { - // @ToDo: methods called from here should assert that they have the lock that we just took - - IBCLoggingDisabler disableLogging( this ); // runs IBCLoggingDisabler::DisableLogging - - // Just in case the processing of delayed list was terminated with exception - m_fProcessingDelayedList = false; - - if (callback != NULL) - { - _ASSERTE(p != NULL); - - // For each callback that we process we use the - // field m_fCallbackFailed to record whether we - // failed or succeeded in resolving the callback - // - m_fCallbackFailed = false; - - callback(&g_IBCLogger, p, NULL); - - if (m_fCallbackFailed == false) - { - // If we were able to successfully process this ibc probe then - // the chances are good that the delayed probes will succeed too. - // Thus it may be worth proccessing the delayed call back list. - // We will process this list if it currently has at least - // MinCountToProcess items in the delay list. - // - int delayListAfter = (m_pDelayList == NULL) ? 0 : m_pDelayList->GetCount(); - if (delayListAfter >= GetMinCountToProcess()) - { - int numRemoved = ProcessDelayedCallbacks(); - if (numRemoved > 0) - { - // Reset the min count back down to the number that we still have remaining - m_iMinCountToProcess = m_pDelayList->GetCount(); - } - - // we increase the minCount by the min count increment so - // that we have to add a few new items to the delay list - // before we retry ProcessDelayedCallbacks() again. - IncMinCountToProcess(c_minCountIncr); - } - } - } - else // (callback == NULL) -- This is a special case - { - _ASSERTE(p == NULL); - - // We just need to call ProcessDelayedCallbacks() unconditionally - if (m_pDelayList->GetCount() > 0) - { - ProcessDelayedCallbacks(); - } - } - - // runs IBCLoggingDisabler::~IBCLoggingDisabler - // which runs IBCLoggingDisabler::EnableLogging - } -} - - -void IBCLogger::LogMethodAccessHelper(const MethodDesc* pMD, ULONG flagNum) -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - MODE_ANY; - PRECONDITION(g_IBCLogger.InstrEnabled()); - } - CONTRACTL_END; - - { - // Don't set the ReadMethodCode flag for EE implemented methods such as Invoke - if ((flagNum == ReadMethodCode) && pMD->IsEEImpl()) - return; - - // we cannot log before the ObjectClass or StringClass are loaded - if (g_pObjectClass == NULL || g_pStringClass == NULL) - goto DelayCallback; - - PTR_MethodTable pMT = pMD->GetMethodTable(); - if (pMT == NULL) - goto DelayCallback; - - if (!pMT->IsRestored_NoLogging()) - goto DelayCallback; - - Module *pModule = pMT->GetModule(); - - if (MethodDescAccessInstrEnabled()) - { - mdToken token; - if ( pMD->HasClassOrMethodInstantiation_NoLogging() ) - { - // We will need to defer the Logging if we cannot compute the PreferredZapModule - - // - // If we are creating a generic type or method we can have null TypeHandle args - // TFS: 749998 - // We can also have unrestored MethodTables in our Instantiation args during FixupNativeEntry - // - Instantiation classInst = pMD->GetClassInstantiation(); - Instantiation methodInst = pMD->GetMethodInstantiation(); - for (DWORD i = 0; i < classInst.GetNumArgs(); i++) - { - TypeHandle thArg = classInst[i]; - if (thArg.IsNull() || thArg.IsEncodedFixup() || !thArg.IsRestored_NoLogging()) - goto DelayCallback; - } - for (DWORD i = 0; i < methodInst.GetNumArgs(); i++) - { - TypeHandle thArg = methodInst[i]; - if (thArg.IsNull() || thArg.IsEncodedFixup() || !thArg.IsRestored_NoLogging()) - goto DelayCallback; - } - } - else - { - token = pMD->GetMemberDef_NoLogging(); - pModule->LogTokenAccess(token, MethodProfilingData, flagNum); - } - } - return; - } - -DelayCallback: - DelayedCallbackPtr(LogMethodAccessWrapper, pMD, (void *)(SIZE_T)flagNum); -} - -void IBCLogger::LogMethodAccessWrapper(IBCLogger* pLogger, const void * pValue1, const void * pValue2) -{ - WRAPPER_NO_CONTRACT; - pLogger->LogMethodAccessHelper((MethodDesc *)pValue1, (ULONG)(SIZE_T)pValue2); -} -// Log access to method code or method header -void IBCLogger::LogMethodCodeAccessHelper(MethodDesc *pMD) -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - MODE_ANY; - PRECONDITION(g_IBCLogger.InstrEnabled()); - } - CONTRACTL_END; - - LogMethodAccessHelper(pMD, ReadMethodCode); -} - -// Log access to method gc info -void IBCLogger::LogMethodGCInfoAccessHelper(MethodDesc* pMD) -{ - WRAPPER_NO_CONTRACT; - - _ASSERTE(InstrEnabled()); - - LogMethodAccessHelper(pMD, ReadGCInfo); - LogMethodAccessHelper(pMD, CommonReadGCInfo); -} - -#define LOADORDER_INSTR 0x00000001 -#define RID_ACCESSORDER_INSTR 0x00000002 -#define METHODDESC_ACCESS_INSTR 0x00000004 -#define ALL_INSTR (LOADORDER_INSTR | RID_ACCESSORDER_INSTR | METHODDESC_ACCESS_INSTR) - -void IBCLogger::EnableAllInstr() -{ - LIMITED_METHOD_CONTRACT; -#if METADATATRACKER_ENABLED - MetaDataTracker::Enable(); - MetaDataTracker::s_IBCLogMetaDataAccess = IBCLogger::LogMetaDataAccessStatic; - MetaDataTracker::s_IBCLogMetaDataSearch = IBCLogger::LogMetaDataSearchAccessStatic; -#endif //METADATATRACKER_ENABLED - dwInstrEnabled = ALL_INSTR; -} - -void IBCLogger::DisableAllInstr() -{ - LIMITED_METHOD_CONTRACT; - dwInstrEnabled = 0; -} - -void IBCLogger::DisableRidAccessOrderInstr() -{ - LIMITED_METHOD_CONTRACT; - dwInstrEnabled &= (~RID_ACCESSORDER_INSTR); -} - -void IBCLogger::DisableMethodDescAccessInstr() -{ - LIMITED_METHOD_CONTRACT; - dwInstrEnabled &= (~METHODDESC_ACCESS_INSTR); -} - -BOOL IBCLogger::MethodDescAccessInstrEnabled() -{ - LIMITED_METHOD_CONTRACT; - return (dwInstrEnabled & METHODDESC_ACCESS_INSTR); -} - -BOOL IBCLogger::RidAccessInstrEnabled() -{ - LIMITED_METHOD_CONTRACT; - return (dwInstrEnabled & RID_ACCESSORDER_INSTR); -} - -#endif // IBCLOGGER_ENABLED diff --git a/src/coreclr/vm/ibclogger.h b/src/coreclr/vm/ibclogger.h deleted file mode 100644 index 16de8380da2d8..0000000000000 --- a/src/coreclr/vm/ibclogger.h +++ /dev/null @@ -1,645 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// IBClogger.H -// - -// -// Infrastructure for recording touches of EE data structures -// -// - - -#ifndef IBCLOGGER_H -#define IBCLOGGER_H - -#include -#include -#include -#include -#include - -// The IBCLogger class records touches of EE data structures. It is important to -// minimize the overhead of IBC recording on non-recording scenarios. Our goal is -// for all public methods to be inlined, and that the cost of doing the instrumentation -// check does not exceed one comparison and one branch. -// - -class MethodDesc; -class MethodTable; -class EEClass; -class TypeHandle; -struct DispatchSlot; -class Module; -struct EEClassHashEntry; -class IBCLogger; - -extern IBCLogger g_IBCLogger; - -typedef PTR_VOID HashDatum; - -typedef Pair< Module*, mdToken > RidMapLogData; - -#if !defined(DACCESS_COMPILE) -#define IBCLOGGER_ENABLED -#endif - -#ifdef IBCLOGGER_ENABLED -// -// Base class for IBC probe callback -// -typedef void (* const pfnIBCAccessCallback)(IBCLogger* pLogger, const void * pValue, const void * pValue2); - -class IbcCallback -{ -public: - IbcCallback(pfnIBCAccessCallback pCallback, const void * pValue1, const void * pValue2) - : m_pCallback(pCallback), - m_pValue1(pValue1), - m_pValue2(pValue2), - m_tryCount(0) -#ifdef _DEBUG - , m_id(0) -#endif - { LIMITED_METHOD_CONTRACT; } - - void Invoke() const - { - WRAPPER_NO_CONTRACT; - - m_pCallback(&g_IBCLogger, m_pValue1, m_pValue2); - } - - SIZE_T GetPfn() const - { - LIMITED_METHOD_CONTRACT; - - return (SIZE_T) m_pCallback; - } - - pfnIBCAccessCallback GetCallback() const - { - LIMITED_METHOD_CONTRACT; - - return m_pCallback; - } - - const void * GetValue1() const - { - LIMITED_METHOD_CONTRACT; - - return m_pValue1; - } - - const void * GetValue2() const - { - LIMITED_METHOD_CONTRACT; - - return m_pValue2; - } - - void SetValid() - { - LIMITED_METHOD_CONTRACT; -#ifdef _DEBUG - m_id = ++s_highestId; -#endif - } - - void Invalidate() - { - LIMITED_METHOD_CONTRACT; -#ifdef _DEBUG - m_id = 0; -#endif - } - - bool IsValid() const - { - WRAPPER_NO_CONTRACT; - -#ifdef _DEBUG - return (m_id > 0) && (m_id <= s_highestId); -#else - return true; -#endif - } - - int IncrementTryCount() - { - return ++m_tryCount; - } - - int GetTryCount() const - { - return m_tryCount; - } - -private: - pfnIBCAccessCallback m_pCallback; - const void * m_pValue1; - const void * m_pValue2; - - int m_tryCount; - -#ifdef _DEBUG - unsigned m_id; - static unsigned s_highestId; -#endif -}; - -class DelayCallbackTableTraits : public DefaultSHashTraits< IbcCallback * > -{ -public: - typedef IbcCallback * key_t; - - static key_t GetKey(element_t e) - { - LIMITED_METHOD_CONTRACT; - return e; - } - - static BOOL Equals(key_t k1, key_t k2) - { - LIMITED_METHOD_CONTRACT; - - return (k1->GetCallback() == k2->GetCallback()) && - (k1->GetValue1() == k2->GetValue1()) && - (k1->GetValue2() == k2->GetValue2()); - } - - static count_t Hash(key_t k) - { - LIMITED_METHOD_CONTRACT; - - SIZE_T hashLarge = (SIZE_T)k->GetCallback() ^ - (SIZE_T)k->GetValue1() ^ - (SIZE_T)k->GetValue2(); - -#if POINTER_BITS == 32 - // sizeof(SIZE_T) == sizeof(COUNT_T) - return hashLarge; -#else - // xor in the upper half as well. - count_t hash = *(count_t *)(&hashLarge); - for (unsigned int i = 1; i < POINTER_BITS / 32; i++) - { - hash ^= ((count_t *)&hashLarge)[i]; - } - - return hash; -#endif // POINTER_BITS - } - - static element_t Null() -{ - WRAPPER_NO_CONTRACT; - return NULL; - } - - static bool IsNull(element_t e) - { - LIMITED_METHOD_CONTRACT; - return e == NULL; - } - - static element_t Deleted() - { - WRAPPER_NO_CONTRACT; - return (element_t)-1; - } - - static bool IsDeleted(const element_t e) - { - LIMITED_METHOD_CONTRACT; - return e == (element_t)-1; - } -}; - -typedef SHash< DelayCallbackTableTraits > DelayCallbackTable; - -class ThreadLocalIBCInfo -{ -public: - ThreadLocalIBCInfo(); - ~ThreadLocalIBCInfo(); - - // BOOL IsLoggingDisable() - // This indicates that logging is currently disabled for this thread - // This is used to prevent the logging functionality from - // triggerring more logging (and thus causing a deadlock) - // It is also used to prevent IBC logging whenever a IBCLoggingDisabler - // object is used. For example we use this to disable IBC profiling - // whenever a thread starts a JIT compile event. That is because we - // don't want to "pollute" the IBC data gathering for the things - // that the JIT compiler touches. - // Finally since our IBC logging will need to allocate unmanaged memory - // we also disable IBC logging when we are inside a "can't alloc region" - // Typically this occurs when a thread is performing a GC. - BOOL IsLoggingDisabled() - { - LIMITED_METHOD_CONTRACT; - return m_fLoggingDisabled || IsInCantAllocRegion(); - } - - // We want to disable IBC logging, any further log calls are to be ignored until - // we call EnableLogging() - // - // This method returns true if it changed the value of m_fLoggingDisabled from false to true - // it returns false if the value of m_fLoggingDisabled was already set to true - // after this method executes the value of m_fLoggingDisabled will be true - bool DisableLogging() - { - LIMITED_METHOD_CONTRACT; - - bool result = (m_fLoggingDisabled == false); - m_fLoggingDisabled = true; - - return result; - } - - // We want to re-enable IBC logging - void EnableLogging() - { - LIMITED_METHOD_CONTRACT; - - _ASSERTE(m_fLoggingDisabled == true); - - m_fLoggingDisabled = false; - } - - bool ProcessingDelayedList() - { - LIMITED_METHOD_CONTRACT; - return m_fProcessingDelayedList; - } - - void SetCallbackFailed() - { - LIMITED_METHOD_CONTRACT; - m_fCallbackFailed = true; - } - - int GetMinCountToProcess() - { - LIMITED_METHOD_CONTRACT; - return m_iMinCountToProcess; - } - - void IncMinCountToProcess(int increment) - { - LIMITED_METHOD_CONTRACT; - m_iMinCountToProcess += increment; - } - - DelayCallbackTable * GetPtrDelayList(); - - void DeleteDelayedCallbacks(); - - void FlushDelayedCallbacks(); - - int ProcessDelayedCallbacks(); - - void CallbackHelper(const void * p, pfnIBCAccessCallback callback); - -private: - bool m_fProcessingDelayedList; - bool m_fCallbackFailed; - bool m_fLoggingDisabled; - - int m_iMinCountToProcess; - - DelayCallbackTable * m_pDelayList; -}; - -class IBCLoggingDisabler -{ -public: - IBCLoggingDisabler(); - IBCLoggingDisabler(bool ignore); // When ignore is true we treat this as a nop - IBCLoggingDisabler(ThreadLocalIBCInfo* pInfo); - ~IBCLoggingDisabler(); - -private: - ThreadLocalIBCInfo* m_pInfo; - bool m_fDisabled; // true if this holder actually disable the logging - // false when this is a nested occurrence and logging was already disabled -}; - -// -// IBCLoggerAwareAllocMemTracker should be used for allocation of IBC tracked structures during type loading. -// -// If type loading fails, the delayed IBC callbacks may contain pointers to the failed type or method. -// IBCLoggerAwareAllocMemTracker will ensure that the delayed IBC callbacks are flushed before the memory of -// the failed type or method is reclaimed. Otherwise, there would be stale pointers in the delayed IBC callbacks -// that would cause crashed during IBC logging. -// -class IBCLoggerAwareAllocMemTracker : public AllocMemTracker -{ -public: - IBCLoggerAwareAllocMemTracker() - { - WRAPPER_NO_CONTRACT; - } - - ~IBCLoggerAwareAllocMemTracker(); -}; - -#else // IBCLOGGER_ENABLED - -typedef const void * pfnIBCAccessCallback; - -class ThreadLocalIBCInfo; -class IBCLoggingDisabler -{ -public: - IBCLoggingDisabler() - { - } - - IBCLoggingDisabler(ThreadLocalIBCInfo*) - { - } - - ~IBCLoggingDisabler() - { - } -}; - -class ThreadLocalIBCInfo -{ -public: - ThreadLocalIBCInfo() - { - } - - ~ThreadLocalIBCInfo() - { - } - - void FlushDelayedCallbacks() - { - } -}; - -class IBCLoggerAwareAllocMemTracker : public AllocMemTracker -{ -public: - IBCLoggerAwareAllocMemTracker() - { - } - - ~IBCLoggerAwareAllocMemTracker() - { - } -}; - -#endif // IBCLOGGER_ENABLED - - -// IBCLogger is responsible for collecting profile data. Logging is turned on by the -// COMPlus_ZapBBInstr environment variable, and the actual writing to the file -// occurs in code:Module.WriteMethodProfileDataLogFile -class IBCLogger -{ - // - // Methods for logging EE data structure accesses. All methods should be defined - // using the LOGACCESS macros, which creates the wrapper method that calls the - // helper when instrumentation is enabled. The public name of these methods should - // be of the form Log##name##Access where name describes the type of access to be - // logged. The private helpers are implemented in IBClogger.cpp. - // - -#ifdef IBCLOGGER_ENABLED - -#define LOGACCESS_PTR(name, type) \ - LOGACCESS(name, type*, (type*), (const void *)); - -#define LOGACCESS_VALUE(name, type) \ - LOGACCESS(name, type, *(type*), (const void *)&); - -#define LOGACCESS(name, type, totype, toptr) \ -public: \ - __forceinline void Log##name##Access(type p) \ - { \ - WRAPPER_NO_CONTRACT; \ - /* We expect this to get inlined, so that it */ \ - /* has low overhead when not instrumenting. */ \ - /* So keep the function really small */ \ - if ( InstrEnabled() ) \ - Log##name##AccessStatic(toptr p); \ - } \ - \ -private: \ - NOINLINE static void Log##name##AccessStatic(const void * p) \ - { \ - WRAPPER_NO_CONTRACT; \ - /* To make the logging callsite as small as */ \ - /* possible keep the part that passes extra */ \ - /* argument to LogAccessThreadSafeHelper */ \ - /* in separate non-inlined static functions */ \ - LogAccessThreadSafeHelperStatic(p, Log##name##AccessWrapper); \ - } \ - \ - static void Log##name##AccessWrapper(IBCLogger* pLogger, const void * pValue1, const void * pValue2) \ - { \ - WRAPPER_NO_CONTRACT; \ - return pLogger->Log##name##AccessHelper(totype pValue1); \ - } \ - void Log##name##AccessHelper(type p); \ - -private: - static void LogAccessThreadSafeHelperStatic( const void * p, pfnIBCAccessCallback callback); - void LogAccessThreadSafeHelper( const void * p, pfnIBCAccessCallback callback); - - void DelayedCallbackPtr(pfnIBCAccessCallback callback, const void * pValue1, const void * pValue2 = NULL); - -#else // IBCLOGGER_ENABLED - -#define LOGACCESS_PTR(name,type) \ -public: \ - void Log##name##Access(type* p) { SUPPORTS_DAC; } \ - -#define LOGACCESS_VALUE(name, type) \ -public: \ - void Log##name##Access(type p) { SUPPORTS_DAC; } \ - -#endif // IBCLOGGER_ENABLED - - // Log access to method code or method header - // Implemented by : code:IBCLogger.LogMethodCodeAccessHelper - LOGACCESS_PTR(MethodCode, MethodDesc) - - // Log access to gc info - // Implemented by : code:IBCLogger.LogMethodGCInfoAccessHelper - LOGACCESS_PTR(MethodGCInfo, MethodDesc) - -#undef LOGACCESS_PTR -#undef LOGACCESS_VALUE - -#define LOGACCESS_PTR(name,type) \ -public: \ - void Log##name##Access(type* p) { SUPPORTS_DAC; } \ - -#define LOGACCESS_VALUE(name, type) \ -public: \ - void Log##name##Access(type p) { SUPPORTS_DAC; } \ - - // Log access to method desc (which adds the method desc to the required list) - // Implemented by : code:IBCLogger.LogMethodDescAccessHelper - LOGACCESS_PTR(MethodDesc, const MethodDesc) - - // Log access to the NDirect data stored for a MethodDesc - // also implies that the IL_STUB for the NDirect method is executed - // Implemented by : code:IBCLogger.LogNDirectCodeAccessHelper - LOGACCESS_PTR(NDirectCode,MethodDesc) - - // Log access to method desc (which addes the method desc to the required list) - // Implemented by : code:IBCLogger.LogMethodDescWriteAccessHelper - LOGACCESS_PTR(MethodDescWrite,MethodDesc) - - // Log access to method desc (which adds the method desc to the required list) - // Implemented by : code:IBCLogger.LogMethodPrecodeAccessHelper - LOGACCESS_PTR(MethodPrecode, MethodDesc) - - // Log access to method desc (which addes the method desc to the required list) - // Implemented by : code:IBCLogger.LogMethodPrecodeWriteAccessHelper - LOGACCESS_PTR(MethodPrecodeWrite,MethodDesc) - - // Log access to method table - // Implemented by : code:IBCLogger.LogMethodTableAccessHelper - LOGACCESS_PTR(MethodTable, MethodTable const) - - // Log access to method table - // Implemented by : code:IBCLogger.LogTypeMethodTableAccessHelper - LOGACCESS_PTR(TypeMethodTable, TypeHandle const) - - // Log write access to method table - // Implemented by : code:IBCLogger.LogTypeMethodTableWriteableAccessHelper - LOGACCESS_PTR(TypeMethodTableWriteable, TypeHandle const) - - // Log read access to private (written to) method table area - // Macro expands to : code:LogMethodTableWriteableDataAccessHelper - LOGACCESS_PTR(MethodTableWriteableData, MethodTable const) - - // Log write access to private (written to) method table area - // Implemented by : code:IBCLogger.LogMethodTableWriteableDataWriteAccessHelper - LOGACCESS_PTR(MethodTableWriteableDataWrite,MethodTable) - - // Log access to method table's NonVirtualSlotsArray - // Implemented by : code:IBCLogger.LogMethodTableNonVirtualSlotsAccessHelper - LOGACCESS_PTR(MethodTableNonVirtualSlots, MethodTable const) - - // Log access to EEClass - // Implemented by : code:IBCLogger.LogEEClassAndMethodTableAccessHelper - LOGACCESS_PTR(EEClassAndMethodTable, MethodTable) - - // Log access to EEClass COW table - // Implemented by : code:IBCLogger.LogEEClassCOWTableAccessHelper - LOGACCESS_PTR(EEClassCOWTable, MethodTable) - - // Log access to the FieldDescs list in the EEClass - // Implemented by : code:IBCLogger.LogFieldDescsAccessHelper - LOGACCESS_PTR(FieldDescs, FieldDesc) - - // Log access to the MTs dispatch map - // Implemented by : code:IBCLogger.LogDispatchMapAccessHelper - LOGACCESS_PTR(DispatchMap,MethodTable) - - // Log read access to the MTs dispatch implementation table - // Implemented by : code:IBCLogger.LogDispatchTableAccessHelper - LOGACCESS_PTR(DispatchTable,MethodTable) - - // Log read access to the MTs dispatch implementation table - // Implemented by : code:IBCLogger.LogDispatchTableAccessHelper - LOGACCESS_PTR(DispatchTableSlot,DispatchSlot) - - // Log a lookup in the cctor info table - // Implemented by : code:IBCLogger.LogCCtorInfoReadAccessHelper - LOGACCESS_PTR(CCtorInfoRead,MethodTable) - - // Log a lookup in the class hash table - // Implemented by : code:IBCLogger.LogClassHashTableAccessHelper - LOGACCESS_PTR(ClassHashTable,EEClassHashEntry) - - // Log a lookup of the method list for a CER - // Implemented by : code:IBCLogger.LogCerMethodListReadAccessHelper - LOGACCESS_PTR(CerMethodListRead,MethodDesc) - - // Log a metadata access - // Implemented by : code:IBCLogger.LogMetaDataAccessHelper - LOGACCESS_PTR(MetaData,const void) - - // Log a metadata search - // Implemented by : code:IBCLogger.LogMetaDataSearchAccessHelper - LOGACCESS_PTR(MetaDataSearch,const void) - - // Log a RVA fielddesc access */ - // Implemented by : code:IBCLogger.LogRVADataAccessHelper - LOGACCESS_PTR(RVAData,FieldDesc) - - // Log a lookup in the type hash table - // Implemented by : code:IBCLogger.LogTypeHashTableAccessHelper - LOGACCESS_PTR(TypeHashTable,TypeHandle const) - - // Log a lookup in the Rid map - // Implemented by : code:IBCLogger.LogRidMapAccessHelper - LOGACCESS_VALUE( RidMap, RidMapLogData ); - -public: - -#ifdef IBCLOGGER_ENABLED - IBCLogger(); - ~IBCLogger(); - - // Methods for enabling/disabling instrumentation. - void EnableAllInstr(); - void DisableAllInstr(); - - void DisableRidAccessOrderInstr(); - void DisableMethodDescAccessInstr(); - - inline BOOL InstrEnabled() - { - SUPPORTS_DAC; - return (dwInstrEnabled != 0); - } - - static CrstStatic * GetSync(); - -private: - void LogMethodAccessHelper(const MethodDesc* pMD, ULONG flagNum); - static void LogMethodAccessWrapper(IBCLogger* pLogger, const void * pValue1, const void * pValue2); - - void LogTypeAccessHelper(TypeHandle th, ULONG flagNum); - static void LogTypeAccessWrapper(IBCLogger* pLogger, const void * pValue1, const void * pValue2); - - BOOL MethodDescAccessInstrEnabled(); - BOOL RidAccessInstrEnabled(); - -private: - DWORD dwInstrEnabled; - - static CrstStatic m_sync; -#else // IBCLOGGER_ENABLED - void EnableAllInstr() - { - } - - void DisableAllInstr() - { - } - - inline BOOL InstrEnabled() - { - return false; - } - - static CrstStatic * GetSync() - { - _ASSERTE(false); - return NULL; - } -#endif // IBCLOGGER_ENABLED -}; - -#endif // IBCLOGGER_H diff --git a/src/coreclr/vm/instmethhash.cpp b/src/coreclr/vm/instmethhash.cpp index 2f0392e558900..2cb27b86fa9df 100644 --- a/src/coreclr/vm/instmethhash.cpp +++ b/src/coreclr/vm/instmethhash.cpp @@ -140,13 +140,6 @@ MethodDesc* InstMethodHashTable::FindMethodDesc(TypeHandle declaringType, } CONTRACTL_END - // We temporarily disable IBC logging here - // because the pMD that we search through may not be restored - // and ComputePreferredZapModule will assert on finding an - // encode fixup pointer - // - IBCLoggingDisabler disableIbcLogging; - MethodDesc *pMDResult = NULL; DWORD dwHash = Hash(declaringType, token, inst); diff --git a/src/coreclr/vm/jithelpers.cpp b/src/coreclr/vm/jithelpers.cpp index c734453b30a2d..04014ce17a291 100644 --- a/src/coreclr/vm/jithelpers.cpp +++ b/src/coreclr/vm/jithelpers.cpp @@ -783,7 +783,7 @@ HCIMPL2(void*, JIT_GetFieldAddr, Object *obj, FieldDesc* pFD) PRECONDITION(CheckPointer(pFD)); } CONTRACTL_END; - if (obj == NULL || g_IBCLogger.InstrEnabled() || pFD->IsEnCNew()) + if (obj == NULL || pFD->IsEnCNew()) { ENDFORBIDGC(); return HCCALL2(JIT_GetFieldAddr_Framed, obj, pFD); @@ -827,7 +827,7 @@ HCIMPL2(INT8, JIT_GetField8, Object *obj, FieldDesc *pFD) { FCALL_CONTRACT; - if (obj == NULL || g_IBCLogger.InstrEnabled() || pFD->IsEnCNew()) + if (obj == NULL || pFD->IsEnCNew()) { ENDFORBIDGC(); return HCCALL2(JIT_GetField_Framed, obj, pFD); @@ -843,7 +843,7 @@ HCIMPL2(INT16, JIT_GetField16, Object *obj, FieldDesc *pFD) { FCALL_CONTRACT; - if (obj == NULL || g_IBCLogger.InstrEnabled() || pFD->IsEnCNew()) + if (obj == NULL || pFD->IsEnCNew()) { ENDFORBIDGC(); return HCCALL2(JIT_GetField_Framed, obj, pFD); @@ -859,7 +859,7 @@ HCIMPL2(INT32, JIT_GetField32, Object *obj, FieldDesc *pFD) { FCALL_CONTRACT; - if (obj == NULL || g_IBCLogger.InstrEnabled() || pFD->IsEnCNew()) + if (obj == NULL || pFD->IsEnCNew()) { ENDFORBIDGC(); return HCCALL2(JIT_GetField_Framed, obj, pFD); @@ -875,7 +875,7 @@ HCIMPL2(INT64, JIT_GetField64, Object *obj, FieldDesc *pFD) { FCALL_CONTRACT; - if (obj == NULL || g_IBCLogger.InstrEnabled() || pFD->IsEnCNew()) + if (obj == NULL || pFD->IsEnCNew()) { ENDFORBIDGC(); return HCCALL2(JIT_GetField_Framed, obj, pFD); @@ -891,7 +891,7 @@ HCIMPL2(FLOAT, JIT_GetFieldFloat, Object *obj, FieldDesc *pFD) { FCALL_CONTRACT; - if (obj == NULL || g_IBCLogger.InstrEnabled() || pFD->IsEnCNew()) + if (obj == NULL || pFD->IsEnCNew()) { ENDFORBIDGC(); return HCCALL2(JIT_GetField_Framed, obj, pFD); @@ -908,7 +908,7 @@ HCIMPL2(DOUBLE, JIT_GetFieldDouble, Object *obj, FieldDesc *pFD) { FCALL_CONTRACT; - if (obj == NULL || g_IBCLogger.InstrEnabled() || pFD->IsEnCNew()) + if (obj == NULL || pFD->IsEnCNew()) { ENDFORBIDGC(); return HCCALL2(JIT_GetField_Framed, obj, pFD); @@ -952,7 +952,7 @@ HCIMPL3(VOID, JIT_SetField8, Object *obj, FieldDesc *pFD, INT8 val) { FCALL_CONTRACT; - if (obj == NULL || g_IBCLogger.InstrEnabled() || pFD->IsEnCNew()) + if (obj == NULL || pFD->IsEnCNew()) { ENDFORBIDGC(); return HCCALL3(JIT_SetField_Framed, obj, pFD, val); @@ -967,7 +967,7 @@ HCIMPL3(VOID, JIT_SetField16, Object *obj, FieldDesc *pFD, INT16 val) { FCALL_CONTRACT; - if (obj == NULL || g_IBCLogger.InstrEnabled() || pFD->IsEnCNew()) + if (obj == NULL || pFD->IsEnCNew()) { ENDFORBIDGC(); return HCCALL3(JIT_SetField_Framed, obj, pFD, val); @@ -982,7 +982,7 @@ HCIMPL3(VOID, JIT_SetField32, Object *obj, FieldDesc *pFD, INT32 val) { FCALL_CONTRACT; - if (obj == NULL || g_IBCLogger.InstrEnabled() || pFD->IsEnCNew()) + if (obj == NULL || pFD->IsEnCNew()) { ENDFORBIDGC(); return HCCALL3(JIT_SetField_Framed, obj, pFD, val); @@ -997,7 +997,7 @@ HCIMPL3(VOID, JIT_SetField64, Object *obj, FieldDesc *pFD, INT64 val) { FCALL_CONTRACT; - if (obj == NULL || g_IBCLogger.InstrEnabled() || pFD->IsEnCNew()) + if (obj == NULL || pFD->IsEnCNew()) { ENDFORBIDGC(); return HCCALL3(JIT_SetField_Framed, obj, pFD, val); @@ -1012,7 +1012,7 @@ HCIMPL3(VOID, JIT_SetFieldFloat, Object *obj, FieldDesc *pFD, FLOAT val) { FCALL_CONTRACT; - if (obj == NULL || g_IBCLogger.InstrEnabled() || pFD->IsEnCNew()) + if (obj == NULL || pFD->IsEnCNew()) { ENDFORBIDGC(); return HCCALL3(JIT_SetField_Framed, obj, pFD, val); @@ -1027,7 +1027,7 @@ HCIMPL3(VOID, JIT_SetFieldDouble, Object *obj, FieldDesc *pFD, DOUBLE val) { FCALL_CONTRACT; - if (obj == NULL || g_IBCLogger.InstrEnabled() || pFD->IsEnCNew()) + if (obj == NULL || pFD->IsEnCNew()) { ENDFORBIDGC(); return HCCALL3(JIT_SetField_Framed, obj, pFD, val); @@ -1072,7 +1072,7 @@ HCIMPL2(Object*, JIT_GetFieldObj, Object *obj, FieldDesc *pFD) PRECONDITION(!pFD->IsPrimitive() && !pFD->IsByValue()); // Assert that we are called only for objects } CONTRACTL_END; - if (obj == NULL || g_IBCLogger.InstrEnabled() || pFD->IsEnCNew()) + if (obj == NULL || pFD->IsEnCNew()) { ENDFORBIDGC(); return HCCALL2(JIT_GetFieldObj_Framed, obj, pFD); @@ -1116,7 +1116,7 @@ HCIMPL3(VOID, JIT_SetFieldObj, Object *obj, FieldDesc *pFD, Object *value) PRECONDITION(!pFD->IsPrimitive() && !pFD->IsByValue()); // Assert that we are called only for objects } CONTRACTL_END; - if (obj == NULL || g_IBCLogger.InstrEnabled() || pFD->IsEnCNew()) + if (obj == NULL || pFD->IsEnCNew()) { ENDFORBIDGC(); return HCCALL3(JIT_SetFieldObj_Framed, obj, pFD, value); @@ -1174,7 +1174,7 @@ HCIMPL4(VOID, JIT_GetFieldStruct, LPVOID retBuff, Object *obj, FieldDesc *pFD, M _ASSERTE(pFieldMT->IsValueType()); - if (obj == NULL || g_IBCLogger.InstrEnabled() || pFD->IsEnCNew()) + if (obj == NULL || pFD->IsEnCNew()) { ENDFORBIDGC(); return HCCALL4(JIT_GetFieldStruct_Framed, retBuff, obj, pFD, pFieldMT); @@ -1228,7 +1228,7 @@ HCIMPL4(VOID, JIT_SetFieldStruct, Object *obj, FieldDesc *pFD, MethodTable *pFie _ASSERTE(pFieldMT->IsValueType()); - if (obj == NULL || g_IBCLogger.InstrEnabled() || pFD->IsEnCNew()) + if (obj == NULL || pFD->IsEnCNew()) { ENDFORBIDGC(); return HCCALL4(JIT_SetFieldStruct_Framed, obj, pFD, pFieldMT, valuePtr); @@ -3241,8 +3241,6 @@ HCIMPL2(CORINFO_GENERIC_HANDLE, JIT_GenericHandleMethodLogging, CORINFO_METHOD_H PRECONDITION(CheckPointer(signature)); } CONTRACTL_END; - g_IBCLogger.LogMethodDescAccess(GetMethod(methodHnd)); - JitGenericHandleCacheKey key(NULL, methodHnd, signature); HashDatum res; if (g_pJitGenericHandleCache->GetValueSpeculative(&key,&res)) @@ -3307,8 +3305,6 @@ HCIMPL2(CORINFO_GENERIC_HANDLE, JIT_GenericHandleClassLogging, CORINFO_CLASS_HAN PRECONDITION(CheckPointer(signature)); } CONTRACTL_END; - g_IBCLogger.LogMethodTableAccess((MethodTable *)classHnd); - JitGenericHandleCacheKey key(classHnd, NULL, signature); HashDatum res; if (g_pJitGenericHandleCache->GetValueSpeculative(&key,&res)) @@ -4538,12 +4534,6 @@ HCIMPL1(void, JIT_LogMethodEnter, CORINFO_METHOD_HANDLE methHnd_) // Record an access to this method desc // - HELPER_METHOD_FRAME_BEGIN_NOPOLL(); - - g_IBCLogger.LogMethodCodeAccess(GetMethod(methHnd_)); - - HELPER_METHOD_FRAME_END_POLL(); - HCIMPLEND diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index 8b706253186ab..241605128e5df 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -5594,7 +5594,7 @@ bool __stdcall TrackAllocationsEnabled() CONTRACTL_END; return ( - (g_IBCLogger.InstrEnabled() != FALSE) + FALSE #ifdef PROFILING_SUPPORTED || CORProfilerTrackAllocationsEnabled() #endif // PROFILING_SUPPORTED diff --git a/src/coreclr/vm/method.cpp b/src/coreclr/vm/method.cpp index 4e655a39f9f0c..8707b73eb71aa 100644 --- a/src/coreclr/vm/method.cpp +++ b/src/coreclr/vm/method.cpp @@ -262,8 +262,6 @@ LPCUTF8 MethodDesc::GetName() SUPPORTS_DAC; }CONTRACTL_END; - g_IBCLogger.LogMethodDescAccess(this); - if (IsArray()) { // Array classes don't have metadata tokens @@ -502,8 +500,6 @@ PCODE MethodDesc::GetMethodEntryPoint() // Keep implementations of MethodDesc::GetMethodEntryPoint and MethodDesc::GetAddrOfSlot in sync! - g_IBCLogger.LogMethodDescAccess(this); - if (HasNonVtableSlot()) { SIZE_T size = GetBaseSize(); @@ -638,8 +634,6 @@ DWORD MethodDesc::GetNumGenericMethodArgs() } CONTRACTL_END - g_IBCLogger.LogMethodDescAccess(this); - if (GetClassification() == mcInstantiated) { InstantiatedMethodDesc *pIMD = AsInstantiatedMethodDesc(); @@ -873,8 +867,6 @@ WORD MethodDesc::InterlockedUpdateFlags(WORD wMask, BOOL fSet) #pragma warning(pop) #endif - g_IBCLogger.LogMethodDescWriteAccess(this); - if (fSet) FastInterlockOr(pdwFlags, dwMask); else @@ -913,8 +905,6 @@ WORD MethodDesc::InterlockedUpdateFlags3(WORD wMask, BOOL fSet) #pragma warning(pop) #endif - g_IBCLogger.LogMethodDescWriteAccess(this); - if (fSet) FastInterlockOr(pdwFlags, dwMask); else @@ -939,8 +929,6 @@ PCODE MethodDesc::GetNativeCode() SUPPORTS_DAC; _ASSERTE(!IsDefaultInterfaceMethod() || HasNativeCodeSlot()); - g_IBCLogger.LogMethodDescAccess(this); - if (HasNativeCodeSlot()) { // When profiler is enabled, profiler may ask to rejit a code even though we @@ -1377,7 +1365,6 @@ Module *MethodDesc::GetModule() const STATIC_CONTRACT_FORBID_FAULT; SUPPORTS_DAC; - g_IBCLogger.LogMethodDescAccess(this); Module *pModule = GetModule_NoLogging(); return pModule; @@ -2004,9 +1991,6 @@ PCODE MethodDesc::TryGetMultiCallableAddrOfCode(CORINFO_ACCESS_FLAGS accessFlags } CONTRACTL_END - // Record this method desc if required - g_IBCLogger.LogMethodDescAccess(this); - if (IsGenericMethodDefinition()) { _ASSERTE(!"Cannot take the address of an uninstantiated generic method."); @@ -2398,8 +2382,6 @@ void MethodDesc::CheckRestore(ClassLoadLevel level) if (!GetMethodTable()->IsFullyLoaded()) { - g_IBCLogger.LogMethodDescAccess(this); - if (GetClassification() == mcInstantiated) { #ifndef DACCESS_COMPILE @@ -2409,8 +2391,6 @@ void MethodDesc::CheckRestore(ClassLoadLevel level) // it might be out-of-module ClassLoader::EnsureLoaded(TypeHandle(GetMethodTable()), level); - g_IBCLogger.LogMethodDescWriteAccess(this); - pIMD->m_wFlags2 = pIMD->m_wFlags2 & ~InstantiatedMethodDesc::Unrestored; if (ETW_PROVIDER_ENABLED(MICROSOFT_WINDOWS_DOTNETRUNTIME_PROVIDER)) @@ -4040,9 +4020,6 @@ void ComPlusCallMethodDesc::InitRetThunk() if (m_pComPlusCallInfo->m_pRetThunk != NULL) return; - // Record the fact that we are writting into the ComPlusCallMethodDesc - g_IBCLogger.LogMethodDescAccess(this); - UINT numStackBytes = CbStackPop(); LPVOID pRetThunk = ComPlusCall::GetRetThunk(numStackBytes); diff --git a/src/coreclr/vm/method.hpp b/src/coreclr/vm/method.hpp index 50981f7280694..0e62b4a67d66a 100644 --- a/src/coreclr/vm/method.hpp +++ b/src/coreclr/vm/method.hpp @@ -943,7 +943,6 @@ class MethodDesc { LIMITED_METHOD_CONTRACT; MethodTable *pMT = GetMethodTable(); - g_IBCLogger.LogMethodTableAccess(pMT); return !IsEnCAddedMethod() // The slot numbers are currently meaningless for @@ -999,7 +998,6 @@ class MethodDesc { WRAPPER_NO_CONTRACT; MethodTable *pMT = GetMethodTable_NoLogging(); - g_IBCLogger.LogEEClassAndMethodTableAccess(pMT); EEClass *pClass = pMT->GetClass_NoLogging(); PREFIX_ASSUME(pClass != NULL); return pClass; @@ -2414,7 +2412,6 @@ class StoredSigMethodDesc : public MethodDesc return (PCCOR_SIGNATURE) DacInstantiateTypeByAddress(GetSigRVA(), m_cSig, true); #else // !DACCESS_COMPILE - g_IBCLogger.LogNDirectCodeAccess(this); return (PCCOR_SIGNATURE) m_pSig; #endif // !DACCESS_COMPILE } @@ -3544,7 +3541,6 @@ inline PTR_MethodTable MethodDesc::GetMethodTable() const { LIMITED_METHOD_DAC_CONTRACT; - g_IBCLogger.LogMethodDescAccess(this); return GetMethodTable_NoLogging(); } @@ -3581,7 +3577,6 @@ inline mdMethodDef MethodDesc::GetMemberDef_NoLogging() const inline mdMethodDef MethodDesc::GetMemberDef() const { LIMITED_METHOD_DAC_CONTRACT; - g_IBCLogger.LogMethodDescAccess(this); return GetMemberDef_NoLogging(); } @@ -3683,7 +3678,6 @@ inline BOOL MethodDesc::IsGenericMethodDefinition() const { LIMITED_METHOD_DAC_CONTRACT; - g_IBCLogger.LogMethodDescAccess(this); return GetClassification() == mcInstantiated && AsInstantiatedMethodDesc()->IMD_IsGenericMethodDefinition(); } diff --git a/src/coreclr/vm/method.inl b/src/coreclr/vm/method.inl index fd32a95bee382..feca2073300be 100644 --- a/src/coreclr/vm/method.inl +++ b/src/coreclr/vm/method.inl @@ -102,8 +102,6 @@ inline bool MethodDesc::IsLCGMethod() inline bool MethodDesc::IsILStub() { WRAPPER_NO_CONTRACT; - - g_IBCLogger.LogMethodDescAccess(this); return ((mcDynamic == GetClassification()) && dac_cast(this)->IsILStub()); } diff --git a/src/coreclr/vm/methodtable.cpp b/src/coreclr/vm/methodtable.cpp index c1016ff9bed15..3cf84381442fc 100644 --- a/src/coreclr/vm/methodtable.cpp +++ b/src/coreclr/vm/methodtable.cpp @@ -369,8 +369,6 @@ PTR_Module MethodTable::GetModule() { LIMITED_METHOD_DAC_CONTRACT; - g_IBCLogger.LogMethodTableAccess(this); - // Fast path for non-generic non-array case if ((m_dwFlags & (enum_flag_HasComponentSize | enum_flag_GenericsMask)) == 0) return GetLoaderModule(); @@ -414,8 +412,6 @@ PTR_DispatchMap MethodTable::GetDispatchMap() return NULL; } - g_IBCLogger.LogDispatchMapAccess(pMT); - TADDR pSlot = pMT->GetMultipurposeSlotPtr(enum_flag_HasDispatchMapSlot, c_DispatchMapSlotOffsets); return *dac_cast(pSlot); } @@ -1233,8 +1229,6 @@ Module* MethodTable::GetModuleForStatics() WRAPPER_NO_CONTRACT; SUPPORTS_DAC; - g_IBCLogger.LogMethodTableAccess(this); - if (HasGenericsStaticsInfo()) { DWORD dwDynamicClassDomainID; @@ -1587,8 +1581,6 @@ BOOL MethodTable::CanCastToClass(MethodTable *pTargetMT, TypeHandlePairList *pVi if (pMT->IsEquivalentTo(pTargetMT)) return TRUE; - g_IBCLogger.LogMethodTableAccess(pMT); - if (pMT->CanCastByVarianceToInterfaceOrDelegate(pTargetMT, pVisited)) return TRUE; @@ -1603,8 +1595,6 @@ BOOL MethodTable::CanCastToClass(MethodTable *pTargetMT, TypeHandlePairList *pVi if (pMT->IsEquivalentTo(pTargetMT)) return TRUE; - g_IBCLogger.LogMethodTableAccess(pMT); - pMT = pMT->GetParentMethodTable(); } while (pMT); } @@ -3762,8 +3752,6 @@ void MethodTable::DoRunClassInitThrowing() STRESS_LOG2(LF_CLASSLOADER, LL_INFO100000, "DoRunClassInit: returning SUCCESS for init %pT in appdomain %p\n", this, pDomain); // No need to set pThrowable in case of error it will already have been set. - - g_IBCLogger.LogMethodTableAccess(this); Exit: ; } @@ -4167,8 +4155,6 @@ void MethodTable::CheckRestore() ClassLoader::EnsureLoaded(this); _ASSERTE(IsFullyLoaded()); } - - g_IBCLogger.LogMethodTableAccess(this); } #ifndef DACCESS_COMPILE @@ -4533,8 +4519,6 @@ void MethodTable::DoFullyLoad(Generics::RecursionGraph * const pVisited, const while (pField < pFieldEnd) { - g_IBCLogger.LogFieldDescsAccess(pField); - if (pField->GetFieldType() == ELEMENT_TYPE_VALUETYPE) { TypeHandle th = pField->GetFieldTypeHandleThrowing((ClassLoadLevel) (level - 1)); @@ -4762,7 +4746,6 @@ void MethodTable::SetOHDelegate (OBJECTHANDLE _ohDelegate) { LIMITED_METHOD_CONTRACT; _ASSERTE(GetClass()); - g_IBCLogger.LogEEClassCOWTableAccess(this); GetClass_NoLogging()->SetOHDelegate(_ohDelegate); } @@ -4869,9 +4852,6 @@ CorElementType MethodTable::GetInternalCorElementType() // This should not touch the EEClass, at least not in the // common cases of ELEMENT_TYPE_CLASS and ELEMENT_TYPE_VALUETYPE. - - g_IBCLogger.LogMethodTableAccess(this); - CorElementType ret; switch (GetFlag(enum_flag_Category_ElementTypeMask)) @@ -4924,9 +4904,6 @@ CorElementType MethodTable::GetVerifierCorElementType() // This should not touch the EEClass, at least not in the // common cases of ELEMENT_TYPE_CLASS and ELEMENT_TYPE_VALUETYPE. - - g_IBCLogger.LogMethodTableAccess(this); - CorElementType ret; switch (GetFlag(enum_flag_Category_ElementTypeMask)) @@ -4969,9 +4946,6 @@ CorElementType MethodTable::GetSignatureCorElementType() // This should not touch the EEClass, at least not in the // common cases of ELEMENT_TYPE_CLASS and ELEMENT_TYPE_VALUETYPE. - - g_IBCLogger.LogMethodTableAccess(this); - CorElementType ret; switch (GetFlag(enum_flag_Category_ElementTypeMask)) @@ -5243,7 +5217,6 @@ BOOL MethodTable::FindDispatchEntry(UINT32 typeID, UINT32 iCurInheritanceChainDelta = 0; while (pCurMT != NULL) { - g_IBCLogger.LogMethodTableAccess(pCurMT); if (pCurMT->FindDispatchEntryForCurrentType( typeID, slotNumber, pEntry)) { @@ -6229,7 +6202,6 @@ void MethodTable::GetGuid(GUID *pGuid, BOOL bGenerateIfNotFound, BOOL bClassic / // Remember that we didn't find the GUID, so we can skip looking during // future checks. (Note that this is a very important optimization in the // prejit case.) - g_IBCLogger.LogEEClassCOWTableAccess(this); GetClass_NoLogging()->SetHasNoGuid(); } } @@ -6446,7 +6418,6 @@ unsigned MethodTable::GetTypeDefRid() { LIMITED_METHOD_DAC_CONTRACT; - g_IBCLogger.LogMethodTableAccess(this); return GetTypeDefRid_NoLogging(); } @@ -6877,7 +6848,6 @@ void MethodTable::MethodDataObject::FillEntryDataForAncestor(MethodTable * pMT) for (; it.IsValid(); it.Next()) { MethodDesc * pMD = it.GetMethodDesc(); - g_IBCLogger.LogMethodDescAccess(pMD); unsigned slot = pMD->GetSlot(); if (slot == MethodTable::NO_SLOT) @@ -7853,8 +7823,6 @@ PCODE MethodTable::GetRestoredSlot(DWORD slotNumber) MethodTable * pMT = this; while (true) { - g_IBCLogger.LogMethodTableAccess(pMT); - pMT = pMT->GetCanonicalMethodTable(); _ASSERTE(pMT != NULL); @@ -7889,8 +7857,6 @@ MethodTable * MethodTable::GetRestoredSlotMT(DWORD slotNumber) MethodTable * pMT = this; while (true) { - g_IBCLogger.LogMethodTableAccess(pMT); - pMT = pMT->GetCanonicalMethodTable(); _ASSERTE(pMT != NULL); diff --git a/src/coreclr/vm/methodtable.h b/src/coreclr/vm/methodtable.h index 52eb8f9095569..48ef1cd689439 100644 --- a/src/coreclr/vm/methodtable.h +++ b/src/coreclr/vm/methodtable.h @@ -858,9 +858,7 @@ class MethodTable { LIMITED_METHOD_DAC_CONTRACT; - g_IBCLogger.LogMethodTableAccess(this); - - return !(GetWriteableData()->m_dwFlags & MethodTableWriteableData::enum_flag_Unrestored); + return IsRestored_NoLogging(); } //------------------------------------------------------------------- @@ -954,8 +952,6 @@ class MethodTable { LIMITED_METHOD_DAC_CONTRACT; - g_IBCLogger.LogMethodTableAccess(this); - DWORD dwFlags = GetWriteableData()->m_dwFlags; if (dwFlags & MethodTableWriteableData::enum_flag_IsNotFullyLoaded) @@ -1224,7 +1220,6 @@ class MethodTable { // Non-virtual slots < GetNumVtableSlots live in a single chunk pointed to by an optional member _ASSERTE(HasNonVirtualSlotsArray()); - g_IBCLogger.LogMethodTableNonVirtualSlotsAccess(this); return GetNonVirtualSlotsArray() + (slotNum - GetNumVirtuals()); } } @@ -1396,7 +1391,6 @@ class MethodTable { LIMITED_METHOD_DAC_CONTRACT; - g_IBCLogger.LogMethodTableAccess(this); return GetNumVirtuals_NoLogging(); } @@ -1420,7 +1414,6 @@ class MethodTable return 0; } MethodTable *pMTParent = GetParentMethodTable(); - g_IBCLogger.LogMethodTableAccess(this); return pMTParent == NULL ? 0 : pMTParent->GetNumVirtuals(); } @@ -1780,7 +1773,6 @@ class MethodTable { LIMITED_METHOD_DAC_CONTRACT; PRECONDITION(IsParentMethodTablePointerValid()); - g_IBCLogger.LogMethodTableAccess(this); return GetParentMethodTable() == pMT; } @@ -2728,7 +2720,6 @@ class MethodTable inline PTR_Const_MethodTableWriteableData GetWriteableData() const { LIMITED_METHOD_DAC_CONTRACT; - g_IBCLogger.LogMethodTableWriteableDataAccess(this); return GetWriteableData_NoLogging(); } @@ -2741,7 +2732,6 @@ class MethodTable inline PTR_MethodTableWriteableData GetWriteableDataForWrite() { LIMITED_METHOD_DAC_CONTRACT; - g_IBCLogger.LogMethodTableWriteableDataWriteAccess(this); return GetWriteableDataForWrite_NoLogging(); } diff --git a/src/coreclr/vm/methodtable.inl b/src/coreclr/vm/methodtable.inl index 049e4da57f3e1..adcdbd3346985 100644 --- a/src/coreclr/vm/methodtable.inl +++ b/src/coreclr/vm/methodtable.inl @@ -43,8 +43,6 @@ inline PTR_EEClass MethodTable::GetClass() LIMITED_METHOD_DAC_CONTRACT; _ASSERTE_IMPL(GetClass_NoLogging() != NULL); - - g_IBCLogger.LogEEClassAndMethodTableAccess(this); return GetClass_NoLogging(); } @@ -301,8 +299,6 @@ inline BOOL MethodTable::IsValueType() { LIMITED_METHOD_DAC_CONTRACT; - g_IBCLogger.LogMethodTableAccess(this); - return GetFlag(enum_flag_Category_ValueType_Mask) == enum_flag_Category_ValueType; } @@ -839,7 +835,6 @@ inline BOOL MethodTable::SetComCallWrapperTemplate(ComCallWrapperTemplate *pTemp } CONTRACTL_END; - g_IBCLogger.LogEEClassCOWTableAccess(this); return GetClass_NoLogging()->SetComCallWrapperTemplate(pTemplate); } @@ -862,7 +857,6 @@ inline BOOL MethodTable::SetComClassFactory(ClassFactoryBase *pFactory) } CONTRACTL_END; - g_IBCLogger.LogEEClassCOWTableAccess(this); return GetClass_NoLogging()->SetComClassFactory(pFactory); } #endif // FEATURE_COMINTEROP_UNMANAGED_ACTIVATION @@ -1000,8 +994,6 @@ inline BOOL MethodTable::IsSharedByGenericInstantiations() { LIMITED_METHOD_DAC_CONTRACT; - g_IBCLogger.LogMethodTableAccess(this); - return TestFlagWithMask(enum_flag_GenericsMask, enum_flag_GenericsMask_SharedInst); } diff --git a/src/coreclr/vm/methodtablebuilder.cpp b/src/coreclr/vm/methodtablebuilder.cpp index 21f7b0df5dfab..bb330ee8654cd 100644 --- a/src/coreclr/vm/methodtablebuilder.cpp +++ b/src/coreclr/vm/methodtablebuilder.cpp @@ -10468,10 +10468,6 @@ MethodTableBuilder::SetupMethodTable2( #ifdef _DEBUG { - // disable ibc logging because we can assert in ComputerPreferredZapModule for partially constructed - // generic types - IBCLoggingDisabler disableLogging; - DeclaredMethodIterator it(*this); while (it.Next()) { diff --git a/src/coreclr/vm/object.cpp b/src/coreclr/vm/object.cpp index 83ac8e718c337..9e7fff5456fe1 100644 --- a/src/coreclr/vm/object.cpp +++ b/src/coreclr/vm/object.cpp @@ -466,14 +466,6 @@ VOID Object::Validate(BOOL bDeep, BOOL bVerifyNextHeader, BOOL bVerifySyncBlock) STATIC_CONTRACT_MODE_COOPERATIVE; STATIC_CONTRACT_CANNOT_TAKE_LOCK; - if (g_IBCLogger.InstrEnabled() && !GCStress::IsEnabled()) - { - // If we are instrumenting for IBC (and GCStress is not enabled) - // then skip these Object::Validate() as they slow down the - // instrument phase by an order of magnitude - return; - } - if (g_fEEShutDown & ShutDown_Phase2) { // During second phase of shutdown the code below is not guaranteed to work. diff --git a/src/coreclr/vm/precode.cpp b/src/coreclr/vm/precode.cpp index 90a290ac56dcc..b9366dddcf212 100644 --- a/src/coreclr/vm/precode.cpp +++ b/src/coreclr/vm/precode.cpp @@ -147,11 +147,6 @@ MethodDesc* Precode::GetMethodDesc(BOOL fSpeculative /*= FALSE*/) // GetMethodDesc() on platform specific precode types returns TADDR. It should return // PTR_MethodDesc instead. It is a workaround to resolve cyclic dependency between headers. // Once we headers factoring of headers cleaned up, we should be able to get rid of it. - - // For speculative calls, pMD can be garbage that causes IBC logging to crash - if (!fSpeculative) - g_IBCLogger.LogMethodPrecodeAccess((PTR_MethodDesc)pMD); - return (PTR_MethodDesc)pMD; } @@ -339,8 +334,6 @@ BOOL Precode::SetTargetInterlocked(PCODE target, BOOL fOnlyRedirectFromPrestub) if (fOnlyRedirectFromPrestub && !IsPointingToPrestub(expected)) return FALSE; - g_IBCLogger.LogMethodPrecodeWriteAccess(GetMethodDesc()); - PrecodeType precodeType = GetType(); switch (precodeType) { @@ -468,7 +461,7 @@ TADDR Precode::AllocateTemporaryEntryPoints(MethodDescChunk * pChunk, TADDR temporaryEntryPoints; SIZE_T oneSize = SizeOfTemporaryEntryPoint(t); MethodDesc * pMD = pChunk->GetFirstMethodDesc(); - + if (t == PRECODE_FIXUP || t == PRECODE_STUB) { LoaderHeap *pStubHeap; diff --git a/src/coreclr/vm/precode.h b/src/coreclr/vm/precode.h index e456e6dbc1bc9..4822ccfec7054 100644 --- a/src/coreclr/vm/precode.h +++ b/src/coreclr/vm/precode.h @@ -300,9 +300,6 @@ struct FixupPrecode } CONTRACTL_END; - MethodDesc * pMD = (MethodDesc*)GetMethodDesc(); - g_IBCLogger.LogMethodPrecodeWriteAccess(pMD); - PCODE oldTarget = (PCODE)GetData()->Target; if (oldTarget != ((PCODE)this + FixupCodeOffset)) { @@ -554,12 +551,6 @@ class Precode { } PTR_Precode pPrecode = PTR_Precode(pInstr); - - if (!fSpeculative) - { - g_IBCLogger.LogMethodPrecodeAccess(pPrecode->GetMethodDesc()); - } - return pPrecode; } diff --git a/src/coreclr/vm/prestub.cpp b/src/coreclr/vm/prestub.cpp index 089c27342ab21..3bc301ec9386a 100644 --- a/src/coreclr/vm/prestub.cpp +++ b/src/coreclr/vm/prestub.cpp @@ -430,9 +430,6 @@ PCODE MethodDesc::PrepareILBasedCode(PrepareCodeConfig* pConfig) DACNotifyCompilationFinished(this, pCode); } - // Mark the code as hot in case the method ends up in the native image - g_IBCLogger.LogMethodCodeAccess(this); - return pCode; } @@ -2014,9 +2011,6 @@ PCODE MethodDesc::DoPrestub(MethodTable *pDispatchingMT, CallerGCMode callerGCMo MethodTable *pMT = GetMethodTable(); - // Running a prestub on a method causes us to access its MethodTable - g_IBCLogger.LogMethodDescAccess(this); - if (ContainsGenericVariables()) { COMPlusThrow(kInvalidOperationException, IDS_EE_CODEEXECUTION_CONTAINSGENERICVAR); diff --git a/src/coreclr/vm/readytoruninfo.cpp b/src/coreclr/vm/readytoruninfo.cpp index 7096b963c947c..4d1220a195e8f 100644 --- a/src/coreclr/vm/readytoruninfo.cpp +++ b/src/coreclr/vm/readytoruninfo.cpp @@ -730,19 +730,6 @@ ReadyToRunInfo::ReadyToRunInfo(Module * pModule, LoaderAllocator* pLoaderAllocat } } - // For format version 2.2 and later, there is an optional profile-data section - if (IsImageVersionAtLeast(2, 2)) - { - IMAGE_DATA_DIRECTORY * pProfileDataInfoDir = m_pComposite->FindSection(ReadyToRunSectionType::ProfileDataInfo); - if (pProfileDataInfoDir != NULL) - { - CORCOMPILE_METHOD_PROFILE_LIST * pMethodProfileList; - pMethodProfileList = (CORCOMPILE_METHOD_PROFILE_LIST *)m_pComposite->GetImage()->GetDirectoryData(pProfileDataInfoDir); - - pModule->SetMethodProfileList(pMethodProfileList); - } - } - // For format version 3.1 and later, there is an optional attributes section IMAGE_DATA_DIRECTORY *attributesPresenceDataInfoDir = m_component.FindSection(ReadyToRunSectionType::AttributePresence); if (attributesPresenceDataInfoDir != NULL) diff --git a/src/coreclr/vm/threads.cpp b/src/coreclr/vm/threads.cpp index 1d9c2b15b469e..a7acad063a1b3 100644 --- a/src/coreclr/vm/threads.cpp +++ b/src/coreclr/vm/threads.cpp @@ -1575,8 +1575,6 @@ Thread::Thread() m_pPendingTypeLoad = NULL; - m_pIBCInfo = NULL; - m_dwAVInRuntimeImplOkayCount = 0; #if defined(HAVE_GCCOVER) && defined(USE_REDIRECT_FOR_GCSTRESS) && !defined(TARGET_UNIX) // GCCOVER @@ -2725,10 +2723,6 @@ Thread::~Thread() g_pThinLockThreadIdDispenser->DisposeId(GetThreadId()); - if (m_pIBCInfo) { - delete m_pIBCInfo; - } - m_tailCallTls.FreeArgBuffer(); #ifdef FEATURE_EVENT_TRACE diff --git a/src/coreclr/vm/threads.h b/src/coreclr/vm/threads.h index e9eb6d139fcf8..d5db56a460dfe 100644 --- a/src/coreclr/vm/threads.h +++ b/src/coreclr/vm/threads.h @@ -135,7 +135,6 @@ class LoadLevelLimiter; class DomainAssembly; class DeadlockAwareLock; struct HelperMethodFrameCallerList; -class ThreadLocalIBCInfo; class EECodeInfo; class DebuggerPatchSkip; class FaultingExceptionFrame; @@ -2652,37 +2651,8 @@ class Thread } #endif - private: - - ThreadLocalIBCInfo* m_pIBCInfo; - public: -#ifndef DACCESS_COMPILE - - ThreadLocalIBCInfo* GetIBCInfo() - { - LIMITED_METHOD_CONTRACT; - _ASSERTE(g_IBCLogger.InstrEnabled()); - return m_pIBCInfo; - } - - void SetIBCInfo(ThreadLocalIBCInfo* pInfo) - { - LIMITED_METHOD_CONTRACT; - _ASSERTE(g_IBCLogger.InstrEnabled()); - m_pIBCInfo = pInfo; - } - - void FlushIBCInfo() - { - WRAPPER_NO_CONTRACT; - if (m_pIBCInfo != NULL) - m_pIBCInfo->FlushDelayedCallbacks(); - } - -#endif // #ifndef DACCESS_COMPILE - // Indicate whether this thread should run in the background. Background threads // don't interfere with the EE shutting down. Whereas a running non-background // thread prevents us from shutting down (except through System.Exit(), of course) diff --git a/src/coreclr/vm/typedesc.cpp b/src/coreclr/vm/typedesc.cpp index 23c6b1ee5f3ed..7636b6b2ef144 100644 --- a/src/coreclr/vm/typedesc.cpp +++ b/src/coreclr/vm/typedesc.cpp @@ -542,9 +542,6 @@ OBJECTREF ParamTypeDesc::GetManagedClassObject() GetTemplateMethodTableInternal()->GetWriteableDataForWrite()->m_hExposedClassObject = m_hExposedClassObject; } - // Log the TypeVarTypeDesc access - g_IBCLogger.LogTypeMethodTableWriteableAccess(&th); - GCPROTECT_END(); } return GetManagedClassObjectIfExists(); @@ -560,8 +557,6 @@ BOOL TypeDesc::IsRestored() STATIC_CONTRACT_CANNOT_TAKE_LOCK; SUPPORTS_DAC; - TypeHandle th = TypeHandle(this); - g_IBCLogger.LogTypeMethodTableAccess(&th); return IsRestored_NoLogging(); } diff --git a/src/coreclr/vm/typehandle.cpp b/src/coreclr/vm/typehandle.cpp index 13e59e5ffeb6f..9aec49bbc92d3 100644 --- a/src/coreclr/vm/typehandle.cpp +++ b/src/coreclr/vm/typehandle.cpp @@ -30,11 +30,6 @@ BOOL TypeHandle::Verify() if (IsNull()) return(TRUE); - // If you try to do IBC logging of a type being created, the type - // will look inconsistent. IBC logging knows to filter out such types. - if (g_IBCLogger.InstrEnabled()) - return TRUE; - if (!IsRestored_NoLogging()) return TRUE; @@ -1036,8 +1031,6 @@ void TypeHandle::CheckRestore() const ClassLoader::EnsureLoaded(*this); _ASSERTE(IsFullyLoaded()); } - - g_IBCLogger.LogTypeMethodTableAccess(this); } #ifndef DACCESS_COMPILE @@ -1354,9 +1347,6 @@ BOOL SatisfiesClassConstraints(TypeHandle instanceTypeHnd, TypeHandle typicalTyp SigTypeContext typeContext; SigTypeContext::InitTypeContext(instanceTypeHnd, &typeContext); - // Log the TypeVarTypeDesc access - g_IBCLogger.LogTypeMethodTableWriteableAccess(&thActualArg); - BOOL bSatisfiesConstraints = formalInst[i].AsGenericVariable()->SatisfiesConstraints(&typeContext, thActualArg, pInstContext); diff --git a/src/coreclr/vm/typehash.cpp b/src/coreclr/vm/typehash.cpp index 2a81b0490494b..8eba079f33694 100644 --- a/src/coreclr/vm/typehash.cpp +++ b/src/coreclr/vm/typehash.cpp @@ -494,12 +494,10 @@ TypeHandle EETypeHashTable::GetValue(TypeKey *pKey) if (pItem) { - TypeHandle th = pItem->GetTypeHandle(); - g_IBCLogger.LogTypeHashTableAccess(&th); return pItem->GetTypeHandle(); } - else - return TypeHandle(); + + return TypeHandle(); } #ifndef DACCESS_COMPILE diff --git a/src/coreclr/vm/vars.cpp b/src/coreclr/vm/vars.cpp index 9280db1e3eb95..ae4209310707b 100644 --- a/src/coreclr/vm/vars.cpp +++ b/src/coreclr/vm/vars.cpp @@ -45,8 +45,6 @@ GPTR_IMPL(IdDispenser, g_pThinLockThreadIdDispenser); GPTR_IMPL(IdDispenser, g_pModuleIndexDispenser); -IBCLogger g_IBCLogger; - // For [ g_TrapReturningThreads; -EXTERN IBCLogger g_IBCLogger; - #ifdef _DEBUG // next two variables are used to enforce an ASSERT in Thread::DbgFindThread // that does not allow g_TrapReturningThreads to creep up unchecked. diff --git a/src/coreclr/vm/virtualcallstub.cpp b/src/coreclr/vm/virtualcallstub.cpp index b51f8bee7e213..67b4c9334e045 100644 --- a/src/coreclr/vm/virtualcallstub.cpp +++ b/src/coreclr/vm/virtualcallstub.cpp @@ -2029,8 +2029,6 @@ VirtualCallStubManager::Resolver( } #endif // _DEBUG - g_IBCLogger.LogMethodTableAccess(pMT); - // NOTE: CERs are not hardened against transparent proxy types, // so no need to worry about throwing an exception from here. @@ -2046,7 +2044,6 @@ VirtualCallStubManager::Resolver( // this target and backpatch the callsite. if (!implSlot.IsNull()) { - g_IBCLogger.LogDispatchTableSlotAccess(&implSlot); #if defined(LOGGING) || defined(_DEBUG) { pMD = implSlot.GetMethodDesc(); @@ -2113,10 +2110,6 @@ VirtualCallStubManager::Resolver( // to change. fShouldPatch = TRUE; } - else - { - g_IBCLogger.LogMethodDescAccess(pMD); - } } } } diff --git a/src/coreclr/vm/zapsig.cpp b/src/coreclr/vm/zapsig.cpp index 6dede7725e291..331e4520d0583 100644 --- a/src/coreclr/vm/zapsig.cpp +++ b/src/coreclr/vm/zapsig.cpp @@ -233,17 +233,7 @@ BOOL ZapSig::GetSignatureForTypeHandle(TypeHandle handle, if ((index != 0) && (this->pfnTokenDefinition != NULL)) { - // - // We do not want to log the metadata lookups that we perform here - // - IBCLoggingDisabler disableLogging; - - // During IBC profiling this calls - // code:Module::TokenDefinitionHelper (*this->pfnTokenDefinition)(this->context.pModuleContext, pTypeHandleModule, index, &token); - - // ibcExternalType tokens are actually encoded as mdtTypeDef tokens in the signature - _ASSERTE(TypeFromToken(token) == ibcExternalType); token = TokenFromRid(RidFromToken(token), mdtTypeDef); } @@ -676,7 +666,7 @@ Module *ZapSig::DecodeModuleFromIndexIfLoaded(Module *fromModule, { // Unexpected failure reading MetaData fValidAssemblyRef = FALSE; } - + if (fValidAssemblyRef) { pAssembly = fromModule->GetAssemblyIfLoaded( @@ -913,8 +903,6 @@ MethodDesc *ZapSig::DecodeMethod(Module *pInfoModule, !(isInstantiatingStub || isUnboxingStub) && !actualOwnerRequired, actualOwnerRequired); - g_IBCLogger.LogMethodDescAccess(pMethod); - if (methodFlags & ENCODE_METHOD_SIG_Constrained) { TypeHandle constrainedType = sig.GetTypeHandleThrowing(pInfoModule, @@ -1198,10 +1186,6 @@ BOOL ZapSig::EncodeMethod( externalTokens = ZapSig::MulticoreJitTokens; pInfoModule = pMethod->GetModule_NoLogging(); } - else if (pfnDefineToken != NULL) - { - externalTokens = ZapSig::IbcTokens; - } ZapSig zapSig(pInfoModule, pEncodeModuleContext, externalTokens, (EncodeModuleCallback) pfnEncodeModule, @@ -1221,22 +1205,8 @@ BOOL ZapSig::EncodeMethod( if (fMethodNeedsInstantiation) methodFlags |= ENCODE_METHOD_SIG_MethodInstantiation; - // - // For backward compatibility, IBC tokens use slightly different encoding: - // - Owning type is uncoditionally encoded - // - Number of method instantiation arguments is not encoded - // - if (externalTokens == ZapSig::IbcTokens) - { - // The type is always encoded before flags for IBC - if (!zapSig.GetSignatureForTypeHandle(ownerType, pSigBuilder)) - return FALSE; - } - else - { - // Assume that the owner type is going to be needed - methodFlags |= ENCODE_METHOD_SIG_OwnerType; - } + // Assume that the owner type is going to be needed + methodFlags |= ENCODE_METHOD_SIG_OwnerType; if (IsNilToken(methodToken)) { @@ -1278,13 +1248,6 @@ BOOL ZapSig::EncodeMethod( // if ((index != 0) && (pfnDefineToken != NULL)) { - // - // We do not want to log the metadata lookups that we perform here - // - IBCLoggingDisabler disableLogging; - - // During IBC profiling this calls - // code:Module::TokenDefinitionHelper() (*((TokenDefinitionCallback) pfnDefineToken))(pEncodeModuleContext, pTypeHandleModule, index, &methodToken); } } @@ -1367,11 +1330,6 @@ BOOL ZapSig::EncodeMethod( else { Instantiation inst = pMethod->GetMethodInstantiation(); - - // Number of method instantiation arguments is not encoded in IBC tokens - see comment above - if (externalTokens != ZapSig::IbcTokens) - pSigBuilder->AppendData(inst.GetNumArgs()); - for (DWORD i = 0; i < inst.GetNumArgs(); i++) { TypeHandle t = inst[i]; diff --git a/src/coreclr/vm/zapsig.h b/src/coreclr/vm/zapsig.h index 67a06b95e64fd..290ca007a186a 100644 --- a/src/coreclr/vm/zapsig.h +++ b/src/coreclr/vm/zapsig.h @@ -37,7 +37,6 @@ class ZapSig { IllegalValue, NormalTokens, - IbcTokens, MulticoreJitTokens };