-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Change callvirt
into calli
for virtual delegates
#83461
Merged
Merged
Changes from 15 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
a175351
Changed how NaN values are compared due to their multiple bit represe…
f9ed58c
Merge branch 'dotnet:main' into main
LeVladIonescu a381c06
Fixed typo
d91a78f
Merge branch 'dotnet:main' into main
LeVladIonescu 1291fe3
Merge branch 'dotnet:main' into main
LeVladIonescu 9a58bb3
Merge branch 'dotnet:main' into main
LeVladIonescu 8db950e
Merge branch 'dotnet:main' into main
LeVladIonescu f587d24
Merge branch 'dotnet:main' into main
LeVladIonescu f5dbeaf
Merge branch 'dotnet:main' into main
LeVladIonescu 287419e
Merge branch 'dotnet:main' into main
LeVladIonescu fbc1526
Work to make JIT virtual delegates not depend on the target_method
afd58dd
Merge branch 'dotnet:main' into delegates_issue
LeVladIonescu 45f4845
Merge branch 'dotnet:main' into delegates_issue
LeVladIonescu 91c3920
Switched order of how MonoObject is passed to the icall
81973db
Initialise pointer for build warning
3b0d6cb
Check return value in the test
f67f5fb
Retrieved method in icall and changed test location
dc2c525
Added check for unbox & rgctx trampolines and modified caching
4ba3366
Deleted unused vars
7b65607
Added test for lazy fetch trampoline (rgctx)
e7e8913
Merge branch 'dotnet:main' into delegates_issue
LeVladIonescu d6e1d3d
Added boxing for valuetype ref
0074bea
Added RequiresProcessIsolation property for tests in merged directory
be6daed
Using get_ftnptr callback and moving boxing inside the icall
596837e
Merge branch 'dotnet:main' into delegates_issue
LeVladIonescu 414f451
Merge branch 'dotnet:main' into delegates_issue
LeVladIonescu 1d2c4fb
Rremoved add_delegate_trampoline since it's not used anymore
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -324,6 +324,7 @@ mono_marshal_init (void) | |
register_icall (monoeg_g_free, mono_icall_sig_void_ptr, FALSE); | ||
register_icall (mono_object_isinst_icall, mono_icall_sig_object_object_ptr, TRUE); | ||
register_icall (mono_struct_delete_old, mono_icall_sig_void_ptr_ptr, FALSE); | ||
register_icall (mono_get_addr_compiled_method, mono_icall_sig_ptr_object_ptr, FALSE); | ||
register_icall (mono_delegate_begin_invoke, mono_icall_sig_object_object_ptr, FALSE); | ||
register_icall (mono_delegate_end_invoke, mono_icall_sig_object_object_ptr, FALSE); | ||
register_icall (mono_gc_wbarrier_generic_nostore_internal, mono_icall_sig_void_ptr, TRUE); | ||
|
@@ -2085,7 +2086,7 @@ free_signature_pointer_pair (SignaturePointerPair *pair) | |
MonoMethod * | ||
mono_marshal_get_delegate_invoke_internal (MonoMethod *method, gboolean callvirt, gboolean static_method_with_first_arg_bound, MonoMethod *target_method) | ||
{ | ||
MonoMethodSignature *sig, *invoke_sig; | ||
MonoMethodSignature *sig, *invoke_sig, *target_method_sig = NULL; | ||
MonoMethodBuilder *mb; | ||
MonoMethod *res; | ||
GHashTable *cache; | ||
|
@@ -2129,6 +2130,11 @@ mono_marshal_get_delegate_invoke_internal (MonoMethod *method, gboolean callvirt | |
} | ||
|
||
closed_over_null = sig->param_count == mono_method_signature_internal (target_method)->param_count; | ||
|
||
/* | ||
* We don't want to use target_method's signature because it can be freed early | ||
*/ | ||
target_method_sig = mono_method_signature_internal (target_method); | ||
} | ||
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. The caching code needs to be modified to cache based on either the class or the signature. I.e. this code:
and:
|
||
|
||
if (static_method_with_first_arg_bound) { | ||
|
@@ -2239,7 +2245,7 @@ mono_marshal_get_delegate_invoke_internal (MonoMethod *method, gboolean callvirt | |
/* FIXME: Other subtypes */ | ||
mb->mem_manager = m_method_get_mem_manager (method); | ||
|
||
get_marshal_cb ()->emit_delegate_invoke_internal (mb, sig, invoke_sig, static_method_with_first_arg_bound, callvirt, closed_over_null, method, target_method, target_class, ctx, container); | ||
get_marshal_cb ()->emit_delegate_invoke_internal (mb, sig, invoke_sig, target_method_sig, static_method_with_first_arg_bound, callvirt, closed_over_null, method, target_method, target_class, ctx, container); | ||
|
||
get_marshal_cb ()->mb_skip_visibility (mb); | ||
|
||
|
@@ -5481,6 +5487,31 @@ mono_struct_delete_old (MonoClass *klass, char *ptr) | |
} | ||
} | ||
|
||
void* | ||
mono_get_addr_compiled_method (MonoObject *object, MonoMethod *method) | ||
{ | ||
ERROR_DECL (error); | ||
MonoMethod *res; | ||
gpointer addr; | ||
|
||
if (object == NULL) { | ||
mono_error_set_null_reference (error); | ||
mono_error_set_pending_exception (error); | ||
return NULL; | ||
} | ||
|
||
res = mono_object_get_virtual_method_internal (object, method); | ||
|
||
addr = mono_compile_method_checked (res, error); | ||
|
||
if (!is_ok (error)) { | ||
mono_error_set_pending_exception (error); | ||
return NULL; | ||
} | ||
|
||
return addr; | ||
} | ||
|
||
void | ||
ves_icall_System_Runtime_InteropServices_Marshal_DestroyStructure (gpointer src, MonoReflectionTypeHandle type, MonoError *error) | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
public class Tests | ||
{ | ||
public static int Main () { | ||
try { | ||
var del = (Func<string, string>)Delegate.CreateDelegate (typeof (Func<string, string>), null, typeof (object).GetMethod ("ToString")); | ||
Console.WriteLine (del ("FOO")); | ||
} catch(Exception e) { | ||
vargaz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Console.WriteLine(e); | ||
return 0; | ||
} | ||
|
||
return 100; | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
lambdageek marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<DebugType>PdbOnly</DebugType> | ||
<Optimize>True</Optimize> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="Tests.cs" /> | ||
</ItemGroup> | ||
</Project> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This optimized version depends on target_method as well, so it might need to be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are suggesting to retrieve the method the way it was done before ? i.e. in the il based on its field address inside MonoDelegate class and not in the call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean that optimized version needs to be removed since it will make the wrapper depend on target_method.