Skip to content

Instantly share code, notes, and snippets.

@danrabinowitz
Created June 22, 2018 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danrabinowitz/ee5e31a347b8d5ceaaf7283ff9a760a4 to your computer and use it in GitHub Desktop.
Save danrabinowitz/ee5e31a347b8d5ceaaf7283ff9a760a4 to your computer and use it in GitHub Desktop.
2.5.1 iseq patch to fix ruby for bootsnap
--- a/compile.c 2018-05-13 19:35:50.000000000 -0700
+++ b/compile.c 2018-05-13 19:34:53.000000000 -0700
@@ -4569,6 +4569,7 @@
DECL_ANCHOR(else_seq);
LABEL *then_label, *else_label, *end_label;
VALUE branches = 0;
+ int ci_size, ci_kw_size;
INIT_ANCHOR(cond_seq);
INIT_ANCHOR(then_seq);
@@ -4579,8 +4580,20 @@
compile_branch_condition(iseq, cond_seq, node->nd_cond,
then_label, else_label);
+ ci_size = iseq->body->ci_size;
+ ci_kw_size = iseq->body->ci_kw_size;
CHECK(COMPILE_(then_seq, "then", node_body, popped));
+ if (!then_label->refcnt) {
+ iseq->body->ci_size = ci_size;
+ iseq->body->ci_kw_size = ci_kw_size;
+ }
+ ci_size = iseq->body->ci_size;
+ ci_kw_size = iseq->body->ci_kw_size;
CHECK(COMPILE_(else_seq, "else", node_else, popped));
+ if (!else_label->refcnt) {
+ iseq->body->ci_size = ci_size;
+ iseq->body->ci_kw_size = ci_kw_size;
+ }
ADD_SEQ(ret, cond_seq);
@@ -8513,6 +8526,7 @@
for (i=0; i<ci_kw_size; i++) {
const struct rb_call_info_kw_arg *kw_arg = dump_ci_kw_entries[i].kw_arg;
int j;
+ assert(kw_arg != NULL);
VALUE *keywords = ALLOCA_N(VALUE, kw_arg->keyword_len);
for (j=0; j<kw_arg->keyword_len; j++) {
keywords[j] = (VALUE)ibf_dump_object(dump, kw_arg->keywords[j]); /* kw_arg->keywords[n] is Symbol */
@@ -8622,7 +8636,15 @@
rb_raise(rb_eRuntimeError, "path object size mismatch");
}
path = rb_fstring(RARRAY_AREF(pathobj, 0));
- realpath = rb_fstring(RARRAY_AREF(pathobj, 1));
+ realpath = RARRAY_AREF(pathobj, 1);
+ if (!NIL_P(realpath)) {
+ if (!RB_TYPE_P(realpath, T_STRING)) {
+ rb_raise(rb_eArgError, "unexpected realpath %"PRIxVALUE
+ "(%x), path=%+"PRIsVALUE,
+ realpath, TYPE(realpath), path);
+ }
+ realpath = rb_fstring(realpath);
+ }
}
else {
rb_raise(rb_eRuntimeError, "unexpected path object");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment