Skip to content

Commit

Permalink
* compile.c (iseq_compile_each): check
Browse files Browse the repository at this point in the history
  iseq->compile_data->option->specialized_instruction for opt_* insn.
* test/ruby/test_iseq.rb: check no specialized_instructions option.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48870 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
ko1 committed Dec 17, 2014
1 parent fcf6fa8 commit 6eac885
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
@@ -1,3 +1,10 @@
Wed Dec 17 10:18:42 2014 Koichi Sasada <ko1@atdot.net>

* compile.c (iseq_compile_each): check
iseq->compile_data->option->specialized_instruction for opt_* insn.

* test/ruby/test_iseq.rb: check no specialized_instructions option.

Wed Dec 17 09:48:57 2014 Eric Wong <e@80x24.org>

* compile.c (iseq_compile_each): only emit opt_str_freeze,
Expand Down
11 changes: 6 additions & 5 deletions compile.c
Expand Up @@ -4406,8 +4406,8 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
*/
if (node->nd_recv && nd_type(node->nd_recv) == NODE_STR &&
node->nd_mid == idFreeze && node->nd_args == NULL &&
iseq->compile_data->current_block == Qfalse)
{
iseq->compile_data->current_block == Qfalse &&
iseq->compile_data->option->specialized_instruction) {
VALUE str = rb_fstring(node->nd_recv->nd_lit);
iseq_add_mark_object(iseq, str);
ADD_INSN1(ret, line, opt_str_freeze, str);
Expand All @@ -4422,8 +4422,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 &&
iseq->compile_data->current_block == Qfalse)
{
iseq->compile_data->current_block == Qfalse &&
iseq->compile_data->option->specialized_instruction) {
VALUE str = rb_fstring(node->nd_args->nd_head->nd_lit);
node->nd_args->nd_head->nd_lit = str;
COMPILE(ret, "recv", node->nd_recv);
Expand Down Expand Up @@ -5419,7 +5419,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 &&
iseq->compile_data->current_block == Qfalse)
iseq->compile_data->current_block == Qfalse &&
iseq->compile_data->option->specialized_instruction)
{
VALUE str = rb_fstring(node->nd_args->nd_head->nd_lit);
node->nd_args->nd_head->nd_lit = str;
Expand Down
10 changes: 10 additions & 0 deletions test/ruby/test_iseq.rb
Expand Up @@ -124,4 +124,14 @@ def test_label_fstring
ISeq.of(c.instance_method(:foobar)).label
assert_same a, b
end

def test_diable_opt
src = "a['foo'] = a['bar']; 'a'.freeze"
_,_,_,_,_,_,_,_,_,_,_,_,_,body= RubyVM::InstructionSequence.compile(src, __FILE__, __FILE__, __LINE__, false).to_a
body.each{|insn|
next if Integer === insn
op = insn.first
assert(!op.to_s.match(/^opt_/), "#{op}")
}
end
end

0 comments on commit 6eac885

Please sign in to comment.