зеркало из https://github.com/github/ruby.git
move fields to ec.
* vm_core.h (rb_thread_t): move root_lep, root_svar and ensure_list to rb_execution_context_t. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
7c7d74365d
Коммит
957d1ccdf9
19
cont.c
19
cont.c
|
@ -414,9 +414,6 @@ cont_save_thread(rb_context_t *cont, rb_thread_t *th)
|
|||
VM_ASSERT(th->status == THREAD_RUNNABLE);
|
||||
sth->errinfo = th->errinfo;
|
||||
sth->first_proc = th->first_proc;
|
||||
sth->root_lep = th->root_lep;
|
||||
sth->root_svar = th->root_svar;
|
||||
sth->ensure_list = th->ensure_list;
|
||||
|
||||
sth->trace_arg = th->trace_arg;
|
||||
|
||||
|
@ -490,10 +487,10 @@ cont_capture(volatile int *volatile stat)
|
|||
rb_ensure_list_t *p;
|
||||
int size = 0;
|
||||
rb_ensure_entry_t *entry;
|
||||
for (p=th->ensure_list; p; p=p->next)
|
||||
for (p=th->ec.ensure_list; p; p=p->next)
|
||||
size++;
|
||||
entry = cont->ensure_array = ALLOC_N(rb_ensure_entry_t,size+1);
|
||||
for (p=th->ensure_list; p; p=p->next) {
|
||||
for (p=th->ec.ensure_list; p; p=p->next) {
|
||||
if (!p->entry.marker)
|
||||
p->entry.marker = rb_ary_tmp_new(0); /* dummy object */
|
||||
*entry++ = p->entry;
|
||||
|
@ -548,6 +545,9 @@ cont_restore_thread(rb_context_t *cont)
|
|||
th->ec.raised_flag = sth->ec.raised_flag;
|
||||
th->ec.tag = sth->ec.tag;
|
||||
th->ec.protect_tag = sth->ec.protect_tag;
|
||||
th->ec.root_lep = sth->ec.root_lep;
|
||||
th->ec.root_svar = sth->ec.root_svar;
|
||||
th->ec.ensure_list = sth->ec.ensure_list;
|
||||
}
|
||||
else {
|
||||
/* fiber */
|
||||
|
@ -558,9 +558,6 @@ cont_restore_thread(rb_context_t *cont)
|
|||
|
||||
th->errinfo = sth->errinfo;
|
||||
th->first_proc = sth->first_proc;
|
||||
th->root_lep = sth->root_lep;
|
||||
th->root_svar = sth->root_svar;
|
||||
th->ensure_list = sth->ensure_list;
|
||||
|
||||
VM_ASSERT(sth->status == THREAD_RUNNABLE);
|
||||
}
|
||||
|
@ -1065,7 +1062,7 @@ rb_cont_call(int argc, VALUE *argv, VALUE contval)
|
|||
rb_raise(rb_eRuntimeError, "continuation called across fiber");
|
||||
}
|
||||
}
|
||||
rollback_ensure_stack(contval, th->ensure_list, cont->ensure_array);
|
||||
rollback_ensure_stack(contval, th->ec.ensure_list, cont->ensure_array);
|
||||
|
||||
cont->argc = argc;
|
||||
cont->value = make_passing_arg(argc, argv);
|
||||
|
@ -1265,8 +1262,8 @@ rb_fiber_start(void)
|
|||
argv = (argc = cont->argc) > 1 ? RARRAY_CONST_PTR(args) : &args;
|
||||
cont->value = Qnil;
|
||||
th->errinfo = Qnil;
|
||||
th->root_lep = rb_vm_proc_local_ep(cont->saved_thread.first_proc);
|
||||
th->root_svar = Qfalse;
|
||||
th->ec.root_lep = rb_vm_proc_local_ep(cont->saved_thread.first_proc);
|
||||
th->ec.root_svar = Qfalse;
|
||||
fib->status = FIBER_RUNNING;
|
||||
|
||||
EXEC_EVENT_HOOK(th, RUBY_EVENT_FIBER_SWITCH, th->self, 0, 0, 0, Qnil);
|
||||
|
|
6
eval.c
6
eval.c
|
@ -895,8 +895,8 @@ rb_ensure(VALUE (*b_proc)(ANYARGS), VALUE data1, VALUE (*e_proc)(ANYARGS), VALUE
|
|||
ensure_list.entry.marker = 0;
|
||||
ensure_list.entry.e_proc = e_proc;
|
||||
ensure_list.entry.data2 = data2;
|
||||
ensure_list.next = th->ensure_list;
|
||||
th->ensure_list = &ensure_list;
|
||||
ensure_list.next = th->ec.ensure_list;
|
||||
th->ec.ensure_list = &ensure_list;
|
||||
TH_PUSH_TAG(th);
|
||||
if ((state = EXEC_TAG()) == TAG_NONE) {
|
||||
result = (*b_proc) (data1);
|
||||
|
@ -906,7 +906,7 @@ rb_ensure(VALUE (*b_proc)(ANYARGS), VALUE data1, VALUE (*e_proc)(ANYARGS), VALUE
|
|||
if (!NIL_P(errinfo) && !RB_TYPE_P(errinfo, T_OBJECT)) {
|
||||
th->errinfo = Qnil;
|
||||
}
|
||||
th->ensure_list=ensure_list.next;
|
||||
th->ec.ensure_list=ensure_list.next;
|
||||
(*ensure_list.entry.e_proc)(ensure_list.entry.data2);
|
||||
th->errinfo = errinfo;
|
||||
if (state)
|
||||
|
|
4
thread.c
4
thread.c
|
@ -581,8 +581,8 @@ thread_do_start(rb_thread_t *th, VALUE args)
|
|||
rb_proc_t *proc;
|
||||
GetProcPtr(th->first_proc, proc);
|
||||
th->errinfo = Qnil;
|
||||
th->root_lep = rb_vm_proc_local_ep(th->first_proc);
|
||||
th->root_svar = Qfalse;
|
||||
th->ec.root_lep = rb_vm_proc_local_ep(th->first_proc);
|
||||
th->ec.root_svar = Qfalse;
|
||||
EXEC_EVENT_HOOK(th, RUBY_EVENT_THREAD_BEGIN, th->self, 0, 0, 0, Qundef);
|
||||
th->value = rb_vm_invoke_proc(th, proc,
|
||||
(int)RARRAY_LEN(args), RARRAY_CONST_PTR(args),
|
||||
|
|
6
vm.c
6
vm.c
|
@ -2407,7 +2407,7 @@ rb_thread_mark(void *ptr)
|
|||
RUBY_MARK_UNLESS_NULL(th->errinfo);
|
||||
RUBY_MARK_UNLESS_NULL(th->pending_interrupt_queue);
|
||||
RUBY_MARK_UNLESS_NULL(th->pending_interrupt_mask_stack);
|
||||
RUBY_MARK_UNLESS_NULL(th->root_svar);
|
||||
RUBY_MARK_UNLESS_NULL(th->ec.root_svar);
|
||||
RUBY_MARK_UNLESS_NULL(th->top_self);
|
||||
RUBY_MARK_UNLESS_NULL(th->top_wrapper);
|
||||
rb_fiber_mark_self(th->fiber);
|
||||
|
@ -2539,7 +2539,7 @@ th_init(rb_thread_t *th, VALUE self)
|
|||
th->status = THREAD_RUNNABLE;
|
||||
th->errinfo = Qnil;
|
||||
th->last_status = Qnil;
|
||||
th->root_svar = Qfalse;
|
||||
th->ec.root_svar = Qfalse;
|
||||
th->ec.local_storage_recursive_hash = Qnil;
|
||||
th->ec.local_storage_recursive_hash_for_trace = Qnil;
|
||||
#ifdef NON_SCALAR_THREAD_ID
|
||||
|
@ -2564,7 +2564,7 @@ ruby_thread_init(VALUE self)
|
|||
|
||||
th->top_wrapper = 0;
|
||||
th->top_self = rb_vm_top_self();
|
||||
th->root_svar = Qfalse;
|
||||
th->ec.root_svar = Qfalse;
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
14
vm_core.h
14
vm_core.h
|
@ -751,6 +751,13 @@ typedef struct rb_thread_context_struct {
|
|||
st_table *local_storage;
|
||||
VALUE local_storage_recursive_hash;
|
||||
VALUE local_storage_recursive_hash_for_trace;
|
||||
|
||||
/* eval env */
|
||||
const VALUE *root_lep;
|
||||
VALUE root_svar;
|
||||
|
||||
/* ensure & callcc */
|
||||
rb_ensure_list_t *ensure_list;
|
||||
} rb_execution_context_t;
|
||||
|
||||
typedef struct rb_thread_struct {
|
||||
|
@ -775,10 +782,6 @@ typedef struct rb_thread_struct {
|
|||
VALUE top_self;
|
||||
VALUE top_wrapper;
|
||||
|
||||
/* eval env */
|
||||
const VALUE *root_lep;
|
||||
VALUE root_svar;
|
||||
|
||||
/* thread control */
|
||||
rb_nativethread_id_t thread_id;
|
||||
#ifdef NON_SCALAR_THREAD_ID
|
||||
|
@ -845,9 +848,6 @@ typedef struct rb_thread_struct {
|
|||
rb_fiber_t *root_fiber;
|
||||
rb_jmpbuf_t root_jmpbuf;
|
||||
|
||||
/* ensure & callcc */
|
||||
rb_ensure_list_t *ensure_list;
|
||||
|
||||
/* misc */
|
||||
enum method_missing_reason method_missing_reason: 8;
|
||||
unsigned int abort_on_exception: 1;
|
||||
|
|
|
@ -369,11 +369,11 @@ lep_svar(rb_thread_t *th, const VALUE *lep)
|
|||
{
|
||||
VALUE svar;
|
||||
|
||||
if (lep && (th == NULL || th->root_lep != lep)) {
|
||||
if (lep && (th == NULL || th->ec.root_lep != lep)) {
|
||||
svar = lep[VM_ENV_DATA_INDEX_ME_CREF];
|
||||
}
|
||||
else {
|
||||
svar = th->root_svar;
|
||||
svar = th->ec.root_svar;
|
||||
}
|
||||
|
||||
VM_ASSERT(svar == Qfalse || vm_svar_valid_p(svar));
|
||||
|
@ -386,11 +386,11 @@ lep_svar_write(rb_thread_t *th, const VALUE *lep, const struct vm_svar *svar)
|
|||
{
|
||||
VM_ASSERT(vm_svar_valid_p((VALUE)svar));
|
||||
|
||||
if (lep && (th == NULL || th->root_lep != lep)) {
|
||||
if (lep && (th == NULL || th->ec.root_lep != lep)) {
|
||||
vm_env_write(lep, VM_ENV_DATA_INDEX_ME_CREF, (VALUE)svar);
|
||||
}
|
||||
else {
|
||||
RB_OBJ_WRITE(th->self, &th->root_svar, svar);
|
||||
RB_OBJ_WRITE(th->self, &th->ec.root_svar, svar);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче