8000 Make UJIT.disasm accept Procs · github/ruby@7551179 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7551179

Browse files
committed
Make UJIT.disasm accept Procs
1 parent 9a41ea2 commit 7551179

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

ujit.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
module UJIT
22
def self.disasm(iseq)
3-
if iseq.is_a? Method
4-
iseq = RubyVM::InstructionSequence.of(iseq)
5-
end
3+
iseq = RubyVM::InstructionSequence.of(iseq)
64

75
blocks = UJIT.blocks_for(iseq)
86
return if blocks.empty?

ujit_iface.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,9 @@ iseqw_ujit_collect_blocks(st_data_t key, st_data_t value, st_data_t argp)
353353
static VALUE
354354
ujit_blocks_for(VALUE mod, VALUE rb_iseq)
355355
{
356+
if (!rb_obj_is_iseq(rb_iseq)) {
357+
return rb_ary_new();
358+
}
356359
const rb_iseq_t *iseq = rb_iseqw_to_iseq(rb_iseq);
357360
st_table * vt = (st_table *)version_tbl;
358361
struct ujit_block_itr itr;
@@ -367,6 +370,9 @@ ujit_blocks_for(VALUE mod, VALUE rb_iseq)
367370
static VALUE
368371
ujit_install_entry(VALUE mod, VALUE iseq)
369372
{
373+
if (!rb_obj_is_iseq(iseq)) {
374+
rb_raise(rb_eTypeError, "not an InstructionSequence");
375+
}
370376
rb_ujit_compile_iseq(rb_iseqw_to_iseq(iseq));
371377
return iseq;
372378
}

0 commit comments

Comments
 (0)
0