Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 5.6k
Call into PerfMap logic exclusively in preemptive mode#129019
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
99f405d1759f5de1f7ef1029f87dd94d6a5e05223a01bf23e8dd3e3fbe0225a9d6d2e91863d4216a5f316d21f2665990ef5d786fddf2fb2ab4670650fe248692f86c4efa3adb827e26d5a9fe472b55af65aff2d6e53ede9b75b3dbfee6d0e08272b40b295d368ae6e5ff57154bb4207d51c6416391ae1172ceed1ac595059634b7aa495255a48108bbc550f228676f38dd7a77File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -494,27 +494,82 @@ internal static Delegate CreateDelegateForDynamicMethod(Type type, object? targe | ||
| Justification = "The parameter 'methodType' is passed by ref to QCallTypeHandle")] | ||
| private bool BindToMethodName(object? target, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.AllMethods)] RuntimeType methodType, string method, DelegateBindingFlags flags) | ||
| { | ||
| Delegate d = this; | ||
| return BindToMethodName(ObjectHandleOnStack.Create(ref d), ObjectHandleOnStack.Create(ref target), | ||
| new QCallTypeHandle(ref methodType), method, flags); | ||
| bool ret; | ||
| BindToMethodDetails bindToMethodDetails; | ||
| unsafe | ||
| { | ||
| ret = BindToMethodName(RuntimeHelpers.GetMethodTable(this), (target != null) ? RuntimeHelpers.GetMethodTable(target) : null, | ||
| new QCallTypeHandle(ref methodType), method, flags, ObjectHandleOnStack.Create(ref target), out bindToMethodDetails); | ||
| } | ||
| if (ret) | ||
| { | ||
| // Apply the results of the QCall to the delegate instance. | ||
| _methodPtr = bindToMethodDetails.methodPtr; | ||
| _methodPtrAux = bindToMethodDetails.methodPtrAux; | ||
| _extraData = bindToMethodDetails.extraData; | ||
| if (bindToMethodDetails.loaderAllocatorGCHandle.IsAllocated) | ||
| { | ||
| _helperObject = bindToMethodDetails.loaderAllocatorGCHandle.Target; | ||
| GC.KeepAlive(methodType); | ||
| } | ||
| if (bindToMethodDetails.selfReferentialTarget != 0) | ||
| _target = this; | ||
| else | ||
| _target = target; | ||
| } | ||
| return ret; | ||
| } | ||
| private struct BindToMethodDetails | ||
| { | ||
| public int selfReferentialTarget; // Whether the delegate's target object is the same as the first argument of the method to bind to. Only meaningful for open instance delegates. | ||
| public IntPtr methodPtr; | ||
| public IntPtr methodPtrAux; | ||
| public IntPtr extraData; | ||
| public GCHandle loaderAllocatorGCHandle; // The loader allocator needed if the delegate needs to keep it alive | ||
| } | ||
| [LibraryImport(RuntimeHelpers.QCall, EntryPoint = "Delegate_BindToMethodName", StringMarshalling = StringMarshalling.Utf8)] | ||
| [return: MarshalAs(UnmanagedType.Bool)] | ||
| private static partial bool BindToMethodName(ObjectHandleOnStack d, ObjectHandleOnStack target, QCallTypeHandle methodType, string method, DelegateBindingFlags flags); | ||
| private static partial bool BindToMethodName(MethodTable* pDelegateMT, MethodTable *pTargetMT, QCallTypeHandle methodType, string method, DelegateBindingFlags flags, ObjectHandleOnStack targetParameter, out BindToMethodDetails bindToMethodDetails); | ||
| private bool BindToMethodInfo(object? target, IRuntimeMethodInfo method, RuntimeType methodType, DelegateBindingFlags flags) | ||
| { | ||
| Delegate d = this; | ||
| bool ret = BindToMethodInfo(ObjectHandleOnStack.Create(ref d), ObjectHandleOnStack.Create(ref target), | ||
| method.Value, new QCallTypeHandle(ref methodType), flags); | ||
| GC.KeepAlive(method); | ||
| bool ret; | ||
| BindToMethodDetails bindToMethodDetails; | ||
| unsafe | ||
| { | ||
| ret = BindToMethodInfo(RuntimeHelpers.GetMethodTable(this), (target != null) ? RuntimeHelpers.GetMethodTable(target) : null, | ||
| IRuntimeMethodInfo.GetValue(method), new QCallTypeHandle(ref methodType), flags, ObjectHandleOnStack.Create(ref target), out bindToMethodDetails); | ||
| } | ||
davidwrighton marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| if (ret) | ||
| { | ||
| // Apply the results of the QCall to the delegate instance. | ||
| _methodPtr = bindToMethodDetails.methodPtr; | ||
| _methodPtrAux = bindToMethodDetails.methodPtrAux; | ||
| _extraData = bindToMethodDetails.extraData; | ||
| if (bindToMethodDetails.loaderAllocatorGCHandle.IsAllocated) | ||
| { | ||
| _helperObject = bindToMethodDetails.loaderAllocatorGCHandle.Target; | ||
| GC.KeepAlive(method); | ||
| } | ||
| if (bindToMethodDetails.selfReferentialTarget != 0) | ||
| _target = this; | ||
| else | ||
| _target = target; | ||
| } | ||
| return ret; | ||
| } | ||
| [LibraryImport(RuntimeHelpers.QCall, EntryPoint = "Delegate_BindToMethodInfo")] | ||
| [return: MarshalAs(UnmanagedType.Bool)] | ||
| private static partial bool BindToMethodInfo(ObjectHandleOnStack d, ObjectHandleOnStack target, RuntimeMethodHandleInternal method, QCallTypeHandle methodType, DelegateBindingFlags flags); | ||
| private static partial bool BindToMethodInfo(MethodTable* pDelegateMT, MethodTable *pTargetMT, RuntimeMethodHandleInternal method, QCallTypeHandle methodType, DelegateBindingFlags flags, ObjectHandleOnStack targetParameter, out BindToMethodDetails bindToMethodDetails); | ||
| private static Delegate InternalAlloc(RuntimeType type) | ||
| { | ||
| @@ -562,12 +617,31 @@ private void DelegateConstruct(object target, IntPtr method) | ||
| throw new ArgumentNullException(nameof(method)); | ||
| } | ||
| Delegate _this = this; | ||
| Construct(ObjectHandleOnStack.Create(ref _this), ObjectHandleOnStack.Create(ref target), method); | ||
| BindToMethodDetails bindToMethodDetails; | ||
| unsafe | ||
| { | ||
| Construct(RuntimeHelpers.GetMethodTable(this), (target != null) ? RuntimeHelpers.GetMethodTable(target) : null, | ||
| method, out bindToMethodDetails); | ||
| } | ||
| // Apply the results of the QCall to the delegate instance. | ||
| _methodPtr = bindToMethodDetails.methodPtr; | ||
| _methodPtrAux = bindToMethodDetails.methodPtrAux; | ||
| _extraData = bindToMethodDetails.extraData; | ||
| if (bindToMethodDetails.loaderAllocatorGCHandle.IsAllocated) | ||
| { | ||
| _helperObject = bindToMethodDetails.loaderAllocatorGCHandle.Target; | ||
| } | ||
| if (bindToMethodDetails.selfReferentialTarget != 0) | ||
| _target = this; | ||
| else | ||
| _target = target; | ||
| } | ||
| [LibraryImport(RuntimeHelpers.QCall, EntryPoint = "Delegate_Construct")] | ||
| private static partial void Construct(ObjectHandleOnStack _this, ObjectHandleOnStack target, IntPtr method); | ||
| private static partial void Construct(MethodTable* pDelegateMT, MethodTable* pTargetMT, IntPtr method, out BindToMethodDetails bindToMethodDetails); | ||
| [MethodImpl(MethodImplOptions.InternalCall)] | ||
| private static extern unsafe void* GetMulticastInvoke(MethodTable* pMT); | ||
| @@ -805,11 +879,16 @@ private static Wrapper[] DeleteFromInvocationList(ReadOnlySpan<Wrapper> invocati | ||
| internal static IntPtr AdjustTarget(object target, IntPtr methodPtr) | ||
| { | ||
| return AdjustTarget(ObjectHandleOnStack.Create(ref target), methodPtr); | ||
| unsafe | ||
| { | ||
| IntPtr result = AdjustTarget(RuntimeHelpers.GetMethodTable(target), methodPtr); | ||
| GC.KeepAlive(target); | ||
| return result; | ||
| } | ||
| } | ||
| [LibraryImport(RuntimeHelpers.QCall, EntryPoint = "Delegate_AdjustTarget")] | ||
| private static partial IntPtr AdjustTarget(ObjectHandleOnStack target, IntPtr methodPtr); | ||
| private static partial IntPtr AdjustTarget(MethodTable* targetMT, IntPtr methodPtr); | ||
davidwrighton marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| internal void InitializeVirtualCallStub(IntPtr methodPtr) | ||
| { | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.