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

ruby-changes:47317

From: nobu <ko1@a...>
Date: Thu, 27 Jul 2017 21:18:05 +0900 (JST)
Subject: [ruby-changes:47317] nobu:r59434 (trunk): vm_core.h: shrink trap_list size

nobu	2017-07-27 21:17:56 +0900 (Thu, 27 Jul 2017)

  New Revision: 59434

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

  Log:
    vm_core.h: shrink trap_list size
    
    * vm_core.h (rb_vm_struct): separate trap_list cmd and safe to
      each arrays, to shrink the size.

  Modified files:
    trunk/signal.c
    trunk/vm.c
    trunk/vm_core.h
Index: signal.c
===================================================================
--- signal.c	(revision 59433)
+++ signal.c	(revision 59434)
@@ -1022,11 +1022,11 @@ void https://github.com/ruby/ruby/blob/trunk/signal.c#L1022
 rb_trap_exit(void)
 {
     rb_vm_t *vm = GET_VM();
-    VALUE trap_exit = vm->trap_list[0].cmd;
+    VALUE trap_exit = vm->trap_list.cmd[0];
 
     if (trap_exit) {
-	vm->trap_list[0].cmd = 0;
-	signal_exec(trap_exit, vm->trap_list[0].safe, 0);
+	vm->trap_list.cmd[0] = 0;
+	signal_exec(trap_exit, vm->trap_list.safe[0], 0);
     }
 }
 
@@ -1034,8 +1034,8 @@ void https://github.com/ruby/ruby/blob/trunk/signal.c#L1034
 rb_signal_exec(rb_thread_t *th, int sig)
 {
     rb_vm_t *vm = GET_VM();
-    VALUE cmd = vm->trap_list[sig].cmd;
-    int safe = vm->trap_list[sig].safe;
+    VALUE cmd = vm->trap_list.cmd[sig];
+    int safe = vm->trap_list.safe[sig];
 
     if (cmd == 0) {
 	switch (sig) {
@@ -1237,7 +1237,7 @@ trap(int sig, sighandler_t func, VALUE c https://github.com/ruby/ruby/blob/trunk/signal.c#L1237
     rb_vm_t *vm = GET_VM();
 
     /*
-     * Be careful. ruby_signal() and trap_list[sig].cmd must be changed
+     * Be careful. ruby_signal() and trap_list.cmd[sig] must be changed
      * atomically. In current implementation, we only need to don't call
      * RUBY_VM_CHECK_INTS().
      */
@@ -1248,7 +1248,7 @@ trap(int sig, sighandler_t func, VALUE c https://github.com/ruby/ruby/blob/trunk/signal.c#L1248
 	oldfunc = ruby_signal(sig, func);
 	if (oldfunc == SIG_ERR) rb_sys_fail_str(rb_signo2signm(sig));
     }
-    oldcmd = vm->trap_list[sig].cmd;
+    oldcmd = vm->trap_list.cmd[sig];
     switch (oldcmd) {
       case 0:
       case Qtrue:
@@ -1264,8 +1264,8 @@ trap(int sig, sighandler_t func, VALUE c https://github.com/ruby/ruby/blob/trunk/signal.c#L1264
 	break;
     }
 
-    vm->trap_list[sig].cmd = command;
-    vm->trap_list[sig].safe = rb_safe_level();
+    vm->trap_list.cmd[sig] = command;
+    vm->trap_list.safe[sig] = rb_safe_level();
 
     return oldcmd;
 }
@@ -1422,7 +1422,7 @@ init_sigchld(int sig) https://github.com/ruby/ruby/blob/trunk/signal.c#L1422
 	ruby_signal(sig, oldfunc);
     }
     else {
-	GET_VM()->trap_list[sig].cmd = 0;
+	GET_VM()->trap_list.cmd[sig] = 0;
     }
     return 0;
 }
Index: vm_core.h
===================================================================
--- vm_core.h	(revision 59433)
+++ vm_core.h	(revision 59434)
@@ -547,9 +547,9 @@ typedef struct rb_vm_struct { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L547
 
     /* signal */
     struct {
-	VALUE cmd;
-	int safe;
-    } trap_list[RUBY_NSIG];
+	VALUE cmd[RUBY_NSIG];
+	unsigned char safe[RUBY_NSIG];
+    } trap_list;
 
     /* hook */
     rb_hook_list_t event_hooks;
Index: vm.c
===================================================================
--- vm.c	(revision 59433)
+++ vm.c	(revision 59434)
@@ -2115,8 +2115,6 @@ void rb_vm_trace_mark_event_hooks(rb_hoo https://github.com/ruby/ruby/blob/trunk/vm.c#L2115
 void
 rb_vm_mark(void *ptr)
 {
-    int i;
-
     RUBY_MARK_ENTER("vm");
     RUBY_GC_INFO("-------------------------------------------------\n");
     if (ptr) {
@@ -2144,10 +2142,7 @@ rb_vm_mark(void *ptr) https://github.com/ruby/ruby/blob/trunk/vm.c#L2142
 
 	rb_vm_trace_mark_event_hooks(&vm->event_hooks);
 
-	for (i = 0; i < RUBY_NSIG; i++) {
-	    if (vm->trap_list[i].cmd)
-		rb_gc_mark(vm->trap_list[i].cmd);
-	}
+	rb_gc_mark_values(RUBY_NSIG, vm->trap_list.cmd);
     }
 
     RUBY_MARK_LEAVE("vm");

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

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