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:
parent
9e9f57e4a0
commit
083a25f903
3 changed files with 14 additions and 19 deletions
20
signal.c
20
signal.c
|
@ -1022,11 +1022,11 @@ void
|
|||
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
|
|||
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 command)
|
|||
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 command)
|
|||
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 command)
|
|||
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)
|
|||
ruby_signal(sig, oldfunc);
|
||||
}
|
||||
else {
|
||||
GET_VM()->trap_list[sig].cmd = 0;
|
||||
GET_VM()->trap_list.cmd[sig] = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
7
vm.c
7
vm.c
|
@ -2115,8 +2115,6 @@ void rb_vm_trace_mark_event_hooks(rb_hook_list_t *hooks);
|
|||
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)
|
|||
|
||||
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");
|
||||
|
|
|
@ -547,9 +547,9 @@ typedef struct rb_vm_struct {
|
|||
|
||||
/* 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;
|
||||
|
|
Loading…
Reference in a new issue