ruby-changes:56992
From: Nobuyoshi <ko1@a...>
Date: Tue, 13 Aug 2019 09:50:39 +0900 (JST)
Subject: [ruby-changes:56992] Nobuyoshi Nakada: 0c2d81dada (master): Renamed ruby_finalize_{0, 1}
https://git.ruby-lang.org/ruby.git/commit/?id=0c2d81dada From 0c2d81dada88b5a3946c3162187df4223bfe6b4f Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Mon, 12 Aug 2019 17:44:30 +0900 Subject: Renamed ruby_finalize_{0,1} And pass rb_execution_context_t as an argument. diff --git a/eval.c b/eval.c index 4378382..395da9e 100644 --- a/eval.c +++ b/eval.c @@ -25,6 +25,7 @@ https://github.com/ruby/ruby/blob/trunk/eval.c#L25 #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) https://github.com/ruby/ruby/blob/trunk/eval.c#L110 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) https://github.com/ruby/ruby/blob/trunk/eval.c#L129 } 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) https://github.com/ruby/ruby/blob/trunk/eval.c#L158 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) https://github.com/ruby/ruby/blob/trunk/eval.c#L195 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) https://github.com/ruby/ruby/blob/trunk/eval.c#L212 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) https://github.com/ruby/ruby/blob/trunk/eval.c#L239 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; diff --git a/eval_error.c b/eval_error.c index 17c0e86..847072a 100644 --- a/eval_error.c +++ b/eval_error.c @@ -429,10 +429,9 @@ sysexit_status(VALUE err) https://github.com/ruby/ruby/blob/trunk/eval_error.c#L429 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; diff --git a/eval_jump.c b/eval_jump.c index a74aed9..8b1275b 100644 --- a/eval_jump.c +++ b/eval_jump.c @@ -107,11 +107,10 @@ exec_end_procs_chain(struct end_proc_data *volatile *procs, VALUE *errp) https://github.com/ruby/ruby/blob/trunk/eval_jump.c#L107 } } -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) https://github.com/ruby/ruby/blob/trunk/eval_jump.c#L121 } else { EC_TMPPOP_TAG(); - error_handle(state); + error_handle(ec, state); if (!NIL_P(ec->errinfo)) errinfo = ec->errinfo; EC_REPUSH_TAG(); goto again; diff --git a/gc.c b/gc.c index 0eb3a23..e666e61 100644 --- a/gc.c +++ b/gc.c @@ -847,7 +847,6 @@ void rb_vm_update_references(void *ptr); https://github.com/ruby/ruby/blob/trunk/gc.c#L847 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) https://github.com/ruby/ruby/blob/trunk/gc.c#L3230 } 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; diff --git a/include/ruby/backward.h b/include/ruby/backward.h index 262ed2c..863edf0 100644 --- a/include/ruby/backward.h +++ b/include/ruby/backward.h @@ -36,15 +36,25 @@ DECLARE_DEPRECATED_FEATURE(2.2, rb_frame_pop); https://github.com/ruby/ruby/blob/trunk/include/ruby/backward.h#L36 /* 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))); diff --git a/include/ruby/intern.h b/include/ruby/intern.h index 9f8462e..0aaeb82 100644 --- a/include/ruby/intern.h +++ b/include/ruby/intern.h @@ -461,7 +461,6 @@ int rb_mod_method_arity(VALUE, ID); https://github.com/ruby/ruby/blob/trunk/include/ruby/intern.h#L461 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); https://github.com/ruby/ruby/blob/trunk/include/ruby/intern.h#L519 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*); https://github.com/ruby/ruby/blob/trunk/include/ruby/intern.h#L717 #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 */ diff --git a/internal.h b/internal.h index 2ba4986..4df3826 100644 --- a/internal.h +++ b/internal.h @@ -2204,7 +2204,6 @@ struct timeval rb_time_timeval(VALUE); https://github.com/ruby/ruby/blob/trunk/internal.h#L2204 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); diff --git a/signal.c b/signal.c index 1b9e071..c33c756 100644 --- a/signal.c +++ b/signal.c @@ -1091,9 +1091,8 @@ signal_exec(VALUE cmd, int safe, int sig) https://github.com/ruby/ruby/blob/trunk/signal.c#L1091 } 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) { diff --git a/vm_core.h b/vm_core.h index d5e18ba..ae49798 100644 --- a/vm_core.h +++ b/vm_core.h @@ -582,6 +582,7 @@ typedef struct rb_at_exit_list { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L582 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 * https://github.com/ruby/ruby/blob/trunk/vm_core.h#L1919 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); diff --git a/vm_trace.c b/vm_trace.c index ac7550d..eb1c2af 100644 --- a/vm_trace.c +++ b/vm_trace.c @@ -270,13 +270,6 @@ rb_remove_event_hook_with_data(rb_event_hook_func_t func, VALUE data (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/