aboutsummaryrefslogtreecommitdiffstats
path: root/iseq.c
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-04-17 09:41:41 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-04-17 09:41:41 +0000
commit744e5df7156c8bb3fea61bacb1bf27d3d8698548 (patch)
treeedb3f475ee4fde34b9804504b359ea1bb17325c6 /iseq.c
parentf399134e8ff61faa81d624e2dd2e05ed61d32af1 (diff)
downloadruby-744e5df7156c8bb3fea61bacb1bf27d3d8698548.tar.gz
Reverting compaction for now
For some reason symbols (or classes) are being overridden in trunk git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67598 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'iseq.c')
-rw-r--r--iseq.c100
1 files changed, 18 insertions, 82 deletions
diff --git a/iseq.c b/iseq.c
index 82f045d62a..67fc862a33 100644
--- a/iseq.c
+++ b/iseq.c
@@ -137,11 +137,11 @@ rb_vm_insn_null_translator(const void *addr)
return (VALUE)addr;
}
-typedef VALUE iseq_value_itr_t(void *ctx, VALUE obj);
+typedef void iseq_value_itr_t(void *ctx, VALUE obj);
typedef VALUE rb_vm_insns_translator_t(const void *addr);
static int
-iseq_extract_values(VALUE *code, size_t pos, iseq_value_itr_t * func, void *data, rb_vm_insns_translator_t * translator)
+iseq_extract_values(const VALUE *code, size_t pos, iseq_value_itr_t * func, void *data, rb_vm_insns_translator_t * translator)
{
VALUE insn = translator((void *)code[pos]);
int len = insn_len(insn);
@@ -157,10 +157,7 @@ iseq_extract_values(VALUE *code, size_t pos, iseq_value_itr_t * func, void *data
{
VALUE op = code[pos + op_no + 1];
if (!SPECIAL_CONST_P(op)) {
- VALUE newop = func(data, op);
- if (newop != op) {
- code[pos + op_no + 1] = newop;
- }
+ func(data, op);
}
break;
}
@@ -168,10 +165,7 @@ iseq_extract_values(VALUE *code, size_t pos, iseq_value_itr_t * func, void *data
{
union iseq_inline_storage_entry *const is = (union iseq_inline_storage_entry *)code[pos + op_no + 1];
if (is->once.value) {
- VALUE nv = func(data, is->once.value);
- if (is->once.value != nv) {
- is->once.value = nv;
- }
+ func(data, is->once.value);
}
break;
}
@@ -187,7 +181,7 @@ static void
rb_iseq_each_value(const rb_iseq_t *iseq, iseq_value_itr_t * func, void *data)
{
unsigned int size;
- VALUE *code;
+ const VALUE *code;
size_t n;
rb_vm_insns_translator_t * translator;
const struct rb_iseq_constant_body *const body = iseq->body;
@@ -211,65 +205,10 @@ rb_iseq_each_value(const rb_iseq_t *iseq, iseq_value_itr_t * func, void *data)
}
}
-static VALUE
-update_each_insn_value(void *ctx, VALUE obj)
-{
- return rb_gc_new_location(obj);
-}
-
-void
-rb_iseq_update_references(rb_iseq_t *iseq)
-{
- if (iseq->body) {
- struct rb_iseq_constant_body *body = iseq->body;
-
- body->variable.coverage = rb_gc_new_location(body->variable.coverage);
- body->variable.pc2branchindex = rb_gc_new_location(body->variable.pc2branchindex);
- body->location.label = rb_gc_new_location(body->location.label);
- body->location.base_label = rb_gc_new_location(body->location.base_label);
- body->location.pathobj = rb_gc_new_location(body->location.pathobj);
- if (body->local_iseq) {
- body->local_iseq = (struct rb_iseq_struct *)rb_gc_new_location((VALUE)body->local_iseq);
- }
- if (body->parent_iseq) {
- body->parent_iseq = (struct rb_iseq_struct *)rb_gc_new_location((VALUE)body->parent_iseq);
- }
- if (FL_TEST(iseq, ISEQ_MARKABLE_ISEQ)) {
- rb_iseq_each_value(iseq, update_each_insn_value, NULL);
- }
-
- if (body->param.flags.has_kw && ISEQ_COMPILE_DATA(iseq) == NULL) {
- int i, j;
-
- i = body->param.keyword->required_num;
-
- for (j = 0; i < body->param.keyword->num; i++, j++) {
- VALUE obj = body->param.keyword->default_values[j];
- if (obj != Qundef) {
- body->param.keyword->default_values[j] = rb_gc_new_location(obj);
- }
- }
- }
-
- if (body->catch_table) {
- struct iseq_catch_table *table = body->catch_table;
- unsigned int i;
- for(i = 0; i < table->size; i++) {
- struct iseq_catch_table_entry *entry;
- entry = &table->entries[i];
- if (entry->iseq) {
- entry->iseq = (rb_iseq_t *)rb_gc_new_location((VALUE)entry->iseq);
- }
- }
- }
- }
-}
-
-static VALUE
+static void
each_insn_value(void *ctx, VALUE obj)
{
- rb_gc_mark_no_pin(obj);
- return obj;
+ rb_gc_mark(obj);
}
void
@@ -286,12 +225,12 @@ rb_iseq_mark(const rb_iseq_t *iseq)
rb_iseq_each_value(iseq, each_insn_value, NULL);
}
- rb_gc_mark_no_pin(body->variable.coverage);
- rb_gc_mark_no_pin(body->variable.pc2branchindex);
- rb_gc_mark_no_pin(body->location.label);
- rb_gc_mark_no_pin(body->location.base_label);
- rb_gc_mark_no_pin(body->location.pathobj);
- RUBY_MARK_NO_PIN_UNLESS_NULL((VALUE)body->parent_iseq);
+ rb_gc_mark(body->variable.coverage);
+ rb_gc_mark(body->variable.pc2branchindex);
+ rb_gc_mark(body->location.label);
+ rb_gc_mark(body->location.base_label);
+ rb_gc_mark(body->location.pathobj);
+ RUBY_MARK_UNLESS_NULL((VALUE)body->parent_iseq);
if (body->param.flags.has_kw && ISEQ_COMPILE_DATA(iseq) == NULL) {
const struct rb_iseq_param_keyword *const keyword = body->param.keyword;
@@ -314,7 +253,7 @@ rb_iseq_mark(const rb_iseq_t *iseq)
const struct iseq_catch_table_entry *entry;
entry = &table->entries[i];
if (entry->iseq) {
- rb_gc_mark_no_pin((VALUE)entry->iseq);
+ rb_gc_mark((VALUE)entry->iseq);
}
}
}
@@ -325,14 +264,11 @@ rb_iseq_mark(const rb_iseq_t *iseq)
}
else if (FL_TEST_RAW(iseq, ISEQ_USE_COMPILE_DATA)) {
const struct iseq_compile_data *const compile_data = ISEQ_COMPILE_DATA(iseq);
- if (RTEST(compile_data->mark_ary)) {
- rb_gc_mark(compile_data->mark_ary);
- }
- RUBY_MARK_UNLESS_NULL(compile_data->err_info);
- if (RTEST(compile_data->catch_table_ary)) {
- rb_gc_mark(compile_data->catch_table_ary);
- }
VM_ASSERT(compile_data != NULL);
+
+ RUBY_MARK_UNLESS_NULL(compile_data->mark_ary);
+ RUBY_MARK_UNLESS_NULL(compile_data->err_info);
+ RUBY_MARK_UNLESS_NULL(compile_data->catch_table_ary);
}
else {
/* executable */