ruby-changes:5658
From: nobu <ko1@a...>
Date: Sun, 15 Jun 2008 18:17:28 +0900 (JST)
Subject: [ruby-changes:5658] Ruby:r17165 (trunk): * vm_core.h (rb_vm_t), vm.c (rb_vm_mark): moved preallocated special
nobu 2008-06-15 18:17:06 +0900 (Sun, 15 Jun 2008) New Revision: 17165 Modified files: trunk/ChangeLog trunk/eval.c trunk/gc.c trunk/proc.c trunk/version.h trunk/vm.c trunk/vm_core.h Log: * vm_core.h (rb_vm_t), vm.c (rb_vm_mark): moved preallocated special exceptions. * eval.c (Init_eval), gc.c (Init_GC), proc.c (Init_Proc): freeze preallocated special exceptions. * eval.c (rb_longjmp): duplicate the thrown exception to set backtrace if it was frozen. * gc.c (rb_memerror): raise nomem_error without backtrace if failed to make backtrace. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/version.h?r1=17165&r2=17164&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=17165&r2=17164&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/gc.c?r1=17165&r2=17164&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/eval.c?r1=17165&r2=17164&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/vm_core.h?r1=17165&r2=17164&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/proc.c?r1=17165&r2=17164&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/vm.c?r1=17165&r2=17164&diff_format=u Index: ChangeLog =================================================================== --- ChangeLog (revision 17164) +++ ChangeLog (revision 17165) @@ -1,3 +1,17 @@ +Sun Jun 15 18:17:03 2008 Nobuyoshi Nakada <nobu@r...> + + * vm_core.h (rb_vm_t), vm.c (rb_vm_mark): moved preallocated special + exceptions. + + * eval.c (Init_eval), gc.c (Init_GC), proc.c (Init_Proc): freeze + preallocated special exceptions. + + * eval.c (rb_longjmp): duplicate the thrown exception to set backtrace + if it was frozen. + + * gc.c (rb_memerror): raise nomem_error without backtrace if failed to + make backtrace. + Sat Jun 14 22:52:35 2008 Nobuyoshi Nakada <nobu@r...> * ext/stringio/stringio.c (strio_sysread): should not raise at empty Index: vm_core.h =================================================================== --- vm_core.h (revision 17164) +++ vm_core.h (revision 17165) @@ -281,6 +281,13 @@ struct iseq_compile_data *compile_data; }; +enum ruby_special_exceptions { + ruby_error_reenter, + ruby_error_nomemory, + ruby_error_sysstack, + ruby_special_error_count +}; + typedef struct rb_iseq_struct rb_iseq_t; #define GetVMPtr(obj, ptr) \ @@ -307,6 +314,8 @@ /* object management */ VALUE mark_object_ary; + VALUE special_exceptions[ruby_special_error_count]; + /* load */ VALUE top_self; VALUE load_path; @@ -648,7 +657,7 @@ NOINLINE(void rb_gc_save_machine_context(rb_thread_t *)); -RUBY_EXTERN VALUE sysstack_error; +#define sysstack_error GET_VM()->special_exceptions[ruby_error_sysstack] /* for thread */ Index: proc.c =================================================================== --- proc.c (revision 17164) +++ proc.c (revision 17165) @@ -1756,7 +1756,7 @@ rb_eSysStackError = rb_define_class("SystemStackError", rb_eException); sysstack_error = rb_exc_new2(rb_eSysStackError, "stack level too deep"); OBJ_TAINT(sysstack_error); - rb_register_mark_object(sysstack_error); + OBJ_FREEZE(sysstack_error); /* utility functions */ rb_define_global_function("proc", rb_block_proc, 0); Index: eval.c =================================================================== --- eval.c (revision 17164) +++ eval.c (revision 17165) @@ -20,9 +20,8 @@ ID rb_frame_callee(void); VALUE rb_eLocalJumpError; VALUE rb_eSysStackError; -VALUE sysstack_error; -static VALUE exception_error; +#define exception_error GET_VM()->special_exceptions[ruby_error_reenter] #include "eval_error.c" #include "eval_safe.c" @@ -372,6 +371,9 @@ at = get_backtrace(mesg); if (NIL_P(at)) { at = rb_make_backtrace(); + if (OBJ_FROZEN(mesg)) { + mesg = rb_obj_dup(mesg); + } set_backtrace(mesg, at); } } @@ -1198,7 +1200,8 @@ exception_error = rb_exc_new2(rb_eFatal, "exception reentered"); rb_ivar_set(exception_error, idThrowState, INT2FIX(TAG_FATAL)); - rb_register_mark_object(exception_error); + OBJ_TAINT(exception_error); + OBJ_FREEZE(exception_error); } Index: gc.c =================================================================== --- gc.c (revision 17164) +++ gc.c (revision 17165) @@ -84,7 +84,7 @@ #endif #endif -static VALUE nomem_error; +#define nomem_error GET_VM()->special_exceptions[ruby_error_nomemory] #define MARK_STACK_MAX 1024 @@ -265,6 +265,11 @@ fprintf(stderr, "[FATAL] failed to allocate memory\n"); exit(EXIT_FAILURE); } + if (rb_thread_raised_p(th, RAISED_NOMEMORY)) { + rb_thread_raised_clear(th); + GET_THREAD()->errinfo = nomem_error; + JUMP_TAG(TAG_RAISE); + } rb_thread_raised_set(th, RAISED_NOMEMORY); rb_exc_raise(nomem_error); } @@ -2394,8 +2399,9 @@ rb_define_module_function(rb_mObSpace, "_id2ref", id2ref, 1); - rb_global_variable(&nomem_error); nomem_error = rb_exc_new2(rb_eNoMemError, "failed to allocate memory"); + OBJ_TAINT(nomem_error); + OBJ_FREEZE(nomem_error); rb_define_method(rb_mKernel, "hash", rb_obj_id, 0); rb_define_method(rb_mKernel, "__id__", rb_obj_id, 0); Index: vm.c =================================================================== --- vm.c (revision 17164) +++ vm.c (revision 17165) @@ -1393,6 +1393,7 @@ RUBY_MARK_UNLESS_NULL(vm->load_path); RUBY_MARK_UNLESS_NULL(vm->loaded_features); RUBY_MARK_UNLESS_NULL(vm->top_self); + rb_gc_mark_locations(vm->special_exceptions, vm->special_exceptions + ruby_special_error_count - 1); if (vm->loading_table) { rb_mark_tbl(vm->loading_table); Index: version.h =================================================================== --- version.h (revision 17164) +++ version.h (revision 17165) @@ -1,7 +1,7 @@ #define RUBY_VERSION "1.9.0" -#define RUBY_RELEASE_DATE "2008-06-14" +#define RUBY_RELEASE_DATE "2008-06-15" #define RUBY_VERSION_CODE 190 -#define RUBY_RELEASE_CODE 20080614 +#define RUBY_RELEASE_CODE 20080615 #define RUBY_PATCHLEVEL 0 #define RUBY_VERSION_MAJOR 1 @@ -9,7 +9,7 @@ #define RUBY_VERSION_TEENY 0 #define RUBY_RELEASE_YEAR 2008 #define RUBY_RELEASE_MONTH 6 -#define RUBY_RELEASE_DAY 14 +#define RUBY_RELEASE_DAY 15 #ifdef RUBY_EXTERN RUBY_EXTERN const char ruby_version[]; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/