# Rb\_rescue2 with vm

**URL:** <https://www.ruby-forum.com/t/rb-rescue2-with-vm/88633>\
**Category:** Development\
**Created:** [March 13, 2007, 6:37am UTC](https://www.ruby-forum.com/t/rb-rescue2-with-vm/88633 "2007-03-13T06:37:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wanabe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/51bf81/32.png) [@wanabe](https://www.ruby-forum.com/u/wanabe)\
**Post date:** [March 13, 2007, 6:37am UTC](https://www.ruby-forum.com/t/rb-rescue2-with-vm/88633/1 "2007-03-13T06:37:15Z")

</div>

e$B$O$8$a$^$7$F!"%o%J%Y$H?=$7$^$9!#e(B

1.9 e$B$Ne(B rb\_rescue2 e$B$rFI$s$G$$$Fe(B xxx\_TAG  
e$B7OE}$NO"B3$GFI$_$K$/$+$C$?$N$Ge(B  
e$B\<B83E\*$Ke(B VM e$B$r;H$C$?7A$K$7$F$_$^$7$?!#e(B

# e$B$"$/$^$G\<B83$J$N$G%P%C%/%H%l!\<%9Ey$O9MN8$7$F$$$^$;$s!#e(B

e$B$b$H$b$H$NF05!$N!“e(Bmoriq e$B$5$s$NF|5-$K$”$C$?e(B Zlib::GzipReader  
e$B$NF0:nITNI$Oe(B  
e$B!Je(B [http://moriq.tdiary.net/20070309.html](http://moriq.tdiary.net/20070309.html) e$B!Ke(B  
e$B\<j85$G3NG’$7$?8B$j$G$O2r\>C$5$l$F$$$^$9!#e(B

1.9 e$B$NJ}8~@-$H$7$F$O$3$&$$$&$N$O$"$j$J$s$G$7$g$&$+!#e(B  
e$BB.EY!&%a%b%j$N%3%9%H$r9M$($k$H8=\>u$N$[$&$,$h$5$=$&$G$9$,!"e(B  
e$BJ]\<i$NLL$+$i$Oe(B VM  
e$B$rB?MQ$7$?$[$&$,=hM}$bJ,;6$;$:!"8D?ME\*$K$O9%$-$G$9!#e(B

# Index: compile.c

— compile.c (revision 12030)  
+++ compile.c (working copy)  
@@ -3679,6 +3679,7 @@  
VALUE argc;  
VALUE flag = 0;  
VALUE parent\_block = iseq-\>compile\_data-\>current\_block;

- int is\_cfcall = (node-\>nd\_tval == 0);  
iseq-\>compile\_data-\>current\_block = Qfalse;

#if SUPPORT\_JOKE  
@@ -3736,7 +3737,7 @@  
if (type == NODE\_CALL) {  
COMPILE(recv, “recv”, node-\>nd\_recv);  
}

- else if (type == NODE\_FCALL || type == NODE\_VCALL) {

- else if (!is\_cfcall && (type == NODE\_FCALL || type == NODE\_VCALL))  
{  
ADD\_CALL\_RECEIVER(recv, nd\_line(node));  
}

@@ -3748,10 +3749,17 @@  
argc = INT2FIX(0);  
}

- debugp\_param(“call args argc”, argc);
- 
- if (is\_cfcall) {
- 

```
   debugp_param("call cfunc", node->nd_cfnc);

```

- 

```
   ADD_SEQ(ret, args);

```

- 

```
   ADD_INSN1(ret, nd_line(node), cfcall, node->nd_cfnc);

```

- 

```
   break;

```

- }  
ADD\_SEQ(ret, recv);  
ADD\_SEQ(ret, args);

- debugp\_param(“call args argc”, argc);  
debugp\_param(“call method”, ID2SYM(mid));

- int state;

- volatile VALUE result;

- volatile VALUE e\_info = GET\_THREAD()-\>errinfo;  
va\_list args;

- 
- PUSH\_TAG(PROT\_NONE);

- if ((state = EXEC\_TAG()) == 0) {

- 

```
 retry_entry:

```

- result = (\*b\_proc) (data1);

- int len = 0;
- VALUE eclass;
- NODE \*r\_node = 0;
- NODE \*rb\_node = 0;
- NODE \*e\_node = 0;
- NODE \*b\_node = NEW\_CFCALL(INT2NUM(b\_proc),  
NEW\_ARRAY(NEW\_LIT(data1)));
- if(r\_proc != 0) {
- r\_node = NEW\_CFCALL(INT2NUM(r\_proc), NEW\_ARRAY(NEW\_LIT(data2)));  
}

- else if (state == TAG\_RAISE) {
- int handle = Qfalse;
- VALUE eclass;
- 
- va\_init\_list(args, data2);
- while (eclass = va\_arg(args, VALUE)) {
- 

```
 if (rb_obj_is_kind_of(GET_THREAD()->errinfo, eclass)) {

```

- handle = Qtrue;
- break;
- 

```
 }

```

- }
- va\_end(args);
- 
- if (handle) {
- 

```
 if (r_proc) {

```

- PUSH\_TAG(PROT\_NONE);
- if ((state = EXEC\_TAG()) == 0) {
- 

```
   result = (*r_proc) (data2, GET_THREAD()->errinfo);

```

- }
- POP\_TAG();
- if (state == TAG\_RETRY) {
- 

```
   state = 0;

```

- 

```
   GET_THREAD()->errinfo = Qnil;

```

- 

```
   goto retry_entry;

```

- }
- 

```
 }

```

- 

```
 else {

```

- result = Qnil;
- state = 0;
- 

```
 }

```

- 

```
 if (state == 0) {

```

- GET\_THREAD()-\>errinfo = e\_info;
- 

```
 }

```

- }

- rb\_node = NEW\_RESBODY(0, r\_node, 0);
- 
- va\_init\_list(args, data2);
- while (eclass = va\_arg(args, VALUE)) {
- NODE \*n = NEW\_ARRAY(NEW\_LIT(eclass));
- n-\>nd\_next = e\_node;
- n-\>nd\_alen = ++len;
- e\_node = n;  
}

- POP\_TAG();
- if (state)
- JUMP\_TAG(state);

- va\_end(args);

- return result;

- rb\_node-\>nd\_args = e\_node;
- return yarvcore\_eval\_parsed(NEW\_RESCUE(b\_node, rb\_node, 0),  
rb\_str\_new2(“in rb\_rescue”));  
}

# VALUE Index: insns.def

— insns.def (revision 12030)  
+++ insns.def (working copy)  
@@ -2425,3 +2425,18 @@  
ret = INT2FIX(42);  
}

+/\*\*

- @c call
- @e call the function using function pointer
- @j e$B4X?t%]%$%s%?$,\<($94X?t$r%3!\<%k$9$ke(B
- \*/  
+DEFINE\_INSN  
+cfcall  
+(VALUE ptr)  
+(VALUE arg)  
+(VALUE ret)  
+{
- VALUE (\*func)(ANYARGS) = NUM2INT(ptr);
- ret = func(arg);  
+}
- 

# Index: node.h

— node.h (revision 12030)  
+++ node.h (working copy)  
@@ -316,6 +316,7 @@  
#define NEW\_EVSTR(n) NEW\_NODE(NODE\_EVSTR,0,(n),0)  
#define NEW\_CALL(r,m,a) NEW\_NODE(NODE\_CALL,r,m,a)  
#define NEW\_FCALL(m,a) NEW\_NODE(NODE\_FCALL,0,m,a)  
+#define NEW\_CFCALL(p,a) NEW\_NODE(NODE\_FCALL,p,0,a)  
#define NEW\_VCALL(m) NEW\_NODE(NODE\_VCALL,0,m,0)  
#define NEW\_SUPER(a) NEW\_NODE(NODE\_SUPER,0,0,a)  
#define NEW\_ZSUPER() NEW\_NODE(NODE\_ZSUPER,0,0,0)

---

<div class="post-metadata">

**Author:** ![wanabe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/51bf81/32.png) [@wanabe](https://www.ruby-forum.com/u/wanabe)\
**Post date:** [March 14, 2007, 4:04pm UTC](https://www.ruby-forum.com/t/rb-rescue2-with-vm/88633/2 "2007-03-14T16:04:08Z")

</div>

e$B%o%J%Y$G$9!#e(B

VM e$B$KMj$i$:$H$be(B Zlib::GzipReader  
e$B$NF0:nITNI$r2r7h$G$-$?$N$G%Q%C%A$rAw$j$^$9!#e(B

# Index: eval.c

— eval.c (revision 12066)  
+++ eval.c (working copy)  
@@ -1340,6 +1340,7 @@  
int handle = Qfalse;  
VALUE eclass;

- GET\_THREAD()-\>cfp++;  
va\_init\_list(args, data2);  
while (eclass = va\_arg(args, VALUE)) {  
if (rb\_obj\_is\_kind\_of(GET\_THREAD()-\>errinfo, eclass)) {  
@@ -2732,7 +2733,7 @@  
VALUE  
rb\_errinfo(void)  
{

- return get\_errinfo();

- return GET\_THREAD()-\>errinfo;  
}

static void

---

<div class="post-metadata">

**Author:** ![wanabe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/51bf81/32.png) [@wanabe](https://www.ruby-forum.com/u/wanabe)\
**Post date:** [April 12, 2007, 9:38am UTC](https://www.ruby-forum.com/t/rb-rescue2-with-vm/88633/3 "2007-04-12T09:38:35Z")

</div>

e$B!!$5$5$@$G$9!%e(B

e$B!!$3$A$i$bCY$/$J$C$F$7$^$C$F$9$\_$^$;$s!%e(B

wanabe wrote:

> e$B%o%J%Y$G$9!#e(B
> 
> VM e$B$KMj$i$:$H$be(B Zlib::GzipReader e$B$NF0:nITNI$r2r7h$G$-$?$N$G%Q%C%A$rAw$je(B  
> e$B$^$9!#e(B

e$B!!$3$A$i$b!$$5$C$-$H:,$,F1$8!Je(Bcfp  
e$B$rLa$7$F$$$J$$$N$,LdBj!K$@$H;W$$$^$7e(B  
e$B$?!%$=$N$h$&$K=$@5$7$^$9!%$4;XE&$"$j$,$H$&$4$6$$$^$7$?!%e(Berrinfo  
e$B$N$[$&e(B  
e$B$O!$$A$g$C$H$o$+$i$J$+$C$?$s$G$9$,!$$3$l$O$^$:$$$G$7$g$&$+!%e(B

e$B!!$H$3$m$G!$85$N%a!\<%k$K$"$C$?e(BCe$B4X?t$r8F$S=P$9$b$N$G$9$,!$e(BJIT/AOTe$B%3%s%Q%$e(B  
e$B%i$N%$%s%?!\<%U%’!\<%9$H$7$FMQ0U$7$h$&$H;W$C$F$$$^$9!%e(B
