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

ruby-changes:39219

From: nobu <ko1@a...>
Date: Mon, 20 Jul 2015 09:08:53 +0900 (JST)
Subject: [ruby-changes:39219] nobu:r51300 (trunk): ruby_vm_throw_flags

nobu	2015-07-20 09:08:23 +0900 (Mon, 20 Jul 2015)

  New Revision: 51300

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

  Log:
    ruby_vm_throw_flags
    
    * vm_core.h (ruby_vm_throw_flags): constants for throw.

  Modified files:
    trunk/compile.c
    trunk/vm_core.h
    trunk/vm_insnhelper.c
Index: vm_core.h
===================================================================
--- vm_core.h	(revision 51299)
+++ vm_core.h	(revision 51300)
@@ -145,6 +145,12 @@ enum ruby_tag_type { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L145
 #define TAG_FATAL	RUBY_TAG_FATAL
 #define TAG_MASK	RUBY_TAG_MASK
 
+enum ruby_vm_throw_flags {
+    VM_THROW_NO_ESCAPE_FLAG = 0x8000,
+    VM_THROW_LEVEL_SHIFT = 16,
+    VM_THROW_STATE_MASK = 0xff
+};
+
 /* iseq data type */
 
 struct iseq_compile_data_ensure_node_stack;
Index: compile.c
===================================================================
--- compile.c	(revision 51299)
+++ compile.c	(revision 51300)
@@ -3725,11 +3725,11 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ https://github.com/ruby/ruby/blob/trunk/compile.c#L3725
 
 		level++;
 		if (ip->compile_data->redo_label != 0) {
-		    level = 0x8000;
+		    level = VM_THROW_NO_ESCAPE_FLAG;
 		    goto break_by_insn;
 		}
 		else if (ip->type == ISEQ_TYPE_BLOCK) {
-		    level <<= 16;
+		    level <<= VM_THROW_LEVEL_SHIFT;
 		    goto break_by_insn;
 		}
 		else if (ip->type == ISEQ_TYPE_EVAL) {
@@ -3785,7 +3785,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ https://github.com/ruby/ruby/blob/trunk/compile.c#L3785
 		    break;
 		}
 
-		level = 0x8000;
+		level = VM_THROW_NO_ESCAPE_FLAG;
 		if (ip->compile_data->redo_label != 0) {
 		    /* while loop */
 		    break;
@@ -3846,7 +3846,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ https://github.com/ruby/ruby/blob/trunk/compile.c#L3846
 	}
 	else {
 	    const rb_iseq_t *ip = iseq;
-	    unsigned long level = 0x8000;
+	    const unsigned long level = VM_THROW_NO_ESCAPE_FLAG;
 
 	    while (ip) {
 		if (!ip->compile_data) {
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 51299)
+++ vm_insnhelper.c	(revision 51300)
@@ -830,7 +830,8 @@ vm_throw_continue(rb_thread_t *th, VALUE https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L830
 }
 
 static VALUE
-vm_throw_start(rb_thread_t * const th, rb_control_frame_t * const reg_cfp, int state, const int flag, const rb_num_t level, const VALUE throwobj)
+vm_throw_start(rb_thread_t *const th, rb_control_frame_t *const reg_cfp, enum ruby_tag_type state,
+	       const int flag, const rb_num_t level, const VALUE throwobj)
 {
     rb_control_frame_t *escape_cfp = NULL;
     const rb_control_frame_t * const eocfp = RUBY_VM_END_CONTROL_FRAME(th); /* end of control frame pointer */
@@ -966,9 +967,9 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L967
 vm_throw(rb_thread_t *th, rb_control_frame_t *reg_cfp,
 	 rb_num_t throw_state, VALUE throwobj)
 {
-    const int state = (int)(throw_state & 0xff);
-    const int flag = (int)(throw_state & 0x8000);
-    const rb_num_t level = throw_state >> 16;
+    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(th, reg_cfp, state, flag, level, throwobj);

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

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