[前][次][番号順一覧][スレッド一覧]

ruby-changes:52895

From: mame <ko1@a...>
Date: Wed, 17 Oct 2018 16:17:02 +0900 (JST)
Subject: [ruby-changes:52895] mame:r65107 (trunk): Remove the level information from throw instruction

mame	2018-10-17 16:16:50 +0900 (Wed, 17 Oct 2018)

  New Revision: 65107

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65107

  Log:
    Remove the level information from throw instruction
    
    It is no longer used.

  Modified files:
    trunk/compile.c
    trunk/vm_core.h
    trunk/vm_insnhelper.c
Index: vm_core.h
===================================================================
--- vm_core.h	(revision 65106)
+++ vm_core.h	(revision 65107)
@@ -194,7 +194,6 @@ enum ruby_tag_type { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L194
 
 enum ruby_vm_throw_flags {
     VM_THROW_NO_ESCAPE_FLAG = 0x8000,
-    VM_THROW_LEVEL_SHIFT = 16,
     VM_THROW_STATE_MASK = 0xff
 };
 
Index: compile.c
===================================================================
--- compile.c	(revision 65106)
+++ compile.c	(revision 65107)
@@ -5361,7 +5361,7 @@ static int https://github.com/ruby/ruby/blob/trunk/compile.c#L5361
 compile_break(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped)
 {
     const int line = nd_line(node);
-    unsigned long level = 0;
+    unsigned long throw_flag = 0;
 
     if (ISEQ_COMPILE_DATA(iseq)->redo_label != 0) {
 	/* while/until */
@@ -5382,7 +5382,7 @@ compile_break(rb_iseq_t *iseq, LINK_ANCH https://github.com/ruby/ruby/blob/trunk/compile.c#L5382
       break_by_insn:
 	/* escape from block */
 	CHECK(COMPILE(ret, "break val (block)", node->nd_stts));
-	ADD_INSN1(ret, line, throw, INT2FIX(level | TAG_BREAK));
+	ADD_INSN1(ret, line, throw, INT2FIX(throw_flag | TAG_BREAK));
 	if (popped) {
 	    ADD_INSN(ret, line, pop);
 	}
@@ -5401,13 +5401,11 @@ compile_break(rb_iseq_t *iseq, LINK_ANCH https://github.com/ruby/ruby/blob/trunk/compile.c#L5401
 		break;
 	    }
 
-	    level++;
 	    if (ISEQ_COMPILE_DATA(ip)->redo_label != 0) {
-		level = VM_THROW_NO_ESCAPE_FLAG;
+		throw_flag = VM_THROW_NO_ESCAPE_FLAG;
 		goto break_by_insn;
 	    }
 	    else if (ip->body->type == ISEQ_TYPE_BLOCK) {
-		level <<= VM_THROW_LEVEL_SHIFT;
 		goto break_by_insn;
 	    }
 	    else if (ip->body->type == ISEQ_TYPE_EVAL) {
@@ -5426,7 +5424,7 @@ static int https://github.com/ruby/ruby/blob/trunk/compile.c#L5424
 compile_next(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped)
 {
     const int line = nd_line(node);
-    unsigned long level = 0;
+    unsigned long throw_flag = 0;
 
     if (ISEQ_COMPILE_DATA(iseq)->redo_label != 0) {
 	LABEL *splabel = NEW_LABEL(0);
@@ -5470,7 +5468,7 @@ compile_next(rb_iseq_t *iseq, LINK_ANCHO https://github.com/ruby/ruby/blob/trunk/compile.c#L5468
 		break;
 	    }
 
-	    level = VM_THROW_NO_ESCAPE_FLAG;
+	    throw_flag = VM_THROW_NO_ESCAPE_FLAG;
 	    if (ISEQ_COMPILE_DATA(ip)->redo_label != 0) {
 		/* while loop */
 		break;
@@ -5486,7 +5484,7 @@ compile_next(rb_iseq_t *iseq, LINK_ANCHO https://github.com/ruby/ruby/blob/trunk/compile.c#L5484
 	}
 	if (ip != 0) {
 	    CHECK(COMPILE(ret, "next val", node->nd_stts));
-	    ADD_INSN1(ret, line, throw, INT2FIX(level | TAG_NEXT));
+	    ADD_INSN1(ret, line, throw, INT2FIX(throw_flag | TAG_NEXT));
 
 	    if (popped) {
 		ADD_INSN(ret, line, pop);
@@ -5538,7 +5536,6 @@ compile_redo(rb_iseq_t *iseq, LINK_ANCHO https://github.com/ruby/ruby/blob/trunk/compile.c#L5536
     }
     else {
 	const rb_iseq_t *ip = iseq;
-	const unsigned long level = VM_THROW_NO_ESCAPE_FLAG;
 
 	while (ip) {
 	    if (!ISEQ_COMPILE_DATA(ip)) {
@@ -5560,7 +5557,7 @@ compile_redo(rb_iseq_t *iseq, LINK_ANCHO https://github.com/ruby/ruby/blob/trunk/compile.c#L5557
 	}
 	if (ip != 0) {
 	    ADD_INSN(ret, line, putnil);
-	    ADD_INSN1(ret, line, throw, INT2FIX(level | TAG_REDO));
+	    ADD_INSN1(ret, line, throw, INT2FIX(VM_THROW_NO_ESCAPE_FLAG | TAG_REDO));
 
 	    if (popped) {
 		ADD_INSN(ret, line, pop);
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 65106)
+++ vm_insnhelper.c	(revision 65107)
@@ -1086,7 +1086,7 @@ vm_throw_continue(const rb_execution_con https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1086
 
 static VALUE
 vm_throw_start(const rb_execution_context_t *ec, rb_control_frame_t *const reg_cfp, enum ruby_tag_type state,
-	       const int flag, const rb_num_t level, const VALUE throwobj)
+	       const int flag, const VALUE throwobj)
 {
     const rb_control_frame_t *escape_cfp = NULL;
     const rb_control_frame_t * const eocfp = RUBY_VM_END_CONTROL_FRAME(ec); /* end of control frame pointer */
@@ -1154,13 +1154,8 @@ vm_throw_start(const rb_execution_contex https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1154
 	}
     }
     else if (state == TAG_RETRY) {
-	rb_num_t i;
 	const VALUE *ep = VM_ENV_PREV_EP(GET_EP());
 
-	for (i = 0; i < level; i++) {
-	    ep = VM_ENV_PREV_EP(ep);
-	}
-
 	escape_cfp = rb_vm_search_cf_from_ep(ec, reg_cfp, ep);
     }
     else if (state == TAG_RETURN) {
@@ -1244,10 +1239,9 @@ vm_throw(const rb_execution_context_t *e https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1239
 {
     const int state = (int)(throw_state & VM_THROW_STATE_MASK);
     const int flag = (int)(throw_state & VM_THROW_NO_ESCAPE_FLAG);
-    const rb_num_t level = throw_state >> VM_THROW_LEVEL_SHIFT;
 
     if (state != 0) {
-	return vm_throw_start(ec, reg_cfp, state, flag, level, throwobj);
+	return vm_throw_start(ec, reg_cfp, state, flag, throwobj);
     }
     else {
 	return vm_throw_continue(ec, throwobj);

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]