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

ruby-changes:39284

From: ko1 <ko1@a...>
Date: Sat, 25 Jul 2015 04:49:40 +0900 (JST)
Subject: [ruby-changes:39284] ko1:r51365 (trunk): * vm_core.h: constify rb_iseq_constant_body::catch_table.

ko1	2015-07-25 04:49:16 +0900 (Sat, 25 Jul 2015)

  New Revision: 51365

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

  Log:
    * vm_core.h: constify rb_iseq_constant_body::catch_table.
    * compile.c (iseq_set_exception_table): catch up this fix.
    * iseq.c: ditto.
    * vm.c (vm_exec): ditto.

  Modified files:
    trunk/ChangeLog
    trunk/compile.c
    trunk/iseq.c
    trunk/vm.c
    trunk/vm_core.h
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 51364)
+++ ChangeLog	(revision 51365)
@@ -1,3 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Jul 25 04:47:01 2015  Koichi Sasada  <ko1@a...>
+
+	* vm_core.h: constify rb_iseq_constant_body::catch_table.
+
+	* compile.c (iseq_set_exception_table): catch up this fix.
+
+	* iseq.c: ditto.
+
+	* vm.c (vm_exec): ditto.
+
 Fri Jul 24 21:29:54 2015  Nobuyoshi Nakada  <nobu@r...>
 
 	* st.c (EQUAL, st_delete_safe): fix arguments order to compare
Index: vm_core.h
===================================================================
--- vm_core.h	(revision 51364)
+++ vm_core.h	(revision 51365)
@@ -335,7 +335,7 @@ struct rb_iseq_constant_body { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L335
     const ID *local_table;		/* must free */
 
     /* catch table */
-    struct iseq_catch_table *catch_table;
+    const struct iseq_catch_table *catch_table;
 
     /* for child iseq */
     const struct rb_iseq_struct *parent_iseq;
Index: iseq.c
===================================================================
--- iseq.c	(revision 51364)
+++ iseq.c	(revision 51365)
@@ -1387,7 +1387,7 @@ rb_iseq_disasm(const rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/iseq.c#L1387
 	rb_str_cat2(str, "== catch table\n");
     }
     if (iseq->body->catch_table) for (i = 0; i < iseq->body->catch_table->size; i++) {
-	struct iseq_catch_table_entry *entry = &iseq->body->catch_table->entries[i];
+	const struct iseq_catch_table_entry *entry = &iseq->body->catch_table->entries[i];
 	rb_str_catf(str,
 		    "| catch type: %-6s st: %04d ed: %04d sp: %04d cont: %04d\n",
 		    catch_type((int)entry->type), (int)entry->start,
@@ -1894,7 +1894,7 @@ iseq_data_to_ary(const rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/iseq.c#L1894
     /* exception */
     if (iseq->body->catch_table) for (i=0; i<iseq->body->catch_table->size; i++) {
 	VALUE ary = rb_ary_new();
-	struct iseq_catch_table_entry *entry = &iseq->body->catch_table->entries[i];
+	const struct iseq_catch_table_entry *entry = &iseq->body->catch_table->entries[i];
 	rb_ary_push(ary, exception_type2symbol(entry->type));
 	if (entry->iseq) {
 	    rb_ary_push(ary, iseq_data_to_ary(entry->iseq));
Index: compile.c
===================================================================
--- compile.c	(revision 51364)
+++ compile.c	(revision 51365)
@@ -1714,44 +1714,47 @@ iseq_set_exception_table(rb_iseq_t *iseq https://github.com/ruby/ruby/blob/trunk/compile.c#L1714
     tlen = (int)RARRAY_LEN(iseq->compile_data->catch_table_ary);
     tptr = RARRAY_CONST_PTR(iseq->compile_data->catch_table_ary);
 
-    iseq->body->catch_table = 0;
     if (tlen > 0) {
-	iseq->body->catch_table = xmalloc(iseq_catch_table_bytes(tlen));
-	iseq->body->catch_table->size = tlen;
-    }
+	struct iseq_catch_table *table = xmalloc(iseq_catch_table_bytes(tlen));
+	table->size = tlen;
 
-    if (iseq->body->catch_table) for (i = 0; i < iseq->body->catch_table->size; i++) {
-	ptr = RARRAY_CONST_PTR(tptr[i]);
-	entry = &iseq->body->catch_table->entries[i];
-	entry->type = (enum catch_type)(ptr[0] & 0xffff);
-	entry->start = label_get_position((LABEL *)(ptr[1] & ~1));
-	entry->end = label_get_position((LABEL *)(ptr[2] & ~1));
-	entry->iseq = (rb_iseq_t *)ptr[3];
-
-	/* register iseq as mark object */
-	if (entry->iseq != 0) {
-	    iseq_add_mark_object(iseq, (VALUE)entry->iseq);
-	}
+	for (i = 0; i < table->size; i++) {
+	    ptr = RARRAY_CONST_PTR(tptr[i]);
+	    entry = &table->entries[i];
+	    entry->type = (enum catch_type)(ptr[0] & 0xffff);
+	    entry->start = label_get_position((LABEL *)(ptr[1] & ~1));
+	    entry->end = label_get_position((LABEL *)(ptr[2] & ~1));
+	    entry->iseq = (rb_iseq_t *)ptr[3];
+
+	    /* register iseq as mark object */
+	    if (entry->iseq != 0) {
+		iseq_add_mark_object(iseq, (VALUE)entry->iseq);
+	    }
 
-	/* stack depth */
-	if (ptr[4]) {
-	    LABEL *lobj = (LABEL *)(ptr[4] & ~1);
-	    entry->cont = label_get_position(lobj);
-	    entry->sp = label_get_sp(lobj);
-
-	    /* TODO: Dirty Hack!  Fix me */
-	    if (entry->type == CATCH_TYPE_RESCUE ||
-		entry->type == CATCH_TYPE_BREAK ||
-		entry->type == CATCH_TYPE_NEXT) {
-		entry->sp--;
+	    /* stack depth */
+	    if (ptr[4]) {
+		LABEL *lobj = (LABEL *)(ptr[4] & ~1);
+		entry->cont = label_get_position(lobj);
+		entry->sp = label_get_sp(lobj);
+
+		/* TODO: Dirty Hack!  Fix me */
+		if (entry->type == CATCH_TYPE_RESCUE ||
+		    entry->type == CATCH_TYPE_BREAK ||
+		    entry->type == CATCH_TYPE_NEXT) {
+		    entry->sp--;
+		}
+	    }
+	    else {
+		entry->cont = 0;
 	    }
 	}
-	else {
-	    entry->cont = 0;
-	}
+	iseq->body->catch_table = table;
+	RB_OBJ_WRITE(iseq, &iseq->compile_data->catch_table_ary, 0); /* free */
+    }
+    else {
+	iseq->body->catch_table = NULL;
     }
 
-    RB_OBJ_WRITE(iseq, &iseq->compile_data->catch_table_ary, 0); /* free */
     return COMPILE_OK;
 }
 
Index: vm.c
===================================================================
--- vm.c	(revision 51364)
+++ vm.c	(revision 51365)
@@ -1478,8 +1478,8 @@ vm_exec(rb_thread_t *th) https://github.com/ruby/ruby/blob/trunk/vm.c#L1478
     }
     else {
 	int i;
-	struct iseq_catch_table_entry *entry;
-	struct iseq_catch_table *ct;
+	const struct iseq_catch_table_entry *entry;
+	const struct iseq_catch_table *ct;
 	unsigned long epc, cont_pc, cont_sp;
 	const rb_iseq_t *catch_iseq;
 	rb_control_frame_t *cfp;

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

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