Use rb_execution_context_t instead of rb_thread_t

to represent execution context [Feature #14038]

* vm_core.h (rb_thread_t): rb_thread_t::ec is now a pointer.
  There are many code using `th` to represent execution context
  (such as cfp, VM stack and so on). To access `ec`, they need to
  use `th->ec->...` (adding one indirection) so that we need to
  replace them by passing `ec` instead of `th`.

* vm_core.h (GET_EC()): introduced to access current ec. Also
  remove `ruby_current_thread` global variable.

* cont.c (rb_context_t): introduce rb_context_t::thread_ptr instead of
  rb_context_t::thread_value.

* cont.c (ec_set_vm_stack): added to update vm_stack explicitly.

* cont.c (ec_switch): added to switch ec explicitly.

* cont.c (rb_fiber_close): added to terminate fibers explicitly.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60440 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2017-10-26 08:32:49 +00:00
parent 07f04f468d
commit 837fd5e494
32 changed files with 743 additions and 576 deletions

View file

@ -116,26 +116,26 @@ rb_exec_end_proc(void)
enum ruby_tag_type state;
volatile int safe = rb_safe_level();
rb_thread_t *th = GET_THREAD();
volatile VALUE errinfo = th->ec.errinfo;
volatile VALUE errinfo = th->ec->errinfo;
TH_PUSH_TAG(th);
if ((state = EXEC_TAG()) == TAG_NONE) {
again:
exec_end_procs_chain(&ephemeral_end_procs, &th->ec.errinfo);
exec_end_procs_chain(&end_procs, &th->ec.errinfo);
exec_end_procs_chain(&ephemeral_end_procs, &th->ec->errinfo);
exec_end_procs_chain(&end_procs, &th->ec->errinfo);
}
else {
VAR_INITIALIZED(th);
TH_TMPPOP_TAG();
error_handle(state);
if (!NIL_P(th->ec.errinfo)) errinfo = th->ec.errinfo;
if (!NIL_P(th->ec->errinfo)) errinfo = th->ec->errinfo;
TH_REPUSH_TAG();
goto again;
}
TH_POP_TAG();
rb_set_safe_level_force(safe);
th->ec.errinfo = errinfo;
th->ec->errinfo = errinfo;
}
void