void ZapImage::OutputEntrypointsTableForReadyToRun() { BeginRegion(CORINFO_REGION_COLD); NativeWriter arrayWriter; NativeWriter hashtableWriter; NativeSection * pArraySection = arrayWriter.NewSection(); NativeSection * pHashtableSection = hashtableWriter.NewSection(); VertexArray vertexArray(pArraySection); pArraySection->Place(&vertexArray); VertexHashtable vertexHashtable; pHashtableSection->Place(&vertexHashtable); bool fEmpty = true; SHash< NoRemoveSHashTraits < BlobVertexSHashTraits > > fixupBlobs; COUNT_T nCount = m_MethodCompilationOrder.GetCount(); for (COUNT_T i = 0; i < nCount; i++) { ZapMethodHeader * pMethod = m_MethodCompilationOrder[i]; mdMethodDef token = GetJitInfo()->getMethodDefFromMethod(pMethod->GetHandle()); CORINFO_SIG_INFO sig; GetJitInfo()->getMethodSig(pMethod->GetHandle(), &sig); int rid = RidFromToken(token); _ASSERTE(rid != 0); BlobVertex * pFixupBlob = NULL; if (pMethod->m_pFixupList != NULL) { NibbleWriter writer; m_pImportTable->PlaceFixups(pMethod->m_pFixupList, writer); DWORD cbBlob; PVOID pBlob = writer.GetBlob(&cbBlob); pFixupBlob = fixupBlobs.Lookup(BlobVertexKey(pBlob, cbBlob)); if (pFixupBlob == NULL) { void * pMemory = new (GetHeap()) BYTE[sizeof(BlobVertex) + cbBlob]; pFixupBlob = new (pMemory) BlobVertex(cbBlob); memcpy(pFixupBlob->GetData(), pBlob, cbBlob); fixupBlobs.Add(pFixupBlob); } } if (sig.sigInst.classInstCount > 0 || sig.sigInst.methInstCount > 0) { CORINFO_MODULE_HANDLE module = GetJitInfo()->getClassModule(pMethod->GetClassHandle()); _ASSERTE(GetCompileInfo()->IsInCurrentVersionBubble(module)); SigBuilder sigBuilder; CORINFO_RESOLVED_TOKEN resolvedToken = {}; resolvedToken.tokenScope = module; resolvedToken.token = token; resolvedToken.hClass = pMethod->GetClassHandle(); resolvedToken.hMethod = pMethod->GetHandle(); GetCompileInfo()->EncodeMethod(module, pMethod->GetHandle(), &sigBuilder, NULL, NULL, &resolvedToken); DWORD cbBlob; PVOID pBlob = sigBuilder.GetSignature(&cbBlob); void * pMemory = new (GetHeap()) BYTE[sizeof(BlobVertex) + cbBlob]; BlobVertex * pSigBlob = new (pMemory) BlobVertex(cbBlob); memcpy(pSigBlob->GetData(), pBlob, cbBlob); int dwHash = GetCompileInfo()->GetVersionResilientMethodHashCode(pMethod->GetHandle()); vertexHashtable.Append(dwHash, pHashtableSection->Place(new (GetHeap()) EntryPointWithBlobVertex(pMethod->GetMethodIndex(), pFixupBlob, pSigBlob))); } else { vertexArray.Set(rid - 1, new (GetHeap()) EntryPointVertex(pMethod->GetMethodIndex(), pFixupBlob)); } fEmpty = false; } if (fEmpty) return; vertexArray.ExpandLayout(); vector<byte>& arrayBlob = arrayWriter.Save(); ZapNode * pArrayBlob = ZapBlob::NewBlob(this, &arrayBlob[0], arrayBlob.size()); m_pCodeMethodDescsSection->Place(pArrayBlob); vector<byte>& hashtableBlob = hashtableWriter.Save(); ZapNode * pHashtableBlob = ZapBlob::NewBlob(this, &hashtableBlob[0], hashtableBlob.size()); m_pCodeMethodDescsSection->Place(pHashtableBlob); ZapReadyToRunHeader * pReadyToRunHeader = GetReadyToRunHeader(); pReadyToRunHeader->RegisterSection(READYTORUN_SECTION_METHODDEF_ENTRYPOINTS, pArrayBlob); pReadyToRunHeader->RegisterSection(READYTORUN_SECTION_INSTANCE_METHOD_ENTRYPOINTS, pHashtableBlob); pReadyToRunHeader->RegisterSection(READYTORUN_SECTION_RUNTIME_FUNCTIONS, m_pRuntimeFunctionSection); if (m_pLazyMethodCallHelperSection->GetNodeCount() != 0) pReadyToRunHeader->RegisterSection(READYTORUN_SECTION_DELAYLOAD_METHODCALL_THUNKS, m_pLazyMethodCallHelperSection); if (m_pExceptionInfoLookupTable->GetSize() != 0) pReadyToRunHeader->RegisterSection(READYTORUN_SECTION_EXCEPTION_INFO, m_pExceptionInfoLookupTable); EndRegion(CORINFO_REGION_COLD); }
CONTRACTL { STANDARD_VM_CHECK; PRECONDITION(CheckPointer(pSigModule, NULL_NOT_OK)); PRECONDITION(CheckPointer(ppNewSig, NULL_NOT_OK)); PRECONDITION(CheckPointer(pcbNewSig, NULL_NOT_OK)); } CONTRACTL_END; SigPointer sigPtr(pSig, cbSig); SigBuilder sigBuilder; sigPtr.ConvertToInternalSignature(pSigModule, pTypeContext, &sigBuilder); DWORD cbNewSig; PVOID pConvertedSig = sigBuilder.GetSignature(&cbNewSig); PVOID pNewSig = pamTracker->Track(pCreationHeap->AllocMem(S_SIZE_T(cbNewSig))); memcpy(pNewSig, pConvertedSig, cbNewSig); *ppNewSig = (PCCOR_SIGNATURE)pNewSig; *pcbNewSig = cbNewSig; } // static MethodDesc* ILStubCache::CreateAndLinkNewILStubMethodDesc(LoaderAllocator* pAllocator, MethodTable* pMT, DWORD dwStubFlags, Module* pSigModule, PCCOR_SIGNATURE pSig, DWORD cbSig, SigTypeContext *pTypeContext, ILStubLinker* pStubLinker) { CONTRACT (MethodDesc*) {