[#78949] [Ruby trunk Feature#13095] [PATCH] io.c (rb_f_syscall): remove deprecation notice — kosaki.motohiro@...
Issue #13095 has been updated by Motohiro KOSAKI.
3 messages
2017/01/03
[#78997] [Ruby trunk Bug#13110] Byte-based operations for String — shugo@...
Issue #13110 has been updated by Shugo Maeda.
3 messages
2017/01/06
[#79228] Re: [ruby-cvs:64576] naruse:r57410 (trunk): Prevent GC by volatile [Bug #13150] — Eric Wong <normalperson@...>
naruse@ruby-lang.org wrote:
5 messages
2017/01/23
[#79511] Re: [ruby-cvs:64576] naruse:r57410 (trunk): Prevent GC by volatile [Bug #13150]
— Eric Wong <normalperson@...>
2017/02/13
Eric Wong <normalperson@yhbt.net> wrote:
[#79518] Re: [ruby-cvs:64576] naruse:r57410 (trunk): Prevent GC by volatile [Bug #13150]
— Nobuyoshi Nakada <nobu@...>
2017/02/13
On 2017/02/13 10:04, Eric Wong wrote:
[#79298] [Ruby trunk Bug#13085][Assigned] io.c io_fwrite creates garbage — nobu@...
Issue #13085 has been updated by Nobuyoshi Nakada.
3 messages
2017/01/29
[#79337] Re: [ruby-changes:45397] normal:r57469 (trunk): io.c: recycle garbage on write — SASADA Koichi <ko1@...>
Eric:
4 messages
2017/01/31
[#79352] Re: [ruby-changes:45397] normal:r57469 (trunk): io.c: recycle garbage on write
— Eric Wong <normalperson@...>
2017/01/31
SASADA Koichi <ko1@atdot.net> wrote:
[ruby-core:79338] [Ruby trunk Bug#3841][Closed] RubyVM::InstructionSequence.to_a() and disasm() do not work properly for "for <var> in <list>"
From:
ko1@...
Date:
2017-01-31 08:40:26 UTC
List:
ruby-core #79338
Issue #3841 has been updated by Koichi Sasada.
Description updated
Status changed from Assigned to Closed
I'm not sure who fix this issue, but 2.5dev doesn't have this issue.
----------------------------------------
Bug #3841: RubyVM::InstructionSequence.to_a() and disasm() do not work properly for "for <var> in <list>"
https://bugs.ruby-lang.org/issues/3841#change-62758
* Author: Sean O'Neil
* Status: Closed
* Priority: Normal
* Assignee: Koichi Sasada
* Target version: next minor
* ruby -v: ruby 1.9.2p0 (2010-08-18 revision 29036) [i386-mswin32_90]
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
I have been playing with the concept of caching compiled Ruby instruction sequences and reloading them later. For now the simplest way to do it is to use RubyVM::InstructionSequence.to_a() and Marshal.dump() to convert the resulting array to a smaller binary byte sequence. While testing this, I found that some Ruby scripts worked fine when an instruction sequence was reloaded, but others broke.
As a test, I decided to try compiling irb.rb and its dependencies. When I try to reload the compiled sequences, the first file that breaks is irb/extend-command.rb. I tracked it down to the way "for <vars> in <list>" code block and parameters are handled, but I am not sure how to fix it. When I converted each "for <vars> in <list>" loop to "<list>.each {|<vars>|", it started working perfectly. Here's an example of how the disassembly differs between the two loops:
```
def self.install_extend_commands
@EXTEND_COMMANDS.each {|args|
def_extend_command(*args)
}
end
== disasm: <RubyVM::InstructionSequence:block in install_extend_commands@irb/extend-command.rb>
== catch table
| catch type: redo st: 0000 ed: 0012 sp: 0000 cont: 0000
| catch type: next st: 0000 ed: 0012 sp: 0000 cont: 0012
|------------------------------------------------------------------------
local table (size: 2, argc: 1 [opts: 0, rest: -1, post: 0, block: -1] s3)
[ 2] args<Arg>
0000 trace 1 ( 110)
0002 putnil
0003 getdynamic args, 0
0006 send :def_extend_command, 1, nil, 10, <ic:0>
0012 leave
def self.install_extend_commands
for args in @EXTEND_COMMANDS
def_extend_command(*args)
end
end
== disasm: <RubyVM::InstructionSequence:block in install_extend_commands@irb/extend-command.rb>
== catch table
| catch type: redo st: 0005 ed: 0016 sp: 0000 cont: 0005
| catch type: next st: 0005 ed: 0016 sp: 0000 cont: 0016
|------------------------------------------------------------------------
local table (size: 2, argc: 1 [opts: 0, rest: -1, post: 0, block: -1] s3)
[ 2] ?<Arg>
0000 getdynamic *, 0 ( 206)
0003 setlocal args ( 204)
0005 trace 1 ( 205)
0007 putnil
0008 getlocal args
0010 send :def_extend_command, 1, nil, 10, <ic:0>
0016 leave
```
In this example, rb_id2name() returns NULL for the name of the argument passed to the code block. That is why it puts a "?" in the local table and a "*" in the getdynamic command. The to_a() method has a similar problem, and it appears to put a number there instead. When I use the load() method to convert the array back into an instruction sequence and try to execute it, the code block ends up receiving a number as a parameter instead of the entry in the list it is supposed to get.
I imagine this is not a high priority for the Ruby core team, and I don't mind putting in some work to fix it. However, it looks like it would take me a while to figure out, so I would appreciate any tips you could give me to point me in the right direction.
Thank you,
Sean O'Neil
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>