logo       
Google Custom Search
    AddThis Social Bookmark Button

[ruby-dev:27858] Re: tail call and conservertive GC: msg#00242

Subject: [ruby-dev:27858] Re: tail call and conservertive GC
In article <TYOMLEM04FRaqbC8wSA0000003d@xxxxxxxxxxxxxxxxxxxxxxxx>,
  nobuyoshi nakada <nobuyoshi.nakada@xxxxxx> writes:

> rb_parser_compile_string()のvparserもvolatileなはずですが、そっ
> ちも消えてしまってるんでしょうか。

あー、そっか。たしかに。

rb_parser_compile_string には渡っているけれど、yycompile も
やっぱり tail call されるので、今度こそここで消える、という
ことでした。

(gdb) disassemble rb_parser_compile_string
Dump of assembler code for function rb_parser_compile_string:
0x080b1100 <rb_parser_compile_string+0>:        push   %ebp
0x080b1101 <rb_parser_compile_string+1>:        mov    $0x12,%edx
0x080b1106 <rb_parser_compile_string+6>:        mov    %esp,%ebp
0x080b1108 <rb_parser_compile_string+8>:        sub    $0x18,%esp
0x080b110b <rb_parser_compile_string+11>:       mov    %ebx,0xfffffff4(%ebp)
0x080b110e <rb_parser_compile_string+14>:       mov    0x10(%ebp),%ebx
0x080b1111 <rb_parser_compile_string+17>:       mov    %esi,0xfffffff8(%ebp)
0x080b1114 <rb_parser_compile_string+20>:       mov    0x14(%ebp),%esi
0x080b1117 <rb_parser_compile_string+23>:       mov    %edi,0xfffffffc(%ebp)
0x080b111a <rb_parser_compile_string+26>:       mov    0xc(%ebp),%edi
0x080b111d <rb_parser_compile_string+29>:       mov    %edx,0x4(%esp)
0x080b1121 <rb_parser_compile_string+33>:       mov    0x8(%ebp),%ecx
0x080b1124 <rb_parser_compile_string+36>:       mov    %ecx,(%esp)
0x080b1127 <rb_parser_compile_string+39>:       call   0x810c7d0 <rb_check_type>
0x080b112c <rb_parser_compile_string+44>:       mov    0x8(%ebp),%edx
0x080b112f <rb_parser_compile_string+47>:       mov    0x10(%edx),%ecx
0x080b1132 <rb_parser_compile_string+50>:       mov    %ebx,0x4c(%ecx)
0x080b1135 <rb_parser_compile_string+53>:       mov    0x814a958,%ebx
0x080b113b <rb_parser_compile_string+59>:       movl   $0x80b1cd0,0x6c(%ecx)
0x080b1142 <rb_parser_compile_string+66>:       movl   $0x0,0x68(%ecx)
0x080b1149 <rb_parser_compile_string+73>:       movl   $0x0,0x5c(%ecx)
0x080b1150 <rb_parser_compile_string+80>:       movl   $0x0,0x58(%ecx)
0x080b1157 <rb_parser_compile_string+87>:       movl   $0x0,0x54(%ecx)
0x080b115e <rb_parser_compile_string+94>:       mov    %ebx,0x34(%ecx)
0x080b1161 <rb_parser_compile_string+97>:       mov    0xfffffff4(%ebp),%ebx
0x080b1164 <rb_parser_compile_string+100>:      mov    %esi,0x10(%ebp)
0x080b1167 <rb_parser_compile_string+103>:      mov    0xfffffff8(%ebp),%esi
0x080b116a <rb_parser_compile_string+106>:      mov    %edi,0xc(%ebp)
0x080b116d <rb_parser_compile_string+109>:      mov    0xfffffffc(%ebp),%edi
0x080b1170 <rb_parser_compile_string+112>:      mov    %ecx,0x8(%ebp)
0x080b1173 <rb_parser_compile_string+115>:      mov    %ebp,%esp
0x080b1175 <rb_parser_compile_string+117>:      pop    %ebp
0x080b1176 <rb_parser_compile_string+118>:      jmp    0x80b1ac0 <yycompile>
End of assembler dump.
(gdb) 

>> まぁ、tail call になるのを防止すればいいわけですが、tail
>> call になっているのはここに限らずかなりある感じです。
>
> この推測が正しければ、volatileなローカル変数に保存しておくこと
> で解決しないでしょうか。

解決しません。ローカル変数は stack frame の中にあって、その
stack frame は tail call の時点で消えてしまうのです。
-- 
[田中 哲][たなか あきら][Tanaka Akira]





Try Searching:
servers, voip, java, networking, microsoft ...
<Prev in Thread] Current Thread [Next in Thread>