diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-02-12 10:42:36 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-02-12 10:42:36 +0000 |
commit | e52da919872f8cf71c90a27b470cef724204eece (patch) | |
tree | 2d425228fcba503e2f0a82726548f477cefc5da0 /compile.c | |
parent | 48149dff328079a25b9f17d47999a513b14389c6 (diff) | |
download | bundler-e52da919872f8cf71c90a27b470cef724204eece.tar.gz |
* compile.c (compile_array_, defined_expr, iseq_compile_each): hide
and freeze internal literal objects, to prevent from modifying.
[ruby-dev:37959]
* iseq.c (insn_operand_intern): copy internal literal objects.
* insns.def (putstring, duparray): ditto.
* string.c (rb_str_replace): exported.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22255 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compile.c')
-rw-r--r-- | compile.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -295,6 +295,7 @@ PRINTF_ARGS(void ruby_debug_printf(const char*, ...), 1, 2); #define INIT_ANCHOR(name) \ (name##_body__.last = &name##_body__.anchor, name = &name##_body__) +#define hide_obj(obj) (void)(OBJ_FREEZE(obj), RBASIC(obj)->klass = 0) #include "optinsn.inc" #if OPT_INSTRUCTIONS_UNIFICATION @@ -2230,7 +2231,7 @@ compile_array_(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE* node_root, if (opt_p == Qtrue) { if (!poped) { - VALUE ary = rb_ary_new(); + VALUE ary = rb_ary_tmp_new(len); node = node_root; while (node) { rb_ary_push(ary, node->nd_head->nd_lit); @@ -2709,6 +2710,7 @@ defined_expr(rb_iseq_t *iseq, LINK_ANCHOR *ret, if (estr != 0) { if (needstr != Qfalse) { VALUE str = rb_str_new2(estr); + hide_obj(str); ADD_INSN1(ret, nd_line(node), putstring, str); iseq_add_mark_object_compile_time(iseq, str); } @@ -4353,6 +4355,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) case NODE_STR:{ debugp_param("nd_lit", node->nd_lit); if (!poped) { + hide_obj(node->nd_lit); ADD_INSN1(ret, nd_line(node), putstring, node->nd_lit); } break; |