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

ruby-changes:40783

From: ko1 <ko1@a...>
Date: Wed, 2 Dec 2015 17:20:43 +0900 (JST)
Subject: [ruby-changes:40783] ko1:r52862 (trunk): * iseq.h: introduce ISEQ_ORIGINAL_ISEQ() and

ko1	2015-12-02 17:20:35 +0900 (Wed, 02 Dec 2015)

  New Revision: 52862

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

  Log:
    * iseq.h: introduce ISEQ_ORIGINAL_ISEQ() and
      ISEQ_ORIGINAL_ISEQ_ALLOC() macro.
    
    * compile.c: use them to access original iseq buffer.
    
    * iseq.c: ditto.
    
    * vm_core.h: rename iseq field to support this fix.

  Modified files:
    trunk/ChangeLog
    trunk/compile.c
    trunk/iseq.c
    trunk/iseq.h
    trunk/vm_core.h
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 52861)
+++ ChangeLog	(revision 52862)
@@ -1,3 +1,14 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Dec  2 17:19:02 2015  Koichi Sasada  <ko1@a...>
+
+	* iseq.h: introduce ISEQ_ORIGINAL_ISEQ() and
+	  ISEQ_ORIGINAL_ISEQ_ALLOC() macro.
+
+	* compile.c: use them to access original iseq buffer.
+
+	* iseq.c: ditto.
+
+	* vm_core.h: rename iseq field to support this fix.
+
 Wed Dec  2 17:10:32 2015  Koichi Sasada  <ko1@a...>
 
 	* iseq.h: introduce ISEQ_FLIP_CNT_INCREMENT() macro.
Index: vm_core.h
===================================================================
--- vm_core.h	(revision 52861)
+++ vm_core.h	(revision 52862)
@@ -392,7 +392,7 @@ struct rb_iseq_variable_body { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L392
 
     /* original iseq, before encoding
      * used for debug/dump (TODO: union with compile_data) */
-    VALUE *iseq;
+    VALUE *iseq_;
 };
 
 /* T_IMEMO/iseq */
Index: iseq.c
===================================================================
--- iseq.c	(revision 52861)
+++ iseq.c	(revision 52862)
@@ -92,7 +92,7 @@ rb_iseq_free(const rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/iseq.c#L92
 	    ruby_xfree((void *)iseq->body->param.keyword);
 	}
 	compile_data_free(ISEQ_COMPILE_DATA(iseq));
-	ruby_xfree(iseq->variable_body->iseq);
+	ruby_xfree(iseq->variable_body->iseq_);
 	ruby_xfree(iseq->variable_body);
 	ruby_xfree(iseq->body);
     }
@@ -157,7 +157,7 @@ iseq_memsize(const rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/iseq.c#L157
 
     if (variable_body) {
 	size += sizeof(struct rb_iseq_variable_body);
-	if (variable_body->iseq && body) {
+	if (variable_body->iseq_ && body) {
 	    size += body->iseq_size * sizeof(VALUE);
 	}
     }
Index: iseq.h
===================================================================
--- iseq.h	(revision 52861)
+++ iseq.h	(revision 52862)
@@ -23,10 +23,13 @@ rb_call_info_kw_arg_bytes(int keyword_le https://github.com/ruby/ruby/blob/trunk/iseq.h#L23
     return sizeof(struct rb_call_info_kw_arg) + sizeof(VALUE) * (keyword_len - 1);
 }
 
-#define ISEQ_COMPILE_DATA(iseq)      (iseq)->compile_data_
-#define ISEQ_COVERAGE(iseq)          (iseq)->variable_body->coverage_
-#define ISEQ_COVERAGE_SET(iseq, cov) RB_OBJ_WRITE((iseq), &(iseq)->variable_body->coverage_, cov)
+#define ISEQ_COMPILE_DATA(iseq)       (iseq)->compile_data_
+#define ISEQ_COVERAGE(iseq)           (iseq)->variable_body->coverage_
+#define ISEQ_COVERAGE_SET(iseq, cov)  RB_OBJ_WRITE((iseq), &(iseq)->variable_body->coverage_, cov)
 #define ISEQ_FLIP_CNT_INCREMENT(iseq) ((iseq)->variable_body->flip_cnt_++)
+#define ISEQ_ORIGINAL_ISEQ(iseq)      (iseq)->variable_body->iseq_
+#define ISEQ_ORIGINAL_ISEQ_ALLOC(iseq, size) (ISEQ_ORIGINAL_ISEQ(iseq) = ALLOC_N(VALUE, size))
+
 RUBY_SYMBOL_EXPORT_BEGIN
 
 /* compile.c */
Index: compile.c
===================================================================
--- compile.c	(revision 52861)
+++ compile.c	(revision 52862)
@@ -641,26 +641,26 @@ rb_vm_insn_addr2insn(const void *addr) / https://github.com/ruby/ruby/blob/trunk/compile.c#L641
 VALUE *
 rb_iseq_original_iseq(const rb_iseq_t *iseq) /* cold path */
 {
-    if (iseq->variable_body->iseq) return iseq->variable_body->iseq;
+    VALUE *original_code;
 
-    iseq->variable_body->iseq = ALLOC_N(VALUE, iseq->body->iseq_size);
-
-    MEMCPY(iseq->variable_body->iseq, iseq->body->iseq_encoded, VALUE, iseq->body->iseq_size);
+    if (ISEQ_ORIGINAL_ISEQ(iseq)) return ISEQ_ORIGINAL_ISEQ(iseq);
+    original_code = ISEQ_ORIGINAL_ISEQ_ALLOC(iseq, iseq->body->iseq_size);
+    MEMCPY(ISEQ_ORIGINAL_ISEQ(iseq), iseq->body->iseq_encoded, VALUE, iseq->body->iseq_size);
 
 #if OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE
     {
 	unsigned int i;
 
 	for (i = 0; i < iseq->body->iseq_size; /* */ ) {
-	    const void *addr = (const void *)iseq->variable_body->iseq[i];
+	    const void *addr = (const void *)original_code[i];
 	    const int insn = rb_vm_insn_addr2insn(addr);
 
-	    iseq->variable_body->iseq[i] = insn;
+	    original_code[i] = insn;
 	    i += insn_len(insn);
 	}
     }
 #endif
-    return iseq->variable_body->iseq;
+    return original_code;
 }
 
 /*********************************************/

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

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