-
Notifications
You must be signed in to change notification settings - Fork 5.4k
[cDAC] DacDbi code-version node APIs for ReJIT/SOS #126980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
bb2c01d
c3de1dc
3b36f4d
68ab632
77fc8b0
7a10c6f
87f57d6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1199,13 +1199,137 @@ public int GetMDStructuresVersion(uint* pMDStructuresVersion) | |
| } | ||
|
|
||
| public int GetActiveRejitILCodeVersionNode(ulong vmModule, uint methodTk, ulong* pVmILCodeVersionNode) | ||
| => LegacyFallbackHelper.CanFallback() && _legacy is not null ? _legacy.GetActiveRejitILCodeVersionNode(vmModule, methodTk, pVmILCodeVersionNode) : HResults.E_NOTIMPL; | ||
| { | ||
| int hr = HResults.S_OK; | ||
| try | ||
| { | ||
| if (pVmILCodeVersionNode is null) | ||
| throw new ArgumentException("Output pointer cannot be null.", nameof(pVmILCodeVersionNode)); | ||
|
|
||
| *pVmILCodeVersionNode = 0; | ||
|
rcj1 marked this conversation as resolved.
|
||
|
|
||
| if (!_target.Contracts.TryGetContract<IReJIT>(out IReJIT rejit)) | ||
| return hr; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looks like native does a failfast here, should we return an error code?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think so, it's an assert not a failfast and it does nothing if consistency checks are not enabled |
||
|
|
||
| ILoader loader = _target.Contracts.Loader; | ||
| Contracts.ModuleHandle module = loader.GetModuleHandleFromModulePtr(new TargetPointer(vmModule)); | ||
| ModuleLookupTables lookupTables = loader.GetLookupTables(module); | ||
| TargetPointer methodDesc = TargetPointer.Null; | ||
| try | ||
| { | ||
| if ((EcmaMetadataUtils.TokenType)(methodTk & EcmaMetadataUtils.TokenTypeMask) != EcmaMetadataUtils.TokenType.mdtMethodDef) | ||
| throw new ArgumentException("methodTk must be a MethodDef token.", nameof(methodTk)); | ||
| methodDesc = loader.GetModuleLookupMapElement(lookupTables.MethodDefToDesc, methodTk, out _); | ||
| } | ||
|
rcj1 marked this conversation as resolved.
|
||
| catch (ArgumentOutOfRangeException) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any benefit we get by catching this? If the caller passes in a bad methodToken it seems odd to suppress that and return S_OK. |
||
| { | ||
| // Invalid method token | ||
| } | ||
|
rcj1 marked this conversation as resolved.
|
||
| if (methodDesc != TargetPointer.Null) | ||
| { | ||
| ICodeVersions codeVersions = _target.Contracts.CodeVersions; | ||
| ILCodeVersionHandle ilCodeVersion = codeVersions.GetActiveILCodeVersion(methodDesc); | ||
| if (ilCodeVersion.IsValid | ||
| && ilCodeVersion.IsExplicit | ||
| && rejit.GetRejitState(ilCodeVersion) == RejitState.Active) | ||
| { | ||
| *pVmILCodeVersionNode = ilCodeVersion.ILCodeVersionNode.Value; | ||
| } | ||
|
rcj1 marked this conversation as resolved.
rcj1 marked this conversation as resolved.
|
||
| } | ||
| } | ||
| catch (System.Exception ex) | ||
| { | ||
| hr = ex.HResult; | ||
| } | ||
|
|
||
| #if DEBUG | ||
| if (_legacy is not null) | ||
| { | ||
| ulong resultLocal; | ||
| int hrLocal = _legacy.GetActiveRejitILCodeVersionNode(vmModule, methodTk, &resultLocal); | ||
| Debug.ValidateHResult(hr, hrLocal); | ||
| if (hr == HResults.S_OK) | ||
| Debug.Assert(*pVmILCodeVersionNode == resultLocal, $"cDAC: {*pVmILCodeVersionNode:x}, DAC: {resultLocal:x}"); | ||
| } | ||
| #endif | ||
|
|
||
| return hr; | ||
| } | ||
|
|
||
| public int GetNativeCodeVersionNode(ulong vmMethod, ulong codeStartAddress, ulong* pVmNativeCodeVersionNode) | ||
| => LegacyFallbackHelper.CanFallback() && _legacy is not null ? _legacy.GetNativeCodeVersionNode(vmMethod, codeStartAddress, pVmNativeCodeVersionNode) : HResults.E_NOTIMPL; | ||
| { | ||
| int hr = HResults.S_OK; | ||
| try | ||
| { | ||
| if (pVmNativeCodeVersionNode is null) | ||
| throw new ArgumentException("Output pointer cannot be null.", nameof(pVmNativeCodeVersionNode)); | ||
|
|
||
| *pVmNativeCodeVersionNode = 0; | ||
|
|
||
| TargetCodePointer codeAddress = new TargetCodePointer(codeStartAddress); | ||
| ICodeVersions codeVersions = _target.Contracts.CodeVersions; | ||
|
|
||
| NativeCodeVersionHandle nativeCodeVersion = codeVersions.GetNativeCodeVersionForIP(codeAddress); | ||
| if (nativeCodeVersion.Valid && nativeCodeVersion.IsExplicit) | ||
|
rcj1 marked this conversation as resolved.
|
||
| { | ||
| *pVmNativeCodeVersionNode = nativeCodeVersion.CodeVersionNodeAddress.Value; | ||
| } | ||
| } | ||
| catch (System.Exception ex) | ||
| { | ||
| hr = ex.HResult; | ||
| } | ||
|
|
||
| #if DEBUG | ||
| if (_legacy is not null) | ||
| { | ||
| ulong resultLocal; | ||
| int hrLocal = _legacy.GetNativeCodeVersionNode(vmMethod, codeStartAddress, &resultLocal); | ||
| Debug.ValidateHResult(hr, hrLocal); | ||
| if (hr == HResults.S_OK) | ||
| Debug.Assert(*pVmNativeCodeVersionNode == resultLocal, $"cDAC: {*pVmNativeCodeVersionNode:x}, DAC: {resultLocal:x}"); | ||
| } | ||
| #endif | ||
|
|
||
| return hr; | ||
| } | ||
|
|
||
| public int GetILCodeVersionNode(ulong vmNativeCodeVersionNode, ulong* pVmILCodeVersionNode) | ||
| => LegacyFallbackHelper.CanFallback() && _legacy is not null ? _legacy.GetILCodeVersionNode(vmNativeCodeVersionNode, pVmILCodeVersionNode) : HResults.E_NOTIMPL; | ||
| { | ||
| int hr = HResults.S_OK; | ||
| try | ||
| { | ||
| if (pVmILCodeVersionNode is null) | ||
| throw new ArgumentException("Output pointer cannot be null.", nameof(pVmILCodeVersionNode)); | ||
|
|
||
| *pVmILCodeVersionNode = 0; | ||
|
|
||
| ICodeVersions codeVersions = _target.Contracts.CodeVersions; | ||
| NativeCodeVersionHandle nativeCodeVersion = NativeCodeVersionHandle.CreateExplicit(new TargetPointer(vmNativeCodeVersionNode)); | ||
| ILCodeVersionHandle ilCodeVersion = codeVersions.GetILCodeVersion(nativeCodeVersion); | ||
| if (ilCodeVersion.IsValid && ilCodeVersion.IsExplicit) | ||
| { | ||
| *pVmILCodeVersionNode = ilCodeVersion.ILCodeVersionNode.Value; | ||
| } | ||
| } | ||
| catch (System.Exception ex) | ||
| { | ||
| hr = ex.HResult; | ||
| } | ||
|
|
||
| #if DEBUG | ||
| if (_legacy is not null) | ||
| { | ||
| ulong resultLocal; | ||
| int hrLocal = _legacy.GetILCodeVersionNode(vmNativeCodeVersionNode, &resultLocal); | ||
| Debug.ValidateHResult(hr, hrLocal); | ||
| if (hr == HResults.S_OK) | ||
| Debug.Assert(*pVmILCodeVersionNode == resultLocal, $"cDAC: {*pVmILCodeVersionNode:x}, DAC: {resultLocal:x}"); | ||
| } | ||
| #endif | ||
|
|
||
| return hr; | ||
| } | ||
|
|
||
| public int GetILCodeVersionNodeData(ulong ilCodeVersionNode, DacDbiSharedReJitInfo* pData) | ||
| => LegacyFallbackHelper.CanFallback() && _legacy is not null ? _legacy.GetILCodeVersionNodeData(ilCodeVersionNode, pData) : HResults.E_NOTIMPL; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.