summaryrefslogtreecommitdiff
path: root/iseq.c
diff options
context:
space:
mode:
authorAaron Patterson <tenderlove@ruby-lang.org>2022-06-27 14:31:15 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2022-06-29 16:21:48 -0700
commite3ab525f699b5191db70ef095b3d110890441940 (patch)
treeb2dcd5f5dcbaaecc03d18c5fa403469abb96a3f7 /iseq.c
parent66eb58d6bd50dd3ad8691fcc8eb72ad4d45bc04c (diff)
downloadruby-e3ab525f699b5191db70ef095b3d110890441940.tar.gz
Fix ISeq dump / load in array cases
We need to dump relative offsets for inline storage entries so that loading iseqs as an array works as well. This commit also has some minor refactoring to make computing relative ISE information easier. This should fix the iseq dump / load as array tests we're seeing fail in CI. Co-Authored-By: John Hawthorn <john@hawthorn.email>
Diffstat (limited to 'iseq.c')
-rw-r--r--iseq.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/iseq.c b/iseq.c
index 7f02e1b9e5..0ac67f62bc 100644
--- a/iseq.c
+++ b/iseq.c
@@ -2943,6 +2943,26 @@ iseq_type_id(enum iseq_type type)
rb_bug("unsupported iseq type: %d", (int)type);
}
+union iseq_inline_storage_entry *
+ISEQ_IS_ENTRY_START(const struct rb_iseq_constant_body *body, char op_type)
+{
+ unsigned int relative_ic_offset = 0;
+
+ switch(op_type) {
+ case TS_IC:
+ relative_ic_offset += body->ise_size;
+ case TS_ISE:
+ relative_ic_offset += body->ivc_size;
+ case TS_IVC:
+ case TS_ICVARC:
+ break;
+ default:
+ rb_bug("Wrong op type");
+ }
+
+ return &body->is_entries[relative_ic_offset];
+}
+
static VALUE
iseq_data_to_ary(const rb_iseq_t *iseq)
{
@@ -3048,7 +3068,9 @@ iseq_data_to_ary(const rb_iseq_t *iseq)
rb_ary_push(ary, ID2SYM(insn_syms[insn%numberof(insn_syms)]));
for (j=0; j<len-1; j++, seq++) {
- switch (insn_op_type(insn, j)) {
+ enum ruby_insn_type_chars op_type = insn_op_type(insn, j);
+
+ switch (op_type) {
case TS_OFFSET: {
unsigned long idx = nseq - iseq_original + *seq;
rb_ary_push(ary, register_label(labels_table, idx));
@@ -3079,7 +3101,7 @@ iseq_data_to_ary(const rb_iseq_t *iseq)
case TS_ISE:
{
union iseq_inline_storage_entry *is = (union iseq_inline_storage_entry *)*seq;
- rb_ary_push(ary, INT2FIX(is - iseq_body->is_entries));
+ rb_ary_push(ary, INT2FIX(is - ISEQ_IS_ENTRY_START(ISEQ_BODY(iseq), op_type)));
}
break;
case TS_CALLDATA: