ruby-changes:55305
From: nobu <ko1@a...>
Date: Thu, 11 Apr 2019 19:36:43 +0900 (JST)
Subject: [ruby-changes:55305] nobu:r67511 (trunk): Share the exception local ID table
nobu 2019-04-11 19:36:36 +0900 (Thu, 11 Apr 2019) New Revision: 67511 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=67511 Log: Share the exception local ID table [Fix GH-2115] From: Lourens Naud?\195?\169 <lourens@b...> Modified files: trunk/compile.c trunk/iseq.c trunk/iseq.h Index: iseq.c =================================================================== --- iseq.c (revision 67510) +++ iseq.c (revision 67511) @@ -91,7 +91,8 @@ rb_iseq_free(const rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/iseq.c#L91 #if VM_INSN_INFO_TABLE_IMPL == 2 if (body->insns_info.succ_index_table) ruby_xfree(body->insns_info.succ_index_table); #endif - ruby_xfree((void *)body->local_table); + if (LIKELY(body->local_table != rb_iseq_shared_exc_local_tbl)) + ruby_xfree((void *)body->local_table); ruby_xfree((void *)body->is_entries); if (body->ci_entries) { Index: iseq.h =================================================================== --- iseq.h (revision 67510) +++ iseq.h (revision 67511) @@ -21,6 +21,8 @@ typedef struct rb_iseq_struct rb_iseq_t; https://github.com/ruby/ruby/blob/trunk/iseq.h#L21 #define rb_iseq_t rb_iseq_t #endif +extern const ID rb_iseq_shared_exc_local_tbl[]; + static inline size_t rb_call_info_kw_arg_bytes(int keyword_len) { Index: compile.c =================================================================== --- compile.c (revision 67510) +++ compile.c (revision 67511) @@ -106,6 +106,8 @@ struct iseq_compile_data_ensure_node_sta https://github.com/ruby/ruby/blob/trunk/compile.c#L106 struct ensure_range *erange; }; +const ID rb_iseq_shared_exc_local_tbl[] = {idERROR_INFO}; + /** * debug function(macro) interface depend on CPDEBUG * if it is less than 0, runtime option is in effect. @@ -1361,14 +1363,8 @@ iseq_setup(rb_iseq_t *iseq, LINK_ANCHOR https://github.com/ruby/ruby/blob/trunk/compile.c#L1363 static int iseq_set_exception_local_table(rb_iseq_t *iseq) { - /* TODO: every id table is same -> share it. - * Current problem is iseq_free(). - */ - ID *ids = (ID *)ALLOC_N(ID, 1); - iseq->body->local_table_size = 1; - ids[0] = idERROR_INFO; - iseq->body->local_table = ids; + iseq->body->local_table = rb_iseq_shared_exc_local_tbl; return COMPILE_OK; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/