Last active
August 29, 2015 14:24
-
-
Save aidansteele/e30236e64f50a91ce331 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| From 6eea25f98c361458e2840b03cea256f8a4e790fa Mon Sep 17 00:00:00 2001 | |
| From: Aidan Steele <[email protected]> | |
| Date: Fri, 3 Jul 2015 09:58:37 +1000 | |
| Subject: [PATCH] change | |
| --- | |
| compile.c | 13 ++++++++++--- | |
| load.c | 16 ++++++++++++++++ | |
| 2 files changed, 26 insertions(+), 3 deletions(-) | |
| diff --git a/compile.c b/compile.c | |
| index ac4fd5e..183046f 100644 | |
| --- a/compile.c | |
| +++ b/compile.c | |
| @@ -1538,15 +1538,22 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *anchor) | |
| } | |
| case TS_CDHASH: | |
| { | |
| + int i; | |
| VALUE map = operands[j]; | |
| struct cdhash_set_label_struct data; | |
| data.hash = map; | |
| data.pos = pos; | |
| data.len = len; | |
| - rb_hash_foreach(map, cdhash_set_label_i, (VALUE)&data); | |
| + if (RB_TYPE_P(map, T_ARRAY)) { | |
| + data.hash = rb_hash_new(); | |
| + for (i=0; i<RARRAY_LEN(map); i+=2) | |
| + cdhash_set_label_i(RARRAY_AREF(map, i), RARRAY_AREF(map, i+1), &data); | |
| + } else { | |
| + rb_hash_foreach(map, cdhash_set_label_i, (VALUE)&data); | |
| + } | |
| - hide_obj(map); | |
| - generated_iseq[pos + 1 + j] = map; | |
| + hide_obj(data.hash); | |
| + generated_iseq[pos + 1 + j] = data.hash; | |
| break; | |
| } | |
| case TS_LINDEX: | |
| diff --git a/load.c b/load.c | |
| index 65017c9..a2e5d94 100644 | |
| --- a/load.c | |
| +++ b/load.c | |
| @@ -8,6 +8,8 @@ | |
| #include "eval_intern.h" | |
| #include "probes.h" | |
| #include "node.h" | |
| +#include "iseq.h" | |
| +#include "vm_debug.h" | |
| VALUE ruby_dln_librefs; | |
| @@ -605,12 +607,26 @@ rb_load_internal0(rb_thread_t *th, VALUE fname, int wrap) | |
| if (state == 0) { | |
| NODE *node; | |
| VALUE iseq; | |
| + VALUE io; | |
| + VALUE fcname = rb_str_plus(fname, rb_str_new2("o")); | |
| + | |
| + if (getenv("RBO_CACHE") && RTEST(rb_funcall(rb_cFile, rb_intern("exist?"), 1, fcname))) { | |
| + dpv("loading bytecode from", fcname); | |
| + iseq = rb_iseq_load(rb_marshal_load(rb_funcall(rb_cIO, rb_intern("binread"), 1, fcname)), Qnil, Qnil); | |
| + loaded = TRUE; | |
| + } else { | |
| th->mild_compile_error++; | |
| node = (NODE *)rb_load_file_str(fname); | |
| loaded = TRUE; | |
| iseq = rb_iseq_new_top(node, rb_str_new2("<top (required)>"), fname, rb_realpath_internal(Qnil, fname, 1), Qfalse); | |
| th->mild_compile_error--; | |
| + | |
| + io = rb_file_open_str(fcname, "w"); | |
| + rb_marshal_dump(rb_funcall(iseq, rb_intern("to_a"), 0), io); | |
| + rb_io_close(io); | |
| + dpv("wrote bytecode to", fcname); | |
| + } | |
| rb_iseq_eval(iseq); | |
| } | |
| POP_TAG(); | |
| -- | |
| 2.3.2 (Apple Git-55) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment