Skip to content
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

Abstract static interface methods support is incomplete #929

Closed
lostmsu opened this issue Feb 13, 2023 · 0 comments · Fixed by #930
Closed

Abstract static interface methods support is incomplete #929

lostmsu opened this issue Feb 13, 2023 · 0 comments · Fixed by #930
Labels
enhancement feature A new feature (or feature request)
Milestone

Comments

@lostmsu
Copy link
Contributor

lostmsu commented Feb 13, 2023

The current implementation happens to work for generic math via System.Numerics.INumberBase<T> because for all primitive type T happens to be of the same type as the type itself (e.g. for Int32: T == Int32).

In general case this is not true. And the Disassembler.ExtractMethodBody fails on method.DeclaringType.GetGenericArguments()[0]; line with IndexOutOfRangeException because the interface that contains abstract static method does not even have to be generic. As far as I see, at this point the information about the type, that implements that static abstract method is not available at all.

Stacktrace

 Backend.PreCompileKernelMethod[TBackendHook](EntryPointDescription& entry, TBackendHook backendHook) line 606
Backend.PreCompileKernelMethod(EntryPointDescription& entry) line 577
<>c__DisplayClass159_0`2.<LoadSpecializationKernel>b__0(TKernelLoader& loader, KernelInfo& info) line 527
Accelerator.LoadAutoGroupedKernel[TDelegate](MethodInfo method, KernelInfo& kernelInfo) line 559
Accelerator.LoadAutoGroupedKernel[TDelegate](MethodInfo method) line 546
KernelLoaders.LoadAutoGroupedKernel[TIndex,T1,T2,T3,T4,T5,T6,T7](Accelerator accelerator, Action`8 action) line 2956
KernelLoaders.LoadAutoGroupedStreamKernel[TIndex,T1,T2,T3,T4,T5,T6,T7](Accelerator accelerator, Action`8 action) line 3012
RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
----- Inner Stack Trace -----
Disassembler.ExtractMethodBody(MethodBase method) line 64
Disassembler.ctor(MethodBase methodBase, SequencePointEnumerator sequencePointEnumerator, CompilationStackLocation compilationStackLocation) line 155
CodeGenerationPhase.GenerateCodeInternal(MethodBase method, Boolean isExternalRequest, CompilationStackLocation compilationStackLocation, Dictionary`2 detectedMethods, Method& generatedMethod) line 469
lostmsu added a commit to losttech/ILGPU that referenced this issue Feb 13, 2023
This replaces specific GenericMath support introduced in 7bf5578 ( m4rs-mt#898 )  with generic support for static abstract interface members.

Support is implemented using the constrained flag on the call instruction the same way it used to be done on virtual method calls. The call instruction with constrained flag set contains concrete type, that implements given interface, which makes it possible to find concrete method implementation to be called.

fixes m4rs-mt#929
@MoFtZ MoFtZ added this to the v1.4 milestone Feb 14, 2023
@MoFtZ MoFtZ added feature A new feature (or feature request) enhancement labels Feb 14, 2023
lostmsu added a commit to losttech/ILGPU that referenced this issue Feb 14, 2023
This replaces specific GenericMath support introduced in 7bf5578 ( m4rs-mt#898 )  with generic support for static abstract interface members.

Support is implemented using the constrained flag on the call instruction the same way it used to be done on virtual method calls. The call instruction with constrained flag set contains concrete type, that implements given interface, which makes it possible to find concrete method implementation to be called.

fixes m4rs-mt#929
lostmsu added a commit to losttech/ILGPU that referenced this issue Feb 14, 2023
This replaces specific GenericMath support introduced in 7bf5578 ( m4rs-mt#898 )  with generic support for static abstract interface members.

Support is implemented using the constrained flag on the call instruction the same way it used to be done on virtual method calls. The call instruction with constrained flag set contains concrete type, that implements given interface, which makes it possible to find concrete method implementation to be called.

fixes m4rs-mt#929
lostmsu added a commit to losttech/ILGPU that referenced this issue Feb 14, 2023
This replaces specific GenericMath support introduced in 7bf5578 ( m4rs-mt#898 )  with generic support for static abstract interface members.

Support is implemented using the constrained flag on the call instruction the same way it used to be done on virtual method calls. The call instruction with constrained flag set contains concrete type, that implements given interface, which makes it possible to find concrete method implementation to be called.

fixes m4rs-mt#929
lostmsu added a commit to losttech/ILGPU that referenced this issue Feb 15, 2023
This replaces specific GenericMath support introduced in 7bf5578 ( m4rs-mt#898 )  with generic support for static abstract interface members.

Support is implemented using the constrained flag on the call instruction the same way it used to be done on virtual method calls. The call instruction with constrained flag set contains concrete type, that implements given interface, which makes it possible to find concrete method implementation to be called.

fixes m4rs-mt#929
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement feature A new feature (or feature request)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants