1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59434 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2017-07-27 12:17:56 +00:00
parent 9e9f57e4a0
commit 083a25f903
3 changed files with 14 additions and 19 deletions

View file

@ -1022,11 +1022,11 @@ void
rb_trap_exit(void) rb_trap_exit(void)
{ {
rb_vm_t *vm = GET_VM(); 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) { if (trap_exit) {
vm->trap_list[0].cmd = 0; vm->trap_list.cmd[0] = 0;
signal_exec(trap_exit, vm->trap_list[0].safe, 0); signal_exec(trap_exit, vm->trap_list.safe[0], 0);
} }
} }
@ -1034,8 +1034,8 @@ void
rb_signal_exec(rb_thread_t *th, int sig) rb_signal_exec(rb_thread_t *th, int sig)
{ {
rb_vm_t *vm = GET_VM(); rb_vm_t *vm = GET_VM();
VALUE cmd = vm->trap_list[sig].cmd; VALUE cmd = vm->trap_list.cmd[sig];
int safe = vm->trap_list[sig].safe; int safe = vm->trap_list.safe[sig];
if (cmd == 0) { if (cmd == 0) {
switch (sig) { switch (sig) {
@ -1237,7 +1237,7 @@ trap(int sig, sighandler_t func, VALUE command)
rb_vm_t *vm = GET_VM(); 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 * atomically. In current implementation, we only need to don't call
* RUBY_VM_CHECK_INTS(). * RUBY_VM_CHECK_INTS().
*/ */
@ -1248,7 +1248,7 @@ trap(int sig, sighandler_t func, VALUE command)
oldfunc = ruby_signal(sig, func); oldfunc = ruby_signal(sig, func);
if (oldfunc == SIG_ERR) rb_sys_fail_str(rb_signo2signm(sig)); 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) { switch (oldcmd) {
case 0: case 0:
case Qtrue: case Qtrue:
@ -1264,8 +1264,8 @@ trap(int sig, sighandler_t func, VALUE command)
break; break;
} }
vm->trap_list[sig].cmd = command; vm->trap_list.cmd[sig] = command;
vm->trap_list[sig].safe = rb_safe_level(); vm->trap_list.safe[sig] = rb_safe_level();
return oldcmd; return oldcmd;
} }
@ -1422,7 +1422,7 @@ init_sigchld(int sig)
ruby_signal(sig, oldfunc); ruby_signal(sig, oldfunc);
} }
else { else {
GET_VM()->trap_list[sig].cmd = 0; GET_VM()->trap_list.cmd[sig] = 0;
} }
return 0; return 0;
} }

7
vm.c
View file

@ -2115,8 +2115,6 @@ void rb_vm_trace_mark_event_hooks(rb_hook_list_t *hooks);
void void
rb_vm_mark(void *ptr) rb_vm_mark(void *ptr)
{ {
int i;
RUBY_MARK_ENTER("vm"); RUBY_MARK_ENTER("vm");
RUBY_GC_INFO("-------------------------------------------------\n"); RUBY_GC_INFO("-------------------------------------------------\n");
if (ptr) { if (ptr) {
@ -2144,10 +2142,7 @@ rb_vm_mark(void *ptr)
rb_vm_trace_mark_event_hooks(&vm->event_hooks); rb_vm_trace_mark_event_hooks(&vm->event_hooks);
for (i = 0; i < RUBY_NSIG; i++) { rb_gc_mark_values(RUBY_NSIG, vm->trap_list.cmd);
if (vm->trap_list[i].cmd)
rb_gc_mark(vm->trap_list[i].cmd);
}
} }
RUBY_MARK_LEAVE("vm"); RUBY_MARK_LEAVE("vm");

View file

@ -547,9 +547,9 @@ typedef struct rb_vm_struct {
/* signal */ /* signal */
struct { struct {
VALUE cmd; VALUE cmd[RUBY_NSIG];
int safe; unsigned char safe[RUBY_NSIG];
} trap_list[RUBY_NSIG]; } trap_list;
/* hook */ /* hook */
rb_hook_list_t event_hooks; rb_hook_list_t event_hooks;