summaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-12-17 00:54:13 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-12-17 00:54:13 +0000
commitfcf6fa8781fe236a9761ad5d75fa1b87f1afeea2 (patch)
treef0f172234f2556eee22e11e59b8e99f6068d6cc8 /compile.c
parent61a8e7ebf76a1564df17ea4de4fe4ce21dba28f8 (diff)
compile.c: skip opt_* insns for fstr args with block given
* compile.c (iseq_compile_each): only emit opt_str_freeze, opt_aref_with, and opt_aset_with insn when no block is given [Bug #10557] [ruby-core:66595] * test/ruby/test_optimization.rb (test_block_given_aset_aref): new test for bug thanks to Bartosz Kopinski. (test_string_freeze): additional assertion for object_id git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/compile.c b/compile.c
index 6c6d933..8672c0e 100644
--- a/compile.c
+++ b/compile.c
@@ -4405,7 +4405,8 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
* "literal".freeze -> opt_str_freeze("literal")
*/
if (node->nd_recv && nd_type(node->nd_recv) == NODE_STR &&
- node->nd_mid == idFreeze && node->nd_args == NULL)
+ node->nd_mid == idFreeze && node->nd_args == NULL &&
+ iseq->compile_data->current_block == Qfalse)
{
VALUE str = rb_fstring(node->nd_recv->nd_lit);
iseq_add_mark_object(iseq, str);
@@ -4420,7 +4421,8 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
*/
if (node->nd_mid == idAREF && !private_recv_p(node) && node->nd_args &&
nd_type(node->nd_args) == NODE_ARRAY && node->nd_args->nd_alen == 1 &&
- nd_type(node->nd_args->nd_head) == NODE_STR)
+ nd_type(node->nd_args->nd_head) == NODE_STR &&
+ iseq->compile_data->current_block == Qfalse)
{
VALUE str = rb_fstring(node->nd_args->nd_head->nd_lit);
node->nd_args->nd_head->nd_lit = str;
@@ -5416,7 +5418,8 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
*/
if (node->nd_mid == idASET && !private_recv_p(node) && node->nd_args &&
nd_type(node->nd_args) == NODE_ARRAY && node->nd_args->nd_alen == 2 &&
- nd_type(node->nd_args->nd_head) == NODE_STR)
+ nd_type(node->nd_args->nd_head) == NODE_STR &&
+ iseq->compile_data->current_block == Qfalse)
{
VALUE str = rb_fstring(node->nd_args->nd_head->nd_lit);
node->nd_args->nd_head->nd_lit = str;