Skip to content

Commit

Permalink
Remove export_small_typeof
Browse files Browse the repository at this point in the history
I think this might have been part of a scheme to avoid an extra
indirection when this symbol is exposed to the linker. We have a similar
technique used for JIT'd modules, but I'm not sure how it's supposed
to work here between libjulia and libjulia-internal.

On Windows, this is broken for embedding currently, and on Linux this
function was just copying from the `small_typeof` in libjulia to a seem-
ingly unused copy of the symbol in libjulia-internal.

For now, this removes the special machinery and replaces it with a single
copy of the data. If we'd like to optimize this in the future, we might
want to use the existing "ijl_" vs. "jl_" pattern
  • Loading branch information
topolarity committed Aug 15, 2023
1 parent 80ac03b commit 1786bef
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 16 deletions.
14 changes: 0 additions & 14 deletions src/jltypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ extern "C" {
#endif

_Atomic(jl_value_t*) cmpswap_names JL_GLOBALLY_ROOTED;
jl_datatype_t *small_typeof[(jl_max_tags << 4) / sizeof(*small_typeof)]; // 16-bit aligned, like the GC

// compute empirical max-probe for a given size
#define max_probe(size) ((size) <= 1024 ? 16 : (size) >> 6)
Expand Down Expand Up @@ -2528,17 +2527,6 @@ static jl_tvar_t *tvar(const char *name)
(jl_value_t*)jl_any_type);
}

void export_small_typeof(void)
{
void *copy;
#ifdef _OS_WINDOWS_
jl_dlsym(jl_libjulia_handle, "small_typeof", &copy, 1);
#else
jl_dlsym(jl_libjulia_internal_handle, "small_typeof", &copy, 1);
#endif
memcpy(copy, &small_typeof, sizeof(small_typeof));
}

#define XX(name) \
small_typeof[(jl_##name##_tag << 4) / sizeof(*small_typeof)] = jl_##name##_type; \
jl_##name##_type->smalltag = jl_##name##_tag;
Expand Down Expand Up @@ -3360,7 +3348,6 @@ void jl_init_types(void) JL_GC_DISABLED

// override the preferred layout for a couple types
jl_lineinfonode_type->name->mayinlinealloc = 0; // FIXME: assumed to be a pointer by codegen
export_small_typeof();
}

static jl_value_t *core(const char *name)
Expand Down Expand Up @@ -3441,7 +3428,6 @@ void post_boot_hooks(void)
}
}
}
export_small_typeof();
}

void post_image_load_hooks(void) {
Expand Down
2 changes: 0 additions & 2 deletions src/staticdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -2838,7 +2838,6 @@ JL_DLLEXPORT void jl_set_sysimg_so(void *handle)
#endif

extern void rebuild_image_blob_tree(void);
extern void export_small_typeof(void);

static void jl_restore_system_image_from_stream_(ios_t *f, jl_image_t *image, jl_array_t *depmods, uint64_t checksum,
/* outputs */ jl_array_t **restored, jl_array_t **init_order,
Expand Down Expand Up @@ -2917,7 +2916,6 @@ static void jl_restore_system_image_from_stream_(ios_t *f, jl_image_t *image, jl
small_typeof[(jl_##name##_tag << 4) / sizeof(*small_typeof)] = jl_##name##_type;
JL_SMALL_TYPEOF(XX)
#undef XX
export_small_typeof();
jl_global_roots_table = (jl_array_t*)jl_read_value(&s);
// set typeof extra-special values now that we have the type set by tags above
jl_astaggedvalue(jl_nothing)->header = (uintptr_t)jl_nothing_type | jl_astaggedvalue(jl_nothing)->header;
Expand Down

0 comments on commit 1786bef

Please sign in to comment.