* vm_core.h: remove VM_FRAME_MAGIC_LAMBDA and introduce

VM_FRAME_FLAG_LAMBDA. So that lambda block frame is
  VM_FRAME_MAGIC_BLOCK | VM_FRAME_FLAG_LAMBDA.

* vm_core.h: remvoe VM_FRAME_MAGIC_PROC because nobody uses it.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2017-06-03 10:07:44 +00:00
Родитель 08d44417e0
Коммит 26864584d2
4 изменённых файлов: 21 добавлений и 29 удалений

7
vm.c
Просмотреть файл

@ -1008,7 +1008,7 @@ invoke_iseq_block_from_c(rb_thread_t *th, const struct rb_captured_block *captur
{
const rb_iseq_t *iseq = rb_iseq_check(captured->code.iseq);
int i, opt_pc;
VALUE type = is_lambda ? VM_FRAME_MAGIC_LAMBDA : VM_FRAME_MAGIC_BLOCK;
VALUE type = VM_FRAME_MAGIC_BLOCK | (is_lambda ? VM_FRAME_FLAG_LAMBDA : 0);
rb_control_frame_t *cfp = th->ec.cfp;
VALUE *sp = cfp->sp;
const rb_callable_method_entry_t *me = th->passed_bmethod_me;
@ -1021,7 +1021,7 @@ invoke_iseq_block_from_c(rb_thread_t *th, const struct rb_captured_block *captur
}
opt_pc = vm_yield_setup_args(th, iseq, argc, sp, passed_block_handler,
(type == VM_FRAME_MAGIC_LAMBDA ? (splattable ? arg_setup_lambda : arg_setup_method) : arg_setup_block));
(is_lambda ? (splattable ? arg_setup_lambda : arg_setup_method) : arg_setup_block));
cfp->sp = sp;
if (me == NULL) {
@ -1605,10 +1605,8 @@ vm_frametype_name(const rb_control_frame_t *cfp)
case VM_FRAME_MAGIC_CLASS: return "class";
case VM_FRAME_MAGIC_TOP: return "top";
case VM_FRAME_MAGIC_CFUNC: return "cfunc";
case VM_FRAME_MAGIC_PROC: return "proc";
case VM_FRAME_MAGIC_IFUNC: return "ifunc";
case VM_FRAME_MAGIC_EVAL: return "eval";
case VM_FRAME_MAGIC_LAMBDA: return "lambda";
case VM_FRAME_MAGIC_RESCUE: return "rescue";
default:
rb_bug("unknown frame");
@ -1665,7 +1663,6 @@ hook_before_rewind(rb_thread_t *th, const rb_control_frame_t *cfp, int will_fini
THROW_DATA_CONSUMED_SET(err);
break;
case VM_FRAME_MAGIC_BLOCK:
case VM_FRAME_MAGIC_LAMBDA:
if (VM_FRAME_BMETHOD_P(th->ec.cfp)) {
EXEC_EVENT_HOOK(th, RUBY_EVENT_B_RETURN, th->ec.cfp->self, 0, 0, 0, frame_return_value(err));

Просмотреть файл

@ -980,12 +980,12 @@ typedef rb_control_frame_t *
enum {
/* Frame/Environment flag bits:
* MMMM MMMM MMMM MMMM ____ ____ FFFF EEEX (LSB)
* MMMM MMMM MMMM MMMM ____ __FF FFFF EEEX (LSB)
*
* X : tag for GC marking (It seems as Fixnum)
* EEE : 3 bits Env flags
* FFFF: 4 bits Frame flags
* MMMM: 16 bits frame magic (to check frame corruption)
* FF..: 6 bits Frame flags
* MM..: 16 bits frame magic (to check frame corruption)
*/
/* frame types */
@ -994,12 +994,10 @@ enum {
VM_FRAME_MAGIC_CLASS = 0x33330001,
VM_FRAME_MAGIC_TOP = 0x44440001,
VM_FRAME_MAGIC_CFUNC = 0x55550001,
VM_FRAME_MAGIC_PROC = 0x66660001,
VM_FRAME_MAGIC_IFUNC = 0x77770001,
VM_FRAME_MAGIC_EVAL = 0x88880001,
VM_FRAME_MAGIC_LAMBDA = 0x99990001,
VM_FRAME_MAGIC_RESCUE = 0xaaaa0001,
VM_FRAME_MAGIC_DUMMY = 0xbbbb0001,
VM_FRAME_MAGIC_IFUNC = 0x66660001,
VM_FRAME_MAGIC_EVAL = 0x77770001,
VM_FRAME_MAGIC_RESCUE = 0x88880001,
VM_FRAME_MAGIC_DUMMY = 0x99990001,
VM_FRAME_MAGIC_MASK = 0xffff0001,
@ -1008,6 +1006,7 @@ enum {
VM_FRAME_FLAG_FINISH = 0x0020,
VM_FRAME_FLAG_BMETHOD = 0x0040,
VM_FRAME_FLAG_CFRAME = 0x0080,
VM_FRAME_FLAG_LAMBDA = 0x0100,
/* env flag */
VM_ENV_FLAG_LOCAL = 0x0002,
@ -1057,10 +1056,16 @@ VM_FRAME_TYPE(const rb_control_frame_t *cfp)
return VM_ENV_FLAGS(cfp->ep, VM_FRAME_MAGIC_MASK);
}
static inline int
VM_FRAME_LAMBDA_P(const rb_control_frame_t *cfp)
{
return VM_ENV_FLAGS(cfp->ep, VM_FRAME_FLAG_LAMBDA) != 0;
}
static inline int
VM_FRAME_FINISHED_P(const rb_control_frame_t *cfp)
{
return VM_ENV_FLAGS(cfp->ep, VM_FRAME_FLAG_FINISH ) != 0;
return VM_ENV_FLAGS(cfp->ep, VM_FRAME_FLAG_FINISH) != 0;
}
static inline int

Просмотреть файл

@ -60,12 +60,6 @@ control_frame_dump(rb_thread_t *th, rb_control_frame_t *cfp)
case VM_FRAME_MAGIC_CFUNC:
magic = "CFUNC";
break;
case VM_FRAME_MAGIC_PROC:
magic = "PROC";
break;
case VM_FRAME_MAGIC_LAMBDA:
magic = "LAMBDA";
break;
case VM_FRAME_MAGIC_IFUNC:
magic = "IFUNC";
break;
@ -258,8 +252,6 @@ vm_stack_dump_each(rb_thread_t *th, rb_control_frame_t *cfp)
VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_TOP ||
VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_BLOCK ||
VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_CLASS ||
VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_PROC ||
VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_LAMBDA||
VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_CFUNC ||
VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_IFUNC ||
VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_EVAL ||

Просмотреть файл

@ -130,7 +130,7 @@ vm_check_frame_detail(VALUE type, int req_block, int req_me, int req_cref, VALUE
}
else { /* cref or Qfalse */
if (cref_or_me != Qfalse && cref_or_me_type != imemo_cref) {
if ((magic == VM_FRAME_MAGIC_LAMBDA || magic == VM_FRAME_MAGIC_IFUNC) && (cref_or_me_type == imemo_ment)) {
if (((type & VM_FRAME_FLAG_LAMBDA) || magic == VM_FRAME_MAGIC_IFUNC) && (cref_or_me_type == imemo_ment)) {
/* ignore */
}
else {
@ -178,10 +178,8 @@ vm_check_frame(VALUE type,
CHECK(VM_FRAME_MAGIC_TOP, TRUE, FALSE, TRUE, FALSE);
CHECK(VM_FRAME_MAGIC_CFUNC, TRUE, TRUE, FALSE, TRUE);
CHECK(VM_FRAME_MAGIC_BLOCK, FALSE, FALSE, FALSE, FALSE);
CHECK(VM_FRAME_MAGIC_PROC, FALSE, FALSE, FALSE, FALSE);
CHECK(VM_FRAME_MAGIC_IFUNC, FALSE, FALSE, FALSE, TRUE);
CHECK(VM_FRAME_MAGIC_EVAL, FALSE, FALSE, FALSE, FALSE);
CHECK(VM_FRAME_MAGIC_LAMBDA, FALSE, FALSE, FALSE, FALSE);
CHECK(VM_FRAME_MAGIC_RESCUE, FALSE, FALSE, FALSE, FALSE);
CHECK(VM_FRAME_MAGIC_DUMMY, TRUE, FALSE, FALSE, FALSE);
default:
@ -1073,7 +1071,7 @@ vm_throw_start(rb_thread_t *const th, rb_control_frame_t *const reg_cfp, enum ru
}
}
if (VM_FRAME_TYPE(escape_cfp) == VM_FRAME_MAGIC_LAMBDA) {
if (VM_FRAME_LAMBDA_P(escape_cfp)) {
/* lambda{... break ...} */
is_orphan = 0;
state = TAG_RETURN;
@ -1141,7 +1139,7 @@ vm_throw_start(rb_thread_t *const th, rb_control_frame_t *const reg_cfp, enum ru
}
if (lep == target_lep) {
if (VM_FRAME_TYPE(escape_cfp) == VM_FRAME_MAGIC_LAMBDA) {
if (VM_FRAME_LAMBDA_P(escape_cfp)) {
if (in_class_frame) {
/* lambda {class A; ... return ...; end} */
goto valid_return;
@ -2684,7 +2682,7 @@ vm_invoke_iseq_block(rb_thread_t *th, rb_control_frame_t *reg_cfp,
SET_SP(rsp);
vm_push_frame(th, iseq,
is_lambda ? VM_FRAME_MAGIC_LAMBDA : VM_FRAME_MAGIC_BLOCK,
VM_FRAME_MAGIC_BLOCK | (is_lambda ? VM_FRAME_FLAG_LAMBDA : 0),
captured->self,
VM_GUARDED_PREV_EP(captured->ep), 0,
iseq->body->iseq_encoded + opt_pc,