Skip to content

Commit

Permalink
Fix object_id with padding
Browse files Browse the repository at this point in the history
Forgotten in the padding fix : immutables with haspadding fields.
  • Loading branch information
carnaval committed Aug 3, 2015
1 parent e22233e commit 4510e04
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -1102,11 +1102,10 @@ static uptrint_t bits_hash(void *b, size_t sz)
}
}

DLLEXPORT uptrint_t jl_object_id(jl_value_t *v)
static uptrint_t jl_object_id_(jl_value_t *tv, jl_value_t *v)
{
if (jl_is_symbol(v))
if (tv == (jl_value_t*)jl_sym_type)
return ((jl_sym_t*)v)->hash;
jl_value_t *tv = (jl_value_t*)jl_typeof(v);
if (tv == (jl_value_t*)jl_simplevector_type) {
uptrint_t h = 0;
size_t l = jl_svec_len(v);
Expand Down Expand Up @@ -1148,13 +1147,23 @@ DLLEXPORT uptrint_t jl_object_id(jl_value_t *v)
u = f==NULL ? 0 : jl_object_id(f);
}
else {
u = bits_hash(vo, dt->fields[f].size);
jl_datatype_t *fieldtype = (jl_datatype_t*)jl_svecref(dt->types, f);
assert(jl_is_datatype(fieldtype) && !fieldtype->abstract && !fieldtype->mutabl);
if (fieldtype->haspadding)
u = jl_object_id_((jl_value_t*)fieldtype, (jl_value_t*)vo);
else
u = bits_hash(vo, dt->fields[f].size);
}
h = bitmix(h, u);
}
return h;
}

DLLEXPORT uptrint_t jl_object_id(jl_value_t *v)
{
return jl_object_id_(jl_typeof(v), v);
}

// init -----------------------------------------------------------------------

static void add_builtin(const char *name, jl_value_t *v)
Expand Down

0 comments on commit 4510e04

Please sign in to comment.