Skip to content

Commit

Permalink
Cleanup: remove jl_apply_with_saved_exception_state
Browse files Browse the repository at this point in the history
All uses of JL_TRY/JL_CATCH now preserve the exception state, so this
isn't really necessary anymore.
  • Loading branch information
c42f committed Sep 20, 2018
1 parent bcc7bab commit 02d0270
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 22 deletions.
16 changes: 14 additions & 2 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1774,7 +1774,13 @@ static jl_value_t *static_apply_type(jl_codectx_t &ctx, const jl_cgval_t *args,
size_t last_age = jl_get_ptls_states()->world_age;
// call apply_type, but ignore errors. we know that will work in world 1.
jl_get_ptls_states()->world_age = 1;
jl_value_t *result = jl_apply_with_saved_exception_state(v, nargs, 1);
jl_value_t *result;
JL_TRY {
result = jl_apply(v, nargs);
}
JL_CATCH {
result = NULL;
}
jl_get_ptls_states()->world_age = last_age;
return result;
}
Expand Down Expand Up @@ -1856,7 +1862,13 @@ static jl_value_t *static_eval(jl_codectx_t &ctx, jl_value_t *ex, int sparams=tr
size_t last_age = jl_get_ptls_states()->world_age;
// here we know we're calling specific builtin functions that work in world 1.
jl_get_ptls_states()->world_age = 1;
jl_value_t *result = jl_apply_with_saved_exception_state(v, n+1, 1);
jl_value_t *result;
JL_TRY {
result = jl_apply(v, n+1);
}
JL_CATCH {
result = NULL;
}
jl_get_ptls_states()->world_age = last_age;
JL_GC_POP();
return result;
Expand Down
12 changes: 11 additions & 1 deletion src/gf.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,17 @@ jl_code_info_t *jl_type_infer(jl_method_instance_t **pli JL_ROOTS_TEMPORARILY, s
ptls->world_age = jl_typeinf_world;
li->inInference = 1;
in_inference++;
jl_svec_t *linfo_src = (jl_svec_t*)jl_apply_with_saved_exception_state(fargs, 3, 0);
jl_svec_t *linfo_src;
JL_TRY {
linfo_src = (jl_svec_t*)jl_apply(fargs, 3);
}
JL_CATCH {
jl_printf(JL_STDERR, "Internal error: encountered unexpected error in runtime:\n");
jl_static_show(JL_STDERR, jl_current_exception());
jl_printf(JL_STDERR, "\n");
jlbacktrace(); // written to STDERR_FILENO
linfo_src = NULL;
}
ptls->world_age = last_age;
in_inference--;
li->inInference = 0;
Expand Down
1 change: 0 additions & 1 deletion src/julia_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,6 @@ size_t rec_backtrace_ctx(uintptr_t *data, size_t maxsize, bt_context_t *ctx) JL_
size_t rec_backtrace_ctx_dwarf(uintptr_t *data, size_t maxsize, bt_context_t *ctx);
#endif
JL_DLLEXPORT void jl_get_backtrace(jl_array_t **bt, jl_array_t **bt2);
JL_DLLEXPORT jl_value_t *jl_apply_with_saved_exception_state(jl_value_t **args, uint32_t nargs, int drop_exceptions);
void jl_critical_error(int sig, bt_context_t *context, uintptr_t *bt_data, size_t *bt_size);
JL_DLLEXPORT void jl_raise_debugger(void);
int jl_getFunctionInfo(jl_frame_t **frames, uintptr_t pointer, int skipC, int noInline);
Expand Down
18 changes: 0 additions & 18 deletions src/rtutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,24 +302,6 @@ JL_DLLEXPORT void jl_restore_exc_stack(size_t state)
}
}

JL_DLLEXPORT jl_value_t *jl_apply_with_saved_exception_state(jl_value_t **args, uint32_t nargs, int drop_exceptions)
{
jl_value_t *v;
JL_TRY {
v = jl_apply(args, nargs);
}
JL_CATCH {
if (!drop_exceptions) {
jl_printf(JL_STDERR, "Internal error: encountered unexpected error in runtime:\n");
jl_static_show(JL_STDERR, jl_current_exception());
jl_printf(JL_STDERR, "\n");
jlbacktrace(); // written to STDERR_FILENO
}
v = NULL;
}
return v;
}

void jl_copy_exc_stack(jl_exc_stack_t *dest, jl_exc_stack_t *src)
{
assert(dest->reserved_size >= src->top);
Expand Down

0 comments on commit 02d0270

Please sign in to comment.