aboutsummaryrefslogtreecommitdiffstats
path: root/gc.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-26 08:32:49 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-26 08:32:49 +0000
commitfbf899e0204808fa2a01ade8ca8b69feb1bcc479 (patch)
tree7ccbb6b6733ccb07c28b7df28e3e2a6b604cc731 /gc.c
parentf8f36a133c610b9ec6aa1f45ffcfc1e74b5e473f (diff)
downloadruby-fbf899e0204808fa2a01ade8ca8b69feb1bcc479.tar.gz
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
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/gc.c b/gc.c
index 2b9d5b1029..f2afe8499e 100644
--- a/gc.c
+++ b/gc.c
@@ -1812,7 +1812,7 @@ rb_objspace_set_event_hook(const rb_event_flag_t event)
static void
gc_event_hook_body(rb_thread_t *th, rb_objspace_t *objspace, const rb_event_flag_t event, VALUE data)
{
- EXEC_EVENT_HOOK(th, event, th->ec.cfp->self, 0, 0, 0, data);
+ EXEC_EVENT_HOOK(th, event, th->ec->cfp->self, 0, 0, 0, data);
}
#define gc_event_hook_available_p(objspace) ((objspace)->flags.has_hook)
@@ -2784,16 +2784,16 @@ run_finalizer(rb_objspace_t *objspace, VALUE obj, VALUE table)
long finished;
int safe;
} saved;
- rb_thread_t *const th = GET_THREAD();
+ rb_thread_t *const volatile th = GET_THREAD();
#define RESTORE_FINALIZER() (\
- th->ec.cfp = saved.cfp, \
+ th->ec->cfp = saved.cfp, \
rb_set_safe_level_force(saved.safe), \
rb_set_errinfo(saved.errinfo))
saved.safe = rb_safe_level();
saved.errinfo = rb_errinfo();
saved.objid = nonspecial_obj_id(obj);
- saved.cfp = th->ec.cfp;
+ saved.cfp = th->ec->cfp;
saved.finished = 0;
TH_PUSH_TAG(th);
@@ -4001,7 +4001,7 @@ ruby_get_stack_grow_direction(volatile VALUE *addr)
size_t
ruby_stack_length(VALUE **p)
{
- rb_execution_context_t *ec = &GET_THREAD()->ec;
+ rb_execution_context_t *ec = GET_THREAD()->ec;
SET_STACK_END;
if (p) *p = STACK_UPPER(STACK_END, STACK_START, STACK_END);
return STACK_LENGTH;
@@ -4019,7 +4019,7 @@ ruby_stack_length(VALUE **p)
static int
stack_check(rb_thread_t *th, int water_mark)
{
- rb_execution_context_t *ec = &th->ec;
+ rb_execution_context_t *ec = th->ec;
int ret;
SET_STACK_END;
ret = STACK_LENGTH > STACK_LEVEL_MAX - water_mark;
@@ -4784,7 +4784,7 @@ gc_mark_roots(rb_objspace_t *objspace, const char **categoryp)
{
struct gc_list *list;
rb_thread_t *th = GET_THREAD();
- rb_execution_context_t *ec = &th->ec;
+ rb_execution_context_t *ec = th->ec;
#if PRINT_ROOT_TICKS
tick_t start_tick = tick();
@@ -4831,7 +4831,7 @@ gc_mark_roots(rb_objspace_t *objspace, const char **categoryp)
mark_tbl(objspace, finalizer_table);
MARK_CHECKPOINT("machine_context");
- mark_current_machine_context(objspace, &th->ec);
+ mark_current_machine_context(objspace, th->ec);
MARK_CHECKPOINT("encodings");
rb_gc_mark_encodings();
@@ -7712,7 +7712,7 @@ rb_memerror(void)
rb_thread_raised_set(th, RAISED_NOMEMORY);
exc = ruby_vm_special_exception_copy(exc);
}
- th->ec.errinfo = exc;
+ th->ec->errinfo = exc;
TH_JUMP_TAG(th, TAG_RAISE);
}