mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* vm_insnhelper.h: use T_IMEMO to create THROW_DATA.
Add THROW_DATA_NEW(). * internal.h: move defnition of `struct THROW_DATA' from vm_insnhelper.h to internal.h. Rename `THROW_DATA' to `vm_throw_data'. * eval_intern.h (THROW_DATA_P): move to internal.h. THROW_DATA is no longer T_NODE, so check T_IMEMO. * gc.c (gc_mark_children): mark THROW_DATA. * vm.c: catch up these changes. * vm_eval.c: ditto. * vm_insnhelper.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49936 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ac28b985bd
commit
ce179b3d04
8 changed files with 56 additions and 27 deletions
22
ChangeLog
22
ChangeLog
|
@ -1,3 +1,25 @@
|
|||
Wed Mar 11 21:45:36 2015 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* vm_insnhelper.h: use T_IMEMO to create THROW_DATA.
|
||||
|
||||
Add THROW_DATA_NEW().
|
||||
|
||||
* internal.h: move defnition of `struct THROW_DATA'
|
||||
from vm_insnhelper.h to internal.h.
|
||||
|
||||
Rename `THROW_DATA' to `vm_throw_data'.
|
||||
|
||||
* eval_intern.h (THROW_DATA_P): move to internal.h.
|
||||
THROW_DATA is no longer T_NODE, so check T_IMEMO.
|
||||
|
||||
* gc.c (gc_mark_children): mark THROW_DATA.
|
||||
|
||||
* vm.c: catch up these changes.
|
||||
|
||||
* vm_eval.c: ditto.
|
||||
|
||||
* vm_insnhelper.c: ditto.
|
||||
|
||||
Wed Mar 11 21:21:56 2015 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* vm_insnhelper.c: use T_IMEMO to create SVAR.
|
||||
|
|
|
@ -199,8 +199,6 @@ enum ruby_tag_type {
|
|||
#define TAG_FATAL RUBY_TAG_FATAL
|
||||
#define TAG_MASK RUBY_TAG_MASK
|
||||
|
||||
#define THROW_DATA_P(err) RB_TYPE_P((err), T_NODE)
|
||||
|
||||
#define SCOPE_TEST(f) (CREF_VISI(rb_vm_cref()) & (f))
|
||||
#define SCOPE_CHECK(f) (CREF_VISI(rb_vm_cref()) == (f))
|
||||
#define SCOPE_SET(f) (CREF_VISI_SET(rb_vm_cref(), (f)))
|
||||
|
|
4
gc.c
4
gc.c
|
@ -383,6 +383,7 @@ typedef struct RVALUE {
|
|||
union {
|
||||
rb_cref_t cref;
|
||||
struct vm_svar svar;
|
||||
struct vm_throw_data throw_data;
|
||||
} imemo;
|
||||
struct {
|
||||
struct RBasic basic;
|
||||
|
@ -4163,6 +4164,9 @@ gc_mark_children(rb_objspace_t *objspace, VALUE obj)
|
|||
gc_mark(objspace, RANY(obj)->as.imemo.svar.backref);
|
||||
gc_mark(objspace, RANY(obj)->as.imemo.svar.others);
|
||||
return;
|
||||
case imemo_throw_data:
|
||||
gc_mark(objspace, RANY(obj)->as.imemo.throw_data.throw_obj);
|
||||
return;
|
||||
default:
|
||||
rb_bug("T_IMEMO: unreachable");
|
||||
}
|
||||
|
|
13
internal.h
13
internal.h
|
@ -533,6 +533,7 @@ enum imemo_type {
|
|||
imemo_none,
|
||||
imemo_cref,
|
||||
imemo_svar,
|
||||
imemo_throw_data,
|
||||
imemo_mask = 0x07
|
||||
};
|
||||
|
||||
|
@ -645,6 +646,18 @@ struct vm_svar {
|
|||
const VALUE others;
|
||||
};
|
||||
|
||||
/* THROW_DATA */
|
||||
|
||||
struct vm_throw_data {
|
||||
VALUE flags;
|
||||
VALUE reserved;
|
||||
const VALUE throw_obj;
|
||||
const struct rb_control_frame_struct *catch_frame;
|
||||
VALUE throw_state;
|
||||
};
|
||||
|
||||
#define THROW_DATA_P(err) RB_TYPE_P((err), T_IMEMO)
|
||||
|
||||
/* MEMO */
|
||||
|
||||
struct MEMO {
|
||||
|
|
8
vm.c
8
vm.c
|
@ -1176,7 +1176,7 @@ vm_iter_break(rb_thread_t *th, VALUE val)
|
|||
rb_control_frame_t *target_cfp = rb_vm_search_cf_from_ep(th, cfp, ep);
|
||||
|
||||
th->state = TAG_BREAK;
|
||||
th->errinfo = (VALUE)NEW_THROW_DATA(val, target_cfp, TAG_BREAK);
|
||||
th->errinfo = (VALUE)THROW_DATA_NEW(val, target_cfp, TAG_BREAK);
|
||||
TH_JUMP_TAG(th, TAG_BREAK);
|
||||
}
|
||||
|
||||
|
@ -1421,7 +1421,7 @@ vm_exec(rb_thread_t *th)
|
|||
int state;
|
||||
VALUE result;
|
||||
VALUE initial = 0;
|
||||
struct THROW_DATA *err;
|
||||
struct vm_throw_data *err;
|
||||
|
||||
TH_PUSH_TAG(th);
|
||||
_tag.retval = Qnil;
|
||||
|
@ -1429,7 +1429,7 @@ vm_exec(rb_thread_t *th)
|
|||
vm_loop_start:
|
||||
result = vm_exec_core(th, initial);
|
||||
if ((state = th->state) != 0) {
|
||||
err = (struct THROW_DATA *)result;
|
||||
err = (struct vm_throw_data *)result;
|
||||
th->state = 0;
|
||||
goto exception_handler;
|
||||
}
|
||||
|
@ -1444,7 +1444,7 @@ vm_exec(rb_thread_t *th)
|
|||
VALUE type;
|
||||
const rb_control_frame_t *escape_cfp;
|
||||
|
||||
err = (struct THROW_DATA *)th->errinfo;
|
||||
err = (struct vm_throw_data *)th->errinfo;
|
||||
|
||||
exception_handler:
|
||||
cont_pc = cont_sp = catch_iseqval = 0;
|
||||
|
|
|
@ -1132,7 +1132,7 @@ rb_iterate(VALUE (* it_proc) (VALUE), VALUE data1,
|
|||
retval = (*it_proc) (data1);
|
||||
}
|
||||
else {
|
||||
const struct THROW_DATA *err = (struct THROW_DATA *)th->errinfo;
|
||||
const struct vm_throw_data *err = (struct vm_throw_data *)th->errinfo;
|
||||
if (state == TAG_BREAK) {
|
||||
const rb_control_frame_t *escape_cfp = THROW_DATA_CATCH_FRAME(err);
|
||||
|
||||
|
@ -1881,7 +1881,7 @@ rb_throw_obj(VALUE tag, VALUE value)
|
|||
rb_exc_raise(rb_class_new_instance(numberof(desc), desc, rb_eUncaughtThrow));
|
||||
}
|
||||
|
||||
th->errinfo = (VALUE)NEW_THROW_DATA(tag, NULL, TAG_THROW);
|
||||
th->errinfo = (VALUE)THROW_DATA_NEW(tag, NULL, TAG_THROW);
|
||||
JUMP_TAG(TAG_THROW);
|
||||
}
|
||||
|
||||
|
@ -1996,7 +1996,7 @@ rb_catch_protect(VALUE t, rb_block_call_func *func, VALUE data, int *stateptr)
|
|||
/* call with argc=1, argv = [tag], block = Qnil to insure compatibility */
|
||||
val = (*func)(tag, data, 1, (const VALUE *)&tag, Qnil);
|
||||
}
|
||||
else if (state == TAG_THROW && THROW_DATA_VAL((struct THROW_DATA *)th->errinfo) == tag) {
|
||||
else if (state == TAG_THROW && THROW_DATA_VAL((struct vm_throw_data *)th->errinfo) == tag) {
|
||||
rb_vm_rewind_cfp(th, saved_cfp);
|
||||
val = th->tag->retval;
|
||||
th->errinfo = Qnil;
|
||||
|
|
|
@ -642,7 +642,7 @@ vm_throw_continue(rb_thread_t *th, VALUE err)
|
|||
th->state = TAG_THROW;
|
||||
}
|
||||
else if (THROW_DATA_P(err)) {
|
||||
th->state = THROW_DATA_STATE((struct THROW_DATA *)err);
|
||||
th->state = THROW_DATA_STATE((struct vm_throw_data *)err);
|
||||
}
|
||||
else {
|
||||
th->state = TAG_RAISE;
|
||||
|
@ -781,7 +781,7 @@ vm_throw_start(rb_thread_t * const th, rb_control_frame_t * const reg_cfp, int s
|
|||
}
|
||||
|
||||
th->state = state;
|
||||
return (VALUE)NEW_THROW_DATA(throwobj, escape_cfp, state);
|
||||
return (VALUE)THROW_DATA_NEW(throwobj, escape_cfp, state);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
|
|
@ -229,46 +229,38 @@ enum vm_regan_acttype {
|
|||
static VALUE make_no_method_exception(VALUE exc, const char *format,
|
||||
VALUE obj, int argc, const VALUE *argv);
|
||||
|
||||
struct THROW_DATA {
|
||||
VALUE flags;
|
||||
VALUE reserved;
|
||||
VALUE throw_obj;
|
||||
const rb_control_frame_t *catch_frame;
|
||||
VALUE throw_state;
|
||||
};
|
||||
|
||||
static inline struct THROW_DATA *
|
||||
NEW_THROW_DATA(VALUE val, rb_control_frame_t *cf, VALUE st)
|
||||
static inline struct vm_throw_data *
|
||||
THROW_DATA_NEW(VALUE val, rb_control_frame_t *cf, VALUE st)
|
||||
{
|
||||
return (struct THROW_DATA *)rb_node_newnode(NODE_LIT, val, (VALUE)cf, st);
|
||||
return (struct vm_throw_data *)rb_imemo_new(imemo_throw_data, val, (VALUE)cf, st, 0);
|
||||
}
|
||||
|
||||
static inline void
|
||||
THROW_DATA_CATCH_FRAME_SET(struct THROW_DATA *obj, const rb_control_frame_t *cfp)
|
||||
THROW_DATA_CATCH_FRAME_SET(struct vm_throw_data *obj, const rb_control_frame_t *cfp)
|
||||
{
|
||||
obj->catch_frame = cfp;
|
||||
}
|
||||
|
||||
static inline void
|
||||
THROW_DATA_STATE_SET(struct THROW_DATA *obj, int st)
|
||||
THROW_DATA_STATE_SET(struct vm_throw_data *obj, int st)
|
||||
{
|
||||
obj->throw_state = (VALUE)st;
|
||||
}
|
||||
|
||||
static inline VALUE
|
||||
THROW_DATA_VAL(const struct THROW_DATA *obj)
|
||||
THROW_DATA_VAL(const struct vm_throw_data *obj)
|
||||
{
|
||||
return obj->throw_obj;
|
||||
}
|
||||
|
||||
static inline const rb_control_frame_t *
|
||||
THROW_DATA_CATCH_FRAME(const struct THROW_DATA *obj)
|
||||
THROW_DATA_CATCH_FRAME(const struct vm_throw_data *obj)
|
||||
{
|
||||
return obj->catch_frame;
|
||||
}
|
||||
|
||||
static int
|
||||
THROW_DATA_STATE(const struct THROW_DATA *obj)
|
||||
THROW_DATA_STATE(const struct vm_throw_data *obj)
|
||||
{
|
||||
return (int)obj->throw_state;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue