Skip to content

Commit

Permalink
* iseq.h (struct iseq_compile_data): use struct rb_id_table
Browse files Browse the repository at this point in the history
  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.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55002 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nurse committed May 14, 2016
1 parent 005ee0e commit 3b4e68c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
14 changes: 14 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
Sun May 15 03:13:01 2016 NARUSE, Yui <[email protected]>

* 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 <[email protected]>

* lib/mkmf.rb (pkg_config): use xsystem consistently to set up
Expand Down
16 changes: 12 additions & 4 deletions compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "iseq.h"
#include "insns.inc"
#include "insns_info.inc"
#include "id_table.h"
#include "gc.h"

#ifdef HAVE_DLADDR
Expand Down Expand Up @@ -1547,11 +1548,18 @@ static inline VALUE
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;
}

Expand Down
8 changes: 5 additions & 3 deletions iseq.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "gc.h"
#include "vm_core.h"
#include "iseq.h"
#include "id_table.h"

#include "insns.inc"
#include "insns_info.inc"
Expand Down Expand Up @@ -58,8 +59,9 @@ compile_data_free(struct iseq_compile_data *compile_data)
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);
}
}
Expand Down Expand Up @@ -300,7 +302,7 @@ prepare_iseq_build(rb_iseq_t *iseq,
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();
Expand Down
2 changes: 1 addition & 1 deletion iseq.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ struct iseq_compile_data {
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
Expand Down

0 comments on commit 3b4e68c

Please sign in to comment.