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

ruby-changes:45541

From: normal <ko1@a...>
Date: Mon, 13 Feb 2017 10:05:30 +0900 (JST)
Subject: [ruby-changes:45541] normal:r57614 (trunk): cont.c: avoid needless branch for dmark callbacks

normal	2017-02-13 10:05:23 +0900 (Mon, 13 Feb 2017)

  New Revision: 57614

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

  Log:
    cont.c: avoid needless branch for dmark callbacks
    
    gc.c (gc_mark_children, case T_DATA) does not use
    the dmark function pointer if DATA_PTR is NULL
    
    * cont.c (cont_mark, fiber_mark): remove branch, ptr is never NULL

  Modified files:
    trunk/cont.c
Index: cont.c
===================================================================
--- cont.c	(revision 57613)
+++ cont.c	(revision 57614)
@@ -170,48 +170,48 @@ NOINLINE(static VALUE cont_capture(volat https://github.com/ruby/ruby/blob/trunk/cont.c#L170
 static void
 cont_mark(void *ptr)
 {
+    rb_context_t *cont = ptr;
+
     RUBY_MARK_ENTER("cont");
-    if (ptr) {
-	rb_context_t *cont = ptr;
-	rb_gc_mark(cont->value);
+    rb_gc_mark(cont->value);
 
-	rb_thread_mark(&cont->saved_thread);
-	rb_gc_mark(cont->saved_thread.self);
+    rb_thread_mark(&cont->saved_thread);
+    rb_gc_mark(cont->saved_thread.self);
 
-	if (cont->vm_stack) {
+    if (cont->vm_stack) {
 #ifdef CAPTURE_JUST_VALID_VM_STACK
-	    rb_gc_mark_locations(cont->vm_stack,
-				 cont->vm_stack + cont->vm_stack_slen + cont->vm_stack_clen);
+	rb_gc_mark_locations(cont->vm_stack,
+			     cont->vm_stack + cont->vm_stack_slen + cont->vm_stack_clen);
 #else
-	    rb_gc_mark_locations(cont->vm_stack,
-				 cont->vm_stack, cont->saved_thread.stack_size);
+	rb_gc_mark_locations(cont->vm_stack,
+			     cont->vm_stack, cont->saved_thread.stack_size);
 #endif
-	}
+    }
 
-	if (cont->machine.stack) {
-	    if (cont->type == CONTINUATION_CONTEXT) {
-		/* cont */
+    if (cont->machine.stack) {
+	if (cont->type == CONTINUATION_CONTEXT) {
+	    /* cont */
+	    rb_gc_mark_locations(cont->machine.stack,
+				 cont->machine.stack + cont->machine.stack_size);
+	}
+	else {
+	    /* fiber */
+	    rb_thread_t *th;
+	    rb_fiber_t *fib = (rb_fiber_t*)cont;
+	    GetThreadPtr(cont->saved_thread.self, th);
+	    if ((th->fiber != fib) && fib->status == RUNNING) {
 		rb_gc_mark_locations(cont->machine.stack,
 				     cont->machine.stack + cont->machine.stack_size);
-            }
-            else {
-		/* fiber */
-		rb_thread_t *th;
-                rb_fiber_t *fib = (rb_fiber_t*)cont;
-		GetThreadPtr(cont->saved_thread.self, th);
-		if ((th->fiber != fib) && fib->status == RUNNING) {
-		    rb_gc_mark_locations(cont->machine.stack,
-					 cont->machine.stack + cont->machine.stack_size);
-		}
 	    }
 	}
+    }
 #ifdef __ia64
-	if (cont->machine.register_stack) {
-	    rb_gc_mark_locations(cont->machine.register_stack,
-				 cont->machine.register_stack + cont->machine.register_stack_size);
-	}
-#endif
+    if (cont->machine.register_stack) {
+	rb_gc_mark_locations(cont->machine.register_stack,
+			     cont->machine.register_stack + cont->machine.register_stack_size);
     }
+#endif
+
     RUBY_MARK_LEAVE("cont");
 }
 
@@ -307,12 +307,10 @@ rb_fiber_mark_self(rb_fiber_t *fib) https://github.com/ruby/ruby/blob/trunk/cont.c#L307
 static void
 fiber_mark(void *ptr)
 {
+    rb_fiber_t *fib = ptr;
     RUBY_MARK_ENTER("cont");
-    if (ptr) {
-	rb_fiber_t *fib = ptr;
-	rb_fiber_mark_self(fib->prev);
-	cont_mark(&fib->cont);
-    }
+    rb_fiber_mark_self(fib->prev);
+    cont_mark(&fib->cont);
     RUBY_MARK_LEAVE("cont");
 }
 

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

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