[mono][interp] Fix first arg offset computation for unoptimized newobj (#85787)
authorVlad Brezae <brezaevlad@gmail.com>
Fri, 5 May 2023 12:43:09 +0000 (15:43 +0300)
committerGitHub <noreply@github.com>
Fri, 5 May 2023 12:43:09 +0000 (15:43 +0300)
Instead of obtaining the offset directly, we were computing it as the next available offset (once the arguments were pop'ed), which was not accounting for the case where the first argument was aligned.

src/mono/mono/mini/interp/transform.c

index ce237e2de102db411a29a197c355cf95e93fbf7c..1eda837e8a98a197b9af12c4538cf361c47dc5ed 100644 (file)
@@ -6035,9 +6035,15 @@ generate_code (TransformData *td, MonoMethod *method, MonoMethodHeader *header,
                                interp_ins_set_dreg (td->last_ins, td->sp [-1].local);
                        } else if (!td->optimized) {
                                int tos = get_tos_offset (td);
-                               td->sp -= csignature->param_count;
-                               int param_offset = get_tos_offset (td);
-                               int param_size = tos - param_offset;
+                               int param_offset, param_size;
+                               if (csignature->param_count) {
+                                       td->sp -= csignature->param_count;
+                                       param_offset = td->sp [0].offset;
+                                       param_size = tos - param_offset;
+                               } else {
+                                       param_offset = tos;
+                                       param_size = 0;
+                               }
 
                                td->cbb->contains_call_instruction = TRUE;
                                interp_add_ins (td, MINT_NEWOBJ_SLOW_UNOPT);