1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Renamed ruby_finalize_{0,1}

And pass rb_execution_context_t as an argument.
This commit is contained in:
Nobuyoshi Nakada 2019-08-12 17:44:30 +09:00
parent aac4d9d6c7
commit 0c2d81dada
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60
10 changed files with 42 additions and 47 deletions

39
eval.c
View file

@ -25,6 +25,7 @@
#endif
NORETURN(void rb_raise_jump(VALUE, VALUE));
void rb_ec_clear_current_thread_trace_func(const rb_execution_context_t *ec);
VALUE rb_eLocalJumpError;
VALUE rb_eSysStackError;
@ -109,17 +110,18 @@ ruby_init(void)
void *
ruby_options(int argc, char **argv)
{
rb_execution_context_t *ec = GET_EC();
enum ruby_tag_type state;
void *volatile iseq = 0;
ruby_init_stack((void *)&iseq);
EC_PUSH_TAG(GET_EC());
EC_PUSH_TAG(ec);
if ((state = EC_EXEC_TAG()) == TAG_NONE) {
SAVE_ROOT_JMPBUF(GET_THREAD(), iseq = ruby_process_options(argc, argv));
}
else {
rb_clear_trace_func();
state = error_handle(state);
rb_ec_clear_current_thread_trace_func(ec);
state = error_handle(ec, state);
iseq = (void *)INT2FIX(state);
}
EC_POP_TAG();
@ -127,23 +129,23 @@ ruby_options(int argc, char **argv)
}
static void
ruby_finalize_0(void)
rb_ec_teardown(rb_execution_context_t *ec)
{
EC_PUSH_TAG(GET_EC());
EC_PUSH_TAG(ec);
if (EC_EXEC_TAG() == TAG_NONE) {
rb_trap_exit();
rb_vm_trap_exit(rb_ec_vm_ptr(ec));
}
EC_POP_TAG();
rb_exec_end_proc();
rb_clear_trace_func();
rb_ec_exec_end_proc(ec);
rb_ec_clear_current_thread_trace_func(ec);
}
static void
ruby_finalize_1(void)
rb_ec_finalize(rb_execution_context_t *ec)
{
ruby_sig_finalize();
GET_EC()->errinfo = Qnil;
rb_gc_call_finalizer_at_exit();
ec->errinfo = Qnil;
rb_objspace_call_finalizer(rb_ec_vm_ptr(ec)->objspace);
}
/** Runs the VM finalization processes.
@ -156,8 +158,9 @@ ruby_finalize_1(void)
void
ruby_finalize(void)
{
ruby_finalize_0();
ruby_finalize_1();
rb_execution_context_t *ec = GET_EC();
rb_ec_teardown(ec);
rb_ec_finalize(ec);
}
/** Destructs the VM.
@ -192,7 +195,7 @@ ruby_cleanup(volatile int ex)
rb_set_safe_level_force(0);
ruby_init_stack(&errs[STACK_UPPER(errs, 0, 1)]);
SAVE_ROOT_JMPBUF(th, ruby_finalize_0());
SAVE_ROOT_JMPBUF(th, rb_ec_teardown(th->ec));
step_1: step++;
/* protect from Thread#raise */
@ -209,7 +212,7 @@ ruby_cleanup(volatile int ex)
if (ex == 0) ex = state;
}
th->ec->errinfo = errs[1];
sysex = error_handle(ex);
sysex = error_handle(th->ec, ex);
state = 0;
for (nerr = 0; nerr < numberof(errs); ++nerr) {
@ -236,13 +239,13 @@ ruby_cleanup(volatile int ex)
mjit_finish(true); // We still need ISeqs here.
ruby_finalize_1();
rb_ec_finalize(th->ec);
/* unlock again if finalizer took mutexes. */
rb_threadptr_unlock_all_locking_mutexes(GET_THREAD());
rb_threadptr_unlock_all_locking_mutexes(th);
EC_POP_TAG();
rb_thread_stop_timer_thread();
ruby_vm_destruct(GET_VM());
ruby_vm_destruct(th->vm);
if (state) ruby_default_signal(state);
return sysex;

View file

@ -429,10 +429,9 @@ sysexit_status(VALUE err)
rb_bug("Unknown longjmp status %d", status)
static int
error_handle(int ex)
error_handle(rb_execution_context_t *ec, int ex)
{
int status = EXIT_FAILURE;
rb_execution_context_t *ec = GET_EC();
if (rb_ec_set_raised(ec))
return EXIT_FAILURE;

View file

@ -107,11 +107,10 @@ exec_end_procs_chain(struct end_proc_data *volatile *procs, VALUE *errp)
}
}
void
rb_exec_end_proc(void)
static void
rb_ec_exec_end_proc(rb_execution_context_t * ec)
{
enum ruby_tag_type state;
rb_execution_context_t * volatile ec = GET_EC();
volatile VALUE errinfo = ec->errinfo;
EC_PUSH_TAG(ec);
@ -122,7 +121,7 @@ rb_exec_end_proc(void)
}
else {
EC_TMPPOP_TAG();
error_handle(state);
error_handle(ec, state);
if (!NIL_P(ec->errinfo)) errinfo = ec->errinfo;
EC_REPUSH_TAG();
goto again;

13
gc.c
View file

@ -847,7 +847,6 @@ void rb_vm_update_references(void *ptr);
void rb_gcdebug_print_obj_condition(VALUE obj);
static void rb_objspace_call_finalizer(rb_objspace_t *objspace);
static VALUE define_final0(VALUE obj, VALUE block);
static void negative_size_allocation_error(const char *);
@ -3231,20 +3230,14 @@ force_chain_object(st_data_t key, st_data_t val, st_data_t arg)
}
void
rb_gc_call_finalizer_at_exit(void)
{
#if RGENGC_CHECK_MODE >= 2
gc_verify_internal_consistency(Qnil);
#endif
rb_objspace_call_finalizer(&rb_objspace);
}
static void
rb_objspace_call_finalizer(rb_objspace_t *objspace)
{
RVALUE *p, *pend;
size_t i;
#if RGENGC_CHECK_MODE >= 2
gc_verify_internal_consistency(Qnil);
#endif
gc_rest(objspace);
if (ATOMIC_EXCHANGE(finalizing, 1)) return;

View file

@ -36,15 +36,25 @@ DECLARE_DEPRECATED_FEATURE(2.2, rb_frame_pop);
/* eval.c */
NORETURN(ERRORFUNC(("internal function"), void rb_frozen_class_p(VALUE)));
DECLARE_DEPRECATED_INTERNAL_FEATURE(rb_exec_end_proc);
/* error.c */
DECLARE_DEPRECATED_INTERNAL_FEATURE(rb_compile_error);
DECLARE_DEPRECATED_INTERNAL_FEATURE(rb_compile_error_with_enc);
DECLARE_DEPRECATED_INTERNAL_FEATURE(rb_compile_error_append);
/* gc.c */
DECLARE_DEPRECATED_INTERNAL_FEATURE(rb_gc_call_finalizer_at_exit);
/* signal.c */
DECLARE_DEPRECATED_INTERNAL_FEATURE(rb_trap_exit);
/* struct.c */
DECLARE_DEPRECATED_INTERNAL_FEATURE(rb_struct_ptr);
/* thread.c */
DECLARE_DEPRECATED_INTERNAL_FEATURE(rb_clear_trace_func);
/* variable.c */
DECLARE_DEPRECATED_INTERNAL_FEATURE(rb_generic_ivar_table);
NORETURN(ERRORFUNC(("internal function"), VALUE rb_mod_const_missing(VALUE, VALUE)));

View file

@ -461,7 +461,6 @@ int rb_mod_method_arity(VALUE, ID);
int rb_obj_method_arity(VALUE, ID);
VALUE rb_protect(VALUE (*)(VALUE), VALUE, int*);
void rb_set_end_proc(void (*)(VALUE), VALUE);
void rb_exec_end_proc(void);
void rb_thread_schedule(void);
void rb_thread_wait_fd(int);
int rb_thread_fd_writable(int);
@ -520,7 +519,6 @@ VALUE rb_gc_location(VALUE);
void rb_gc_force_recycle(VALUE);
void rb_gc(void);
void rb_gc_copy_finalizer(VALUE,VALUE);
void rb_gc_call_finalizer_at_exit(void);
VALUE rb_gc_enable(void);
VALUE rb_gc_disable(void);
VALUE rb_gc_start(void);
@ -719,7 +717,6 @@ VALUE rb_f_kill(int, const VALUE*);
#define posix_signal ruby_posix_signal
RETSIGTYPE (*posix_signal(int, RETSIGTYPE (*)(int)))(int);
#endif
void rb_trap_exit(void);
const char *ruby_signal_name(int);
void ruby_default_signal(int);
/* sprintf.c */

View file

@ -2204,7 +2204,6 @@ struct timeval rb_time_timeval(VALUE);
VALUE rb_obj_is_mutex(VALUE obj);
VALUE rb_suppress_tracing(VALUE (*func)(VALUE), VALUE arg);
void rb_thread_execute_interrupts(VALUE th);
void rb_clear_trace_func(void);
VALUE rb_get_coverages(void);
int rb_get_coverage_mode(void);
VALUE rb_default_coverage(int);

View file

@ -1091,9 +1091,8 @@ signal_exec(VALUE cmd, int safe, int sig)
}
void
rb_trap_exit(void)
rb_vm_trap_exit(rb_vm_t *vm)
{
rb_vm_t *vm = GET_VM();
VALUE trap_exit = vm->trap_list.cmd[0];
if (trap_exit) {

View file

@ -582,6 +582,7 @@ typedef struct rb_at_exit_list {
struct rb_objspace;
struct rb_objspace *rb_objspace_alloc(void);
void rb_objspace_free(struct rb_objspace *);
void rb_objspace_call_finalizer(struct rb_objspace *);
typedef struct rb_hook_list_struct {
struct rb_event_hook_struct *hooks;
@ -1918,6 +1919,8 @@ rb_exec_event_hook_script_compiled(rb_execution_context_t *ec, const rb_iseq_t *
rb_ary_new_from_args(2, eval_script, (VALUE)iseq));
}
void rb_vm_trap_exit(rb_vm_t *vm);
RUBY_SYMBOL_EXPORT_BEGIN
int rb_thread_check_trap_pending(void);

View file

@ -269,13 +269,6 @@ rb_remove_event_hook_with_data(rb_event_hook_func_t func, VALUE data)
return remove_event_hook(GET_EC(), NULL, func, data);
}
void
rb_clear_trace_func(void)
{
rb_execution_context_t *ec = GET_EC();
rb_threadptr_remove_event_hook(ec, MATCH_ANY_FILTER_TH, 0, Qundef);
}
void
rb_ec_clear_current_thread_trace_func(const rb_execution_context_t *ec)
{