diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-09 17:02:02 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-09 17:02:02 +0000 |
commit | 6fb2ec53949c149323d2b0f264bf4c68be558b8f (patch) | |
tree | 74e9c8645f64bcb766785a7dbaa60afb93de3199 | |
parent | c7e51700ca5060a7d4fbc9f8cd99f8471b5f0935 (diff) | |
download | ruby-6fb2ec53949c149323d2b0f264bf4c68be558b8f.tar.gz |
* 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.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | NEWS | 5 | ||||
-rw-r--r-- | compile.c | 11 | ||||
-rw-r--r-- | test/ruby/test_rubyoptions.rb | 17 |
4 files changed, 32 insertions, 12 deletions
@@ -1,3 +1,14 @@ +Thu Dec 10 02:01:41 2015 Koichi Sasada <ko1@atdot.net> + + * 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@atdot.net> * iseq.c: rename methods @@ -19,10 +19,9 @@ with all sufficient information, see the ChangeLog file. [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: @@ -5340,9 +5340,14 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) } 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); } } diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb index 1f47e7bd0f..96ceb798b1 100644 --- a/test/ruby/test_rubyoptions.rb +++ b/test/ruby/test_rubyoptions.rb @@ -806,15 +806,20 @@ class TestRubyOptions < Test::Unit::TestCase 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 |