Skip to content

Commit

Permalink
Make size and offset in jl_fielddesc_t 32bit length
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyichao committed Sep 16, 2015
1 parent fee7aff commit f4ffde6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f4ffde6

Please sign in to comment.