ruby-changes:40930
From: ko1 <ko1@a...>
Date: Thu, 10 Dec 2015 02:02:20 +0900 (JST)
Subject: [ruby-changes:40930] ko1:r53009 (trunk): * compile.c (iseq_compile_each): do not add debug information
ko1 2015-12-10 02:02:02 +0900 (Thu, 10 Dec 2015) New Revision: 53009 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53009 Log: * compile.c (iseq_compile_each): do not add debug information without --debug or --debug=frozen-string-literal option because String#dup slows down with debug information. [Feature #11725] * NEWS: apply about it. * test/ruby/test_rubyoptions.rb: catch up this fix with refactoring. Modified files: trunk/ChangeLog trunk/NEWS trunk/compile.c trunk/test/ruby/test_rubyoptions.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 53008) +++ ChangeLog (revision 53009) @@ -1,3 +1,14 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Dec 10 02:01:41 2015 Koichi Sasada <ko1@a...> + + * compile.c (iseq_compile_each): do not add debug information + without --debug or --debug=frozen-string-literal option + because String#dup slows down with debug information. + [Feature #11725] + + * NEWS: apply about it. + + * test/ruby/test_rubyoptions.rb: catch up this fix with refactoring. + Thu Dec 10 00:06:56 2015 Koichi Sasada <ko1@a...> * iseq.c: rename methods Index: compile.c =================================================================== --- compile.c (revision 53008) +++ compile.c (revision 53009) @@ -5340,9 +5340,14 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ https://github.com/ruby/ruby/blob/trunk/compile.c#L5340 } else { VALUE str = rb_str_dup(node->nd_lit); - VALUE debug_info = rb_ary_new_from_args(2, iseq->body->location.path, INT2FIX(line)); - rb_ivar_set(str, id_debug_created_info, rb_obj_freeze(debug_info)); - ADD_INSN1(ret, line, putobject, rb_obj_freeze(str)); + if (ISEQ_COMPILE_DATA(iseq)->option->debug_frozen_string_literal || RTEST(ruby_debug)) { + VALUE debug_info = rb_ary_new_from_args(2, iseq->body->location.path, INT2FIX(line)); + rb_ivar_set(str, id_debug_created_info, rb_obj_freeze(debug_info)); + ADD_INSN1(ret, line, putobject, rb_obj_freeze(str)); + } + else { + ADD_INSN1(ret, line, putobject, rb_fstring(str)); + } iseq_add_mark_object_compile_time(iseq, str); } } Index: NEWS =================================================================== --- NEWS (revision 53008) +++ NEWS (revision 53009) @@ -19,10 +19,9 @@ with all sufficient information, see the https://github.com/ruby/ruby/blob/trunk/NEWS#L19 [Feature #8976] * besides, --enable/--disable=frozen-string-literal options also have been introduced. [Feature #8976] - * command line option --debug or --debug=frozen-string-literal enable + * command line options --debug or --debug=frozen-string-literal enable additional debugging mode which shows created location with at frozen - object error (RuntimeError) even if string is dynamically created string - literal (for static string literals shows locations as default). + object error (RuntimeError). [Feature #11725] * safe navigation operator: Index: test/ruby/test_rubyoptions.rb =================================================================== --- test/ruby/test_rubyoptions.rb (revision 53008) +++ test/ruby/test_rubyoptions.rb (revision 53009) @@ -806,15 +806,20 @@ class TestRubyOptions < Test::Unit::Test https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rubyoptions.rb#L806 end def test_frozen_string_literal_debug - assert_in_out_err(["--disable=gems", "--enable-frozen-string-literal", "--debug-frozen-string-literal" ], '"foo" << "bar"', [], /created at/) - assert_in_out_err(["--disable=gems", "--enable-frozen-string-literal", ], '"foo" << "bar"', [], /created at/) - assert_in_out_err(["--disable=gems", "--enable-frozen-string-literal", "--debug-frozen-string-literal" ], '"foo#{123}bar" << "bar"', [], /created at/) - assert_in_out_err(["--disable=gems", "--enable-frozen-string-literal", ], '"foo#{123}bar" << "bar"', [], /can\'t modify frozen String \(RuntimeError\)\n\z/) + with_debug_pat = /created at/ + wo_debug_pat = /can\'t modify frozen String \(RuntimeError\)\n\z/ + + assert_in_out_err(["--disable=gems", "--enable-frozen-string-literal", "--debug-frozen-string-literal" ], '"foo" << "bar"', [], with_debug_pat) + assert_in_out_err(["--disable=gems", "--enable-frozen-string-literal", "--debug=frozen-string-literal" ], '"foo" << "bar"', [], with_debug_pat) + assert_in_out_err(["--disable=gems", "--enable-frozen-string-literal", ], '"foo" << "bar"', [], wo_debug_pat) + assert_in_out_err(["--disable=gems", "--enable-frozen-string-literal", "--debug-frozen-string-literal" ], '"foo#{123}bar" << "bar"', [], with_debug_pat) + assert_in_out_err(["--disable=gems", "--enable-frozen-string-literal", "--debug=frozen-string-literal" ], '"foo#{123}bar" << "bar"', [], with_debug_pat) + assert_in_out_err(["--disable=gems", "--enable-frozen-string-literal", ], '"foo#{123}bar" << "bar"', [], wo_debug_pat) assert_in_out_err(["--disable=gems", "--disable-frozen-string-literal", "--debug-frozen-string-literal" ], '"foo" << "bar"', [], []) + assert_in_out_err(["--disable=gems", "--disable-frozen-string-literal", "--debug=frozen-string-literal" ], '"foo" << "bar"', [], []) assert_in_out_err(["--disable=gems", "--disable-frozen-string-literal", ], '"foo" << "bar"', [], []) assert_in_out_err(["--disable=gems", "--debug-frozen-string-literal" ], '"foo" << "bar"', [], []) + assert_in_out_err(["--disable=gems", "--debug=frozen-string-literal" ], '"foo" << "bar"', [], []) assert_in_out_err(["--disable=gems", ], '"foo" << "bar"', [], []) - assert_in_out_err(["--disable=gems", "--enable-frozen-string-literal", ], '"foo" << "bar"', [], /created at/) - assert_in_out_err(["--disable=gems", "--enable-frozen-string-literal", ], '"foo#{123}bar" << "bar"', [], /can\'t modify frozen String \(RuntimeError\)\n\z/) end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/