Skip to content

Commit c556bb9

Browse files
authored
a bit of cleanup to init/loading (#40637)
1 parent 3389940 commit c556bb9

File tree

9 files changed

+21
-46
lines changed

9 files changed

+21
-46
lines changed

cli/loader_lib.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,9 @@ JL_DLLEXPORT int jl_load_repl(int argc, char * argv[]) {
196196
#endif
197197

198198
// Load the repl entrypoint symbol and jump into it!
199-
int (*entrypoint)(int, char **) = (int (*)(int, char **))lookup_symbol(libjulia_internal, "repl_entrypoint");
199+
int (*entrypoint)(int, char **) = (int (*)(int, char **))lookup_symbol(libjulia_internal, "jl_repl_entrypoint");
200200
if (entrypoint == NULL) {
201-
jl_loader_print_stderr("ERROR: Unable to find `repl_entrypoint()` within libjulia-internal!\n");
201+
jl_loader_print_stderr("ERROR: Unable to find `jl_repl_entrypoint()` within libjulia-internal!\n");
202202
exit(1);
203203
}
204204
return entrypoint(argc, (char **)argv);

src/init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ static void restore_fp_env(void)
628628
}
629629
}
630630

631-
void _julia_init(JL_IMAGE_SEARCH rel)
631+
JL_DLLEXPORT void julia_init(JL_IMAGE_SEARCH rel)
632632
{
633633
jl_init_timing();
634634
// Make sure we finalize the tls callback before starting any threads.

src/jl_exported_funcs.inc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,8 @@
273273
XX(jl_idtable_rehash) \
274274
XX(jl_infer_thunk) \
275275
XX(jl_init_restored_modules) \
276-
XX(jl_init__threading) \
277-
XX(jl_init_with_image__threading) \
276+
XX(jl_init) \
277+
XX(jl_init_with_image) \
278278
XX(jl_install_sigint_handler) \
279279
XX(jl_instantiate_type_in_env) \
280280
XX(jl_instantiate_unionall) \
@@ -538,4 +538,5 @@
538538
XX(jl_vexceptionf) \
539539
XX(jl_vprintf) \
540540
XX(jl_wakeup_thread) \
541-
XX(jl_yield)
541+
XX(jl_yield) \
542+
XX(jl_print_backtrace)

src/jlapi.c

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -500,8 +500,7 @@ static int exec_program(char *program)
500500
jl_load(jl_main_module, program);
501501
}
502502
JL_CATCH {
503-
// TODO: It is possible for this output
504-
// to be mangled due to `jlbacktrace`
503+
// TODO: It is possible for this output to be mangled due to `jl_print_backtrace`
505504
// printing directly to STDERR_FILENO.
506505
int shown_err = 0;
507506
jl_printf(JL_STDERR, "error during bootstrap:\n");
@@ -520,32 +519,13 @@ static int exec_program(char *program)
520519
jl_static_show((JL_STREAM*)STDERR_FILENO, exc);
521520
jl_printf((JL_STREAM*)STDERR_FILENO, "\n");
522521
}
523-
jlbacktrace(); // written to STDERR_FILENO
522+
jl_print_backtrace(); // written to STDERR_FILENO
524523
jl_printf((JL_STREAM*)STDERR_FILENO, "\n");
525524
return 1;
526525
}
527526
return 0;
528527
}
529528

530-
#ifdef JL_GF_PROFILE
531-
static void print_profile(void)
532-
{
533-
size_t i;
534-
void **table = jl_base_module->bindings.table;
535-
for(i=1; i < jl_base_module->bindings.size; i+=2) {
536-
if (table[i] != HT_NOTFOUND) {
537-
jl_binding_t *b = (jl_binding_t*)table[i];
538-
if (b->value != NULL && jl_is_function(b->value) &&
539-
jl_is_gf(b->value)) {
540-
jl_printf(JL_STDERR, "%d\t%s\n",
541-
jl_gf_mtable(b->value)->ncalls,
542-
jl_gf_name(b->value)->name);
543-
}
544-
}
545-
}
546-
}
547-
#endif
548-
549529
static NOINLINE int true_main(int argc, char *argv[])
550530
{
551531
jl_set_ARGS(argc, argv);
@@ -573,9 +553,9 @@ static NOINLINE int true_main(int argc, char *argv[])
573553
}
574554
}
575555

576-
ios_puts("WARNING: Base._start not defined, falling back to economy mode repl.\n", ios_stdout);
556+
jl_printf(JL_STDOUT, "WARNING: Base._start not defined, falling back to economy mode repl.\n");
577557
if (!jl_errorexception_type)
578-
ios_puts("WARNING: jl_errorexception_type not defined; any errors will be fatal.\n", ios_stdout);
558+
jl_printf(JL_STDOUT, "WARNING: jl_errorexception_type not defined; any errors will be fatal.\n");
579559

