[#82311] [Ruby trunk Bug#13794] Infinite loop of sched_yield — charlie@...
Issue #13794 has been reported by catphish (Charlie Smurthwaite).
4 messages
2017/08/09
[#82518] [Ruby trunk Feature#13618] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid — mame@...
Issue #13618 has been updated by mame (Yusuke Endoh).
5 messages
2017/08/30
[#82552] Re: [Ruby trunk Feature#13618] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid
— Eric Wong <normalperson@...>
2017/08/31
[email protected] wrote:
[#82756] Re: [Ruby trunk Feature#13618] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid
— Eric Wrong <normalperson@...>
2017/09/12
Eric Wrong <[email protected]> wrote:
[ruby-core:82448] Exposing rb_iseq_load as a ruby method?
From:
Simen Edvardsen <toalett@...>
Date:
2017-08-22 12:45:48 UTC
List:
ruby-core #82448
RubyVM::InstructionSequence is great, it's great that you can compile code
and disassemble. But for my current project (which is currently a toy, but
this may have other useful applications), what I'd really like is to feed
an instruction sequence constructed in Ruby into the iseq assembler. On the
C level, such a function exists and it works, namely, rb_iseq_load, but
it's not exposed on the Ruby level. Other people apparently found this
function useful too, because I found the following snippet online to
dynamically load it:
require "fiddle"
class RubyVM::InstructionSequence
# Retrieve Ruby Core's C-ext `iseq_load' function address
# I had to modify this line for my system
load_fn_addr =
Fiddle::Handle.new("x64-msvcrt-ruby240.dll")['rb_iseq_load']
# Retrieve `iseq_load' C function representation
load_fn = Fiddle::Function.new(load_fn_addr,
[Fiddle::TYPE_VOIDP] * 3,
Fiddle::TYPE_VOIDP)
# Make `iseq_load' accessible as `load' class method
define_singleton_method(:load) do |data, parent = nil, opt = nil|
load_fn.call(Fiddle.dlwrap(data), parent, opt).to_value
end
end
The original hack was written for Linux, I think, so I had to manually find
the right DLL for my system and swap it in there. But it works, kinda, in a
hacky way.
Would you ever consider exposing rb_iseq_load as a singleton method of
RubyVM::InstructionSequence? The function already performs quite a few
checks on the validity of the input, and there is already an unsafe way to
load ISeqs via ::from_binary. And that would make it easier to do
interesting things with Ruby codegen.
--
- Simen
Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>