diff --git a/compile.c b/compile.c index 1c0309ac8502aa..901fcb15c8d090 100644 --- a/compile.c +++ b/compile.c @@ -1560,15 +1560,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); + data.hash = map; + data.pos = pos; + data.len = len; + if (RB_TYPE_P(map, T_ARRAY)) { + data.hash = rb_hash_new(); + for (i=0; ilocal_table_size; i++) { ID lid = iseq->local_table[i]; if (lid) { - if (rb_id2str(lid)) rb_ary_push(locals, ID2SYM(lid)); + if (rb_id2str(lid)) { + rb_ary_push(locals, ID2SYM(lid)); + } + else { /* hidden variable from id_internal() */ + rb_ary_push(locals, ULONG2NUM(iseq->local_table_size-i+1)); + } } else { rb_ary_push(locals, ID2SYM(rb_intern("#arg_rest"))); diff --git a/load.c b/load.c index e5014c165faef0..4f753f2c521b92 100644 --- a/load.c +++ b/load.c @@ -9,6 +9,8 @@ #include "eval_intern.h" #include "probes.h" #include "node.h" +#include "iseq.h" +#include "vm_debug.h" VALUE ruby_dln_librefs; @@ -606,12 +608,25 @@ rb_load_internal0(rb_thread_t *th, VALUE fname, int wrap) if (state == 0) { NODE *node; VALUE iseq; - - th->mild_compile_error++; - node = (NODE *)rb_load_file_str(fname); - loaded = TRUE; - iseq = rb_iseq_new_top(node, rb_str_new2(""), fname, rb_realpath_internal(Qnil, fname, 1), Qfalse); - th->mild_compile_error--; + VALUE io; + VALUE fcname = rb_str_plus(fname, rb_str_new2("o")); + + if (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(""), 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(); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy