ruby-changes:39735
From: nobu <ko1@a...>
Date: Thu, 10 Sep 2015 12:17:41 +0900 (JST)
Subject: [ruby-changes:39735] nobu:r51816 (trunk): compile.c: register cdhash
nobu 2015-09-10 12:17:30 +0900 (Thu, 10 Sep 2015) New Revision: 51816 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51816 Log: compile.c: register cdhash * compile.c (iseq_build_from_ary_body): register cdhash to the iseq constant body instead of compile time mark array, not to get GCed. [ruby-core:70708] [Feature #8543] Modified files: trunk/ChangeLog trunk/compile.c trunk/test/ruby/test_iseq.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 51815) +++ ChangeLog (revision 51816) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Sep 10 12:17:28 2015 Nobuyoshi Nakada <nobu@r...> + + * compile.c (iseq_build_from_ary_body): register cdhash to the + iseq constant body instead of compile time mark array, not to + get GCed. [ruby-core:70708] [Feature #8543] + Wed Sep 9 18:16:14 2015 NAKAMURA Usaku <usa@r...> * lib/rubygems/stub_specification.rb (Gem::StubSpecification#data): Index: compile.c =================================================================== --- compile.c (revision 51815) +++ compile.c (revision 51816) @@ -6048,7 +6048,7 @@ iseq_build_from_ary_body(rb_iseq_t *iseq https://github.com/ruby/ruby/blob/trunk/compile.c#L6048 } RB_GC_GUARD(op); argv[j] = map; - iseq_add_mark_object_compile_time(iseq, map); + rb_iseq_add_mark_object(iseq, map); } break; case TS_FUNCPTR: Index: test/ruby/test_iseq.rb =================================================================== --- test/ruby/test_iseq.rb (revision 51815) +++ test/ruby/test_iseq.rb (revision 51816) @@ -51,6 +51,26 @@ class TestISeq < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_iseq.rb#L51 assert_raise_with_message(TypeError, /:foobar/) {RubyVM::InstructionSequence.load(ary)} end if defined?(RubyVM::InstructionSequence.load) + def test_loaded_cdhash_mark + iseq = RubyVM::InstructionSequence.compile(<<-'end;', __FILE__, __FILE__, __LINE__+1) + def bug(kw) + case kw + when "false" then false + when "true" then true + when "nil" then nil + else raise("unhandled argument: #{kw.inspect}") + end + end + end; + assert_separately([], <<-"end;") + iseq = #{iseq.to_a.inspect} + RubyVM::InstructionSequence.load(iseq).eval + assert_equal(false, bug("false")) + GC.start + assert_equal(false, bug("false")) + end; + end if defined?(RubyVM::InstructionSequence.load) + def test_disasm_encoding src = "\u{3042} = 1; \u{3042}; \u{3043}" asm = RubyVM::InstructionSequence.compile(src).disasm -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/