Skip to content

Commit 5c83754

Browse files
committed
Adding a few comments; Moving some functions to be closer together
1 parent 9469eb9 commit 5c83754

File tree

3 files changed

+94
-289
lines changed

3 files changed

+94
-289
lines changed

src/gc-common.c

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -709,76 +709,6 @@ JL_DLLEXPORT void jl_throw_out_of_memory_error(void)
709709
jl_throw(jl_memory_exception);
710710
}
711711

712-
size_t jl_genericmemory_nbytes(jl_genericmemory_t *m) JL_NOTSAFEPOINT
713-
{
714-
const jl_datatype_layout_t *layout = ((jl_datatype_t*)jl_typetagof(m))->layout;
715-
size_t sz = layout->size * m->length;
716-
if (layout->flags.arrayelem_isunion)
717-
// account for isbits Union array selector bytes
718-
sz += m->length;
719-
return sz;
720-
}
721-
722-
// tracking Memorys with malloc'd storage
723-
void jl_gc_track_malloced_genericmemory(jl_ptls_t ptls, jl_genericmemory_t *m, int isaligned){
724-
// This is **NOT** a GC safe point.
725-
mallocmemory_t *ma;
726-
if (ptls->gc_tls.heap.mafreelist == NULL) {
727-
ma = (mallocmemory_t*)malloc_s(sizeof(mallocmemory_t));
728-
}
729-
else {
730-
ma = ptls->gc_tls.heap.mafreelist;
731-
ptls->gc_tls.heap.mafreelist = ma->next;
732-
}
733-
ma->a = (jl_genericmemory_t*)((uintptr_t)m | !!isaligned);
734-
ma->next = ptls->gc_tls.heap.mallocarrays;
735-
ptls->gc_tls.heap.mallocarrays = ma;
736-
}
737-
738-
int gc_logging_enabled = 0;
739-
740-
JL_DLLEXPORT void jl_enable_gc_logging(int enable) {
741-
gc_logging_enabled = enable;
742-
}
743-
744-
JL_DLLEXPORT int jl_is_gc_logging_enabled(void) {
745-
return gc_logging_enabled;
746-
}
747-
748-
// gc-debug common functions
749-
// ---
750-
751-
int gc_slot_to_fieldidx(void *obj, void *slot, jl_datatype_t *vt) JL_NOTSAFEPOINT
752-
{
753-
int nf = (int)jl_datatype_nfields(vt);
754-
for (int i = 1; i < nf; i++) {
755-
if (slot < (void*)((char*)obj + jl_field_offset(vt, i)))
756-
return i - 1;
757-
}
758-
return nf - 1;
759-
}
760-
761-
int gc_slot_to_arrayidx(void *obj, void *_slot) JL_NOTSAFEPOINT
762-
{
763-
char *slot = (char*)_slot;
764-
jl_datatype_t *vt = (jl_datatype_t*)jl_typeof(obj);
765-
char *start = NULL;
766-
size_t len = 0;
767-
size_t elsize = sizeof(void*);
768-
if (vt == jl_module_type) {
769-
jl_module_t *m = (jl_module_t*)obj;
770-
start = (char*)m->usings.items;
771-
len = m->usings.len;
772-
}
773-
else if (vt == jl_simplevector_type) {
774-
start = (char*)jl_svec_data(obj);
775-
len = jl_svec_len(obj);
776-
}
777-
if (slot < start || slot >= start + elsize * len)
778-
return -1;
779-
return (slot - start) / elsize;
780-
}
781-
782712
#ifdef __cplusplus
783713
}
784714
#endif

0 commit comments

Comments
 (0)