[前][次][番号順一覧][スレッド一覧]

ruby-changes:48423

From: ko1 <ko1@a...>
Date: Sun, 29 Oct 2017 21:57:12 +0900 (JST)
Subject: [ruby-changes:48423] ko1:r60537 (trunk): `ec` has `thread_ptr`.

ko1	2017-10-29 21:57:04 +0900 (Sun, 29 Oct 2017)

  New Revision: 60537

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60537

  Log:
    `ec` has `thread_ptr`.
    
    * cont.c (rb_context_struct): move rb_context_t::thread_ptr to
      rb_execution_context_t::thread_ptr.
    
    * cont.c (rb_fiberptr_thread_ptr): removed.

  Modified files:
    trunk/cont.c
    trunk/vm_core.h
Index: cont.c
===================================================================
--- cont.c	(revision 60536)
+++ cont.c	(revision 60537)
@@ -110,7 +110,6 @@ typedef struct rb_context_struct { https://github.com/ruby/ruby/blob/trunk/cont.c#L110
     rb_jmpbuf_t jmpbuf;
     rb_ensure_entry_t *ensure_array;
     rb_ensure_list_t *ensure_list;
-    rb_thread_t *thread_ptr;
 } rb_context_t;
 
 
@@ -267,7 +266,7 @@ NOINLINE(static VALUE cont_capture(volat https://github.com/ruby/ruby/blob/trunk/cont.c#L266
 static VALUE
 cont_thread_value(const rb_context_t *cont)
 {
-    return cont->thread_ptr->self;
+    return cont->saved_ec.thread_ptr->self;
 }
 
 static void
@@ -396,12 +395,6 @@ cont_memsize(const void *ptr) https://github.com/ruby/ruby/blob/trunk/cont.c#L395
     return size;
 }
 
-rb_thread_t *
-rb_fiberptr_thread_ptr(const rb_fiber_t *fib)
-{
-    return fib->cont.thread_ptr;
-}
-
 void
 rb_fiber_mark_self(const rb_fiber_t *fib)
 {
@@ -550,7 +543,7 @@ cont_init(rb_context_t *cont, rb_thread_ https://github.com/ruby/ruby/blob/trunk/cont.c#L543
 {
     /* save thread context */
     cont_save_thread(cont, th);
-    cont->thread_ptr = th;
+    cont->saved_ec.thread_ptr = th;
     cont->saved_ec.local_storage = NULL;
     cont->saved_ec.local_storage_recursive_hash = Qnil;
     cont->saved_ec.local_storage_recursive_hash_for_trace = Qnil;
@@ -1474,7 +1467,7 @@ rb_threadptr_root_fiber_setup(rb_thread_ https://github.com/ruby/ruby/blob/trunk/cont.c#L1467
     MEMZERO(fib, rb_fiber_t, 1);
     fib->cont.type = ROOT_FIBER_CONTEXT;
     fib->cont.saved_ec.fiber = fib;
-    fib->cont.thread_ptr = th;
+    fib->cont.saved_ec.thread_ptr = th;
     fiber_status_set(fib, FIBER_RESUMED); /* skip CREATED */
     th->ec = &fib->cont.saved_ec;
 #if FIBER_USE_NATIVE
Index: vm_core.h
===================================================================
--- vm_core.h	(revision 60536)
+++ vm_core.h	(revision 60537)
@@ -771,6 +771,8 @@ typedef struct rb_execution_context_stru https://github.com/ruby/ruby/blob/trunk/vm_core.h#L771
     /* for bmethod */
     const rb_callable_method_entry_t *passed_bmethod_me;
 
+    struct rb_thread_struct *thread_ptr;
+
     /* for GC */
     struct {
 	VALUE *stack_start;
@@ -1594,20 +1596,18 @@ RUBY_SYMBOL_EXPORT_END https://github.com/ruby/ruby/blob/trunk/vm_core.h#L1596
 #define GET_THREAD() ruby_current_thread()
 #define GET_EC()     ruby_current_execution_context()
 
-rb_thread_t *rb_fiberptr_thread_ptr(const rb_fiber_t *fib);
-
 static inline rb_thread_t *
 rb_ec_thread_ptr(const rb_execution_context_t *ec)
 {
-    return rb_fiberptr_thread_ptr(ec->fiber);
+    return ec->thread_ptr;
 }
 
 static inline rb_vm_t *
 rb_ec_vm_ptr(const rb_execution_context_t *ec)
 {
-    const rb_thread_t *th = rb_fiberptr_thread_ptr(ec->fiber);
+    const rb_thread_t *th = rb_ec_thread_ptr(ec);
     if (th) {
-	return rb_fiberptr_thread_ptr(ec->fiber)->vm;
+	return th->vm;
     }
     else {
 	return NULL;

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]