ABCDEFGHIJKLMNOPQRSTUVWXYZ
1
2
ネイティブスタックRuby スタックほしいスタック <要出典>
3
Native: (no symbol information)block (3 levels) in <main>Native: (no symbol information)
4
Native: vm_call_iseq_setup_normal_0start_3params_3locals
Kernel#fooNative: vm_call_iseq_setup_normal_0start_3params_3locals
5
Native: vm_exec_coreblock (2 levels) in <main>Native: vm_exec_core
6
Native: rb_vm_execKernel#fooRuby: block (3 levels) in <main>
← rb_yield() の2つ上に入れて見てるだけ
7
Native: rb_yieldblock in <main>Native: rb_vm_exec
8
Native: rb_fooInteger#timesNative: rb_yield
9
Native: vm_call_cfunc_with_frame<main>Ruby: Kernel#foo
← rb_foo() が foo() であることを知らないと推定できない
10
Native: vm_sendish.constprop.0Native: rb_foo
11
Native: vm_exec_coreNative: vm_call_cfunc_with_frame
↑ vm_call_cfunc_with_cframe() の2つ上に入れる的なヒューリスティックにはできる
12
Native: rb_vm_execNative: vm_sendish.constprop.0
13
Native: rb_yieldNative: vm_exec_core
14
Ruby: block (2 levels) in <main>
← rb_yield() の2つ上に入れて見てるだけ
15
Native: rb_fooNative: rb_vm_exec
16
Native: vm_call_cfunc_with_frameNative: rb_yield
17
Native: vm_sendish.constprop.0Ruby: Kernel#foo
18
Native: vm_exec_coreNative: rb_foo
19
Native: rb_vm_execNative: vm_call_cfunc_with_frame
20
Native: rb_ec_exec_nodeNative: vm_sendish.constprop.0
21
Native: ruby_run_nodeNative: vm_exec_core
22
Native: mainRuby: block in <main>
23
Native: (no symbol information)Ruby: Integer#times← 本当にここ?
24
Native: __libc_start_mainRuby: main
25
Native: _startNative: rb_vm_exec
← vm_exec_core のほうが良い
26
Native: (no symbol information)Native: rb_ec_exec_node
27
Native: ruby_run_node
28
ISeqを積む命令は4つだけNative: main
29
sendNative: (no symbol information)
30
opt_send_without_blockNative: __libc_start_main
31
invokesuperNative: _start
32
invokeblockNative: (no symbol information)
33
34
Code↓ foo()
35
1000.times do
some_cfunc do
foo do
do_something
end
end
end
VALUE
rb_foo(int argc, VALUE argv[], VALUE self)
{
rb_yield(self);
return Qnil;
}
RUBY_FUNC_EXPORTED void
Init_mycext(void)
{
rb_define_method(rb_mKernel, "foo", rb_foo, -1);
}
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100