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

ruby-changes:49458

From: normal <ko1@a...>
Date: Wed, 3 Jan 2018 06:52:05 +0900 (JST)
Subject: [ruby-changes:49458] normal:r61574 (trunk): variable.c: fix autoload stack space regression

normal	2018-01-03 06:51:59 +0900 (Wed, 03 Jan 2018)

  New Revision: 61574

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

  Log:
    variable.c: fix autoload stack space regression
    
    r61560 ("offsetof(type, foo.bar) is (arguably) a GCCism")
    introduced 16 bytes of stack overhead on 64-bit systems.
    Remove that overhead and cast, instead.  While we're at it,
    restore the "waitq" name to clarify the purpose of the field.
    
    (This is one unfortunate consequence of the CC0 ccan/list.h
     implementation compared to the *GPL ones in glibc/urcu/linux)
    
    * variable.c (struct autoload_state): remove head field, clarify naming
      (autoload_reset): cast and adjust
      (autoload_sleep_done): ditto
      (rb_autoload_load): ditto

  Modified files:
    trunk/variable.c
Index: variable.c
===================================================================
--- variable.c	(revision 61573)
+++ variable.c	(revision 61574)
@@ -1847,8 +1847,7 @@ struct autoload_state { https://github.com/ruby/ruby/blob/trunk/variable.c#L1847
     VALUE result;
     ID id;
     VALUE thread;
-    struct list_node node;
-    struct list_head head;
+    struct list_node waitq;
 };
 
 struct autoload_data_i {
@@ -2101,11 +2100,11 @@ autoload_reset(VALUE arg) https://github.com/ruby/ruby/blob/trunk/variable.c#L2100
     if (need_wakeups) {
 	struct autoload_state *cur = 0, *nxt;
 
-	list_for_each_safe(&state->head, cur, nxt, node) {
+	list_for_each_safe((struct list_head *)&state->waitq, cur, nxt, waitq) {
 	    VALUE th = cur->thread;
 
 	    cur->thread = Qfalse;
-	    list_del_init(&cur->node); /* idempotent */
+	    list_del_init(&cur->waitq); /* idempotent */
 
 	    /*
 	     * cur is stored on the stack of cur->waiting_th,
@@ -2140,7 +2139,7 @@ autoload_sleep_done(VALUE arg) https://github.com/ruby/ruby/blob/trunk/variable.c#L2139
     struct autoload_state *state = (struct autoload_state *)arg;
 
     if (state->thread != Qfalse && rb_thread_to_be_killed(state->thread)) {
-	list_del(&state->node); /* idempotent after list_del_init */
+	list_del(&state->waitq); /* idempotent after list_del_init */
     }
 
     return Qfalse;
@@ -2176,13 +2175,13 @@ rb_autoload_load(VALUE mod, ID id) https://github.com/ruby/ruby/blob/trunk/variable.c#L2175
 	 * autoload_reset will wake up any threads added to this
 	 * iff the GVL is released during autoload_require
 	 */
-	list_head_init(&state.head);
+	list_head_init((struct list_head *)&state.waitq);
     }
     else if (state.thread == ele->state->thread) {
 	return Qfalse;
     }
     else {
-	list_add_tail(&ele->state->head, &state.node);
+	list_add_tail((struct list_head *)&ele->state->waitq, &state.waitq);
 
 	rb_ensure(autoload_sleep, (VALUE)&state,
 		autoload_sleep_done, (VALUE)&state);

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

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