зеркало из https://github.com/github/ruby.git
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
e7a660a3cf
Коммит
9b45b336ee
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
Sun Jun 15 18:17:03 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* 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@ruby-lang.org>
|
||||
|
||||
* ext/stringio/stringio.c (strio_sysread): should not raise at empty
|
||||
|
|
9
eval.c
9
eval.c
|
@ -20,9 +20,8 @@ NORETURN(void rb_raise_jump(VALUE));
|
|||
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 @@ rb_longjmp(int tag, VALUE mesg)
|
|||
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 @@ Init_eval(void)
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
|
10
gc.c
10
gc.c
|
@ -84,7 +84,7 @@ void *alloca ();
|
|||
#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 @@ rb_memerror(void)
|
|||
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 @@ Init_GC(void)
|
|||
|
||||
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);
|
||||
|
|
2
proc.c
2
proc.c
|
@ -1756,7 +1756,7 @@ Init_Proc(void)
|
|||
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);
|
||||
|
|
|
@ -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[];
|
||||
|
|
1
vm.c
1
vm.c
|
@ -1393,6 +1393,7 @@ rb_vm_mark(void *ptr)
|
|||
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);
|
||||
|
|
11
vm_core.h
11
vm_core.h
|
@ -281,6 +281,13 @@ struct rb_iseq_struct {
|
|||
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 @@ struct rb_vm_struct
|
|||
/* object management */
|
||||
VALUE mark_object_ary;
|
||||
|
||||
VALUE special_exceptions[ruby_special_error_count];
|
||||
|
||||
/* load */
|
||||
VALUE top_self;
|
||||
VALUE load_path;
|
||||
|
@ -648,7 +657,7 @@ VALUE vm_make_env_object(rb_thread_t *th, rb_control_frame_t *cfp);
|
|||
|
||||
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 */
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче