[interp] fix code length for JitInfo (mono/mono#17538)
authorBernhard Urban-Forster <lewurm@gmail.com>
Thu, 24 Oct 2019 18:13:27 +0000 (20:13 +0200)
committerGitHub <noreply@github.com>
Thu, 24 Oct 2019 18:13:27 +0000 (20:13 +0200)
* [interp] fix code length for JitInfo

* fix c++ build

Commit migrated from https://github.com/mono/mono/commit/25b53a642b4756332e5cdb932ed09521da3418df

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

index 3cc82d2..de88b7b 100644 (file)
@@ -7293,8 +7293,9 @@ generate (MonoMethod *method, MonoMethodHeader *header, InterpMethod *rtm, MonoG
        if (td->max_stack_height > header->max_stack * 3 && header->max_stack > 16)
                g_warning ("Excessive stack space usage for method %s, %d/%d", method->name, td->max_stack_height, header->max_stack);
 
-       int code_len;
-       code_len = td->new_code_end - td->new_code;
+       int code_len_u8, code_len_u16;
+       code_len_u8 = (guint8 *) td->new_code_end - (guint8 *) td->new_code;
+       code_len_u16 = td->new_code_end - td->new_code;
 
        rtm->clauses = (MonoExceptionClause*)mono_domain_alloc0 (domain, header->num_clauses * sizeof (MonoExceptionClause));
        memcpy (rtm->clauses, header->clauses, header->num_clauses * sizeof(MonoExceptionClause));
@@ -7306,11 +7307,11 @@ generate (MonoMethod *method, MonoMethodHeader *header, InterpMethod *rtm, MonoG
                int end_off = c->try_offset + c->try_len;
                c->try_offset = get_in_offset (td, c->try_offset);
                c->try_len = find_in_offset (td, end_off) - c->try_offset;
-               g_assert ((c->try_offset + c->try_len) < code_len);
+               g_assert ((c->try_offset + c->try_len) < code_len_u16);
                end_off = c->handler_offset + c->handler_len;
                c->handler_offset = get_in_offset (td, c->handler_offset);
                c->handler_len = find_in_offset (td, end_off) - c->handler_offset;
-               g_assert (c->handler_len >= 0 && (c->handler_offset + c->handler_len) <= code_len);
+               g_assert (c->handler_len >= 0 && (c->handler_offset + c->handler_len) <= code_len_u16);
                if (c->flags & MONO_EXCEPTION_CLAUSE_FILTER)
                        c->data.filter_offset = get_in_offset (td, c->data.filter_offset);
        }
@@ -7332,7 +7333,7 @@ generate (MonoMethod *method, MonoMethodHeader *header, InterpMethod *rtm, MonoG
        jinfo = (MonoJitInfo *)mono_domain_alloc0 (domain, jinfo_len);
        jinfo->is_interp = 1;
        rtm->jinfo = jinfo;
-       mono_jit_info_init (jinfo, method, (guint8*)rtm->code, code_len, (MonoJitInfoFlags)0, header->num_clauses, 0);
+       mono_jit_info_init (jinfo, method, (guint8*)rtm->code, code_len_u8, (MonoJitInfoFlags)0, header->num_clauses, 0);
        for (i = 0; i < jinfo->num_clauses; ++i) {
                MonoJitExceptionInfo *ei = &jinfo->clauses [i];
                MonoExceptionClause *c = rtm->clauses + i;