From f4ffde64fe950d5ec102817e2fa84219f872c349 Mon Sep 17 00:00:00 2001 From: Yichao Yu Date: Fri, 26 Jun 2015 22:04:46 -0400 Subject: [PATCH] Make size and offset in jl_fielddesc_t 32bit length --- src/alloc.c | 5 +++-- src/julia.h | 10 +++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/alloc.c b/src/alloc.c index 522bbba61d5d0..2ff8912660391 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -577,11 +577,12 @@ void jl_compute_field_offsets(jl_datatype_t *st) if (al > alignm) alignm = al; } - if (__unlikely(sz > JL_FIELD_MAX_OFFSET)) - jl_throw(jl_overflow_exception); st->fields[i].offset = sz; st->fields[i].size = fsz; sz += fsz; + if (__unlikely(sz >= JL_FIELD_MAX_SIZE)) { + jl_throw(jl_overflow_exception); + } } st->alignment = alignm; st->size = LLT_ALIGN(sz, alignm); diff --git a/src/julia.h b/src/julia.h index bcfb3b1df71bf..b2d65cc301881 100644 --- a/src/julia.h +++ b/src/julia.h @@ -253,13 +253,13 @@ typedef struct { } jl_uniontype_t; typedef struct { - uint16_t offset; // offset relative to data start, excluding type tag - uint16_t size:15; - uint16_t isptr:1; + uint32_t offset; // offset relative to data start, excluding type tag + uint32_t size:31; + uint32_t isptr:1; } jl_fielddesc_t; -#define JL_FIELD_MAX_OFFSET ((1ul << 16) - 1ul) -#define JL_FIELD_MAX_SIZE ((1ul << 15) - 1ul) +// For both field size and total size +#define JL_FIELD_MAX_SIZE ((((uint32_t)1) << 31) - 1) typedef struct _jl_datatype_t { JL_DATA_TYPE