summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-11 10:53:48 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-11 10:53:48 +0000
commit8c6c9c46d8aecccfa66e9e34a76e7768025671b1 (patch)
tree364a8dfe2aa1075f4e0471ec176efe15e3290fb7
parentc653db51b0b32bea9a8469dbc236538b011cc0b1 (diff)
* vm.c (rb_vm_register_special_exception): make new function to
make and register special exceptions. * vm.c (rb_vm_mark): do not need to mark special exceptions because they are registerd by rb_gc_register_mark_object(). * eval.c (Init_eval): use rb_vm_register_special_exception(). * gc.c (Init_GC): ditto. * proc.c (Init_Proc): ditto. * thread.c (Init_Thread): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog16
-rw-r--r--eval.c5
-rw-r--r--gc.c5
-rw-r--r--proc.c5
-rw-r--r--thread.c4
-rw-r--r--vm.c11
-rw-r--r--vm_core.h4
7 files changed, 33 insertions, 17 deletions
diff --git a/ChangeLog b/ChangeLog
index 7bbf338..8390bc2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+Thu Sep 11 19:50:57 2014 Koichi Sasada <ko1@atdot.net>
+
+ * vm.c (rb_vm_register_special_exception): make new function to
+ make and register special exceptions.
+
+ * vm.c (rb_vm_mark): do not need to mark special exceptions
+ because they are registerd by rb_gc_register_mark_object().
+
+ * eval.c (Init_eval): use rb_vm_register_special_exception().
+
+ * gc.c (Init_GC): ditto.
+
+ * proc.c (Init_Proc): ditto.
+
+ * thread.c (Init_Thread): ditto.
+
Thu Sep 11 19:32:30 2014 Koichi Sasada <ko1@atdot.net>
* gc.c (rb_gc_mark_values): added.
diff --git a/eval.c b/eval.c
index f0a06fb..90da225 100644
--- a/eval.c
+++ b/eval.c
@@ -1691,8 +1691,5 @@ Init_eval(void)
rb_define_global_function("trace_var", rb_f_trace_var, -1); /* in variable.c */
rb_define_global_function("untrace_var", rb_f_untrace_var, -1); /* in variable.c */
- exception_error = rb_exc_new3(rb_eFatal,
- rb_obj_freeze(rb_str_new2("exception reentered")));
- OBJ_TAINT(exception_error);
- OBJ_FREEZE(exception_error);
+ rb_vm_register_special_exception(ruby_error_reenter, rb_eFatal, "exception reentered");
}
diff --git a/gc.c b/gc.c
index 8d56e3a..03af1ea 100644
--- a/gc.c
+++ b/gc.c
@@ -8585,10 +8585,7 @@ Init_GC(void)
rb_define_module_function(rb_mObjSpace, "_id2ref", id2ref, 1);
- nomem_error = rb_exc_new3(rb_eNoMemError,
- rb_obj_freeze(rb_str_new2("failed to allocate memory")));
- OBJ_TAINT(nomem_error);
- OBJ_FREEZE(nomem_error);
+ rb_vm_register_special_exception(ruby_error_nomemory, rb_eNoMemError, "failed to allocate memory");
rb_define_method(rb_cBasicObject, "__id__", rb_obj_id, 0);
rb_define_method(rb_mKernel, "object_id", rb_obj_id, 0);
diff --git a/proc.c b/proc.c
index 63e2319..2c60574 100644
--- a/proc.c
+++ b/proc.c
@@ -2759,10 +2759,7 @@ Init_Proc(void)
rb_define_method(rb_eLocalJumpError, "reason", localjump_reason, 0);
rb_eSysStackError = rb_define_class("SystemStackError", rb_eException);
- sysstack_error = rb_exc_new3(rb_eSysStackError,
- rb_obj_freeze(rb_str_new2("stack level too deep")));
- OBJ_TAINT(sysstack_error);
- OBJ_FREEZE(sysstack_error);
+ rb_vm_register_special_exception(ruby_error_sysstack, rb_eSysStackError, "stack level too deep");
/* utility functions */
rb_define_global_function("proc", rb_block_proc, 0);
diff --git a/thread.c b/thread.c
index a1b6130..7fbe78e 100644
--- a/thread.c
+++ b/thread.c
@@ -5022,9 +5022,7 @@ Init_Thread(void)
rb_define_method(rb_cThread, "inspect", rb_thread_inspect, 0);
- closed_stream_error = rb_exc_new2(rb_eIOError, "stream closed");
- OBJ_TAINT(closed_stream_error);
- OBJ_FREEZE(closed_stream_error);
+ rb_vm_register_special_exception(ruby_error_closed_stream, rb_eIOError, "stream closed");
cThGroup = rb_define_class("ThreadGroup", rb_cObject);
rb_define_alloc_func(cThGroup, thgroup_s_alloc);
diff --git a/vm.c b/vm.c
index aeac7ee..c1d54b1 100644
--- a/vm.c
+++ b/vm.c
@@ -1751,7 +1751,6 @@ rb_vm_mark(void *ptr)
RUBY_MARK_UNLESS_NULL(vm->top_self);
RUBY_MARK_UNLESS_NULL(vm->coverages);
RUBY_MARK_UNLESS_NULL(vm->defined_module_hash);
- rb_gc_mark_locations(vm->special_exceptions, vm->special_exceptions + ruby_special_error_count);
if (vm->loading_table) {
rb_mark_tbl(vm->loading_table);
@@ -1768,6 +1767,16 @@ rb_vm_mark(void *ptr)
RUBY_MARK_LEAVE("vm");
}
+void
+rb_vm_register_special_exception(enum ruby_special_exceptions sp, VALUE cls, const char *mesg)
+{
+ rb_vm_t *vm = GET_VM();
+ VALUE exc = rb_exc_new3(cls, rb_obj_freeze(rb_str_new2(mesg)));
+ OBJ_TAINT(exc);
+ OBJ_FREEZE(exc);
+ ((VALUE *)vm->special_exceptions)[sp] = exc;
+ rb_gc_register_mark_object(exc);
+}
int
rb_vm_add_root_module(ID id, VALUE module)
diff --git a/vm_core.h b/vm_core.h
index f5ddb17..78396d1 100644
--- a/vm_core.h
+++ b/vm_core.h
@@ -383,7 +383,7 @@ typedef struct rb_vm_struct {
/* object management */
VALUE mark_object_ary;
- VALUE special_exceptions[ruby_special_error_count];
+ const VALUE special_exceptions[ruby_special_error_count];
/* load */
VALUE top_self;
@@ -956,6 +956,8 @@ void ruby_thread_init_stack(rb_thread_t *th);
int rb_vm_control_frame_id_and_class(const rb_control_frame_t *cfp, ID *idp, VALUE *klassp);
void rb_vm_rewind_cfp(rb_thread_t *th, rb_control_frame_t *cfp);
+void rb_vm_register_special_exception(enum ruby_special_exceptions sp, VALUE exception_class, const char *mesg);
+
void rb_gc_mark_machine_stack(rb_thread_t *th);
int rb_autoloading_value(VALUE mod, ID id, VALUE* value);