580560
while (!ios_eof(ios_stdin)) {
581561
char *volatile line = NULL;
@@ -597,7 +577,7 @@ static NOINLINE int true_main(int argc, char *argv[])
597577
jl_printf(JL_STDOUT, "\n");
598578
free(line);
599579
line = NULL;
600-
uv_run(jl_global_event_loop(),UV_RUN_NOWAIT);
580+
jl_process_events();
601581
}
602582
JL_CATCH {
603583
if (line) {
@@ -607,7 +587,7 @@ static NOINLINE int true_main(int argc, char *argv[])
607587
jl_printf((JL_STREAM*)STDERR_FILENO, "\nparser error:\n");
608588
jl_static_show((JL_STREAM*)STDERR_FILENO, jl_current_exception());
609589
jl_printf((JL_STREAM*)STDERR_FILENO, "\n");
610-
jlbacktrace(); // written to STDERR_FILENO
590+
jl_print_backtrace(); // written to STDERR_FILENO
611591
}
612592
}
613593
return 0;
@@ -665,7 +645,7 @@ static void rr_detach_teleport(void) {
665645
#endif
666646
}
667647

668-
JL_DLLEXPORT int repl_entrypoint(int argc, char *argv[])
648+
JL_DLLEXPORT int jl_repl_entrypoint(int argc, char *argv[])
669649
{
670650
// no-op on Windows, note that the caller must have already converted
671651
// from `wchar_t` to `UTF-8` already if we're running on Windows.

src/julia.expmap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
_IO_stdin_used;
3838
__ZN4llvm23createLowerSimdLoopPassEv;
3939
LLVMExtra*;
40-
repl_entrypoint;
4140

4241
/* freebsd */
4342
environ;

src/julia.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,10 +1639,6 @@ typedef enum {
16391639
JL_IMAGE_JULIA_HOME = 1,
16401640
//JL_IMAGE_LIBJULIA = 2,
16411641
} JL_IMAGE_SEARCH;
1642-
// this helps turn threading compilation mismatches into linker errors
1643-
#define julia_init julia_init__threading
1644-
#define jl_init jl_init__threading
1645-
#define jl_init_with_image jl_init_with_image__threading
16461642

16471643
JL_DLLEXPORT const char *jl_get_libdir(void);
16481644
JL_DLLEXPORT void julia_init(JL_IMAGE_SEARCH rel);
@@ -1965,7 +1961,8 @@ JL_DLLEXPORT jl_value_t *jl_stdout_obj(void) JL_NOTSAFEPOINT;
19651961
JL_DLLEXPORT jl_value_t *jl_stderr_obj(void) JL_NOTSAFEPOINT;
19661962
JL_DLLEXPORT size_t jl_static_show(JL_STREAM *out, jl_value_t *v) JL_NOTSAFEPOINT;
19671963
JL_DLLEXPORT size_t jl_static_show_func_sig(JL_STREAM *s, jl_value_t *type) JL_NOTSAFEPOINT;
1968-
JL_DLLEXPORT void jlbacktrace(void) JL_NOTSAFEPOINT;
1964+
JL_DLLEXPORT void jl_print_backtrace(void) JL_NOTSAFEPOINT;
1965+
JL_DLLEXPORT void jlbacktrace(void) JL_NOTSAFEPOINT; // deprecated
19691966
// Mainly for debugging, use `void*` so that no type cast is needed in C++.
19701967
JL_DLLEXPORT void jl_(void *jl_value) JL_NOTSAFEPOINT;
19711968

src/julia_internal.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -676,8 +676,6 @@ void jl_init_int32_int64_cache(void);
676676

677677
void jl_teardown_codegen(void);
678678

679-
void _julia_init(JL_IMAGE_SEARCH rel);
680-
681679
void jl_set_base_ctx(char *__stk);
682680

683681
extern ssize_t jl_tls_offset;

src/stackwalk.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,11 @@ JL_DLLEXPORT void jlbacktracet(jl_task_t *t)
774774
}
775775
}
776776

777+
JL_DLLEXPORT void jl_print_backtrace(void) JL_NOTSAFEPOINT
778+
{
779+
jlbacktrace();
780+
}
781+
777782
#ifdef __cplusplus
778783
}
779784
#endif

src/task.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,6 @@ NOINLINE static void record_backtrace(jl_ptls_t ptls, int skip) JL_NOTSAFEPOINT
312312
ptls->bt_size = rec_backtrace(ptls->bt_data, JL_MAX_BT_SIZE, skip + 1);
313313
}
314314

315-
JL_DLLEXPORT void julia_init(JL_IMAGE_SEARCH rel)
316-
{
317-
_julia_init(rel);
318-
}
319-
320315
JL_DLLEXPORT void jl_set_next_task(jl_task_t *task) JL_NOTSAFEPOINT
321316
{
322317
jl_get_ptls_states()->next_task = task;

0 commit comments

Comments
 (0)