Skip to content

Commit

Permalink
staticdata: avoid needing unaligned loads, support 64-bit images (#46683
Browse files Browse the repository at this point in the history
)

No functional changes intended here.
  • Loading branch information
vtjnash authored Sep 22, 2022
1 parent 15f8fad commit 45623a8
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 83 deletions.
11 changes: 3 additions & 8 deletions src/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,6 @@ static jl_typename_t *jl_idtable_typename = NULL;
static jl_value_t *jl_bigint_type = NULL;
static int gmp_limb_size = 0;

static void write_uint64(ios_t *s, uint64_t i) JL_NOTSAFEPOINT
{
ios_write(s, (char*)&i, 8);
}

static void write_float64(ios_t *s, double x) JL_NOTSAFEPOINT
{
write_uint64(s, *((uint64_t*)&x));
Expand Down Expand Up @@ -1049,7 +1044,7 @@ static void jl_serialize_value_(jl_serializer_state *s, jl_value_t *v, int as_li
}
else {
write_uint8(s->s, TAG_INT64);
write_int64(s->s, *(int64_t*)data);
write_uint64(s->s, *(int64_t*)data);
}
}
else if (jl_typeis(v, jl_int32_type)) {
Expand Down Expand Up @@ -1626,7 +1621,7 @@ static int64_t write_dependency_list(ios_t *s, jl_array_t **udepsp)
ios_seek(s, initial_pos);
write_uint64(s, pos - initial_pos);
ios_seek(s, pos);
write_int64(s, 0);
write_uint64(s, 0);
}
return pos;
}
Expand Down Expand Up @@ -2939,7 +2934,7 @@ JL_DLLEXPORT int jl_save_incremental(const char *fname, jl_array_t *worklist)
// Go back and update the source-text position to point to the current position
int64_t posfile = ios_pos(&f);
ios_seek(&f, srctextpos);
write_int64(&f, posfile);
write_uint64(&f, posfile);
ios_seek_end(&f);
// Each source-text file is written as
// int32: length of abspath
Expand Down
4 changes: 2 additions & 2 deletions src/ircode.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ static void jl_encode_as_indexed_root(jl_ircode_state *s, jl_value_t *v)
assert(id >= 0);
if (rr.key) {
write_uint8(s->s, TAG_RELOC_METHODROOT);
write_int64(s->s, rr.key);
write_uint64(s->s, rr.key);
}
if (id < 256) {
write_uint8(s->s, TAG_METHODROOT);
Expand Down Expand Up @@ -283,7 +283,7 @@ static void jl_encode_value_(jl_ircode_state *s, jl_value_t *v, int as_literal)
}
else {
write_uint8(s->s, TAG_INT64);
write_int64(s->s, *(int64_t*)data);
write_uint64(s->s, *(int64_t*)data);
}
}
else if (jl_typeis(v, jl_int32_type)) {
Expand Down
15 changes: 14 additions & 1 deletion src/serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static inline uint64_t read_uint64(ios_t *s) JL_NOTSAFEPOINT
return x;
}

static inline void write_int64(ios_t *s, int64_t i) JL_NOTSAFEPOINT
static inline void write_uint64(ios_t *s, uint64_t i) JL_NOTSAFEPOINT
{
ios_write(s, (char*)&i, 8);
}
Expand Down Expand Up @@ -121,6 +121,19 @@ static inline uint32_t read_uint32(ios_t *s) JL_NOTSAFEPOINT
return x;
}

#ifdef _P64
#define write_uint(s, i) write_uint64(s, i)
#else
#define write_uint(s, i) write_uint32(s, i)
#endif

#ifdef _P64
#define read_uint(s) read_uint64(s)
#else
#define read_uint(s) read_uint32(s)
#endif


void *jl_lookup_ser_tag(jl_value_t *v);
void *jl_lookup_common_symbol(jl_value_t *v);
jl_value_t *jl_deser_tag(uint8_t tag);
Expand Down
Loading

0 comments on commit 45623a8

Please sign in to comment.