diff --git a/src/ircode.c b/src/ircode.c index 9f71d8e8dd28c..648b954449aa2 100644 --- a/src/ircode.c +++ b/src/ircode.c @@ -110,14 +110,14 @@ static void jl_encode_as_indexed_root(jl_ircode_state *s, jl_value_t *v) write_uint8(s->s, TAG_RELOC_METHODROOT); write_uint64(s->s, rr.key); } - if (id < 256) { + if (id <= UINT8_MAX) { write_uint8(s->s, TAG_METHODROOT); write_uint8(s->s, id); } else { - assert(id <= UINT16_MAX); + assert(id <= UINT32_MAX); write_uint8(s->s, TAG_LONG_METHODROOT); - write_uint16(s->s, id); + write_uint32(s->s, id); } } @@ -646,11 +646,17 @@ static jl_value_t *jl_decode_value(jl_ircode_state *s) JL_GC_DISABLED key = read_uint64(s->s); tag = read_uint8(s->s); assert(tag == TAG_METHODROOT || tag == TAG_LONG_METHODROOT); - return lookup_root(s->method, key, tag == TAG_METHODROOT ? read_uint8(s->s) : read_uint16(s->s)); + int index = -1; + if (tag == TAG_METHODROOT) + index = read_uint8(s->s); + else if (tag == TAG_LONG_METHODROOT) + index = read_uint32(s->s); + assert(index >= 0); + return lookup_root(s->method, key, index); case TAG_METHODROOT: return lookup_root(s->method, 0, read_uint8(s->s)); case TAG_LONG_METHODROOT: - return lookup_root(s->method, 0, read_uint16(s->s)); + return lookup_root(s->method, 0, read_uint32(s->s)); case TAG_SVEC: JL_FALLTHROUGH; case TAG_LONG_SVEC: return jl_decode_value_svec(s, tag); case TAG_COMMONSYM: