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

ruby-changes:42929

From: naruse <ko1@a...>
Date: Sun, 15 May 2016 03:43:17 +0900 (JST)
Subject: [ruby-changes:42929] naruse:r55002 (trunk): * iseq.h (struct iseq_compile_data): use struct rb_id_table

naruse	2016-05-15 03:43:11 +0900 (Sun, 15 May 2016)

  New Revision: 55002

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

  Log:
    * iseq.h (struct iseq_compile_data): use struct rb_id_table
      instead of st_table.
    
    * iseq.c (prepare_iseq_build): don't allocate ivar_cache_table
      until it has at least one element.
    
    * iseq.c (compile_data_free): free ivar_cache_table only if it
      is allocated.
    
    * compile.c (get_ivar_ic_value): allocate if the table is not
      allocated yet.

  Modified files:
    trunk/ChangeLog
    trunk/compile.c
    trunk/iseq.c
    trunk/iseq.h
Index: iseq.c
===================================================================
--- iseq.c	(revision 55001)
+++ iseq.c	(revision 55002)
@@ -21,6 +21,7 @@ https://github.com/ruby/ruby/blob/trunk/iseq.c#L21
 #include "gc.h"
 #include "vm_core.h"
 #include "iseq.h"
+#include "id_table.h"
 
 #include "insns.inc"
 #include "insns_info.inc"
@@ -58,8 +59,9 @@ compile_data_free(struct iseq_compile_da https://github.com/ruby/ruby/blob/trunk/iseq.c#L59
 	    ruby_xfree(cur);
 	    cur = next;
 	}
-	st_free_table(compile_data->ivar_cache_table);
-
+	if (compile_data->ivar_cache_table) {
+	    rb_id_table_free(compile_data->ivar_cache_table);
+	}
 	ruby_xfree(compile_data);
     }
 }
@@ -300,7 +302,7 @@ prepare_iseq_build(rb_iseq_t *iseq, https://github.com/ruby/ruby/blob/trunk/iseq.c#L302
     ISEQ_COMPILE_DATA(iseq)->option = option;
     ISEQ_COMPILE_DATA(iseq)->last_coverable_line = -1;
 
-    ISEQ_COMPILE_DATA(iseq)->ivar_cache_table = st_init_numtable();
+    ISEQ_COMPILE_DATA(iseq)->ivar_cache_table = NULL;
 
     if (option->coverage_enabled) {
 	VALUE coverages = rb_get_coverages();
Index: iseq.h
===================================================================
--- iseq.h	(revision 55001)
+++ iseq.h	(revision 55002)
@@ -213,7 +213,7 @@ struct iseq_compile_data { https://github.com/ruby/ruby/blob/trunk/iseq.h#L213
     unsigned int ci_index;
     unsigned int ci_kw_index;
     const rb_compile_option_t *option;
-    st_table *ivar_cache_table;
+    struct rb_id_table *ivar_cache_table;
 #if SUPPORT_JOKE
     st_table *labels_table;
 #endif
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 55001)
+++ ChangeLog	(revision 55002)
@@ -1,3 +1,17 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun May 15 03:13:01 2016  NARUSE, Yui  <naruse@r...>
+
+	* iseq.h (struct iseq_compile_data): use struct rb_id_table
+	  instead of st_table.
+
+	* iseq.c (prepare_iseq_build): don't allocate ivar_cache_table
+	  until it has at least one element.
+
+	* iseq.c (compile_data_free): free ivar_cache_table only if it
+	  is allocated.
+
+	* compile.c (get_ivar_ic_value): allocate if the table is not
+	  allocated yet.
+
 Sat May 14 09:04:34 2016  Nobuyoshi Nakada  <nobu@r...>
 
 	* lib/mkmf.rb (pkg_config): use xsystem consistently to set up
Index: compile.c
===================================================================
--- compile.c	(revision 55001)
+++ compile.c	(revision 55002)
@@ -19,6 +19,7 @@ https://github.com/ruby/ruby/blob/trunk/compile.c#L19
 #include "iseq.h"
 #include "insns.inc"
 #include "insns_info.inc"
+#include "id_table.h"
 #include "gc.h"
 
 #ifdef HAVE_DLADDR
@@ -1547,11 +1548,18 @@ static inline VALUE https://github.com/ruby/ruby/blob/trunk/compile.c#L1548
 get_ivar_ic_value(rb_iseq_t *iseq,ID id)
 {
     VALUE val;
-    st_table *tbl = ISEQ_COMPILE_DATA(iseq)->ivar_cache_table;
-    if(!st_lookup(tbl,(st_data_t)id,&val)){
-	val = INT2FIX(iseq->body->is_size++);
-	st_insert(tbl,id,val);
+    struct rb_id_table *tbl = ISEQ_COMPILE_DATA(iseq)->ivar_cache_table;
+    if (tbl) {
+	if (rb_id_table_lookup(tbl,id,&val)) {
+	    return val;
+	}
+    }
+    else {
+	tbl = rb_id_table_create(1);
+	ISEQ_COMPILE_DATA(iseq)->ivar_cache_table = tbl;
     }
+    val = INT2FIX(iseq->body->is_size++);
+    rb_id_table_insert(tbl,id,val);
     return val;
 }
 

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

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