* 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
This commit is contained in:
parent
c653db51b0
commit
8c6c9c46d8
16
ChangeLog
16
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.
|
||||
|
5
eval.c
5
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");
|
||||
}
|
||||
|
5
gc.c
5
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);
|
||||
|
5
proc.c
5
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);
|
||||
|
4
thread.c
4
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);
|
||||
|
11
vm.c
11
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)
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user