[mono][aot] Fix an assert. (#84385)
authorZoltan Varga <vargaz@gmail.com>
Thu, 6 Apr 2023 05:20:31 +0000 (01:20 -0400)
committerGitHub <noreply@github.com>
Thu, 6 Apr 2023 05:20:31 +0000 (01:20 -0400)
This is hit when AOTing GitHub_27678.dll.

src/mono/mono/mini/memory-access.c

index d7d36f904cde559141b2e0836c6bbd5bf8ed4431..58d9c54c2829b5cead23bf191c94f624553ec192 100644 (file)
@@ -116,8 +116,19 @@ mini_emit_memcpy (MonoCompile *cfg, int destreg, int doffset, int srcreg, int so
 {
        int cur_reg;
 
-       /*FIXME arbitrary hack to avoid unbound code expansion.*/
-       g_assert (size < MAX_INLINE_COPY_SIZE);
+       if (size >= MAX_INLINE_COPY_SIZE) {
+               MonoInst *iargs [3];
+
+               int reg = alloc_ireg (cfg);
+               EMIT_NEW_UNALU (cfg, iargs [0], OP_MOVE, reg, destreg);
+               reg = alloc_ireg (cfg);
+               EMIT_NEW_UNALU (cfg, iargs [1], OP_MOVE, reg, srcreg);
+               EMIT_NEW_ICONST (cfg, iargs [2], size);
+
+               mono_emit_method_call (cfg, mini_get_memcpy_method (), iargs, NULL);
+               return;
+       }
+
        g_assert (align > 0);
 
 MONO_DISABLE_WARNING(4127) /* conditional expression is constant */