Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6649dc4

Browse files
committed
Set a compile time flag so iseq marking knows about markables
At compile time, set a flag on the iseq object so that the iseq mark function knows to skip disassembly for iseqs that have no markables.
1 parent 65c9fc9 commit 6649dc4

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

compile.c

+10
Original file line numberDiff line numberDiff line change
@@ -2018,6 +2018,7 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
20182018
rb_hash_rehash(map);
20192019
freeze_hide_obj(map);
20202020
generated_iseq[code_index + 1 + j] = map;
2021+
FL_SET(iseq, ISEQ_MARKABLE_ISEQ);
20212022
break;
20222023
}
20232024
case TS_LINDEX:
@@ -2028,13 +2029,19 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
20282029
{
20292030
VALUE v = operands[j];
20302031
generated_iseq[code_index + 1 + j] = v;
2032+
if (!SPECIAL_CONST_P(v)) {
2033+
FL_SET(iseq, ISEQ_MARKABLE_ISEQ);
2034+
}
20312035
break;
20322036
}
20332037
case TS_VALUE: /* VALUE */
20342038
{
20352039
VALUE v = operands[j];
20362040
generated_iseq[code_index + 1 + j] = v;
20372041
/* to mark ruby object */
2042+
if (!SPECIAL_CONST_P(v)) {
2043+
FL_SET(iseq, ISEQ_MARKABLE_ISEQ);
2044+
}
20382045
break;
20392046
}
20402047
case TS_IC: /* inline cache */
@@ -2045,6 +2052,9 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
20452052
rb_bug("iseq_set_sequence: ic_index overflow: index: %d, size: %d", ic_index, iseq->body->is_size);
20462053
}
20472054
generated_iseq[code_index + 1 + j] = (VALUE)ic;
2055+
if (BIN(once) == insn || BIN(trace_once) == insn) {
2056+
FL_SET(iseq, ISEQ_MARKABLE_ISEQ);
2057+
}
20482058
break;
20492059
}
20502060
case TS_CALLINFO: /* call info */

iseq.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,10 @@ rb_iseq_mark(const rb_iseq_t *iseq)
217217
if (iseq->body) {
218218
const struct rb_iseq_constant_body *body = iseq->body;
219219

220-
rb_iseq_each_value(iseq, each_insn_value, NULL);
220+
if(FL_TEST(iseq, ISEQ_MARKABLE_ISEQ)) {
221+
rb_iseq_each_value(iseq, each_insn_value, NULL);
222+
}
223+
221224
rb_gc_mark(body->variable.coverage);
222225
rb_gc_mark(body->variable.original_iseq);
223226
rb_gc_mark(body->location.label);

iseq.h

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ ISEQ_ORIGINAL_ISEQ_ALLOC(const rb_iseq_t *iseq, long size)
8484
#define ISEQ_NOT_LOADED_YET IMEMO_FL_USER1
8585
#define ISEQ_USE_COMPILE_DATA IMEMO_FL_USER2
8686
#define ISEQ_TRANSLATED IMEMO_FL_USER3
87+
#define ISEQ_MARKABLE_ISEQ IMEMO_FL_USER4
8788

8889
struct iseq_compile_data {
8990
/* GC is needed */

0 commit comments

Comments
 (0)