aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog13
-rw-r--r--signal.c27
-rw-r--r--vm.c7
-rw-r--r--vm_core.h6
4 files changed, 20 insertions, 33 deletions
diff --git a/ChangeLog b/ChangeLog
index db81744d1f..938118d5f9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,16 +1,3 @@
-Wed Jul 16 18:34:47 2014 Koichi Sasada <ko1@atdot.net>
-
- * vm_core.h: remove rb_vm_t::trap_list[RUBY_NSIG], but add
- rb_vm_t::trap_list_cmds (an array) and
- rb_vm_t::trap_list_safes[RUBY_NSIG]
- (separate to two different array).
-
- This modification reduce root objects.
-
- * signal.c: ditto.
-
- * vm.c (rb_vm_mark): remove marking code for rb_vm_t::trap_list.
-
Wed Jul 16 18:08:47 2014 Koichi Sasada <ko1@atdot.net>
* iseq.c (rb_iseq_defined_string): use rb_gc_mark_object() instead of
diff --git a/signal.c b/signal.c
index 1adcaee73a..f6232fdf75 100644
--- a/signal.c
+++ b/signal.c
@@ -861,17 +861,15 @@ signal_exec(VALUE cmd, int safe, int sig)
}
}
-#define TRAP_LIST_CMD(vm, sig) RARRAY_AREF((vm)->trap_list_cmds, (sig))
-#define TRAP_LIST_SAFE(vm, sig) ((vm)->trap_list_safes[sig])
void
rb_trap_exit(void)
{
rb_vm_t *vm = GET_VM();
- VALUE trap_exit = TRAP_LIST_CMD(vm, 0);
+ VALUE trap_exit = vm->trap_list[0].cmd;
if (trap_exit) {
- RARRAY_ASET(vm->trap_list_cmds, 0, Qfalse);
- signal_exec(trap_exit, TRAP_LIST_SAFE(vm, 0), 0);
+ vm->trap_list[0].cmd = 0;
+ signal_exec(trap_exit, vm->trap_list[0].safe, 0);
}
}
@@ -879,8 +877,8 @@ void
rb_signal_exec(rb_thread_t *th, int sig)
{
rb_vm_t *vm = GET_VM();
- VALUE cmd = TRAP_LIST_CMD(vm, sig);
- int safe = TRAP_LIST_SAFE(vm, sig);
+ VALUE cmd = vm->trap_list[sig].cmd;
+ int safe = vm->trap_list[sig].safe;
if (cmd == 0) {
switch (sig) {
@@ -1076,7 +1074,7 @@ trap(int sig, sighandler_t func, VALUE command)
* RUBY_VM_CHECK_INTS().
*/
oldfunc = ruby_signal(sig, func);
- oldcmd = TRAP_LIST_CMD(vm, sig);
+ oldcmd = vm->trap_list[sig].cmd;
switch (oldcmd) {
case 0:
case Qtrue:
@@ -1092,8 +1090,8 @@ trap(int sig, sighandler_t func, VALUE command)
break;
}
- RARRAY_ASET(vm->trap_list_cmds, sig, command);
- vm->trap_list_safes[sig] = rb_safe_level();
+ vm->trap_list[sig].cmd = command;
+ vm->trap_list[sig].safe = rb_safe_level();
return oldcmd;
}
@@ -1242,7 +1240,7 @@ init_sigchld(int sig)
ruby_signal(sig, oldfunc);
}
else {
- RARRAY_ASET(GET_VM()->trap_list_cmds, sig, Qfalse);
+ GET_VM()->trap_list[sig].cmd = 0;
}
rb_enable_interrupt();
}
@@ -1306,13 +1304,6 @@ void
Init_signal(void)
{
VALUE mSignal = rb_define_module("Signal");
- int i;
- VALUE cmds = GET_VM()->trap_list_cmds = rb_ary_tmp_new(RUBY_NSIG);
-
- rb_gc_register_mark_object(cmds);
- for (i=0; i<RUBY_NSIG; i++) {
- RARRAY_ASET(cmds, i, Qfalse);
- }
rb_define_global_function("trap", sig_trap, -1);
rb_define_module_function(mSignal, "trap", sig_trap, -1);
diff --git a/vm.c b/vm.c
index 3c17a7811a..5e9204bd70 100644
--- a/vm.c
+++ b/vm.c
@@ -1737,6 +1737,8 @@ 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) {
@@ -1764,6 +1766,11 @@ 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);
+ }
}
RUBY_MARK_LEAVE("vm");
diff --git a/vm_core.h b/vm_core.h
index 44b63ea43f..39dce05c99 100644
--- a/vm_core.h
+++ b/vm_core.h
@@ -364,8 +364,10 @@ typedef struct rb_vm_struct {
struct st_table *loading_table;
/* signal */
- VALUE trap_list_cmds; /* an Array object */
- int trap_list_safes[RUBY_NSIG];
+ struct {
+ VALUE cmd;
+ int safe;
+ } trap_list[RUBY_NSIG];
/* hook */
rb_hook_list_t event_hooks;