Skip to content

Commit

Permalink
some renaming and fix overloads changed by merge
Browse files Browse the repository at this point in the history
rename jl_typetag_t => jl_taggedvalue_t
rename jl_typetagof => jl_astaggedvalue
  • Loading branch information
JeffBezanson committed Mar 20, 2015
1 parent 65cfde9 commit cbf9da5
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 58 deletions.
6 changes: 3 additions & 3 deletions src/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,20 +495,20 @@ static jl_sym_t *mk_symbol(const char *str)
#endif
jl_sym_t *sym;
size_t len = strlen(str);
size_t nb = (sizeof(jl_typetag_t)+sizeof(jl_sym_t)+len+1+7)&-8;
size_t nb = (sizeof(jl_taggedvalue_t)+sizeof(jl_sym_t)+len+1+7)&-8;

if (nb >= SYM_POOL_SIZE) {
jl_exceptionf(jl_argumenterror_type, "Symbol length exceeds maximum length");
}

#ifdef MEMDEBUG
sym = (jl_sym_t*)((jl_typetag_t*)malloc(nb))->value;
sym = (jl_sym_t*)((jl_taggedvalue_t*)malloc(nb))->value;
#else
if (sym_pool == NULL || pool_ptr+nb > sym_pool+SYM_POOL_SIZE) {
sym_pool = (char*)malloc(SYM_POOL_SIZE);
pool_ptr = sym_pool;
}
sym = (jl_sym_t*)((jl_typetag_t*)malloc(nb))->value;
sym = (jl_sym_t*)((jl_taggedvalue_t*)malloc(nb))->value;
pool_ptr += nb;
#endif
jl_set_typeof(sym, jl_sym_type);
Expand Down
10 changes: 5 additions & 5 deletions src/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
extern "C" {
#endif

#define JL_ARRAY_ALIGN(jl_value, nbytes) (LLT_ALIGN((jl_value)+sizeof(jl_typetag_t), nbytes)-sizeof(jl_typetag_t))
#define JL_ARRAY_ALIGN(jl_value, nbytes) (LLT_ALIGN((jl_value)+sizeof(jl_taggedvalue_t), nbytes)-sizeof(jl_taggedvalue_t))


// array constructors ---------------------------------------------------------
Expand Down Expand Up @@ -101,7 +101,7 @@ static jl_array_t *_new_array_(jl_value_t *atype, uint32_t ndims, size_t *dims,
memset(data, 0, tot);
JL_GC_POP();
}
a->pooled = tsz + sizeof(jl_typetag_t) <= 2048;
a->pooled = tsz + sizeof(jl_taggedvalue_t) <= 2048;

a->data = data;
if (elsz == 1) ((char*)data)[tot-1] = '\0';
Expand Down Expand Up @@ -153,7 +153,7 @@ jl_array_t *jl_reshape_array(jl_value_t *atype, jl_array_t *data, jl_tuple_t *di
int tsz = JL_ARRAY_ALIGN(sizeof(jl_array_t) + ndimwords*sizeof(size_t) + sizeof(void*), 16);
a = (jl_array_t*)allocobj(tsz);
jl_set_typeof(a, atype);
a->pooled = tsz + sizeof(jl_typetag_t) <= 2048;
a->pooled = tsz + sizeof(jl_taggedvalue_t) <= 2048;
a->ndims = ndims;
a->offset = 0;
a->data = NULL;
Expand Down Expand Up @@ -221,7 +221,7 @@ jl_array_t *jl_ptr_to_array_1d(jl_value_t *atype, void *data, size_t nel,
int tsz = JL_ARRAY_ALIGN(sizeof(jl_array_t) + ndimwords*sizeof(size_t), 16);
a = (jl_array_t*)allocobj(tsz);
jl_set_typeof(a, atype);
a->pooled = tsz + sizeof(jl_typetag_t) <= 2048;
a->pooled = tsz + sizeof(jl_taggedvalue_t) <= 2048;
a->data = data;
#ifdef STORE_ARRAY_LEN
a->length = nel;
Expand Down Expand Up @@ -272,7 +272,7 @@ jl_array_t *jl_ptr_to_array(jl_value_t *atype, void *data, jl_tuple_t *dims,
int tsz = JL_ARRAY_ALIGN(sizeof(jl_array_t) + ndimwords*sizeof(size_t), 16);
a = (jl_array_t*)allocobj(tsz);
jl_set_typeof(a, atype);
a->pooled = tsz + sizeof(jl_typetag_t) <= 2048;
a->pooled = tsz + sizeof(jl_taggedvalue_t) <= 2048;
a->data = data;
#ifdef STORE_ARRAY_LEN
a->length = nel;
Expand Down
4 changes: 2 additions & 2 deletions src/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -1291,8 +1291,8 @@ size_t jl_static_show_x(JL_STREAM *out, jl_value_t *v, int depth)
else if (jl_typeof(v) == NULL) {
n += jl_printf(out, "<?::#null>");
}
else if (jl_typetagof(v)->type_bits < 4096U) {
n += jl_printf(out, "<?::#%d>", (int)jl_typetagof(v)->type_bits);
else if (jl_astaggedvalue(v)->type_bits < 4096U) {
n += jl_printf(out, "<?::#%d>", (int)jl_astaggedvalue(v)->type_bits);
}
else if (jl_is_lambda_info(v)) {
jl_lambda_info_t *li = (jl_lambda_info_t*)v;
Expand Down
4 changes: 2 additions & 2 deletions src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ static Value *emit_nthptr_recast(Value *v, Value *idx, MDNode *tbaa, Type *ptype

static Value *emit_typeptr_addr(Value *p)
{
ssize_t offset = offsetof(jl_typetag_t,type) - offsetof(jl_typetag_t,value);
ssize_t offset = offsetof(jl_taggedvalue_t,type) - offsetof(jl_taggedvalue_t,value);
offset /= (signed)sizeof(jl_value_t*); // important: division must be signed
return emit_nthptr_addr(p, offset);
}
Expand Down Expand Up @@ -1152,7 +1152,7 @@ static Value *emit_tuplelen(Value *t,jl_value_t *jt)
return builder.CreateLShr(builder.CreatePtrToInt(lenbits, T_int64),
ConstantInt::get(T_int32, 52));
#else
return emit_nthptr_recast(t, offsetof(jl_tuple_t,length)/sizeof(jl_value_t*), tbaa_tuplelen, T_psize);
return emit_nthptr_recast(t, (ssize_t)(offsetof(jl_tuple_t,length)/sizeof(jl_value_t*)), tbaa_tuplelen, T_psize);
#endif
}
else { //unboxed
Expand Down
6 changes: 3 additions & 3 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2026,7 +2026,7 @@ static Value *emit_known_call(jl_value_t *ff, jl_value_t **args, size_t nargs,
Value *theF = emit_expr(args[2],ctx);
Value *theFptr = emit_nthptr_recast(
theF,
offsetof(jl_function_t,fptr)/sizeof(void*),
(ssize_t)(offsetof(jl_function_t,fptr)/sizeof(void*)),
tbaa_func,
jl_pfptr_llvmt);
Value *nva = emit_n_varargs(ctx);
Expand Down Expand Up @@ -2632,7 +2632,7 @@ static Value *emit_call(jl_value_t **args, size_t arglen, jl_codectx_t *ctx, jl_
#endif
// extract pieces of the function object
// TODO: try extractvalue instead
theFptr = emit_nthptr_recast(theFunc, offsetof(jl_function_t,fptr)/sizeof(void*), tbaa_func, jl_pfptr_llvmt);
theFptr = emit_nthptr_recast(theFunc, (ssize_t)(offsetof(jl_function_t,fptr)/sizeof(void*)), tbaa_func, jl_pfptr_llvmt);
theF = theFunc;
}
else {
Expand Down Expand Up @@ -2666,7 +2666,7 @@ static Value *emit_call(jl_value_t **args, size_t arglen, jl_codectx_t *ctx, jl_
myargs = builder.CreateGEP(ctx->argTemp,
ConstantInt::get(T_size, argStart+1+ctx->argSpaceOffs));
}
theFptr = emit_nthptr_recast(theFunc, offsetof(jl_function_t,fptr)/sizeof(void*), tbaa_func, jl_pfptr_llvmt);
theFptr = emit_nthptr_recast(theFunc, (ssize_t)(offsetof(jl_function_t,fptr)/sizeof(void*)), tbaa_func, jl_pfptr_llvmt);
Value *r1 = builder.CreateCall3(prepare_call(theFptr), theFunc, myargs,
ConstantInt::get(T_int32,nargs));
builder.CreateBr(mergeBB1);
Expand Down
6 changes: 3 additions & 3 deletions src/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ static jl_value_t *jl_deserialize_datatype(ios_t *s, int pos, jl_value_t **loc)
arraylist_push(&flagref_list, (void*)(uptrint_t)pos);
if (has_instance) {
arraylist_push(&flagref_list, dt);
arraylist_push(&flagref_list, &jl_typetagof(dt->instance)->type);
arraylist_push(&flagref_list, &jl_astaggedvalue(dt->instance)->type);
arraylist_push(&flagref_list, (void*)(uptrint_t)-1);
}
}
Expand Down Expand Up @@ -1074,7 +1074,7 @@ static jl_value_t *jl_deserialize_value_(ios_t *s, jl_value_t *vtag, jl_value_t
}
}
if (mode == MODE_MODULE) {
aty = jl_deserialize_value(s, &jl_typetagof(a)->type);
aty = jl_deserialize_value(s, &jl_astaggedvalue(a)->type);
assert(aty == jl_typeof(a));
}
return (jl_value_t*)a;
Expand Down Expand Up @@ -1311,7 +1311,7 @@ static jl_value_t *jl_deserialize_value_(ios_t *s, jl_value_t *vtag, jl_value_t
}
// TODO: put WeakRefs on the weak_refs list
if (mode == MODE_MODULE) {
dt = (jl_datatype_t*)jl_deserialize_value(s, &jl_typetagof(v)->type);
dt = (jl_datatype_t*)jl_deserialize_value(s, &jl_astaggedvalue(v)->type);
assert((jl_value_t*)dt == jl_typeof(v));
}
return v;
Expand Down
46 changes: 23 additions & 23 deletions src/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ static inline void objprofile_count(void* ty, int old, int sz)

//static inline void gc_setmark_other(jl_value_t *v, int mark_mode) // unused function
//{
// jl_typetag_t *o = jl_typetagof(v);
// jl_taggedvalue_t *o = jl_astaggedvalue(v);
// _gc_setmark(o, mark_mode);
// verify_val(o);
//}
Expand Down Expand Up @@ -418,8 +418,8 @@ static inline int gc_setmark_pool(void *o, int mark_mode)

static inline int gc_setmark(jl_value_t *v, int sz, int mark_mode)
{
jl_typetag_t *o = jl_typetagof(v);
sz += sizeof(jl_typetag_t);
jl_taggedvalue_t *o = jl_astaggedvalue(v);
sz += sizeof(jl_taggedvalue_t);
#ifdef MEMDEBUG
return gc_setmark_big(o, mark_mode);
#endif
Expand Down Expand Up @@ -610,7 +610,7 @@ void *jl_gc_managed_realloc(void *d, size_t sz, size_t oldsz, int isaligned, jl_
{
maybe_collect();

if (gc_bits(jl_typetagof(owner)) == GC_MARKED) {
if (gc_bits(jl_astaggedvalue(owner)) == GC_MARKED) {
perm_scanned_bytes += sz - oldsz;
live_bytes += sz - oldsz;
}
Expand Down Expand Up @@ -686,9 +686,9 @@ static void sweep_weak_refs(void)
return;
do {
wr = (jl_weakref_t*)lst[n];
if (gc_marked(jl_typetagof(wr))) {
if (gc_marked(jl_astaggedvalue(wr))) {
// weakref itself is alive
if (!gc_marked(jl_typetagof(wr->value)))
if (!gc_marked(jl_astaggedvalue(wr->value)))
wr->value = (jl_value_t*)jl_nothing;
n++;
}
Expand Down Expand Up @@ -942,7 +942,7 @@ static void sweep_malloced_arrays(void)
mallocarray_t **pma = &mallocarrays;
while (ma != NULL) {
mallocarray_t *nxt = ma->next;
if (gc_marked(jl_typetagof(ma->a))) {
if (gc_marked(jl_astaggedvalue(ma->a))) {
pma = &ma->next;
}
else {
Expand Down Expand Up @@ -1361,7 +1361,7 @@ void reset_remset(void)

DLLEXPORT void gc_queue_root(jl_value_t *ptr)
{
jl_typetag_t *o = jl_typetagof(ptr);
jl_taggedvalue_t *o = jl_astaggedvalue(ptr);
assert(gc_bits(o) != GC_QUEUED);
gc_bits(o) = GC_QUEUED;
arraylist_push(remset, ptr);
Expand All @@ -1379,7 +1379,7 @@ static int push_root(jl_value_t *v, int d, int);
static inline int gc_push_root(void *v, int d) // v isa jl_value_t*
{
assert(v != NULL);
jl_typetag_t* o = jl_typetagof(v);
jl_taggedvalue_t* o = jl_astaggedvalue(v);
verify_val(o);
int bits = gc_bits(o);
if (!gc_marked(o)) {
Expand All @@ -1391,7 +1391,7 @@ static inline int gc_push_root(void *v, int d) // v isa jl_value_t*
void jl_gc_setmark(jl_value_t *v) // TODO rename this as it is misleading now
{
// int64_t s = perm_scanned_bytes;
jl_typetag_t *o = jl_typetagof(v);
jl_taggedvalue_t *o = jl_astaggedvalue(v);
if (!gc_marked(o)) {
// objprofile_count(jl_typeof(v), 1, 16);
#ifdef MEMDEBUG
Expand Down Expand Up @@ -1436,7 +1436,7 @@ NOINLINE static int gc_mark_module(jl_module_t *m, int d)
for(i=1; i < m->bindings.size; i+=2) {
if (table[i] != HT_NOTFOUND) {
jl_binding_t *b = (jl_binding_t*)table[i];
gc_setmark_buf(b, gc_bits(jl_typetagof(m)));
gc_setmark_buf(b, gc_bits(jl_astaggedvalue(m)));
#ifdef GC_VERIFY
void* vb = gc_val_buf(b);
verify_parent1("module", m, &vb, "binding_buff");
Expand Down Expand Up @@ -1468,7 +1468,7 @@ static void gc_mark_task_stack(jl_task_t *ta, int d)
{
if (ta->stkbuf != NULL || ta == jl_current_task) {
if (ta->stkbuf != NULL) {
gc_setmark_buf(ta->stkbuf, gc_bits(jl_typetagof(ta)));
gc_setmark_buf(ta->stkbuf, gc_bits(jl_astaggedvalue(ta)));
}
#ifdef COPY_STACKS
ptrint_t offset;
Expand Down Expand Up @@ -1558,7 +1558,7 @@ static int push_root(jl_value_t *v, int d, int bits)
}
else if (((jl_datatype_t*)(vt))->name == jl_array_typename) {
jl_array_t *a = (jl_array_t*)v;
jl_typetag_t *o = jl_typetagof(v);
jl_taggedvalue_t *o = jl_astaggedvalue(v);
int todo = !(bits & GC_MARKED);
if (a->pooled)
#ifdef MEMDEBUG
Expand Down Expand Up @@ -1693,10 +1693,10 @@ static void visit_mark_stack_inc(int mark_mode)
{
while(mark_sp > 0 && !should_timeout()) {
jl_value_t* v = mark_stack[--mark_sp];
assert(gc_bits(jl_typetagof(v)) == GC_QUEUED ||
gc_bits(jl_typetagof(v)) == GC_MARKED ||
gc_bits(jl_typetagof(v)) == GC_MARKED_NOESC);
push_root(v, 0, gc_bits(jl_typetagof(v)));
assert(gc_bits(jl_astaggedvalue(v)) == GC_QUEUED ||
gc_bits(jl_astaggedvalue(v)) == GC_MARKED ||
gc_bits(jl_astaggedvalue(v)) == GC_MARKED_NOESC);
push_root(v, 0, gc_bits(jl_astaggedvalue(v)));
}
}

Expand Down Expand Up @@ -1777,9 +1777,9 @@ static void post_mark(arraylist_t *list, int dryrun)
for(size_t i=0; i < list->len; i+=2) {
jl_value_t *v = (jl_value_t*)list->items[i];
jl_value_t *fin = (jl_value_t*)list->items[i+1];
int isfreed = !gc_marked(jl_typetagof(v));
int isfreed = !gc_marked(jl_astaggedvalue(v));
gc_push_root(fin, 0);
int isold = list == &finalizer_list && gc_bits(jl_typetagof(v)) == GC_MARKED && gc_bits(jl_typetagof(fin)) == GC_MARKED;
int isold = list == &finalizer_list && gc_bits(jl_astaggedvalue(v)) == GC_MARKED && gc_bits(jl_astaggedvalue(fin)) == GC_MARKED;
if (!dryrun && (isfreed || isold)) {
// remove from this list
if (i < list->len - 2) {
Expand Down Expand Up @@ -2086,7 +2086,7 @@ void jl_gc_collect(int full)
for(int i = 0; i < last_remset->len; i++) {
jl_value_t *item = (jl_value_t*)last_remset->items[i];
objprofile_count(jl_typeof(item), 2, 0);
gc_bits(jl_typetagof(item)) = GC_MARKED;
gc_bits(jl_astaggedvalue(item)) = GC_MARKED;
}
for (int i = 0; i < rem_bindings.len; i++) {
void *ptr = rem_bindings.items[i];
Expand Down Expand Up @@ -2206,7 +2206,7 @@ void jl_gc_collect(int full)
// so that we don't trigger the barrier again on them.
if (sweep_mask == GC_MARKED_NOESC) {
for (int i = 0; i < remset->len; i++) {
gc_bits(jl_typetagof(remset->items[i])) = GC_QUEUED;
gc_bits(jl_astaggedvalue(remset->items[i])) = GC_QUEUED;
}
for (int i = 0; i < rem_bindings.len; i++) {
void *ptr = rem_bindings.items[i];
Expand Down Expand Up @@ -2309,7 +2309,7 @@ void *reallocb(void *b, size_t sz)
}
}

#define jl_valueof(v) (((jl_typetag_t*)(v))->value)
#define jl_valueof(v) (((jl_taggedvalue_t*)(v))->value)

DLLEXPORT jl_value_t *allocobj(size_t sz)
{
Expand Down Expand Up @@ -2530,7 +2530,7 @@ static void big_obj_stats(void)

mallocarray_t *ma = mallocarrays;
while (ma != NULL) {
if (gc_marked(jl_typetagof(ma->a))) {
if (gc_marked(jl_astaggedvalue(ma->a))) {
nused++;
nbytes += array_nbytes(ma->a);
}
Expand Down
6 changes: 3 additions & 3 deletions src/jlapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,9 @@ DLLEXPORT const char* jl_ver_string(void)
}

// Create function versions of some useful macros
#undef jl_typetagof
DLLEXPORT jl_typetag_t *jl_typetagof(jl_value_t *v) {
return jl_typetagof__MACRO(v);
#undef jl_astaggedvalue
DLLEXPORT jl_taggedvalue_t *jl_astaggedvalue(jl_value_t *v) {
return jl_astaggedvalue__MACRO(v);
}

#undef jl_typeof
Expand Down
Loading

0 comments on commit cbf9da5

Please sign in to comment.