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

ruby-changes:39188

From: ko1 <ko1@a...>
Date: Thu, 16 Jul 2015 22:14:03 +0900 (JST)
Subject: [ruby-changes:39188] ko1:r51269 (trunk): * vm_core.h: constify rb_iseq_t::parent_iseq.

ko1	2015-07-16 22:13:50 +0900 (Thu, 16 Jul 2015)

  New Revision: 51269

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

  Log:
    * vm_core.h: constify rb_iseq_t::parent_iseq.
      rb_iseq_t::local_iseq is not constant data because
      local_iseq::flip_cnt can be modified (commentted).
    * compile.c: catch up this fix.
    * iseq.c: ditto.
    * vm_insnhelper.c: ditto.

  Modified files:
    trunk/ChangeLog
    trunk/compile.c
    trunk/iseq.c
    trunk/vm_core.h
    trunk/vm_insnhelper.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 51268)
+++ ChangeLog	(revision 51269)
@@ -1,3 +1,16 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Jul 16 22:05:29 2015  Koichi Sasada  <ko1@a...>
+
+	* vm_core.h: constify rb_iseq_t::parent_iseq.
+
+	  rb_iseq_t::local_iseq is not constant data because
+	  local_iseq::flip_cnt can be modified (commentted).
+
+	* compile.c: catch up this fix.
+
+	* iseq.c: ditto.
+
+	* vm_insnhelper.c: ditto.
+
 Thu Jul 16 21:47:47 2015  Naohisa Goto  <ngotogenome@g...>
 
 	* process.c (redirect_dup2): when the new FD of dup2() coflicts
Index: vm_core.h
===================================================================
--- vm_core.h	(revision 51268)
+++ vm_core.h	(revision 51269)
@@ -336,8 +336,8 @@ struct rb_iseq_struct { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L336
     struct iseq_catch_table *catch_table;
 
     /* for child iseq */
-    struct rb_iseq_struct *parent_iseq;
-    struct rb_iseq_struct *local_iseq;
+    const struct rb_iseq_struct *parent_iseq;
+    struct rb_iseq_struct *local_iseq; /* local_iseq->flip_cnt can be modified */
 
     /****************/
     /* dynamic data */
Index: iseq.c
===================================================================
--- iseq.c	(revision 51268)
+++ iseq.c	(revision 51269)
@@ -102,7 +102,7 @@ iseq_free(void *ptr) https://github.com/ruby/ruby/blob/trunk/iseq.c#L102
 static void
 iseq_mark(void *ptr)
 {
-    rb_iseq_t *iseq = ptr;
+    const rb_iseq_t *iseq = ptr;
 
     RUBY_MARK_ENTER("iseq");
 
@@ -915,7 +915,7 @@ rb_iseq_base_label(VALUE self) https://github.com/ruby/ruby/blob/trunk/iseq.c#L915
 VALUE
 rb_iseq_first_lineno(VALUE self)
 {
-    rb_iseq_t *iseq;
+    const rb_iseq_t *iseq;
     GetISeqPtr(self, iseq);
     return iseq->location.first_lineno;
 }
@@ -923,7 +923,7 @@ rb_iseq_first_lineno(VALUE self) https://github.com/ruby/ruby/blob/trunk/iseq.c#L923
 VALUE
 rb_iseq_method_name(VALUE self)
 {
-    rb_iseq_t *iseq, *local_iseq;
+    const rb_iseq_t *iseq, *local_iseq;
     GetISeqPtr(self, iseq);
     local_iseq = iseq->local_iseq;
     if (local_iseq->type == ISEQ_TYPE_METHOD) {
Index: compile.c
===================================================================
--- compile.c	(revision 51268)
+++ compile.c	(revision 51269)
@@ -1068,7 +1068,7 @@ iseq_set_exception_local_table(rb_iseq_t https://github.com/ruby/ruby/blob/trunk/compile.c#L1068
 }
 
 static int
-get_lvar_level(rb_iseq_t *iseq)
+get_lvar_level(const rb_iseq_t *iseq)
 {
     int lev = 0;
     while (iseq != iseq->local_iseq) {
@@ -1079,7 +1079,7 @@ get_lvar_level(rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/compile.c#L1079
 }
 
 static int
-get_dyna_var_idx_at_raw(rb_iseq_t *iseq, ID id)
+get_dyna_var_idx_at_raw(const rb_iseq_t *iseq, ID id)
 {
     int i;
 
@@ -1092,7 +1092,7 @@ get_dyna_var_idx_at_raw(rb_iseq_t *iseq, https://github.com/ruby/ruby/blob/trunk/compile.c#L1092
 }
 
 static int
-get_local_var_idx(rb_iseq_t *iseq, ID id)
+get_local_var_idx(const rb_iseq_t *iseq, ID id)
 {
     int idx = get_dyna_var_idx_at_raw(iseq->local_iseq, id);
 
@@ -1104,7 +1104,7 @@ get_local_var_idx(rb_iseq_t *iseq, ID id https://github.com/ruby/ruby/blob/trunk/compile.c#L1104
 }
 
 static int
-get_dyna_var_idx(rb_iseq_t *iseq, ID id, int *level, int *ls)
+get_dyna_var_idx(const rb_iseq_t *iseq, ID id, int *level, int *ls)
 {
     int lv = 0, idx = -1;
 
@@ -3124,10 +3124,10 @@ defined_expr(rb_iseq_t *iseq, LINK_ANCHO https://github.com/ruby/ruby/blob/trunk/compile.c#L3124
 }
 
 static VALUE
-make_name_for_block(rb_iseq_t *iseq)
+make_name_for_block(const rb_iseq_t *iseq)
 {
     int level = 1;
-    rb_iseq_t *ip = iseq;
+    const rb_iseq_t *ip = iseq;
 
     if (iseq->parent_iseq != 0) {
 	while (ip->local_iseq != ip) {
@@ -3716,7 +3716,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ https://github.com/ruby/ruby/blob/trunk/compile.c#L3716
 	    COMPILE_ERROR((ERROR_ARGS "Can't escape from eval with break"));
 	}
 	else {
-	    rb_iseq_t *ip = iseq->parent_iseq;
+	    const rb_iseq_t *ip = iseq->parent_iseq;
 	    while (ip) {
 		if (!ip->compile_data) {
 		    ip = 0;
@@ -3781,8 +3781,8 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ https://github.com/ruby/ruby/blob/trunk/compile.c#L3781
 	    COMPILE_ERROR((ERROR_ARGS "Can't escape from eval with next"));
 	}
 	else {
-	    rb_iseq_t *ip;
-	    ip = iseq;
+	    const rb_iseq_t *ip = iseq;
+
 	    while (ip) {
 		if (!ip->compile_data) {
 		    ip = 0;
@@ -3849,10 +3849,10 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ https://github.com/ruby/ruby/blob/trunk/compile.c#L3849
 	    }
 	}
 	else {
-	    rb_iseq_t *ip;
+	    const rb_iseq_t *ip = iseq;
 	    unsigned long level;
 	    level = 0x8000 | 0x4000;
-	    ip = iseq;
+
 	    while (ip) {
 		if (!ip->compile_data) {
 		    ip = 0;
@@ -4639,7 +4639,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ https://github.com/ruby/ruby/blob/trunk/compile.c#L4639
 	else {
 	    /* NODE_ZSUPER */
 	    int i;
-	    rb_iseq_t *liseq = iseq->local_iseq;
+	    const rb_iseq_t *liseq = iseq->local_iseq;
 	    int lvar_level = get_lvar_level(iseq);
 
 	    argc = liseq->param.lead_num;
@@ -5382,7 +5382,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ https://github.com/ruby/ruby/blob/trunk/compile.c#L5382
 		ADD_INSN2(ret, line, getlocal, INT2FIX(2), INT2FIX(0));
 	    }
 	    else {
-		rb_iseq_t *ip = iseq;
+		const rb_iseq_t *ip = iseq;
 		int level = 0;
 		while (ip) {
 		    if (ip->type == ISEQ_TYPE_RESCUE) {
@@ -6253,7 +6253,8 @@ int https://github.com/ruby/ruby/blob/trunk/compile.c#L6253
 rb_dvar_defined(ID id)
 {
     rb_thread_t *th = GET_THREAD();
-    rb_iseq_t *iseq;
+    const rb_iseq_t *iseq;
+
     if (th->base_block && (iseq = th->base_block->iseq)) {
 	while (iseq->type == ISEQ_TYPE_BLOCK ||
 	       iseq->type == ISEQ_TYPE_RESCUE ||
@@ -6278,7 +6279,7 @@ int https://github.com/ruby/ruby/blob/trunk/compile.c#L6279
 rb_local_defined(ID id)
 {
     rb_thread_t *th = GET_THREAD();
-    rb_iseq_t *iseq;
+    const rb_iseq_t *iseq;
 
     if (th->base_block && th->base_block->iseq) {
 	int i;
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 51268)
+++ vm_insnhelper.c	(revision 51269)
@@ -841,7 +841,7 @@ vm_throw_start(rb_thread_t * const th, r https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L841
     else if (state == TAG_BREAK) {
 	int is_orphan = 1;
 	VALUE *ep = GET_EP();
-	rb_iseq_t *base_iseq = GET_ISEQ();
+	const rb_iseq_t *base_iseq = GET_ISEQ();
 	escape_cfp = reg_cfp;
 
 	while (base_iseq->type != ISEQ_TYPE_BLOCK) {
@@ -1869,7 +1869,7 @@ current_method_entry(rb_thread_t *th, rb https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1869
     rb_control_frame_t *top_cfp = cfp;
 
     if (cfp->iseq && cfp->iseq->type == ISEQ_TYPE_BLOCK) {
-	rb_iseq_t *local_iseq = cfp->iseq->local_iseq;
+	const rb_iseq_t *local_iseq = cfp->iseq->local_iseq;
 	do {
 	    cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
 	    if (RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th, cfp)) {

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

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