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

[interp] Add wrapper for calli to native pointer #57119

Merged
merged 1 commit into from
Aug 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/mono/mono/mini/interp/transform.c
Original file line number Diff line number Diff line change
Expand Up @@ -3162,8 +3162,21 @@ interp_transform_call (TransformData *td, MonoMethod *method, MonoMethod *target
* the InterpMethod pointer. FIXME
*/
native = csignature->pinvoke || method->wrapper_type == MONO_WRAPPER_RUNTIME_INVOKE;

target_method = NULL;
if (!method->dynamic && !method->wrapper_type && csignature->pinvoke && !csignature->suppress_gc_transition) {
// native calli needs a wrapper
target_method = mono_marshal_get_native_func_wrapper_indirect (method->klass, csignature, FALSE);
calli = FALSE;
native = FALSE;
// The function pointer is passed last, but the wrapper expects it as first argument
// Switch the arguments
StackInfo sp_fp = td->sp [-1];
StackInfo *start = &td->sp [-csignature->param_count - 1];
memmove (start + 1, start, csignature->param_count * sizeof (StackInfo));
*start = sp_fp;

// The method we are calling has a different signature
csignature = mono_method_signature_internal (target_method);
}
} else {
target_method = interp_get_method (method, token, image, generic_context, error);
return_val_if_nok (error, FALSE);
Expand Down